Feature Specification: Resource nixos-module
Created: 2026-10-07
Status: Implemented
Input: Reconstructed from the code at 093e68b6f (core/resources/nixos-module/default.nix, core/setups/hosts-common.nix, the "code".nixos-module requests in core/components/), pull request #1184.
User Scenarios & Testing (mandatory)
The nixos-module resource passes a NixOS module from a component to its
node unchanged. It wraps no contract and selects no provider. The shared
resource rules are in the resource family spec.
User Story 1 - Add a component's own NixOS configuration (Priority: P1)
A component needs NixOS settings that no other resource expresses, for
example the service module of the component. The component requests
"code".nixos-module.module = { ... }. apply returns a list with the
policy module first and then each requested module. The node imports the
list.
Why this priority: 13 components put their main NixOS configuration on the node through this resource.
Independent Test: nix-unit-resources-nixos-module evaluates the
apply output as a node. Each check that builds a node with such a component
also evaluates it.
Acceptance Scenarios:
- Given a component that requests
"code".nixos-module.module.imports = [ ../bind.nix ], When its node evaluates, Then the node imports../bind.nix. - Given two requests on one node, When
processruns, Then the list holds both modules after the policy module.
User Story 2 - Add a module from the environment (Priority: P3)
An environment can add one module to every node that uses it. It sets the
policy option module. core/setups/hosts-common.nix sets
"fediversity".nixos-module = { }, so the policy module is empty there.
Why this priority: the setups use no policy module.
Independent Test: no check covers a non-empty policy module.
Acceptance Scenarios:
- Given the policy
module = { }, Whenprocessruns, Then the list starts with an empty module.
Edge Cases
- A node whose component makes no request still gets a list with the policy module.
- The request
modulehas typeunspecified. The module system of the node checks its content.
Requirements (mandatory)
Functional Requirements
- FR-001: The request MUST accept
moduleof any type. - FR-002: The policy MUST accept
module(default{ }). - FR-003:
applyMUST return[ policy.module ]followed by themoduleof each request, in request order. - FR-004:
core/setups/hosts-common.nixMUST add theprocessoutput to theimportsof each node.
Key Entities
module: a NixOS module, given as-is by a component or by the environment.
Success Criteria (mandatory)
Measurable Outcomes
- SC-001:
nix-unit-resources-nixos-modulepasses, and every component check that builds a node with a"code".nixos-modulerequest evaluates without error.
Assumptions
- A component author uses this resource only for settings that no dedicated resource covers.
Known Deviations
None.