auto-upgrade: store flake input refs #80

Merged
pederbs merged 1 commits from retain-flake-inputs into main 2024-09-21 22:19:19 +02:00

View File

@ -1,4 +1,4 @@
{ ... }: { inputs, pkgs, lib, ... }:
{ {
system.autoUpgrade = { system.autoUpgrade = {
enable = true; enable = true;
@ -12,4 +12,15 @@
"--no-write-lock-file" "--no-write-lock-file"
]; ];
}; };
# workaround for https://github.com/NixOS/nix/issues/6895
# via https://git.lix.systems/lix-project/lix/issues/400
environment.etc."current-system-flake-inputs.json".source
= pkgs.writers.writeJSON "flake-inputs.json" (
lib.flip lib.mapAttrs inputs (name: input:
# inputs.*.sourceInfo sans outPath, since writeJSON will otherwise serialize sourceInfo like a derivation
lib.removeAttrs (input.sourceInfo or {}) [ "outPath" ]
pederbs marked this conversation as resolved Outdated

Maybe this could be simplified?

lib.removeAttrs (input.sourceInfo or {} // { store-path = input.outPath; }) [ "outPath" ]
Maybe this could be simplified? ``` lib.removeAttrs (input.sourceInfo or {} // { store-path = input.outPath; }) [ "outPath" ] ```

i was looking for that library function, but my search for "filterAttrs" turned up empty

i was looking for that library function, but my search for "filterAttrs" turned up empty
// { store-path = input.outPath; } # comment this line if you don't want to retain a store reference to the flake inputs
)
);
} }