+5
-1
nixos/README-modular-services.md
+5
-1
nixos/README-modular-services.md
······
+11
-1
nixos/doc/manual/default.nix
+11
-1
nixos/doc/manual/default.nix
······-inherit (evalModules { modules = [ ../../modules/system/service/portable/service.nix ]; }) options;
······
+3
-1
nixos/doc/manual/development/modular-services.md
+3
-1
nixos/doc/manual/development/modular-services.md
···-Refer to the contributor documentation in [`nixos/README-modular-services.md`](https://github.com/NixOS/nixpkgs/blob/master/nixos/README-modular-services.md).
···+For more details, refer to the contributor documentation in [`nixos/README-modular-services.md`](https://github.com/NixOS/nixpkgs/blob/master/nixos/README-modular-services.md).
+90
nixos/modules/system/service/README.md
+90
nixos/modules/system/service/README.md
···- **Simple attribute structure**: Unlike `environment.etc`, `configData` uses a simpler structure with just `enable`, `name`, `text`, `source`, and `path` attributes. Complex ownership options were omitted for simplicity and portability.+The modular service infrastructure avoids exposing `pkgs` as a module argument to service modules. Instead, derivations and builder functions are provided through lexical closure, making dependency relationships explicit and avoiding uncertainty about where dependencies come from.+- **Explicit dependencies**: Services declare what they need rather than implicitly depending on `pkgs`+- **No interference**: Service modules can be reused in different contexts without assuming a specific `pkgs` instance. An unexpected `pkgs` version is not a failure mode anymore.+- **Clarity**: With fewer ways to do things, there's no ambiguity about where dependencies come from (from the module, not the OS or service manager)+- **Portable layer**: Service modules in `portable/` do not receive `pkgs` as a module argument. Any required derivations must be provided by the caller.+- **Systemd integration**: The `systemd/system.nix` module imports `config-data.nix` as a function, providing `pkgs` in lexical closure:+1. Should explicitly declare their package dependencies as options rather than using `pkgs` defaults:+2. `passthru.services` can still provide a complete module using the package's lexical scope, making the module truly self-contained:
+4
-1
nixos/modules/system/service/portable/config-data.nix
+4
-1
nixos/modules/system/service/portable/config-data.nix
···
+45
-1
nixos/modules/system/service/portable/lib.nix
+45
-1
nixos/modules/system/service/portable/lib.nix
······+`serviceManagerPkgs`: A Nixpkgs instance which will be used for built-in logic such as converting `configData.<path>.text` to a store path.+`extraRootModules`: Modules to be loaded into the "root" service submodule, but not into its sub-`services`. That's the modules' own responsibility.+`extraRootSpecialArgs`: Fixed module arguments that are provided in a similar manner to `extraRootModules`.+`serviceSubmodule`: a Module System option type which is a `submodule` with the portable modules and this function's inputs loaded into it.
+8
-2
nixos/modules/system/service/portable/service.nix
+8
-2
nixos/modules/system/service/portable/service.nix
······
+17
-9
nixos/modules/system/service/portable/test.nix
+17
-9
nixos/modules/system/service/portable/test.nix
······
······
+3
-1
nixos/modules/system/service/systemd/service.nix
+3
-1
nixos/modules/system/service/systemd/service.nix
······
+14
-30
nixos/modules/system/service/systemd/system.nix
+14
-30
nixos/modules/system/service/systemd/system.nix
···A collection of NixOS [modular services](https://nixos.org/manual/nixos/unstable/#modular-services) that are configured as systemd services.
···A collection of NixOS [modular services](https://nixos.org/manual/nixos/unstable/#modular-services) that are configured as systemd services.
+3
-17
nixos/tests/modular-service-etc/python-http-server.nix
+3
-17
nixos/tests/modular-service-etc/python-http-server.nix
·········
·········+enable = lib.mkDefault (config.python-http-server.directory == config.configData."webroot".path);
+31
-4
nixos/tests/modular-service-etc/test.nix
+31
-4
nixos/tests/modular-service-etc/test.nix
······-switch_output = server.succeed("/run/current-system/specialisation/updated/bin/switch-to-configuration test")assert "webserver.service" not in switch_output, f"webserver.service was mentioned in switch output: {switch_output}"
······+switch_output = server.succeed("/run/current-system/specialisation/updated/bin/switch-to-configuration test 2>&1 | tee /dev/stderr")assert "webserver.service" not in switch_output, f"webserver.service was mentioned in switch output: {switch_output}"
+2
nixos/tests/php/fpm-modular.nix
+2
nixos/tests/php/fpm-modular.nix
+7
-1
pkgs/by-name/gh/ghostunnel/package.nix
+7
-1
pkgs/by-name/gh/ghostunnel/package.nix
······
+7
-3
pkgs/by-name/gh/ghostunnel/service.nix
+7
-3
pkgs/by-name/gh/ghostunnel/service.nix
·········
·········
+7
-1
pkgs/development/interpreters/php/generic.nix
+7
-1
pkgs/development/interpreters/php/generic.nix
······
+14
-6
pkgs/development/interpreters/php/service.nix
+14
-6
pkgs/development/interpreters/php/service.nix
············
············