From 056f6f706874d4e334426588807e0b09b42a6eed Mon Sep 17 00:00:00 2001 From: Luc Perkins Date: Sun, 31 Jul 2022 22:05:33 +0200 Subject: [PATCH] Add visit command --- flake.nix | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/flake.nix b/flake.nix index 88a84af..2c0b2ee 100644 --- a/flake.nix +++ b/flake.nix @@ -11,26 +11,37 @@ flake-utils.lib.eachDefaultSystem (system: let pkgs = import nixpkgs { inherit system; }; - inherit (pkgs) mkShell; - format = pkgs.writeScriptBin "format" '' - ${pkgs.nixfmt}/bin/nixfmt **/*.nix + inherit (pkgs) mkShell writeScriptBin; + run = pkg: "${pkgs.${pkg}}/bin/${pkg}"; + + format = writeScriptBin "format" '' + ${run "nixfmt"} **/*.nix ''; - update = pkgs.writeScriptBin "update" '' + update = writeScriptBin "update" '' # Update root - ${pkgs.nix}/bin/nix flake update + $${run "nix"} flake update for dir in `ls -d */`; do # Iterate through all the templates ( cd $dir - ${pkgs.nix}/bin/nix flake update # Update flake.lock - ${pkgs.direnv}/bin/direnv reload # Make sure things work after the update + ${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 = with pkgs; [ format update ]; + buildInputs = [ format update visit ]; }; }; }