diff --git a/modules/options/prune-lock.nix b/modules/options/prune-lock.nix index cd92b80..b34735b 100644 --- a/modules/options/prune-lock.nix +++ b/modules/options/prune-lock.nix @@ -30,10 +30,15 @@ let pkgs: pkgs.writeShellApplication { name = "prune-lock"; + runtimeInputs = [ pkgs.diffutils ]; text = '' - nix flake metadata > /dev/null ${prune-cmd pkgs} flake.lock pruned.lock - mv pruned.lock flake.lock + if cmp -s flake.lock pruned.lock; then + rm pruned.lock + else + mv pruned.lock flake.lock + fi + nix flake metadata > /dev/null ''; }; diff --git a/modules/write-flake.nix b/modules/write-flake.nix index 33dc05d..da09c31 100644 --- a/modules/write-flake.nix +++ b/modules/write-flake.nix @@ -110,9 +110,12 @@ let pkgs.writeShellApplication { name = "write-flake"; meta.description = "Generate a flake.nix file"; + runtimeInputs = [ pkgs.diffutils ]; text = '' cd ${config.flake-file.intoPath} - cat ${formatted pkgs} > flake.nix + if ! cmp -s ${formatted pkgs} flake.nix; then + cat ${formatted pkgs} > flake.nix + fi ${hooks} ''; };