From 43df5c9b0b8285d34353eb2d00975809f5b0bc0a Mon Sep 17 00:00:00 2001 From: Luc Perkins Date: Sun, 31 Jul 2022 23:12:51 +0200 Subject: [PATCH] Put templates on top of main flake --- flake.nix | 94 +++++++++++++++++++++++++++---------------------------- 1 file changed, 47 insertions(+), 47 deletions(-) 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 ]; + }; + }; + } + ); }