diff --git a/flake.nix b/flake.nix index e81d42b..e3ba3fb 100644 --- a/flake.nix +++ b/flake.nix @@ -8,52 +8,7 @@ }; 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 = { cue = { path = ./cue; @@ -155,5 +110,50 @@ 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 ]; + }; + }; + } + ); }