added fetchfromgh, which takes a github username and repo like someuser/somerepo and returns a pkgs.fetchFromGitHub call
This commit is contained in:
@@ -6,6 +6,7 @@
|
|||||||
pkgs,
|
pkgs,
|
||||||
...
|
...
|
||||||
}: let
|
}: let
|
||||||
|
fetchfromgh = import ./nix/fetchfromgh.nix { inherit pkgs; };
|
||||||
vipkg = import ./commands/vipkg.nix { inherit pkgs; };
|
vipkg = import ./commands/vipkg.nix { inherit pkgs; };
|
||||||
keyring = import ./wm-controls/keyring.nix { inherit pkgs; };
|
keyring = import ./wm-controls/keyring.nix { inherit pkgs; };
|
||||||
invoke = import ./commands/invoke.nix { inherit pkgs; };
|
invoke = import ./commands/invoke.nix { inherit pkgs; };
|
||||||
@@ -77,6 +78,8 @@ in {
|
|||||||
|
|
||||||
|
|
||||||
# Nix Shortcuts
|
# Nix Shortcuts
|
||||||
|
movOpts.movScripts.nixShortcuts.fetchfromgh.enable =
|
||||||
|
scriptOverride "Provides a full pkgs.fetchFromGitHub call from a repository url" "nixShortcuts" "fetchfromgh";
|
||||||
movOpts.movScripts.nixShortcuts.garbage-collect.enable =
|
movOpts.movScripts.nixShortcuts.garbage-collect.enable =
|
||||||
scriptOverride "Enables the garbage-collect script" "nixShortcuts" "garbage-collect";
|
scriptOverride "Enables the garbage-collect script" "nixShortcuts" "garbage-collect";
|
||||||
movOpts.movScripts.nixShortcuts.nsp.enable =
|
movOpts.movScripts.nixShortcuts.nsp.enable =
|
||||||
@@ -106,6 +109,7 @@ in {
|
|||||||
++ lib.optionals config.movOpts.movScripts.hyprlandControls.mkscreenshots.enable [ mkscreenshots ]
|
++ lib.optionals config.movOpts.movScripts.hyprlandControls.mkscreenshots.enable [ mkscreenshots ]
|
||||||
|
|
||||||
# Nix Shortcuts Overrides
|
# Nix Shortcuts Overrides
|
||||||
|
++ lib.optionals config.movOpts.movScripts.nixShortcuts.fetchfromgh.enable [ fetchfromgh ]
|
||||||
++ lib.optionals config.movOpts.movScripts.nixShortcuts.garbage-collect.enable [ garbage-collect ]
|
++ lib.optionals config.movOpts.movScripts.nixShortcuts.garbage-collect.enable [ garbage-collect ]
|
||||||
++ lib.optionals config.movOpts.movScripts.nixShortcuts.nsp.enable [ nsp ]
|
++ lib.optionals config.movOpts.movScripts.nixShortcuts.nsp.enable [ nsp ]
|
||||||
++ lib.optionals config.movOpts.movScripts.nixShortcuts.rebuild.enable [ rebuild ];
|
++ lib.optionals config.movOpts.movScripts.nixShortcuts.rebuild.enable [ rebuild ];
|
||||||
|
|||||||
38
modules/home/scripts/nix/fetchfromgh.nix
Normal file
38
modules/home/scripts/nix/fetchfromgh.nix
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
{ pkgs ? import <nixpkgs> { } }:
|
||||||
|
|
||||||
|
pkgs.writeShellApplication {
|
||||||
|
name = "fetchfromgh";
|
||||||
|
runtimeInputs = [
|
||||||
|
pkgs.nix-prefetch-scripts
|
||||||
|
];
|
||||||
|
text = ''
|
||||||
|
if [ $# -ne 1 ] || ! echo "$1" | grep -qE "[A-Za-z0-9_-]+/[A-Za-z0-9_-]+"; then
|
||||||
|
echo "Usage: fetchfromgh someuser/somerepo"
|
||||||
|
echo " - i.e. fetchfromgh pagedMov/nixos-config"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if ! curl -s -o /dev/null -w "%{http_code}" "https://github.com/$1" | grep -q "200"; then
|
||||||
|
echo "Couldn't find that repository, curl returned 404."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
json=$(nix-prefetch-git --quiet "https://github.com/$1")
|
||||||
|
|
||||||
|
url=$(echo "$json" | jq '.url' | tr -d '"')
|
||||||
|
owner=$(echo "$url" | awk -F'/' '{print $(NF-1)}')
|
||||||
|
repo=$(echo "$url" | awk -F'/' '{print $NF}')
|
||||||
|
rev=$(echo "$json" | jq '.rev' | tr -d '"')
|
||||||
|
hash=$(echo "$json" | jq '.hash' | tr -d '"')
|
||||||
|
|
||||||
|
output="\
|
||||||
|
src = pkgs.fetchFromGitHub {
|
||||||
|
owner = \"$owner\";
|
||||||
|
repo = \"$repo\";
|
||||||
|
rev = \"$rev\";
|
||||||
|
hash = \"$hash\";
|
||||||
|
};
|
||||||
|
"
|
||||||
|
echo "$output"
|
||||||
|
'';
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user