diff --git a/hosts/idols-aquamarine/preservation.nix b/hosts/idols-aquamarine/preservation.nix index b8d1c382..c1b818d7 100644 --- a/hosts/idols-aquamarine/preservation.nix +++ b/hosts/idols-aquamarine/preservation.nix @@ -73,17 +73,25 @@ in # re-downloading tens of GB is not a boot step. "models" + # Caches. A cold flake cache makes `nix run ` re-download its + # input at boot, which needs DNS, and on a tmpfs root cache writes are RAM. + ".cache" + ".config/systemd/user" ".config/containers/systemd" ]; }; }; - # `.config`/`.local` are not immediate parents of any persisted path here, so - # tmpfiles would create them root:root 0755 and the user could not write - # under them. Same fix as hosts/idols-ai/preservation.nix, plus the `.config` - # subdirectories that hold a mount point. + # The parents of the persisted paths below are not themselves persisted, so + # tmpfiles would create them root:root 0755 and the user could not write under + # them. Same fix as hosts/idols-ai/preservation.nix. systemd.tmpfiles.settings.preservation = { + "/home/${username}/.cache".d = { + user = username; + group = lib.mkForce username; + mode = lib.mkForce "0750"; + }; "/home/${username}/.config".d = { user = username; group = lib.mkForce username; diff --git a/outputs/x86_64-linux/tests/idols-aquamarine/expected.nix b/outputs/x86_64-linux/tests/idols-aquamarine/expected.nix index e3c4adce..8836bfa2 100644 --- a/outputs/x86_64-linux/tests/idols-aquamarine/expected.nix +++ b/outputs/x86_64-linux/tests/idols-aquamarine/expected.nix @@ -8,6 +8,7 @@ cStatesCapped = true; nativeIpv6Preference = true; sourceCheckoutsPersistent = true; + cachePersistent = true; userUnitDirsPersistent = true; rootlessPodmanEnabled = true; stableKernel = true; diff --git a/outputs/x86_64-linux/tests/idols-aquamarine/expr.nix b/outputs/x86_64-linux/tests/idols-aquamarine/expr.nix index 42299f9f..aea37fd0 100644 --- a/outputs/x86_64-linux/tests/idols-aquamarine/expr.nix +++ b/outputs/x86_64-linux/tests/idols-aquamarine/expr.nix @@ -37,6 +37,11 @@ in d: d.directory == "/home/${myvars.username}/src" ) cfg.preservation.preserveAt."/persistent".users.${myvars.username}.directories; + # A cold flake cache re-downloads the input of a `nix run ` at boot. + cachePersistent = builtins.any ( + d: d.directory == "/home/${myvars.username}/.cache" + ) cfg.preservation.preserveAt."/persistent".users.${myvars.username}.directories; + # Directories the tmpfs root would otherwise drop. userUnitDirsPersistent = let