From 99b84bd224228f64af12d228790ad2b2631e4738 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vili=20Sinerv=C3=A4?= Date: Fri, 25 Jul 2025 13:12:41 +0300 Subject: [PATCH] Use lib.mkEnableOption where possible --- modules/hardware/amd-laptop.nix | 7 +------ modules/hardware/intel-laptop.nix | 8 ++------ modules/hardware/keychron-q11.nix | 5 +---- modules/hardware/nvidia.nix | 5 +---- modules/hardware/onlykey.nix | 6 ++---- modules/hardware/trackball.nix | 6 ++---- modules/networking/home-wg.nix | 5 +---- modules/networking/idacloud-wg.nix | 9 +-------- modules/networking/netflix-wg.nix | 5 +---- modules/platform/hetzner.nix | 5 +---- modules/platform/vm.nix | 5 +---- modules/programs/bitwarden.nix | 5 +---- modules/programs/communication.nix | 6 ++---- modules/programs/firefox.nix | 5 +---- modules/programs/i3.nix | 5 +---- modules/programs/moonlight.nix | 5 +---- modules/programs/nvim.nix | 5 +---- modules/programs/redshift.nix | 5 +---- modules/programs/symlinked/symlinks.nix | 6 ++---- modules/programs/usb-automount.nix | 5 +---- modules/roles/base.nix | 10 +++++----- modules/roles/desktop.nix | 6 ++---- modules/roles/development.nix | 5 +---- modules/roles/study.nix | 6 +----- modules/services/cert-store-server.nix | 5 +---- modules/services/forgejo-runner.nix | 5 +---- modules/services/forgejo.nix | 5 +---- modules/services/gaming-server.nix | 5 +---- modules/services/hydra.nix | 5 +---- modules/services/nextcloud.nix | 10 ++-------- modules/services/siit-dc.nix | 6 ++---- modules/services/utils/acme-http-client.nix | 5 +---- modules/services/utils/cert-store-client.nix | 5 +---- modules/services/utils/nginx-https-server.nix | 5 +---- modules/services/vaultwarden.nix | 5 +---- modules/users/vili.nix | 5 +---- 36 files changed, 48 insertions(+), 158 deletions(-) diff --git a/modules/hardware/amd-laptop.nix b/modules/hardware/amd-laptop.nix index 1dec90a..6c2672e 100644 --- a/modules/hardware/amd-laptop.nix +++ b/modules/hardware/amd-laptop.nix @@ -8,10 +8,7 @@ let cfg = config.custom.hardware.amdLaptop; in { - options.custom.hardware.amdLaptop.enable = lib.mkOption { - type = lib.types.bool; - default = false; - }; + options.custom.hardware.amdLaptop.enable = lib.mkEnableOption "AMD laptop hardware configuration"; config = lib.mkIf cfg.enable { environment.systemPackages = with pkgs; [ zenmonitor ]; @@ -45,8 +42,6 @@ in }; }; - - logind.lidSwitch = if config.boot.resumeDevice != "" then "hibernate" else "suspend"; }; boot = { diff --git a/modules/hardware/intel-laptop.nix b/modules/hardware/intel-laptop.nix index 27f8b76..cb51c65 100644 --- a/modules/hardware/intel-laptop.nix +++ b/modules/hardware/intel-laptop.nix @@ -8,10 +8,8 @@ let cfg = config.custom.hardware.intelLaptop; in { - options.custom.hardware.intelLaptop.enable = lib.mkOption { - type = lib.types.bool; - default = false; - }; + options.custom.hardware.intelLaptop.enable = + lib.mkEnableOption "Intel laptop hardware configuration"; config = lib.mkIf cfg.enable { services = { @@ -35,8 +33,6 @@ in }; }; - - logind.lidSwitch = if config.boot.resumeDevice != "" then "hibernate" else "suspend"; }; boot = { diff --git a/modules/hardware/keychron-q11.nix b/modules/hardware/keychron-q11.nix index 943cbac..db94b0f 100644 --- a/modules/hardware/keychron-q11.nix +++ b/modules/hardware/keychron-q11.nix @@ -8,10 +8,7 @@ let cfg = config.custom.hardware.keychron; in { - options.custom.hardware.keychron.enable = lib.mkOption { - type = lib.types.bool; - default = false; - }; + options.custom.hardware.keychron.enable = lib.mkEnableOption "Keychron Q11 hardware configuration"; config = lib.mkIf cfg.enable { environment.systemPackages = with pkgs; if config.services.xserver.enable then [ via ] else [ ]; diff --git a/modules/hardware/nvidia.nix b/modules/hardware/nvidia.nix index fc0c241..64fa53d 100644 --- a/modules/hardware/nvidia.nix +++ b/modules/hardware/nvidia.nix @@ -8,10 +8,7 @@ let cfg = config.custom.hardware.nvidia; in { - options.custom.hardware.nvidia.enable = lib.mkOption { - type = lib.types.bool; - default = false; - }; + options.custom.hardware.nvidia.enable = lib.mkEnableOption "NVIDIA dGPU hardware configuration"; config = lib.mkIf cfg.enable { hardware = { diff --git a/modules/hardware/onlykey.nix b/modules/hardware/onlykey.nix index 0da583a..33f8ef9 100644 --- a/modules/hardware/onlykey.nix +++ b/modules/hardware/onlykey.nix @@ -8,10 +8,8 @@ let cfg = config.custom.hardware.onlykey; in { - options.custom.hardware.onlykey.enable = lib.mkOption { - type = lib.types.bool; - default = false; - }; + options.custom.hardware.onlykey.enable = + lib.mkEnableOption "OnlyKey USB security key hardware configuration"; config = lib.mkIf cfg.enable { environment.systemPackages = with pkgs; [ diff --git a/modules/hardware/trackball.nix b/modules/hardware/trackball.nix index 6f6bced..af38a62 100644 --- a/modules/hardware/trackball.nix +++ b/modules/hardware/trackball.nix @@ -3,10 +3,8 @@ let cfg = config.custom.hardware.trackball; in { - options.custom.hardware.trackball.enable = lib.mkOption { - type = lib.types.bool; - default = false; - }; + options.custom.hardware.trackball.enable = + lib.mkEnableOption "Logitech MX Ergo trackball hardware configuration"; config = lib.mkIf cfg.enable { nixpkgs.overlays = [ diff --git a/modules/networking/home-wg.nix b/modules/networking/home-wg.nix index 3cf31f4..a8aff73 100644 --- a/modules/networking/home-wg.nix +++ b/modules/networking/home-wg.nix @@ -6,10 +6,7 @@ in { options.custom.networking = { homeWg = { - enable = lib.mkOption { - type = lib.types.bool; - default = false; - }; + enable = lib.mkEnableOption "Home WireGuard"; guaSuffix = lib.mkOption { type = with lib.types; nullOr (strMatching "^[0-9a-zA-Z:]+$"); default = null; diff --git a/modules/networking/idacloud-wg.nix b/modules/networking/idacloud-wg.nix index 7b97414..73c3cd6 100644 --- a/modules/networking/idacloud-wg.nix +++ b/modules/networking/idacloud-wg.nix @@ -3,14 +3,7 @@ let cfg = config.custom.networking.idacloudWg; in { - options.custom.networking = { - idacloudWg = { - enable = lib.mkOption { - type = lib.types.bool; - default = false; - }; - }; - }; + options.custom.networking.idacloudWg.enable = lib.mkEnableOption "Idacloud WireGuard"; config = lib.mkIf cfg.enable { sops = { diff --git a/modules/networking/netflix-wg.nix b/modules/networking/netflix-wg.nix index 729b776..8d3b7db 100644 --- a/modules/networking/netflix-wg.nix +++ b/modules/networking/netflix-wg.nix @@ -6,10 +6,7 @@ in { options.custom.networking = { netflixWg = { - enable = lib.mkOption { - type = lib.types.bool; - default = false; - }; + enable = lib.mkEnableOption "Netflix WireGuard"; suffix = lib.mkOption { type = with lib.types; nullOr (strMatching "^[0-9.]+$"); default = null; diff --git a/modules/platform/hetzner.nix b/modules/platform/hetzner.nix index a51b916..bcc32b2 100644 --- a/modules/platform/hetzner.nix +++ b/modules/platform/hetzner.nix @@ -4,10 +4,7 @@ let in { options.custom.platform.hetzner = { - enable = lib.mkOption { - type = lib.types.bool; - default = false; - }; + enable = lib.mkEnableOption "Hetzner cloud configuration"; ipv4Address = lib.mkOption { type = with lib.types; nullOr (strMatching "^[0-9]+.[0-9]+.[0-9]+.[0-9]+/32$"); default = null; diff --git a/modules/platform/vm.nix b/modules/platform/vm.nix index ae8636d..0b1ba2c 100644 --- a/modules/platform/vm.nix +++ b/modules/platform/vm.nix @@ -7,10 +7,7 @@ let cfg = config.custom.platform.vm; in { - options.custom.platform.vm.enable = lib.mkOption { - type = lib.types.bool; - default = false; - }; + options.custom.platform.vm.enable = lib.mkEnableOption "KVM virtual machine guest configuration"; config = lib.mkIf cfg.enable { services.qemuGuest.enable = true; diff --git a/modules/programs/bitwarden.nix b/modules/programs/bitwarden.nix index 10880fb..edd5b33 100644 --- a/modules/programs/bitwarden.nix +++ b/modules/programs/bitwarden.nix @@ -8,10 +8,7 @@ let cfg = config.custom.programs.bitwarden; in { - options.custom.programs.bitwarden.enable = lib.mkOption { - type = lib.types.bool; - default = false; - }; + options.custom.programs.bitwarden.enable = lib.mkEnableOption "Bitwarden desktop applications"; config = lib.mkIf cfg.enable { environment.systemPackages = with pkgs; [ diff --git a/modules/programs/communication.nix b/modules/programs/communication.nix index 42c587d..92ef733 100644 --- a/modules/programs/communication.nix +++ b/modules/programs/communication.nix @@ -8,10 +8,8 @@ let cfg = config.custom.programs.communication; in { - options.custom.programs.communication.enable = lib.mkOption { - type = lib.types.bool; - default = false; - }; + options.custom.programs.communication.enable = + lib.mkEnableOption "messaging/communication programs"; config = lib.mkIf cfg.enable { environment.systemPackages = with pkgs; [ diff --git a/modules/programs/firefox.nix b/modules/programs/firefox.nix index 6d304b2..7c12984 100644 --- a/modules/programs/firefox.nix +++ b/modules/programs/firefox.nix @@ -11,10 +11,7 @@ let }; in { - options.custom.programs.firefox.enable = lib.mkOption { - type = lib.types.bool; - default = false; - }; + options.custom.programs.firefox.enable = lib.mkEnableOption "customized Firefox configuration"; config = lib.mkIf cfg.enable { programs.firefox = { diff --git a/modules/programs/i3.nix b/modules/programs/i3.nix index b025544..42cd451 100644 --- a/modules/programs/i3.nix +++ b/modules/programs/i3.nix @@ -8,10 +8,7 @@ let cfg = config.custom.programs.i3; in { - options.custom.programs.i3.enable = lib.mkOption { - type = lib.types.bool; - default = false; - }; + options.custom.programs.i3.enable = lib.mkEnableOption "i3 window manager"; config = lib.mkIf cfg.enable { environment.systemPackages = with pkgs; [ diff --git a/modules/programs/moonlight.nix b/modules/programs/moonlight.nix index b5295b7..a6be3c8 100644 --- a/modules/programs/moonlight.nix +++ b/modules/programs/moonlight.nix @@ -8,10 +8,7 @@ let cfg = config.custom.programs.moonlight; in { - options.custom.programs.moonlight.enable = lib.mkOption { - type = lib.types.bool; - default = false; - }; + options.custom.programs.moonlight.enable = lib.mkEnableOption "Moonlight game streaming client"; config = lib.mkIf cfg.enable { environment.systemPackages = with pkgs; [ diff --git a/modules/programs/nvim.nix b/modules/programs/nvim.nix index b06b15b..ecd52fd 100644 --- a/modules/programs/nvim.nix +++ b/modules/programs/nvim.nix @@ -8,10 +8,7 @@ let cfg = config.custom.programs.nvim; in { - options.custom.programs.nvim.enable = lib.mkOption { - type = lib.types.bool; - default = false; - }; + options.custom.programs.nvim.enable = lib.mkEnableOption "customized nVim configuration"; imports = [ nixvim.nixosModules.nixvim ]; diff --git a/modules/programs/redshift.nix b/modules/programs/redshift.nix index 6d2a19e..9b2f05e 100644 --- a/modules/programs/redshift.nix +++ b/modules/programs/redshift.nix @@ -3,10 +3,7 @@ let cfg = config.custom.programs.redshift; in { - options.custom.programs.redshift.enable = lib.mkOption { - type = lib.types.bool; - default = false; - }; + options.custom.programs.redshift.enable = lib.mkEnableOption "redshift blue-light reducer"; config = lib.mkIf cfg.enable { services.redshift = { diff --git a/modules/programs/symlinked/symlinks.nix b/modules/programs/symlinked/symlinks.nix index 25eff9c..45f2498 100644 --- a/modules/programs/symlinked/symlinks.nix +++ b/modules/programs/symlinked/symlinks.nix @@ -3,10 +3,8 @@ let cfg = config.custom.programs.symlinks; in { - options.custom.programs.symlinks.enable = lib.mkOption { - type = lib.types.bool; - default = false; - }; + options.custom.programs.symlinks.enable = + lib.mkEnableOption "automatic symlinks of specific configuration files"; config = lib.mkIf cfg.enable { system.userActivationScripts.mkDesktopSettingsSymlinks.text = diff --git a/modules/programs/usb-automount.nix b/modules/programs/usb-automount.nix index 9ce4f0f..ca888ea 100644 --- a/modules/programs/usb-automount.nix +++ b/modules/programs/usb-automount.nix @@ -3,10 +3,7 @@ let cfg = config.custom.programs.usbAutoMount; in { - options.custom.programs.usbAutoMount.enable = lib.mkOption { - type = lib.types.bool; - default = false; - }; + options.custom.programs.usbAutoMount.enable = lib.mkEnableOption "auto-mounting of USB storage"; config = lib.mkIf cfg.enable { services = { diff --git a/modules/roles/base.nix b/modules/roles/base.nix index d0d7675..e750b55 100644 --- a/modules/roles/base.nix +++ b/modules/roles/base.nix @@ -7,10 +7,7 @@ }: { options.custom = { - base.enable = lib.mkOption { - type = lib.types.bool; - default = true; - }; + base.enable = lib.mkEnableOption "base configuration for my hosts"; networking.guaPref = lib.mkOption { type = with lib.types; nullOr (strMatching "^[0-9a-zA-Z:]+$"); default = "2001:14ba:a090:39"; @@ -19,6 +16,9 @@ }; config = { + custom.base.enable = lib.mkDefault true; + } + // (lib.mkIf config.custom.base.enable { ######################################## Packages ############################################### environment.systemPackages = with pkgs; [ tmux @@ -196,5 +196,5 @@ efi.canTouchEfiVariables = lib.mkDefault true; timeout = lib.mkDefault 0; }; - }; + }); } diff --git a/modules/roles/desktop.nix b/modules/roles/desktop.nix index 0916f91..5fccf42 100644 --- a/modules/roles/desktop.nix +++ b/modules/roles/desktop.nix @@ -8,10 +8,7 @@ let cfg = config.custom.roles.desktop; in { - options.custom.roles.desktop.enable = lib.mkOption { - type = lib.types.bool; - default = false; - }; + options.custom.roles.desktop.enable = lib.mkEnableOption "desktop role"; config = lib.mkIf cfg.enable { custom = { @@ -20,6 +17,7 @@ in }; environment.systemPackages = with pkgs; [ + libreoffice alacritty vlc flameshot diff --git a/modules/roles/development.nix b/modules/roles/development.nix index 7530904..f63c837 100644 --- a/modules/roles/development.nix +++ b/modules/roles/development.nix @@ -8,10 +8,7 @@ let cfg = config.custom.roles.development; in { - options.custom.roles.development.enable = lib.mkOption { - type = lib.types.bool; - default = false; - }; + options.custom.roles.development.enable = lib.mkEnableOption "development role"; config = lib.mkIf cfg.enable { custom.programs.nvim.enable = true; diff --git a/modules/roles/study.nix b/modules/roles/study.nix index 60c7482..01d0957 100644 --- a/modules/roles/study.nix +++ b/modules/roles/study.nix @@ -8,14 +8,10 @@ let cfg = config.custom.roles.study; in { - options.custom.roles.study.enable = lib.mkOption { - type = lib.types.bool; - default = false; - }; + options.custom.roles.study.enable = lib.mkEnableOption "study configuration"; config = lib.mkIf cfg.enable { environment.systemPackages = with pkgs; [ - libreoffice zotero kile texliveFull diff --git a/modules/services/cert-store-server.nix b/modules/services/cert-store-server.nix index ce6785f..6dd6afc 100644 --- a/modules/services/cert-store-server.nix +++ b/modules/services/cert-store-server.nix @@ -44,10 +44,7 @@ let ''; in { - options.custom.services.certStoreServer.enable = lib.mkOption { - type = lib.types.bool; - default = false; - }; + options.custom.services.certStoreServer.enable = lib.mkEnableOption "cert-store server"; config = lib.mkIf cfg.enable { sops = { diff --git a/modules/services/forgejo-runner.nix b/modules/services/forgejo-runner.nix index 467e73c..b699769 100644 --- a/modules/services/forgejo-runner.nix +++ b/modules/services/forgejo-runner.nix @@ -8,10 +8,7 @@ let cfg = config.custom.services.forgejoRunner; in { - options.custom.services.forgejoRunner.enable = lib.mkOption { - type = lib.types.bool; - default = false; - }; + options.custom.services.forgejoRunner.enable = lib.mkEnableOption "Forgejo actions runner"; config = lib.mkIf cfg.enable { sops.secrets.forgejo-token = { diff --git a/modules/services/forgejo.nix b/modules/services/forgejo.nix index bc682e8..8103193 100644 --- a/modules/services/forgejo.nix +++ b/modules/services/forgejo.nix @@ -3,10 +3,7 @@ let cfg = config.custom.services.forgejo; in { - options.custom.services.forgejo.enable = lib.mkOption { - type = lib.types.bool; - default = false; - }; + options.custom.services.forgejo.enable = lib.mkEnableOption "self-hosted Forgejo instance"; config = lib.mkIf cfg.enable { custom.services = { diff --git a/modules/services/gaming-server.nix b/modules/services/gaming-server.nix index ba3cbe4..3cb6450 100644 --- a/modules/services/gaming-server.nix +++ b/modules/services/gaming-server.nix @@ -8,10 +8,7 @@ let cfg = config.custom.services.gamingServer; in { - options.custom.services.gamingServer.enable = lib.mkOption { - type = lib.types.bool; - default = false; - }; + options.custom.services.gamingServer.enable = lib.mkEnableOption "Game streaming server"; config = lib.mkIf cfg.enable { systemd.tmpfiles.settings."vili-home" = { diff --git a/modules/services/hydra.nix b/modules/services/hydra.nix index 20355e4..f7870fa 100644 --- a/modules/services/hydra.nix +++ b/modules/services/hydra.nix @@ -4,10 +4,7 @@ let hydraDomain = "ci.sinerva.eu"; in { - options.custom.services.hydra.enable = lib.mkOption { - type = lib.types.bool; - default = false; - }; + options.custom.services.hydra.enable = lib.mkEnableOption "Hydra continous integration server"; config = lib.mkIf cfg.enable { custom.services = { diff --git a/modules/services/nextcloud.nix b/modules/services/nextcloud.nix index 49eb0fe..379f337 100644 --- a/modules/services/nextcloud.nix +++ b/modules/services/nextcloud.nix @@ -10,19 +10,13 @@ in { options.custom.services = { nextcloud = { - enable = lib.mkOption { - type = lib.types.bool; - default = false; - }; + enable = lib.mkEnableOption "self-hosted Nextcloud instance"; domain = lib.mkOption { type = with lib.types; nullOr str; default = null; }; collabora = { - enable = lib.mkOption { - type = lib.types.bool; - default = false; - }; + enable = lib.mkEnableOption "self-hosted Collabora server alongside Nextcloud"; domain = lib.mkOption { type = with lib.types; nullOr str; default = null; diff --git a/modules/services/siit-dc.nix b/modules/services/siit-dc.nix index ab6483a..6617b3f 100644 --- a/modules/services/siit-dc.nix +++ b/modules/services/siit-dc.nix @@ -3,10 +3,8 @@ let cfg = config.custom.services.siit; in { - options.custom.services.siit.enable = lib.mkOption { - type = lib.types.bool; - default = false; - }; + options.custom.services.siit.enable = + lib.mkEnableOption "IPv4 to IPv6 stateless translator (SIIT-DC)"; config = lib.mkIf cfg.enable { networking = { diff --git a/modules/services/utils/acme-http-client.nix b/modules/services/utils/acme-http-client.nix index e620010..50ddee4 100644 --- a/modules/services/utils/acme-http-client.nix +++ b/modules/services/utils/acme-http-client.nix @@ -4,10 +4,7 @@ let in { options = { - custom.services.acmeHttpClient.enable = lib.mkOption { - type = lib.types.bool; - default = false; - }; + custom.services.acmeHttpClient.enable = lib.mkEnableOption "ACME HTTP client"; services.nginx.virtualHosts = lib.mkOption { type = lib.types.attrsOf ( diff --git a/modules/services/utils/cert-store-client.nix b/modules/services/utils/cert-store-client.nix index 429d99f..0669a84 100644 --- a/modules/services/utils/cert-store-client.nix +++ b/modules/services/utils/cert-store-client.nix @@ -4,10 +4,7 @@ let in { options = { - custom.services.certStoreClient.enable = lib.mkOption { - type = lib.types.bool; - default = false; - }; + custom.services.certStoreClient.enable = lib.mkEnableOption "cert-store client"; services.nginx.virtualHosts = lib.mkOption { type = lib.types.attrsOf ( diff --git a/modules/services/utils/nginx-https-server.nix b/modules/services/utils/nginx-https-server.nix index b4079e7..2bd8a2a 100644 --- a/modules/services/utils/nginx-https-server.nix +++ b/modules/services/utils/nginx-https-server.nix @@ -4,10 +4,7 @@ let in { options = { - custom.services.nginxHttpsServer.enable = lib.mkOption { - type = lib.types.bool; - default = false; - }; + custom.services.nginxHttpsServer.enable = lib.mkEnableOption "default nginx HTTPS server configuration"; services.nginx.virtualHosts = lib.mkOption { type = lib.types.attrsOf ( diff --git a/modules/services/vaultwarden.nix b/modules/services/vaultwarden.nix index d0b66d5..bf6a112 100644 --- a/modules/services/vaultwarden.nix +++ b/modules/services/vaultwarden.nix @@ -3,10 +3,7 @@ let cfg = config.custom.services.vaultwarden; in { - options.custom.services.vaultwarden.enable = lib.mkOption { - type = lib.types.bool; - default = false; - }; + options.custom.services.vaultwarden.enable = lib.mkEnableOption "self-hosted Vaultwarden instance"; config = lib.mkIf cfg.enable { custom.services = { diff --git a/modules/users/vili.nix b/modules/users/vili.nix index a1c2769..b427088 100644 --- a/modules/users/vili.nix +++ b/modules/users/vili.nix @@ -3,10 +3,7 @@ let cfg = config.custom.users.vili; in { - options.custom.users.vili.enable = lib.mkOption { - type = lib.types.bool; - default = false; - }; + options.custom.users.vili.enable = lib.mkEnableOption "user 'vili'"; config = lib.mkIf cfg.enable { sops.secrets =