Moved scripts to the overlay folder to be used as packages
All scripts have been moved to the overlay folder in the top level directory Overlay is now instantiated per configuration to make use of the host variable
This commit is contained in:
36
overlay/scripts/nix/fetchfromgh.nix
Normal file
36
overlay/scripts/nix/fetchfromgh.nix
Normal file
@@ -0,0 +1,36 @@
|
||||
{ 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