changes 08-09-25
This commit is contained in:
36
overlay/scripts/nix/templates/fetchfromgh.nix
Normal file
36
overlay/scripts/nix/templates/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"
|
||||
'';
|
||||
}
|
||||
19
overlay/scripts/nix/templates/mkshell.nix
Normal file
19
overlay/scripts/nix/templates/mkshell.nix
Normal file
@@ -0,0 +1,19 @@
|
||||
{ pkgs ? import <nixpkgs> { } }:
|
||||
|
||||
pkgs.writeShellApplication {
|
||||
name = "mkshell";
|
||||
runtimeInputs = [];
|
||||
text = ''
|
||||
command cat <<EOF
|
||||
devShells.\''${system}.default = pkgs.mkShell {
|
||||
buildInputs = with pkgs; [
|
||||
];
|
||||
|
||||
shellHook = '''
|
||||
export SHELL=\''${pkgs.zsh}/bin/zsh
|
||||
exec \''${pkgs.zsh}/bin/zsh
|
||||
''';
|
||||
};
|
||||
EOF
|
||||
'';
|
||||
}
|
||||
Reference in New Issue
Block a user