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

Make scripts less janky

This commit is contained in:
Luc Perkins 2024-04-15 16:52:35 -03:00
parent 8f13f3a774
commit d0e18d08b9
No known key found for this signature in database
GPG Key ID: 16DB1108FB591835
2 changed files with 31 additions and 21 deletions

1
empty/.envrc Normal file
View File

@ -0,0 +1 @@
use flake

View File

@ -6,26 +6,35 @@
outputs = { self, nixpkgs }:
let
overlays = [
(final: prev:
let
exec = pkg: "${prev.${pkg}}/bin/${pkg}";
in
{
format = prev.writeScriptBin "format" ''
${exec "nixpkgs-fmt"} **/*.nix
'';
(final: prev: {
format = final.writeShellApplication {
name = "format";
runtimeInputs = with final; [ nixpkgs-fmt ];
text = "nixpkgs-fmt '**/*.nix'";
};
check = prev.writeScriptBin "check" ''
for dir in `ls -d */`; do # Iterate through all the templates
check = final.writeShellApplication {
name = "check";
text = ''
SYSTEM=$(nix eval --impure --raw --expr 'builtins.currentSystem')
for dir in */; do # Iterate through all the templates
(
cd $dir
cd "''${dir}"
echo "checking ''${dir}"
nix flake check --all-systems --no-build
echo "building ''${dir}"
nix build ".#devShells.''${SYSTEM}.default"
)
done
'';
};
dvt = prev.writeScriptBin "dvt" ''
dvt = final.writeShellApplication {
name = "dvt";
text = ''
if [ -z $1 ]; then
echo "no template specified"
exit 1
@ -33,31 +42,31 @@
TEMPLATE=$1
${exec "nix"} \
nix \
--experimental-features 'nix-command flakes' \
flake init \
--template \
"github:the-nix-way/dev-templates#''${TEMPLATE}"
'';
};
update = prev.writeScriptBin "update" ''
for dir in `ls -d */`; do # Iterate through all the templates
update = final.writeShellApplication {
name = "update";
text = ''
for dir in */; do # Iterate through all the templates
(
cd $dir
cd "''${dir}"
echo "updating ''${dir}"
# Update flake.lock
nix flake update
echo "checking ''${dir}"
# Make sure things work after the update
nix flake check --all-systems --no-build
)
done
'';
})
};
})
];
supportedSystems = [ "x86_64-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin" ];
forEachSupportedSystem = f: nixpkgs.lib.genAttrs supportedSystems (system: f {