From 2edce8e6c8f74aabf2a85547ae92e3c43b36876d Mon Sep 17 00:00:00 2001 From: Colin Date: Sat, 12 Oct 2024 19:36:50 +0000 Subject: [PATCH] refactor: use mkEnableOption,mkPackageOption where applicable --- hosts/common/programs/firefox/default.nix | 9 ++------- hosts/common/programs/swayidle.nix | 5 +---- hosts/common/users/guest.nix | 5 +---- hosts/modules/nixcache.nix | 5 +---- hosts/modules/roles/build-machine.nix | 5 +---- hosts/modules/services/rsync-net/default.nix | 5 +---- hosts/modules/wg-home.nix | 5 +---- modules/persist/default.nix | 5 +---- modules/services/dropbear.nix | 12 ++---------- modules/services/dyn-dns.nix | 5 +---- modules/services/eg25-manager.nix | 5 +---- modules/services/hickory-dns/default.nix | 5 +---- modules/services/kiwix-serve.nix | 14 ++------------ modules/wowlan.nix | 5 +---- 14 files changed, 17 insertions(+), 73 deletions(-) diff --git a/hosts/common/programs/firefox/default.nix b/hosts/common/programs/firefox/default.nix index 10a953601..d21364b88 100644 --- a/hosts/common/programs/firefox/default.nix +++ b/hosts/common/programs/firefox/default.nix @@ -146,10 +146,8 @@ in default = {}; type = types.attrsOf (types.submodule ({ name, ...}: { options = { - package = mkOption { - type = types.package; - default = pkgs.firefox-extensions."${name}"; - }; + enable = mkEnableOption "enable the ${name} Firefox addon"; + package = mkPackageOption pkgs.firefox-extensions name {}; nativeMessagingHosts = mkOption { type = types.listOf types.str; default = []; @@ -158,9 +156,6 @@ in type = types.listOf types.str; default = []; }; - enable = mkOption { - type = types.bool; - }; }; })); }; diff --git a/hosts/common/programs/swayidle.nix b/hosts/common/programs/swayidle.nix index 260302ad1..124d896d6 100644 --- a/hosts/common/programs/swayidle.nix +++ b/hosts/common/programs/swayidle.nix @@ -2,10 +2,7 @@ let cfg = config.sane.programs.swayidle; idleAction = with lib; types.submodule ({ config, name, ... }: { - options.enable = mkOption { - type = types.bool; - default = true; - }; + options.enable = mkEnableOption "invoke ${name} when sway is idle for so long"; options.command = mkOption { type = types.str; default = name; diff --git a/hosts/common/users/guest.nix b/hosts/common/users/guest.nix index 3d8f8b2c5..7d9ed502b 100644 --- a/hosts/common/users/guest.nix +++ b/hosts/common/users/guest.nix @@ -5,10 +5,7 @@ let in { options = with lib; { - sane.guest.enable = mkOption { - default = false; - type = types.bool; - }; + sane.guest.enable = mkEnableOption "enable guest account, accessible by select authorized ssh keys"; }; config = lib.mkIf cfg.enable { diff --git a/hosts/modules/nixcache.nix b/hosts/modules/nixcache.nix index 35e932849..1dd1def22 100644 --- a/hosts/modules/nixcache.nix +++ b/hosts/modules/nixcache.nix @@ -21,10 +21,7 @@ let in { options = with lib; { - sane.nixcache.enable = mkOption { - default = false; - type = types.bool; - }; + sane.nixcache.enable = mkEnableOption "fetch binaries from and build packages on one of my other machines"; sane.nixcache.enable-trusted-keys = mkOption { default = config.sane.nixcache.enable; type = types.bool; diff --git a/hosts/modules/roles/build-machine.nix b/hosts/modules/roles/build-machine.nix index ce5aa5851..ef584c4a1 100644 --- a/hosts/modules/roles/build-machine.nix +++ b/hosts/modules/roles/build-machine.nix @@ -5,10 +5,7 @@ let in { options.sane.roles.build-machine = with lib; { - enable = mkOption { - type = types.bool; - default = false; - }; + enable = mkEnableOption "allow my other machines to dispatch build jobs to this one"; }; config = lib.mkMerge [ diff --git a/hosts/modules/services/rsync-net/default.nix b/hosts/modules/services/rsync-net/default.nix index c5b82bc60..d64f527c9 100644 --- a/hosts/modules/services/rsync-net/default.nix +++ b/hosts/modules/services/rsync-net/default.nix @@ -14,10 +14,7 @@ let in { options = with lib; { - sane.services.rsync-net.enable = mkOption { - default = false; - type = types.bool; - }; + sane.services.rsync-net.enable = mkEnableOption "periodically backup data to rsync.net"; sane.services.rsync-net.dirs = mkOption { type = types.listOf types.str; description = '' diff --git a/hosts/modules/wg-home.nix b/hosts/modules/wg-home.nix index cb9446c4d..86dbc3f51 100644 --- a/hosts/modules/wg-home.nix +++ b/hosts/modules/wg-home.nix @@ -28,10 +28,7 @@ let in { options = with lib; { - sane.services.wg-home.enable = mkOption { - type = types.bool; - default = false; - }; + sane.services.wg-home.enable = mkEnableOption "wireguard VPN connecting my devices to eachother"; sane.services.wg-home.visibleToWan = mkOption { type = types.bool; default = false; diff --git a/modules/persist/default.nix b/modules/persist/default.nix index ba31c4bc3..5a016dd72 100644 --- a/modules/persist/default.nix +++ b/modules/persist/default.nix @@ -165,10 +165,7 @@ let in { options = { - sane.persist.enable = mkOption { - default = false; - type = types.bool; - }; + sane.persist.enable = mkEnableOption "selectively persist data to disk"; sane.persist.sys = mkOption { description = "directories (or files) to persist to disk, relative to the fs root /"; default = {}; diff --git a/modules/services/dropbear.nix b/modules/services/dropbear.nix index 0f9485f0b..03e024e2c 100644 --- a/modules/services/dropbear.nix +++ b/modules/services/dropbear.nix @@ -5,16 +5,8 @@ in { options = { sane.services.dropbear = with lib; { - enable = mkOption { - default = false; - type = types.bool; - }; - - package = mkOption { - type = types.package; - default = pkgs.dropbear; - defaultText = literalExpression "pkgs.dropbear"; - }; + enable = mkEnableOption "dropbear SSH server"; + package = mkPackageOption pkgs "dropbear" {}; port = mkOption { type = types.port; diff --git a/modules/services/dyn-dns.nix b/modules/services/dyn-dns.nix index f68f0b4c5..ef8e97170 100644 --- a/modules/services/dyn-dns.nix +++ b/modules/services/dyn-dns.nix @@ -13,10 +13,7 @@ in { options = { sane.services.dyn-dns = { - enable = mkOption { - default = false; - type = types.bool; - }; + enable = mkEnableOption "keep track of the public WAN address of this machine, as viewed externally"; ipPath = mkOption { default = "/var/lib/uninsane/wan.txt"; diff --git a/modules/services/eg25-manager.nix b/modules/services/eg25-manager.nix index db810be9d..53d43eea3 100644 --- a/modules/services/eg25-manager.nix +++ b/modules/services/eg25-manager.nix @@ -13,10 +13,7 @@ in { options.sane.services.eg25-manager = with lib; { enable = mkEnableOption "Quectel EG25 modem manager service"; - package = mkOption { - type = types.package; - default = pkgs.eg25-manager; - }; + package = mkPackageOption pkgs "eg25-manager" {}; }; config = lib.mkIf cfg.enable { # eg25-manager package ships udev rules *and* a systemd service. diff --git a/modules/services/hickory-dns/default.nix b/modules/services/hickory-dns/default.nix index 0b4e0a8a5..e38715085 100644 --- a/modules/services/hickory-dns/default.nix +++ b/modules/services/hickory-dns/default.nix @@ -166,10 +166,7 @@ in { options = with lib; { sane.services.hickory-dns = { - enable = mkOption { - default = false; - type = types.bool; - }; + enable = mkEnableOption "hickory DNS server"; asSystemResolver = mkOption { default = false; type = types.bool; diff --git a/modules/services/kiwix-serve.nix b/modules/services/kiwix-serve.nix index 6e23e4d6d..936002579 100644 --- a/modules/services/kiwix-serve.nix +++ b/modules/services/kiwix-serve.nix @@ -7,18 +7,8 @@ in { options = { sane.services.kiwix-serve = { - enable = mkOption { - default = false; - type = types.bool; - }; - package = mkOption { - type = types.package; - default = pkgs.kiwix-tools; - defaultText = literalExpression "pkgs.kiwix-tools"; - description = lib.mdDoc '' - The package that provides `bin/kiwix-serve`. - ''; - }; + enable = mkEnableOption "serve .zim files (like Wikipedia archives) with kiwix"; + package = mkPackageOption pkgs "kiwix-tools" {}; port = mkOption { type = types.port; default = 80; diff --git a/modules/wowlan.nix b/modules/wowlan.nix index f89348065..d2892b181 100644 --- a/modules/wowlan.nix +++ b/modules/wowlan.nix @@ -117,10 +117,7 @@ let in { options = with lib; { - sane.wowlan.enable = mkOption { - default = false; - type = types.bool; - }; + sane.wowlan.enable = mkEnableOption "Wake on Wireless LAN packets"; sane.wowlan.patterns = mkOption { default = []; type = types.listOf patternOpts;