From 93624900ad5fa6333f19f408178ad00e3835469e Mon Sep 17 00:00:00 2001 From: Jelle Spreeuwenberg Date: Mon, 27 Apr 2026 16:47:12 +0200 Subject: [PATCH] refactor: reorganize features --- .../{xdg.nix => desktop-defaults.nix} | 33 ++++--- modules/capabilities/email.nix | 88 ------------------- modules/capabilities/local-apps.nix | 34 ------- .../{region-nl.nix => locale-nl.nix} | 2 +- modules/capabilities/networking.nix | 2 +- modules/capabilities/nh.nix | 14 --- modules/capabilities/niri/default.nix | 13 +-- modules/capabilities/nix.nix | 10 ++- .../{bitwarden.nix => passwords.nix} | 3 +- modules/capabilities/pim.nix | 86 +++++++++++++++++- modules/capabilities/services/openssh.nix | 2 +- .../{standard-boot.nix => systemd-boot.nix} | 2 +- modules/capabilities/terminal.nix | 27 ------ modules/data.nix | 4 +- modules/hosts/orion/default.nix | 2 +- modules/lib/schema.nix | 62 ++++++++++++- modules/profiles/host-base.nix | 3 +- modules/profiles/workstation-base.nix | 12 ++- 18 files changed, 193 insertions(+), 206 deletions(-) rename modules/capabilities/{xdg.nix => desktop-defaults.nix} (68%) delete mode 100644 modules/capabilities/email.nix delete mode 100644 modules/capabilities/local-apps.nix rename modules/capabilities/{region-nl.nix => locale-nl.nix} (93%) delete mode 100644 modules/capabilities/nh.nix rename modules/capabilities/{bitwarden.nix => passwords.nix} (86%) rename modules/capabilities/{standard-boot.nix => systemd-boot.nix} (96%) diff --git a/modules/capabilities/xdg.nix b/modules/capabilities/desktop-defaults.nix similarity index 68% rename from modules/capabilities/xdg.nix rename to modules/capabilities/desktop-defaults.nix index 1c609c6..e795b5c 100644 --- a/modules/capabilities/xdg.nix +++ b/modules/capabilities/desktop-defaults.nix @@ -1,26 +1,39 @@ { config, ... }: let repo = config.repo; - repoHelpers = repo.helpers; in { - flake.modules.homeManager.xdg = + flake.modules.homeManager.desktop-defaults = { config, pkgs, ... }: let - browserPackage = repoHelpers.resolvePackagePath { - inherit pkgs; - path = repo.desktop.browser.packagePath; - }; - fileManagerPackage = repoHelpers.resolvePackagePath { - inherit pkgs; - path = repo.desktop.fileManager.packagePath; - }; + browserPackage = pkgs.${repo.desktop.browser.packageAttr}; + fileManagerPackage = pkgs.${repo.desktop.fileManager.packageAttr}; homeDir = config.home.homeDirectory; localDir = "${homeDir}/.local"; mediaDir = "${homeDir}/media"; in { home.preferXdgDirectories = true; + home.sessionVariables.BROWSER = repo.desktop.browser.command; + + home.packages = + with pkgs; + [ + postman + spotify + calcure + planify + unzip + gimp + dbeaver-bin + ] + ++ [ + browserPackage + fileManagerPackage + ]; + + programs.imv.enable = true; + programs.sioyek.enable = true; xdg = { enable = true; diff --git a/modules/capabilities/email.nix b/modules/capabilities/email.nix deleted file mode 100644 index ba7ee2c..0000000 --- a/modules/capabilities/email.nix +++ /dev/null @@ -1,88 +0,0 @@ -{ config, ... }: -let - account = config.repo.account; -in -{ - flake.modules.homeManager.email = - { - config, - lib, - ... - }: - let - mkOffice365Account = - { - address, - primary, - ... - }: - { - enable = true; - inherit address primary; - realName = account.realName; - userName = address; - thunderbird = { - enable = true; - settings = id: { - "mail.smtpserver.smtp_${id}.authMethod" = 10; - "mail.server.server_${id}.authMethod" = 10; - }; - }; - flavor = "outlook.office365.com"; - }; - mkMxrouteAccount = - { - address, - primary, - ... - }: - { - enable = true; - inherit address primary; - realName = account.realName; - userName = address; - thunderbird.enable = true; - imap = { - authentication = "plain"; - host = "taylor.mxrouting.net"; - port = 993; - tls.enable = true; - }; - smtp = { - authentication = "plain"; - host = "taylor.mxrouting.net"; - port = 465; - tls.enable = true; - }; - }; - mkEmailAccount = - email: - if email.type == "office365" then - mkOffice365Account email - else if email.type == "mxrouting" then - mkMxrouteAccount email - else - throw "Unsupported email type `${email.type}` for ${config.home.username}"; - in - { - programs.thunderbird = { - enable = true; - profiles.${config.home.username} = { - isDefault = true; - withExternalGnupg = true; - settings = { - "mail.ui.display.message_pane_vertical" = true; - "mail.ui.display.thread_pane_view_type" = "cards"; - "mail.uidensity" = 1; - "privacy.donottrackheader.enabled" = true; - "mail.server.server2.hidden" = true; - "mailnews.start_page.enabled" = false; - "mail.provider.enabled" = false; - "layout.css.devPixelsPerPx" = 0.85; - }; - }; - }; - - accounts.email.accounts = lib.mapAttrs (_: mkEmailAccount) account.emails; - }; -} diff --git a/modules/capabilities/local-apps.nix b/modules/capabilities/local-apps.nix deleted file mode 100644 index 48ab463..0000000 --- a/modules/capabilities/local-apps.nix +++ /dev/null @@ -1,34 +0,0 @@ -{ config, ... }: -let - repo = config.repo; - repoHelpers = repo.helpers; -in -{ - flake.modules.homeManager.local-apps = - { pkgs, ... }: - let - browserPackage = repoHelpers.resolvePackagePath { - inherit pkgs; - path = repo.desktop.browser.packagePath; - }; - in - { - home.sessionVariables.BROWSER = repo.desktop.browser.command; - - home.packages = - with pkgs; - [ - postman - spotify - calcure - planify - unzip - gimp - dbeaver-bin - ] - ++ [ browserPackage ]; - - programs.imv.enable = true; - programs.sioyek.enable = true; - }; -} diff --git a/modules/capabilities/region-nl.nix b/modules/capabilities/locale-nl.nix similarity index 93% rename from modules/capabilities/region-nl.nix rename to modules/capabilities/locale-nl.nix index c8ed307..73e0a49 100644 --- a/modules/capabilities/region-nl.nix +++ b/modules/capabilities/locale-nl.nix @@ -1,6 +1,6 @@ { ... }: { - flake.modules.nixos.region-nl = { + flake.modules.nixos.locale-nl = { time.timeZone = "Europe/Amsterdam"; i18n.defaultLocale = "en_US.UTF-8"; diff --git a/modules/capabilities/networking.nix b/modules/capabilities/networking.nix index a71af55..c8d4354 100644 --- a/modules/capabilities/networking.nix +++ b/modules/capabilities/networking.nix @@ -6,7 +6,7 @@ }; }; - flake.modules.nixos.networking = { + flake.modules.nixos.network-manager = { networking = { nftables.enable = true; networkmanager.enable = true; diff --git a/modules/capabilities/nh.nix b/modules/capabilities/nh.nix deleted file mode 100644 index 2261544..0000000 --- a/modules/capabilities/nh.nix +++ /dev/null @@ -1,14 +0,0 @@ -{ config, ... }: -let - account = config.repo.account; -in -{ - flake.modules.homeManager.nh = - { ... }: - { - programs.nh = { - enable = true; - flake = account.nixosConfigurationPath; - }; - }; -} diff --git a/modules/capabilities/niri/default.nix b/modules/capabilities/niri/default.nix index 06de109..f517835 100644 --- a/modules/capabilities/niri/default.nix +++ b/modules/capabilities/niri/default.nix @@ -5,7 +5,6 @@ }: let repo = config.repo; - repoHelpers = repo.helpers; in { flake.modules.nixos.niri = @@ -34,10 +33,7 @@ in let repoTheme = repo.theme.kanagawa; browserCommand = repo.desktop.browser.command; - fileManagerPackage = repoHelpers.resolvePackagePath { - inherit pkgs; - path = repo.desktop.fileManager.packagePath; - }; + fileManagerPackage = pkgs.${repo.desktop.fileManager.packageAttr}; terminalCommand = config.repo.terminal.primary.command; outputs = lib.mapAttrs ( _: display: @@ -65,13 +61,6 @@ in ) osConfig.meta.machine.displays; in { - assertions = [ - { - assertion = fileManagerPackage != null; - message = "Unknown file manager package `${lib.showAttrPath repo.desktop.fileManager.packagePath}`."; - } - ]; - home.sessionVariables.NIXOS_OZONE_WL = "1"; dconf.settings = { diff --git a/modules/capabilities/nix.nix b/modules/capabilities/nix.nix index 98d5749..9ed0f38 100644 --- a/modules/capabilities/nix.nix +++ b/modules/capabilities/nix.nix @@ -1,4 +1,7 @@ -{ inputs, ... }: +{ inputs, config, ... }: +let + account = config.repo.account; +in { flake.modules.nixos.nix = { ... }: @@ -53,5 +56,10 @@ enable = true; enableTelevisionIntegration = true; }; + + programs.nh = { + enable = true; + flake = account.nixosConfigurationPath; + }; }; } diff --git a/modules/capabilities/bitwarden.nix b/modules/capabilities/passwords.nix similarity index 86% rename from modules/capabilities/bitwarden.nix rename to modules/capabilities/passwords.nix index 0e5bfa5..f4c97a5 100644 --- a/modules/capabilities/bitwarden.nix +++ b/modules/capabilities/passwords.nix @@ -7,9 +7,8 @@ let account = repo.account; in { - flake.modules.homeManager.bitwarden = + flake.modules.homeManager.passwords = { - config, pkgs, ... }: diff --git a/modules/capabilities/pim.nix b/modules/capabilities/pim.nix index a7dcb83..ace117c 100644 --- a/modules/capabilities/pim.nix +++ b/modules/capabilities/pim.nix @@ -4,9 +4,93 @@ }: let repo = config.repo; + account = repo.account; in { - flake.modules.homeManager.pim = + flake.modules.homeManager.email = + { + config, + lib, + ... + }: + let + mkOffice365Account = + { + address, + primary, + ... + }: + { + enable = true; + inherit address primary; + realName = account.realName; + userName = address; + thunderbird = { + enable = true; + settings = id: { + "mail.smtpserver.smtp_${id}.authMethod" = 10; + "mail.server.server_${id}.authMethod" = 10; + }; + }; + flavor = "outlook.office365.com"; + }; + mkMxrouteAccount = + { + address, + primary, + ... + }: + { + enable = true; + inherit address primary; + realName = account.realName; + userName = address; + thunderbird.enable = true; + imap = { + authentication = "plain"; + host = "taylor.mxrouting.net"; + port = 993; + tls.enable = true; + }; + smtp = { + authentication = "plain"; + host = "taylor.mxrouting.net"; + port = 465; + tls.enable = true; + }; + }; + mkEmailAccount = + email: + if email.type == "office365" then + mkOffice365Account email + else if email.type == "mxrouting" then + mkMxrouteAccount email + else + throw "Unsupported email type `${email.type}` for ${config.home.username}"; + in + { + programs.thunderbird = { + enable = true; + profiles.${config.home.username} = { + isDefault = true; + withExternalGnupg = true; + settings = { + "mail.ui.display.message_pane_vertical" = true; + "mail.ui.display.thread_pane_view_type" = "cards"; + "mail.uidensity" = 1; + "privacy.donottrackheader.enabled" = true; + "mail.server.server2.hidden" = true; + "mailnews.start_page.enabled" = false; + "mail.provider.enabled" = false; + "layout.css.devPixelsPerPx" = 0.85; + }; + }; + }; + + accounts.email.accounts = lib.mapAttrs (_: mkEmailAccount) account.emails; + }; + + flake.modules.homeManager.calendar-tasks = { config, ... diff --git a/modules/capabilities/services/openssh.nix b/modules/capabilities/services/openssh.nix index d6026d4..5759164 100644 --- a/modules/capabilities/services/openssh.nix +++ b/modules/capabilities/services/openssh.nix @@ -8,7 +8,7 @@ let ); in { - flake.modules.nixos.ssh-agent-auth = { + flake.modules.nixos.sudo-ssh-agent-auth = { security.pam = { rssh.enable = true; services.sudo.rssh = true; diff --git a/modules/capabilities/standard-boot.nix b/modules/capabilities/systemd-boot.nix similarity index 96% rename from modules/capabilities/standard-boot.nix rename to modules/capabilities/systemd-boot.nix index e3ada86..a80f9da 100644 --- a/modules/capabilities/standard-boot.nix +++ b/modules/capabilities/systemd-boot.nix @@ -1,6 +1,6 @@ { ... }: { - flake.modules.nixos.standard-boot = + flake.modules.nixos.systemd-boot = { config, pkgs, ... }: { boot = { diff --git a/modules/capabilities/terminal.nix b/modules/capabilities/terminal.nix index d2d417d..b855560 100644 --- a/modules/capabilities/terminal.nix +++ b/modules/capabilities/terminal.nix @@ -2,31 +2,6 @@ let repo = config.repo; - mkPrimaryTerminalOption = - lib: - lib.mkOption { - type = lib.types.submodule { - options = { - package = lib.mkOption { - type = lib.types.package; - }; - - command = lib.mkOption { - type = lib.types.str; - }; - - desktopId = lib.mkOption { - type = lib.types.str; - }; - - execArgs = lib.mkOption { - type = lib.types.listOf lib.types.str; - default = [ ]; - }; - }; - }; - }; - mkPrimaryTerminal = { desktopId, @@ -40,8 +15,6 @@ let { imports = [ terminalModule ]; - options.repo.terminal.primary = mkPrimaryTerminalOption lib; - config = { repo.terminal.primary = { inherit diff --git a/modules/data.nix b/modules/data.nix index 77b7ae3..393ac4a 100644 --- a/modules/data.nix +++ b/modules/data.nix @@ -27,12 +27,12 @@ desktop = { browser = { command = "vivaldi"; - packagePath = [ "vivaldi" ]; + packageAttr = "vivaldi"; }; fileManager = { command = "nautilus"; - packagePath = [ "nautilus" ]; + packageAttr = "nautilus"; }; }; diff --git a/modules/hosts/orion/default.nix b/modules/hosts/orion/default.nix index 07d4e82..0cdb110 100644 --- a/modules/hosts/orion/default.nix +++ b/modules/hosts/orion/default.nix @@ -25,7 +25,7 @@ in nixosModules.openssh nixosModules.caddy nixosModules.server-firewall - nixosModules.ssh-agent-auth + nixosModules.sudo-ssh-agent-auth nixosModules.vaultwarden nixosModules.radicale nixosModules.actual diff --git a/modules/lib/schema.nix b/modules/lib/schema.nix index 8509de7..934d2d1 100644 --- a/modules/lib/schema.nix +++ b/modules/lib/schema.nix @@ -81,6 +81,36 @@ let } ); + desktopApplicationType = lib.types.submodule ( + { ... }: + { + options = { + command = lib.mkOption { + type = lib.types.str; + }; + + packageAttr = lib.mkOption { + type = lib.types.str; + }; + }; + } + ); + + desktopType = lib.types.submodule ( + { ... }: + { + options = { + browser = lib.mkOption { + type = desktopApplicationType; + }; + + fileManager = lib.mkOption { + type = desktopApplicationType; + }; + }; + } + ); + displayType = lib.types.submodule ( { ... }: { @@ -163,6 +193,27 @@ let }; } ); + + terminalPrimaryType = lib.types.submodule { + options = { + package = lib.mkOption { + type = lib.types.package; + }; + + command = lib.mkOption { + type = lib.types.str; + }; + + desktopId = lib.mkOption { + type = lib.types.str; + }; + + execArgs = lib.mkOption { + type = lib.types.listOf lib.types.str; + default = [ ]; + }; + }; + }; in { options.repo = { @@ -176,8 +227,7 @@ in }; desktop = lib.mkOption { - type = lib.types.raw; - default = { }; + type = desktopType; }; services = lib.mkOption { @@ -199,4 +249,12 @@ in }; }; + config.flake.modules.homeManager.repo-schema = + { ... }: + { + options.repo.terminal.primary = lib.mkOption { + type = terminalPrimaryType; + }; + }; + } diff --git a/modules/profiles/host-base.nix b/modules/profiles/host-base.nix index 6cc804c..c54228d 100644 --- a/modules/profiles/host-base.nix +++ b/modules/profiles/host-base.nix @@ -13,7 +13,7 @@ in nixosModules.meta inputs.home-manager.nixosModules.home-manager nixosModules.nix - nixosModules.region-nl + nixosModules.locale-nl nixosModules.sops-password ]; @@ -22,6 +22,7 @@ in backupFileExtension = "bak"; extraSpecialArgs = { inherit inputs; }; sharedModules = [ + hmModules.repo-schema hmModules.syncthing hmModules.shell hmModules.neovim diff --git a/modules/profiles/workstation-base.nix b/modules/profiles/workstation-base.nix index 6bb1555..43f43b0 100644 --- a/modules/profiles/workstation-base.nix +++ b/modules/profiles/workstation-base.nix @@ -13,13 +13,13 @@ in nixosModules.bluetooth nixosModules.flatpak nixosModules.fonts - nixosModules.networking + nixosModules.network-manager nixosModules.niri nixosModules.plymouth nixosModules.printing nixosModules.sddm nixosModules.sops-admin-key-file - nixosModules.standard-boot + nixosModules.systemd-boot nixosModules.theme nixosModules.ai ]; @@ -37,16 +37,15 @@ in flake.modules.homeManager.workstation-base = { imports = [ homeModules.ai - homeModules.bitwarden + homeModules.passwords homeModules.clipboard homeModules.dev-tools + homeModules.desktop-defaults homeModules.email - homeModules.local-apps homeModules.mpv - homeModules.nh homeModules.niri homeModules.nix - homeModules.pim + homeModules.calendar-tasks homeModules.podman homeModules.qbittorrent-client homeModules.sops @@ -56,7 +55,6 @@ in homeModules.terminal-kitty homeModules.theme homeModules.vicinae - homeModules.xdg homeModules.noctalia ]; };