lib/services: move portable service infrastructure out of nixos/
Move the portable modular service base from nixos/modules/system/service/portable/ to lib/services/, making it importable by any module system (home-manager, nix-darwin) without reaching into the nixos/ tree. Moved files: service.nix, lib.nix, config-data.nix, config-data-item.nix, test.nix. All external references updated (systemd/system.nix, doc/manual/default.nix, assertions.nix, README.md). No functional changes - only import paths differ.
This commit is contained in:
+1
-1
@@ -1,4 +1,4 @@
|
||||
# Tests in: ../../../../tests/modular-service-etc/test.nix
|
||||
# Tests in: ../../nixos/tests/modular-service-etc/test.nix
|
||||
# This file is a function that returns a module.
|
||||
pkgs:
|
||||
{
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
# Tests in: ../../../../tests/modular-service-etc/test.nix
|
||||
# Tests in: ../../nixos/tests/modular-service-etc/test.nix
|
||||
|
||||
# Non-modular context provided by the modular services integration.
|
||||
{ pkgs }:
|
||||
@@ -16,8 +16,8 @@ in
|
||||
# https://nixos.org/manual/nixos/unstable/#modular-services
|
||||
_class = "service";
|
||||
imports = [
|
||||
../../../../../modules/generic/meta-maintainers.nix
|
||||
../../../misc/assertions.nix
|
||||
../../modules/generic/meta-maintainers.nix
|
||||
../../nixos/modules/misc/assertions.nix
|
||||
(lib.modules.importApply ./config-data.nix { inherit pkgs; })
|
||||
];
|
||||
options = {
|
||||
@@ -1,7 +1,7 @@
|
||||
# Run:
|
||||
# nix-instantiate --eval nixos/modules/system/service/portable/test.nix
|
||||
# nix-instantiate --eval lib/services/test.nix
|
||||
let
|
||||
lib = import ../../../../../lib;
|
||||
lib = import ../.;
|
||||
|
||||
inherit (lib) mkOption types;
|
||||
|
||||
@@ -134,7 +134,7 @@ let
|
||||
inherit
|
||||
(evalModules {
|
||||
modules = [
|
||||
(modules.importApply ../../modules/system/service/portable/service.nix {
|
||||
(modules.importApply ../../../lib/services/service.nix {
|
||||
pkgs = throw "nixos docs / portableServiceOptions: Do not reference pkgs in docs";
|
||||
})
|
||||
];
|
||||
|
||||
@@ -34,5 +34,5 @@
|
||||
};
|
||||
# impl of assertions is in
|
||||
# - <nixpkgs/nixos/modules/system/activation/top-level.nix>
|
||||
# - <nixpkgs/nixos/modules/system/service/portable/lib.nix>
|
||||
# - <nixpkgs/lib/services/lib.nix>
|
||||
}
|
||||
|
||||
@@ -43,7 +43,7 @@ Many services implement automatic reloading or reloading on e.g. `SIGUSR1`, but
|
||||
|
||||
### Service Manager Integration
|
||||
|
||||
- **Portable base**: The `configData` interface is declared in `portable/config-data.nix`, making it available to all service manager implementations.
|
||||
- **Portable base**: The `configData` interface is declared in `lib/services/config-data.nix`, making it available to all service manager implementations.
|
||||
|
||||
- **Systemd integration**: The systemd implementation (`systemd/system.nix`) maps `configData` entries to `environment.etc` entries under `/etc/system-services/`.
|
||||
|
||||
@@ -66,11 +66,11 @@ The modular service infrastructure avoids exposing `pkgs` as a module argument t
|
||||
|
||||
### Implementation
|
||||
|
||||
- **Portable layer**: Service modules in `portable/` do not receive `pkgs` as a module argument. Any required derivations must be provided by the caller.
|
||||
- **Portable layer**: Service modules in `lib/services/` 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:
|
||||
```nix
|
||||
(import ../portable/config-data.nix { inherit pkgs; })
|
||||
(import lib/services/config-data.nix { inherit pkgs; })
|
||||
```
|
||||
|
||||
- **Service modules**:
|
||||
|
||||
@@ -15,7 +15,7 @@ let
|
||||
mapAttrsToList
|
||||
;
|
||||
|
||||
portable-lib = import ../portable/lib.nix { inherit lib; };
|
||||
portable-lib = import ../../../../../lib/services/lib.nix { inherit lib; };
|
||||
|
||||
dash =
|
||||
before: after:
|
||||
|
||||
Reference in New Issue
Block a user