diff --git a/modules/system/gui.nix b/modules/system/gui.nix index c39a55ce..f1e847ba 100644 --- a/modules/system/gui.nix +++ b/modules/system/gui.nix @@ -6,32 +6,33 @@ inputs: preferred = mkOption { type = types.bool; default = inputs.config.nixos.system.gui.enable; }; autoStart = mkOption { type = types.bool; default = inputs.config.nixos.system.gui.preferred; }; }; - config = - let - inherit (builtins) map; - inherit (inputs.lib) mkIf; - inherit (inputs.config.nixos.system) gui; - in mkIf gui.enable + config = let inherit (inputs.config.nixos.system) gui; in inputs.lib.mkIf gui.enable + { + services = { - services = - { - displayManager = - { sddm = { enable = true; wayland.enable = true; theme = "breeze"; }; defaultSession = "plasma"; }; - desktopManager.plasma6.enable = true; - xserver.enable = true; - }; - systemd.services.display-manager.enable = gui.autoStart; - environment = - { - sessionVariables."GTK_USE_PORTAL" = "1"; - plasma6.excludePackages = inputs.lib.mkIf (!gui.preferred) [ inputs.pkgs.kdePackages.plasma-nm ]; - }; - xdg.portal.extraPortals = map (p: inputs.pkgs."xdg-desktop-portal-${p}") [ "gtk" "wlr" ]; - i18n.inputMethod = - { - enabled = "fcitx5"; - fcitx5.addons = map (p: inputs.pkgs."fcitx5-${p}") [ "rime" "chinese-addons" "mozc" "nord" "material-color" ]; - }; - programs = { dconf.enable = true; }; + displayManager = + { sddm = { enable = true; wayland.enable = true; theme = "breeze"; }; defaultSession = "plasma"; }; + desktopManager.plasma6.enable = true; + xserver.enable = true; }; + systemd.services.display-manager.enable = gui.autoStart; + environment = + { + sessionVariables."GTK_USE_PORTAL" = "1"; + plasma6.excludePackages = inputs.lib.mkIf (!gui.preferred) [ inputs.pkgs.kdePackages.plasma-nm ]; + persistence = let inherit (inputs.config.nixos.system) impermanence; in inputs.lib.mkIf impermanence.enable + { + "${impermanence.root}".directories = + [{ directory = "/var/lib/sddm"; user = "sddm"; group = "sddm"; mode = "0700"; }]; + }; + }; + xdg.portal.extraPortals = builtins.map (p: inputs.pkgs."xdg-desktop-portal-${p}") [ "gtk" "wlr" ]; + i18n.inputMethod = + { + enabled = "fcitx5"; + fcitx5.addons = builtins.map (p: inputs.pkgs."fcitx5-${p}") + [ "rime" "chinese-addons" "mozc" "nord" "material-color" ]; + }; + programs.dconf.enable = true; + }; } diff --git a/modules/system/impermanence.nix b/modules/system/impermanence.nix index 8184a780..83e24004 100644 --- a/modules/system/impermanence.nix +++ b/modules/system/impermanence.nix @@ -7,68 +7,62 @@ inputs: root = mkOption { type = types.nonEmptyStr; default = "/nix/rootfs/current"; }; nodatacow = mkOption { type = types.nullOr types.nonEmptyStr; default = "/nix/nodatacow"; }; }; - config = - let - inherit (inputs.lib) mkIf; - inherit (inputs.config.nixos.system) impermanence; - in mkIf impermanence.enable + config = let inherit (inputs.config.nixos.system) impermanence; in inputs.lib.mkIf impermanence.enable + { + environment.persistence = { - environment.persistence = + "${impermanence.persistence}" = { - "${impermanence.persistence}" = + hideMounts = true; + directories = + [ + "/var/db" + "/var/lib" + "/var/log" + "/var/spool" + "/var/backup" + { directory = "/var/lib/docker/volumes"; mode = "0710"; } + "/srv" + ]; + files = + [ + "/etc/machine-id" + "/etc/ssh/ssh_host_ed25519_key.pub" + "/etc/ssh/ssh_host_ed25519_key" + "/etc/ssh/ssh_host_rsa_key.pub" + "/etc/ssh/ssh_host_rsa_key" + ]; + }; + "${impermanence.root}" = + { + hideMounts = true; + directories = + [ + "/var/lib/systemd/linger" + "/var/lib/systemd/coredump" + "/var/lib/systemd/backlight" + { directory = "/var/lib/docker"; mode = "0710"; } + "/var/lib/flatpak" + ]; + } + // (if builtins.elem "chn" inputs.config.nixos.user.users then + { + users.chn = { - hideMounts = true; - directories = - [ - "/var/db" - "/var/lib" - "/var/log" - "/var/spool" - "/var/backup" - { directory = "/var/lib/docker/volumes"; mode = "0710"; } - "/srv" - ]; - files = - [ - "/etc/machine-id" - "/etc/ssh/ssh_host_ed25519_key.pub" - "/etc/ssh/ssh_host_ed25519_key" - "/etc/ssh/ssh_host_rsa_key.pub" - "/etc/ssh/ssh_host_rsa_key" - ]; - }; - "${impermanence.root}" = - { - hideMounts = true; - directories = - [ - "/var/lib/systemd/linger" - "/var/lib/systemd/coredump" - "/var/lib/systemd/backlight" - { directory = "/var/lib/docker"; mode = "0710"; } - "/var/lib/flatpak" - ] - ++ (if inputs.config.services.displayManager.sddm.enable then - [{ directory = "/var/lib/sddm"; user = "sddm"; group = "sddm"; mode = "0700"; }] else []); - } - // (if builtins.elem "chn" inputs.config.nixos.user.users then - { - users.chn = - { - directories = [ ".cache" ".config/fontconfig" ]; - }; - } else {}); - "${impermanence.nodatacow}" = - { - hideMounts = true; - directories = - [{ directory = "/var/log/journal"; user = "root"; group = "systemd-journal"; mode = "u=rwx,g=rx+s,o=rx"; }] - ++ ( - if inputs.config.nixos.virtualization.kvmHost.enable then - [{ directory = "/var/lib/libvirt/images"; mode = "0711"; }] - else [] - ); + directories = [ ".cache" ".config/fontconfig" ]; }; + } else {}); + "${impermanence.nodatacow}" = + { + hideMounts = true; + directories = + [{ directory = "/var/log/journal"; user = "root"; group = "systemd-journal"; mode = "u=rwx,g=rx+s,o=rx"; }] + ++ ( + if inputs.config.nixos.virtualization.kvmHost.enable then + [{ directory = "/var/lib/libvirt/images"; mode = "0711"; }] + else [] + ); }; }; + }; }