From b67b843c130c7abe81684496d612966ca7a76f5a Mon Sep 17 00:00:00 2001 From: "Casper V. Kristensen" Date: Wed, 3 Apr 2024 00:23:45 +0200 Subject: [PATCH] /tmp on tmpfs, /var/tmp on disk --- modules/base/impermanence.nix | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/modules/base/impermanence.nix b/modules/base/impermanence.nix index 31a492a..b79009b 100644 --- a/modules/base/impermanence.nix +++ b/modules/base/impermanence.nix @@ -15,25 +15,11 @@ impermanence.nixosModules.impermanence ]; - # We *don't* want to use tmpfs for /tmp in case we have to put big files - # there. Instead, we mount it to the disk and instruct systemd to clean it on - # boot. - # TODO: There might be a way to configure /tmp to be in-memory storage until - # it gets too big. - boot.tmp.cleanOnBoot = true; - # Each module will configure the paths they need persisted. Here we define # some general system paths that don't really fit anywhere else. environment.persistence."/nix/persist" = { hideMounts = true; directories = [ - # See comment above for /tmp - { - directory = "/tmp"; - user = "root"; - group = "root"; - mode = "1777"; - } # The uid and gid maps for entities without a static id is saved in # /var/lib/nixos. Persist to ensure they aren't changed between reboots. { @@ -55,6 +41,15 @@ group = "root"; mode = "0755"; } + # /var/tmp is meant for temporary files that are preserved across + # reboots. Some programs might store files too big for in-memory /tmp + # there. Files older than 10 days are cleaned by systemd. + { + directory = "/var/tmp"; + user = "root"; + group = "root"; + mode = "1777"; + } ]; files = [ "/etc/machine-id" # needed for /var/log