Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -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:
{
Expand Down
Original file line number Diff line number Diff line change
@@ -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 }:
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down
Original file line number Diff line number Diff line change
@@ -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;

Expand Down
2 changes: 1 addition & 1 deletion nixos/doc/manual/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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";
})
];
Expand Down
2 changes: 1 addition & 1 deletion nixos/modules/misc/assertions.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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>
}
5 changes: 4 additions & 1 deletion nixos/modules/misc/documentation.nix
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,10 @@ let
&& (t == "directory" -> baseNameOf n != "tests")
&& (t == "file" -> hasSuffix ".nix" n)
);
prefixRegex = "^" + lib.strings.escapeRegex (toString pkgs.path) + "($|/(modules|nixos)($|/.*))";
prefixRegex =
"^"
+ lib.strings.escapeRegex (toString pkgs.path)
+ "($|/(modules|nixos|lib/services)($|/.*)|/lib)";
filteredModules = builtins.path {
name = "source";
inherit (pkgs) path;
Expand Down
6 changes: 3 additions & 3 deletions nixos/modules/system/service/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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/`.

Expand All @@ -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**:
Expand Down
2 changes: 1 addition & 1 deletion nixos/modules/system/service/systemd/system.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Loading