diff --git a/lib/services/lib.nix b/lib/services/lib.nix index 37249512b65b..7c235e066802 100644 --- a/lib/services/lib.nix +++ b/lib/services/lib.nix @@ -52,6 +52,8 @@ rec { let modularServiceConfiguration = lib.services.configure { serviceManagerPkgs = pkgs; + # To load a different portable service base, set `baseModules` instead: + # baseModules = [ (lib.importService { inherit pkgs; }) ]; extraRootModules = [ ./launchd-service.nix # launchd-specific options (plist generation, etc.) ]; @@ -80,18 +82,27 @@ rec { `serviceManagerPkgs` : 1\. A Nixpkgs instance used for built-in logic such as converting - `configData..text` to a store path. + `configData..text` to a store path. Required unless `baseModules` + is set. + + `baseModules` + + : 2\. Modules that replace the portable service base. They are loaded + into the "root" service submodule and must handle propagation to + sub-`services` themselves. Defaults to the portable service base of + this Nixpkgs. Set it to supply a different one, for example a + `service.nix` pinned from another Nixpkgs. `extraRootModules` - : 2\. Modules to be loaded into the "root" service submodule, but not + : 3\. Modules to be loaded into the "root" service submodule, but not into its sub-`services`. That's the modules' own responsibility. Typically contains service-manager-specific option modules (e.g. systemd unit options, launchd plist options). `extraRootSpecialArgs` - : 3\. Fixed module arguments provided alongside `extraRootModules`. + : 4\. Fixed module arguments provided alongside `extraRootModules`. # Output @@ -101,17 +112,15 @@ rec { */ configure = { - serviceManagerPkgs, + serviceManagerPkgs ? throw "lib.services.configure: `serviceManagerPkgs` is required unless `baseModules` is set", + baseModules ? [ (lib.importService { pkgs = serviceManagerPkgs; }) ], extraRootModules ? [ ], extraRootSpecialArgs ? { }, }: let - modules = [ - (lib.modules.importApply ./service.nix { pkgs = serviceManagerPkgs; }) - ]; serviceSubmodule = types.submoduleWith { class = "service"; - modules = modules ++ extraRootModules; + modules = baseModules ++ extraRootModules; specialArgs = extraRootSpecialArgs; }; in