···473473 }
474474475475 # Don't emit tmpfs entry for /tmp, because it most likely comes from the
476476- # boot.tmpOnTmpfs option in configuration.nix (managed declaratively).
476476+ # boot.tmp.useTmpfs option in configuration.nix (managed declaratively).
477477 next if ($mountPoint eq "/tmp" && $fsType eq "tmpfs");
478478479479 # Emit the filesystem.
+39-39
nixos/modules/system/boot/tmp.nix
···33with lib;
4455let
66- cfg = config.boot;
66+ cfg = config.boot.tmp;
77in
88{
99-1010- ###### interface
99+ imports = [
1010+ (mkRenamedOptionModule [ "boot" "cleanTmpDir" ] [ "boot" "tmp" "cleanOnBoot" ])
1111+ (mkRenamedOptionModule [ "boot" "tmpOnTmpfs" ] [ "boot" "tmp" "useTmpfs" ])
1212+ (mkRenamedOptionModule [ "boot" "tmpOnTmpfsSize" ] [ "boot" "tmp" "tmpfsSize" ])
1313+ ];
11141215 options = {
1616+ boot.tmp = {
1717+ cleanOnBoot = mkOption {
1818+ type = types.bool;
1919+ default = false;
2020+ description = lib.mdDoc ''
2121+ Whether to delete all files in {file}`/tmp` during boot.
2222+ '';
2323+ };
13241414- boot.cleanTmpDir = mkOption {
1515- type = types.bool;
1616- default = false;
1717- description = lib.mdDoc ''
1818- Whether to delete all files in {file}`/tmp` during boot.
1919- '';
2020- };
2121-2222- boot.tmpOnTmpfs = mkOption {
2323- type = types.bool;
2424- default = false;
2525- description = lib.mdDoc ''
2626- Whether to mount a tmpfs on {file}`/tmp` during boot.
2727- '';
2828- };
2525+ tmpfsSize = mkOption {
2626+ type = types.oneOf [ types.str types.types.ints.positive ];
2727+ default = "50%";
2828+ description = lib.mdDoc ''
2929+ Size of tmpfs in percentage.
3030+ Percentage is defined by systemd.
3131+ '';
3232+ };
29333030- boot.tmpOnTmpfsSize = mkOption {
3131- type = types.oneOf [ types.str types.types.ints.positive ];
3232- default = "50%";
3333- description = lib.mdDoc ''
3434- Size of tmpfs in percentage.
3535- Percentage is defined by systemd.
3636- '';
3434+ useTmpfs = mkOption {
3535+ type = types.bool;
3636+ default = false;
3737+ description = lib.mdDoc ''
3838+ Whether to mount a tmpfs on {file}`/tmp` during boot.
3939+ '';
4040+ };
3741 };
3838-3942 };
4040-4141- ###### implementation
42434344 config = {
4444-4545 # When changing remember to update /tmp mount in virtualisation/qemu-vm.nix
4646- systemd.mounts = mkIf cfg.tmpOnTmpfs [
4646+ systemd.mounts = mkIf cfg.useTmpfs [
4747 {
4848 what = "tmpfs";
4949 where = "/tmp";
5050 type = "tmpfs";
5151- mountConfig.Options = concatStringsSep "," [ "mode=1777"
5252- "strictatime"
5353- "rw"
5454- "nosuid"
5555- "nodev"
5656- "size=${toString cfg.tmpOnTmpfsSize}" ];
5151+ mountConfig.Options = concatStringsSep "," [
5252+ "mode=1777"
5353+ "strictatime"
5454+ "rw"
5555+ "nosuid"
5656+ "nodev"
5757+ "size=${toString cfg.tmpfsSize}"
5858+ ];
5759 }
5860 ];
59616060- systemd.tmpfiles.rules = optional config.boot.cleanTmpDir "D! /tmp 1777 root root";
6161-6262+ systemd.tmpfiles.rules = optional cfg.cleanOnBoot "D! /tmp 1777 root root";
6263 };
6363-6464}