mirror of
https://github.com/SebastianWendel/nixpkgs.git
synced 2024-09-21 04:49:01 +02:00
nixos/tmp: add tmpOnTmpfsSize
This commit is contained in:
parent
6b369a4de7
commit
f45e8d560e
|
@ -2,6 +2,9 @@
|
||||||
|
|
||||||
with lib;
|
with lib;
|
||||||
|
|
||||||
|
let
|
||||||
|
cfg = config.boot;
|
||||||
|
in
|
||||||
{
|
{
|
||||||
|
|
||||||
###### interface
|
###### 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
|
###### implementation
|
||||||
|
|
||||||
config = {
|
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";
|
what = "tmpfs";
|
||||||
where = "/tmp";
|
where = "/tmp";
|
||||||
type = "tmpfs";
|
type = "tmpfs";
|
||||||
mountConfig.Options = [ "mode=1777" "strictatime" "rw" "nosuid" "nodev" "size=50%" ];
|
mountConfig.Options = [ "mode=1777" "strictatime" "rw" "nosuid" "nodev" "size=${toString cfg.tmpOnTmpfsSize}" ];
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
|
@ -686,7 +686,7 @@ in
|
||||||
fsType = "tmpfs";
|
fsType = "tmpfs";
|
||||||
neededForBoot = true;
|
neededForBoot = true;
|
||||||
# Sync with systemd's tmp.mount;
|
# 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" =
|
"/tmp/xchg" =
|
||||||
{ device = "xchg";
|
{ device = "xchg";
|
||||||
|
|
Loading…
Reference in a new issue