nixpkgs/nixos/modules/system/boot/tmp.nix
Janne Heß 56d7e7492c
nixos/tmp: Make /tmp on ramdisk usable again
@poettering decided we only need a limited number of inodes in our /tmp,
so why not limit that for every systemd user? That makes medium-sized nix
builds impossible so this commit restores the old behaviour which is the
kernel default of half the number of physical RAM pages which does not
seem too unreasonable to me.
2020-12-26 13:13:41 +01:00

46 lines
830 B
Nix

{ config, lib, ... }:
with lib;
{
###### interface
options = {
boot.cleanTmpDir = mkOption {
type = types.bool;
default = false;
description = ''
Whether to delete all files in <filename>/tmp</filename> during boot.
'';
};
boot.tmpOnTmpfs = mkOption {
type = types.bool;
default = false;
description = ''
Whether to mount a tmpfs on <filename>/tmp</filename> during boot.
'';
};
};
###### implementation
config = {
systemd.mounts = mkIf config.boot.tmpOnTmpfs [
{
what = "tmpfs";
where = "/tmp";
mountConfig.Options = [ "mode=1777" "strictatime" "rw" "nosuid" "nodev" "size=50%" ];
}
];
systemd.tmpfiles.rules = optional config.boot.cleanTmpDir "D! /tmp 1777 root root";
};
}