nixos/boot.tmp: remove with lib;

This commit is contained in:
Felix Buehler 2024-08-28 21:19:12 +02:00 committed by Jörg Thalheim
parent 2f7c0a170f
commit a83ffb43de

View File

@ -1,29 +1,26 @@
{ config, lib, ... }:
with lib;
let
cfg = config.boot.tmp;
in
{
imports = [
(mkRenamedOptionModule [ "boot" "cleanTmpDir" ] [ "boot" "tmp" "cleanOnBoot" ])
(mkRenamedOptionModule [ "boot" "tmpOnTmpfs" ] [ "boot" "tmp" "useTmpfs" ])
(mkRenamedOptionModule [ "boot" "tmpOnTmpfsSize" ] [ "boot" "tmp" "tmpfsSize" ])
(lib.mkRenamedOptionModule [ "boot" "cleanTmpDir" ] [ "boot" "tmp" "cleanOnBoot" ])
(lib.mkRenamedOptionModule [ "boot" "tmpOnTmpfs" ] [ "boot" "tmp" "useTmpfs" ])
(lib.mkRenamedOptionModule [ "boot" "tmpOnTmpfsSize" ] [ "boot" "tmp" "tmpfsSize" ])
];
options = {
boot.tmp = {
cleanOnBoot = mkOption {
type = types.bool;
cleanOnBoot = lib.mkOption {
type = lib.types.bool;
default = false;
description = ''
Whether to delete all files in {file}`/tmp` during boot.
'';
};
tmpfsSize = mkOption {
type = types.oneOf [ types.str types.types.ints.positive ];
tmpfsSize = lib.mkOption {
type = lib.types.oneOf [ lib.types.str lib.types.ints.positive ];
default = "50%";
description = ''
Size of tmpfs in percentage.
@ -31,8 +28,8 @@ in
'';
};
useTmpfs = mkOption {
type = types.bool;
useTmpfs = lib.mkOption {
type = lib.types.bool;
default = false;
description = ''
Whether to mount a tmpfs on {file}`/tmp` during boot.
@ -48,12 +45,12 @@ in
config = {
# When changing remember to update /tmp mount in virtualisation/qemu-vm.nix
systemd.mounts = mkIf cfg.useTmpfs [
systemd.mounts = lib.mkIf cfg.useTmpfs [
{
what = "tmpfs";
where = "/tmp";
type = "tmpfs";
mountConfig.Options = concatStringsSep "," [
mountConfig.Options = lib.concatStringsSep "," [
"mode=1777"
"strictatime"
"rw"
@ -64,6 +61,6 @@ in
}
];
systemd.tmpfiles.rules = optional cfg.cleanOnBoot "D! /tmp 1777 root root";
systemd.tmpfiles.rules = lib.optional cfg.cleanOnBoot "D! /tmp 1777 root root";
};
}