2014-07-25 19:05:57 +01:00
|
|
|
{ config, lib, ... }:
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
2021-09-02 14:20:50 +01:00
|
|
|
let
|
|
|
|
cfg = config.boot;
|
|
|
|
in
|
2014-07-25 19:05:57 +01:00
|
|
|
{
|
|
|
|
|
|
|
|
###### 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.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2021-09-02 14:20:50 +01:00
|
|
|
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.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2014-07-25 19:05:57 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
###### implementation
|
|
|
|
|
|
|
|
config = {
|
|
|
|
|
2021-09-02 14:20:50 +01:00
|
|
|
# When changing remember to update /tmp mount in virtualisation/qemu-vm.nix
|
|
|
|
systemd.mounts = mkIf cfg.tmpOnTmpfs [
|
2020-12-23 21:44:20 +00:00
|
|
|
{
|
|
|
|
what = "tmpfs";
|
|
|
|
where = "/tmp";
|
2021-01-09 14:32:17 +00:00
|
|
|
type = "tmpfs";
|
2022-01-31 11:49:29 +00:00
|
|
|
mountConfig.Options = concatStringsSep "," [ "mode=1777"
|
|
|
|
"strictatime"
|
|
|
|
"rw"
|
|
|
|
"nosuid"
|
|
|
|
"nodev"
|
|
|
|
"size=${toString cfg.tmpOnTmpfsSize}" ];
|
2020-12-23 21:44:20 +00:00
|
|
|
}
|
|
|
|
];
|
2014-07-25 19:05:57 +01:00
|
|
|
|
|
|
|
systemd.tmpfiles.rules = optional config.boot.cleanTmpDir "D! /tmp 1777 root root";
|
|
|
|
|
|
|
|
};
|
|
|
|
|
2020-08-08 01:54:16 +01:00
|
|
|
}
|