lol

nixos/tmp: move /tmp options under boot.tmp

+43 -43
+1 -1
nixos/modules/installer/tools/nixos-generate-config.pl
··· 473 473 } 474 474 475 475 # Don't emit tmpfs entry for /tmp, because it most likely comes from the 476 - # boot.tmpOnTmpfs option in configuration.nix (managed declaratively). 476 + # boot.tmp.useTmpfs option in configuration.nix (managed declaratively). 477 477 next if ($mountPoint eq "/tmp" && $fsType eq "tmpfs"); 478 478 479 479 # Emit the filesystem.
+39 -39
nixos/modules/system/boot/tmp.nix
··· 3 3 with lib; 4 4 5 5 let 6 - cfg = config.boot; 6 + cfg = config.boot.tmp; 7 7 in 8 8 { 9 - 10 - ###### interface 9 + imports = [ 10 + (mkRenamedOptionModule [ "boot" "cleanTmpDir" ] [ "boot" "tmp" "cleanOnBoot" ]) 11 + (mkRenamedOptionModule [ "boot" "tmpOnTmpfs" ] [ "boot" "tmp" "useTmpfs" ]) 12 + (mkRenamedOptionModule [ "boot" "tmpOnTmpfsSize" ] [ "boot" "tmp" "tmpfsSize" ]) 13 + ]; 11 14 12 15 options = { 16 + boot.tmp = { 17 + cleanOnBoot = mkOption { 18 + type = types.bool; 19 + default = false; 20 + description = lib.mdDoc '' 21 + Whether to delete all files in {file}`/tmp` during boot. 22 + ''; 23 + }; 13 24 14 - boot.cleanTmpDir = mkOption { 15 - type = types.bool; 16 - default = false; 17 - description = lib.mdDoc '' 18 - Whether to delete all files in {file}`/tmp` during boot. 19 - ''; 20 - }; 21 - 22 - boot.tmpOnTmpfs = mkOption { 23 - type = types.bool; 24 - default = false; 25 - description = lib.mdDoc '' 26 - Whether to mount a tmpfs on {file}`/tmp` during boot. 27 - ''; 28 - }; 25 + tmpfsSize = mkOption { 26 + type = types.oneOf [ types.str types.types.ints.positive ]; 27 + default = "50%"; 28 + description = lib.mdDoc '' 29 + Size of tmpfs in percentage. 30 + Percentage is defined by systemd. 31 + ''; 32 + }; 29 33 30 - boot.tmpOnTmpfsSize = mkOption { 31 - type = types.oneOf [ types.str types.types.ints.positive ]; 32 - default = "50%"; 33 - description = lib.mdDoc '' 34 - Size of tmpfs in percentage. 35 - Percentage is defined by systemd. 36 - ''; 34 + useTmpfs = mkOption { 35 + type = types.bool; 36 + default = false; 37 + description = lib.mdDoc '' 38 + Whether to mount a tmpfs on {file}`/tmp` during boot. 39 + ''; 40 + }; 37 41 }; 38 - 39 42 }; 40 - 41 - ###### implementation 42 43 43 44 config = { 44 - 45 45 # When changing remember to update /tmp mount in virtualisation/qemu-vm.nix 46 - systemd.mounts = mkIf cfg.tmpOnTmpfs [ 46 + systemd.mounts = mkIf cfg.useTmpfs [ 47 47 { 48 48 what = "tmpfs"; 49 49 where = "/tmp"; 50 50 type = "tmpfs"; 51 - mountConfig.Options = concatStringsSep "," [ "mode=1777" 52 - "strictatime" 53 - "rw" 54 - "nosuid" 55 - "nodev" 56 - "size=${toString cfg.tmpOnTmpfsSize}" ]; 51 + mountConfig.Options = concatStringsSep "," [ 52 + "mode=1777" 53 + "strictatime" 54 + "rw" 55 + "nosuid" 56 + "nodev" 57 + "size=${toString cfg.tmpfsSize}" 58 + ]; 57 59 } 58 60 ]; 59 61 60 - systemd.tmpfiles.rules = optional config.boot.cleanTmpDir "D! /tmp 1777 root root"; 61 - 62 + systemd.tmpfiles.rules = optional cfg.cleanOnBoot "D! /tmp 1777 root root"; 62 63 }; 63 - 64 64 }
+2 -2
nixos/modules/virtualisation/qemu-vm.nix
··· 1069 1069 fsType = "ext4"; 1070 1070 autoFormat = true; 1071 1071 }); 1072 - "/tmp" = lib.mkIf config.boot.tmpOnTmpfs { 1072 + "/tmp" = lib.mkIf config.boot.tmp.useTmpfs { 1073 1073 device = "tmpfs"; 1074 1074 fsType = "tmpfs"; 1075 1075 neededForBoot = true; 1076 1076 # Sync with systemd's tmp.mount; 1077 - options = [ "mode=1777" "strictatime" "nosuid" "nodev" "size=${toString config.boot.tmpOnTmpfsSize}" ]; 1077 + options = [ "mode=1777" "strictatime" "nosuid" "nodev" "size=${toString config.boot.tmp.tmpfsSize}" ]; 1078 1078 }; 1079 1079 "/nix/${if cfg.writableStore then ".ro-store" else "store"}" = lib.mkIf cfg.useNixStoreImage { 1080 1080 device = "${lookupDriveDeviceName "nix-store" cfg.qemu.drives}";
+1 -1
nixos/tests/ihatemoney/default.nix
··· 17 17 http = ":8000"; 18 18 }; 19 19 }; 20 - boot.cleanTmpDir = true; 20 + boot.tmp.cleanOnBoot = true; 21 21 # for exchange rates 22 22 security.pki.certificateFiles = [ ./server.crt ]; 23 23 networking.extraHosts = "127.0.0.1 api.exchangerate.host";