Put templates on top of main flake

This commit is contained in:
Luc Perkins 2022-07-31 23:12:51 +02:00
parent 0ba5e5f50a
commit 43df5c9b0b
No known key found for this signature in database
GPG key ID: 4F102D0C16E232F2

View file

@ -8,52 +8,7 @@
}; };
outputs = { self, nixpkgs, flake-utils }: outputs = { self, nixpkgs, flake-utils }:
flake-utils.lib.eachDefaultSystem (system: {
let
pkgs = import nixpkgs { inherit system; };
inherit (pkgs) mkShell writeScriptBin;
run = pkg: "${pkgs.${pkg}}/bin/${pkg}";
format = writeScriptBin "format" ''
${run "nixfmt"} **/*.nix
'';
update = writeScriptBin "update" ''
# Update root
$${run "nix"} flake update
for dir in `ls -d */`; do # Iterate through all the templates
(
cd $dir
${run "nix"} flake update # Update flake.lock
${run "direnv"} reload # Make sure things work after the update
)
done
'';
visit = writeScriptBin "visit" ''
for dir in `ls -d */`; do
(
cd $dir
${run "direnv"} reload
)
done
'';
in {
devShells = {
default = mkShell {
buildInputs = [ format update visit ];
};
};
}
) // {
lib = let
pkgs = nixpkgs;
inherit (pkgs.lib) optionals;
inherit (pkgs.stdenv) isDarwin isLinux;
in {
inherit flake-utils nixpkgs;
};
templates = { templates = {
cue = { cue = {
path = ./cue; path = ./cue;
@ -155,5 +110,50 @@
description = "Zig development environment"; description = "Zig development environment";
}; };
}; };
lib = let
pkgs = nixpkgs;
inherit (pkgs.lib) optionals;
inherit (pkgs.stdenv) isDarwin isLinux;
in {
inherit flake-utils nixpkgs;
};
} // flake-utils.lib.eachDefaultSystem (system:
let
pkgs = import nixpkgs { inherit system; };
inherit (pkgs) mkShell writeScriptBin;
run = pkg: "${pkgs.${pkg}}/bin/${pkg}";
format = writeScriptBin "format" ''
${run "nixfmt"} **/*.nix
'';
update = writeScriptBin "update" ''
# Update root
$${run "nix"} flake update
for dir in `ls -d */`; do # Iterate through all the templates
(
cd $dir
${run "nix"} flake update # Update flake.lock
${run "direnv"} reload # Make sure things work after the update
)
done
'';
visit = writeScriptBin "visit" ''
for dir in `ls -d */`; do
(
cd $dir
${run "direnv"} reload
)
done
'';
in {
devShells = {
default = mkShell {
buildInputs = [ format update visit ];
};
}; };
} }
);
}