1
1
Fork 0
mirror of https://github.com/the-nix-way/dev-templates synced 2024-05-06 04:36:05 +02:00

Streamline scripts again

This commit is contained in:
Luc Perkins 2024-04-15 17:19:53 -03:00
parent 7c3ef7b734
commit d6bccb7908
No known key found for this signature in database
GPG Key ID: 16DB1108FB591835

121
flake.nix
View File

@ -6,78 +6,73 @@
outputs = { self, nixpkgs }:
let
overlays = [
(final: prev: {
format = final.writeShellApplication {
name = "format";
runtimeInputs = with final; [ nixpkgs-fmt ];
text = "nixpkgs-fmt '**/*.nix'";
};
# only run this locally, as Actions will run out of disk space
build = final.writeShellApplication {
name = "build";
text = ''
SYSTEM=$(nix eval --impure --raw --expr 'builtins.currentSystem')
for dir in */; do # Iterate through all the templates
(final: prev:
let
getSystem = "SYSTEM=$(nix eval --impure --raw --expr 'builtins.currentSystem')";
forEachDir = exec: ''
for dir in */; do
(
cd "''${dir}"
${exec}
)
done
'';
in
{
format = final.writeShellApplication {
name = "format";
runtimeInputs = with final; [ nixpkgs-fmt ];
text = "nixpkgs-fmt '**/*.nix'";
};
# only run this locally, as Actions will run out of disk space
build = final.writeShellApplication {
name = "build";
text = ''
${getSystem}
${forEachDir ''
echo "building ''${dir}"
nix build ".#devShells.''${SYSTEM}.default"
)
done
'';
};
''}
'';
};
check = final.writeShellApplication {
name = "check";
text = ''
for dir in */; do # Iterate through all the templates
(
cd "''${dir}"
check = final.writeShellApplication {
name = "check";
text = forEachDir ''
echo "checking ''${dir}"
nix flake check --all-systems --no-build
'';
};
echo "checking ''${dir}"
nix flake check --all-systems --no-build
)
done
'';
};
dvt = final.writeShellApplication {
name = "dvt";
text = ''
if [ -z $1 ]; then
echo "no template specified"
exit 1
fi
dvt = final.writeShellApplication {
name = "dvt";
text = ''
if [ -z $1 ]; then
echo "no template specified"
exit 1
fi
TEMPLATE=$1
TEMPLATE=$1
nix \
--experimental-features 'nix-command flakes' \
flake init \
--template \
"github:the-nix-way/dev-templates#''${TEMPLATE}"
'';
};
nix \
--experimental-features 'nix-command flakes' \
flake init \
--template \
"github:the-nix-way/dev-templates#''${TEMPLATE}"
'';
};
update = final.writeShellApplication {
name = "update";
text = ''
for dir in */; do # Iterate through all the templates
(
cd "''${dir}"
echo "updating ''${dir}"
nix flake update
echo "checking ''${dir}"
nix flake check --all-systems --no-build
)
done
'';
};
})
update = final.writeShellApplication {
name = "update";
text = forEachDir ''
echo "updating ''${dir}"
nix flake update
'';
};
})
];
supportedSystems = [ "x86_64-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin" ];
forEachSupportedSystem = f: nixpkgs.lib.genAttrs supportedSystems (system: f {