diff --git a/nix/flake-parts/lib.nix b/nix/flake-parts/lib.nix new file mode 100644 index 0000000..8813495 --- /dev/null +++ b/nix/flake-parts/lib.nix @@ -0,0 +1,14 @@ +{ lib, inputs, ... }: +let + inherit (lib.options) mkOption; + inherit (lib.types) lazyAttrsOf raw; + inherit (inputs.flake-parts.lib) mkSubmoduleOptions; +in +{ + options.flake = mkSubmoduleOptions { + lib = mkOption { + type = lazyAttrsOf raw; + default = { }; + }; + }; +} diff --git a/nix/lib/default.nix b/nix/lib/modules.nix similarity index 98% rename from nix/lib/default.nix rename to nix/lib/modules.nix index 26ad51d..28b6a0b 100644 --- a/nix/lib/default.nix +++ b/nix/lib/modules.nix @@ -4,7 +4,7 @@ let inherit (lib.attrsets) mapAttrs; in { - flake.lib = { + flake.lib.modules = { /** Return an attribute set for use with a option that needs to be used for all users. diff --git a/nix/lib/options.nix b/nix/lib/options.nix new file mode 100644 index 0000000..a7c873c --- /dev/null +++ b/nix/lib/options.nix @@ -0,0 +1,15 @@ +{ lib, ... }: +let + inherit (lib.options) mkOption; + inherit (lib.types) str; +in +{ + flake.lib.options = { + mkStrOption = + default: + mkOption { + inherit default; + type = str; + }; + }; +} diff --git a/nix/modules/home-manager.nix b/nix/modules/home-manager.nix index c3c8de4..e33893c 100644 --- a/nix/modules/home-manager.nix +++ b/nix/modules/home-manager.nix @@ -1,6 +1,6 @@ { inputs, config, ... }: let - inherit (cfg.lib) forAllUsers'; + inherit (cfg.lib.modules) forAllUsers'; cfg = config.flake; hm = inputs.home-manager; globalCfg = { diff --git a/nix/modules/shell.nix b/nix/modules/shell.nix index 865212f..58ad6f3 100644 --- a/nix/modules/shell.nix +++ b/nix/modules/shell.nix @@ -1,7 +1,7 @@ { config, lib, ... }: let cfg = config.flake; - inherit (cfg.lib) forAllUsers'; + inherit (cfg.lib.modules) forAllUsers'; inherit (lib.attrsets) mapAttrs'; in { diff --git a/nix/modules/users.nix b/nix/modules/users.nix index 471dd15..de640b3 100644 --- a/nix/modules/users.nix +++ b/nix/modules/users.nix @@ -1,7 +1,7 @@ { config, lib, ... }: let cfg = config.flake; - inherit (cfg.lib) forAllUsers'; + inherit (cfg.lib.modules) forAllUsers'; inherit (lib.lists) optional; in {