diff --git a/hosts/default.nix b/hosts/default.nix index dcb2bde..14d611a 100644 --- a/hosts/default.nix +++ b/hosts/default.nix @@ -1,12 +1,13 @@ { inputs, + lib, self, ... }: { imports = [inputs.easy-hosts.flakeModule]; config.easy-hosts = { - shared.specialArgs.marleylib = import ../lib; + shared.specialArgs.marleylib = import ../lib {inherit lib;}; # shared.modules = with inputs; [ # # TODO: Move module imports to custom module diff --git a/lib/default.nix b/lib/default.nix index 8d51c6a..54c5b3a 100644 --- a/lib/default.nix +++ b/lib/default.nix @@ -1,3 +1,3 @@ -{ - module = import ./module.nix; +{lib}: { + module = import ./module.nix {inherit lib;}; } diff --git a/lib/module.nix b/lib/module.nix index cc9ed30..9c07469 100644 --- a/lib/module.nix +++ b/lib/module.nix @@ -1,23 +1,39 @@ -{ +{lib}: { + ## Quickly enable an option. + ## + ## ```nix + ## services.nginx = enabled; + ## ``` + ## + #@ true enabled = { - ## Quickly enable an option. - ## - ## ```nix - ## services.nginx = enabled; - ## ``` - ## - #@ true enable = true; }; + ## Quickly disable an option. + ## + ## ```nix + ## services.nginx = enabled; + ## ``` + ## + #@ false disabled = { - ## Quickly disable an option. - ## - ## ```nix - ## services.nginx = enabled; - ## ``` - ## - #@ false enable = false; }; + + ## Like lib.mkEnableOption, but allows specifying the default. + ## + ## ```nix + ## options.marleyos.wayland = mkEnableOption' "wayland" false; + ## ``` + mkEnableOption' = name: default: + lib.mkOption { + inherit default; + example = true; + description = + if name ? _type && name._type == "mdDoc" + then lib.mdDoc "Whether to enable ${name.text}." + else "Whether to enable ${name}."; + type = lib.types.bool; + }; } diff --git a/modules/home/programs/nh.nix b/modules/home/programs/nh.nix index 8efd1c7..0108445 100644 --- a/modules/home/programs/nh.nix +++ b/modules/home/programs/nh.nix @@ -1,12 +1,16 @@ { config, - lib, + marleylib, osConfig, + lib, ... }: let + inherit (marleylib.module) mkEnableOption'; + + osCfg = osConfig.marleyos.programs.nh.enable; cfg = config.marleyos.programs.nh; in { - options.marleyos.programs.nh.enable = lib.mkEnableOption "nh"; + options.marleyos.programs.nh.enable = mkEnableOption' "nh" osCfg; config = lib.mkIf cfg.enable { programs.nh = {