Add visit command

This commit is contained in:
Luc Perkins 2022-07-31 22:05:33 +02:00
parent eefc02f206
commit 056f6f7068
No known key found for this signature in database
GPG key ID: 4F102D0C16E232F2

View file

@ -11,26 +11,37 @@
flake-utils.lib.eachDefaultSystem (system: flake-utils.lib.eachDefaultSystem (system:
let let
pkgs = import nixpkgs { inherit system; }; pkgs = import nixpkgs { inherit system; };
inherit (pkgs) mkShell; inherit (pkgs) mkShell writeScriptBin;
format = pkgs.writeScriptBin "format" '' run = pkg: "${pkgs.${pkg}}/bin/${pkg}";
${pkgs.nixfmt}/bin/nixfmt **/*.nix
format = writeScriptBin "format" ''
${run "nixfmt"} **/*.nix
''; '';
update = pkgs.writeScriptBin "update" '' update = writeScriptBin "update" ''
# Update root # Update root
${pkgs.nix}/bin/nix flake update $${run "nix"} flake update
for dir in `ls -d */`; do # Iterate through all the templates for dir in `ls -d */`; do # Iterate through all the templates
( (
cd $dir cd $dir
${pkgs.nix}/bin/nix flake update # Update flake.lock ${run "nix"} flake update # Update flake.lock
${pkgs.direnv}/bin/direnv reload # Make sure things work after the update ${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 done
''; '';
in { in {
devShells = { devShells = {
default = mkShell { default = mkShell {
buildInputs = with pkgs; [ format update ]; buildInputs = [ format update visit ];
}; };
}; };
} }