Merge pull request #136471 from Artturin/tmpontmpfssize

This commit is contained in:
Artturi 2021-09-16 02:25:02 +03:00 committed by GitHub
commit 74b3e9ff87
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 3 deletions

View File

@ -2,6 +2,9 @@
with lib;
let
cfg = config.boot;
in
{
###### interface
@ -24,18 +27,28 @@ with lib;
'';
};
boot.tmpOnTmpfsSize = mkOption {
type = types.oneOf [ types.str types.types.ints.positive ];
default = "50%";
description = ''
Size of tmpfs in percentage.
Percentage is defined by systemd.
'';
};
};
###### implementation
config = {
systemd.mounts = mkIf config.boot.tmpOnTmpfs [
# When changing remember to update /tmp mount in virtualisation/qemu-vm.nix
systemd.mounts = mkIf cfg.tmpOnTmpfs [
{
what = "tmpfs";
where = "/tmp";
type = "tmpfs";
mountConfig.Options = [ "mode=1777" "strictatime" "rw" "nosuid" "nodev" "size=50%" ];
mountConfig.Options = [ "mode=1777" "strictatime" "rw" "nosuid" "nodev" "size=${toString cfg.tmpOnTmpfsSize}" ];
}
];

View File

@ -686,7 +686,7 @@ in
fsType = "tmpfs";
neededForBoot = true;
# Sync with systemd's tmp.mount;
options = [ "mode=1777" "strictatime" "nosuid" "nodev" ];
options = [ "mode=1777" "strictatime" "nosuid" "nodev" "size=${toString config.boot.tmpOnTmpfsSize}" ];
};
"/tmp/xchg" =
{ device = "xchg";