Feature Specification: Resource nixos-module

Created: 2026-10-07

Status: Implemented

Input: Reconstructed from the code of core/resources/nixos-module/ and its requests in the components at 093e68b6f, 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 this resource with that module. The node imports the module of the environment policy first, then each requested module.

Why this priority: most components put their main NixOS configuration on the node through this resource.

Independent Test: a unit test that evaluates the output as a node. Each check that builds a node with such a component also evaluates it.

Acceptance Scenarios:

  1. Given a component that requests a module that imports a file, When its node evaluates, Then the node imports that file.
  2. Given two requests on one node, When the policy runs, Then the node imports 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 the resource, through its policy. The setups give an empty policy module.

Why this priority: the setups use no policy module.

Independent Test: no check covers a non-empty policy module.

Acceptance Scenarios:

  1. Given an empty policy module, When the policy runs, Then the node imports an empty module first.

Edge Cases

  • A node whose components make no request still imports the policy module.
  • The resource does not check the content of a requested module. The module system of the node checks it.

Requirements (mandatory)

Functional Requirements

  • FR-001: The request MUST accept a module of any type.
  • FR-002: The policy MUST accept a module, which is empty by default.
  • FR-003: The policy MUST give the policy module followed by the module of each request, in request order.
  • FR-004: The setup MUST make each node import the output of the policy.

Key Entities

  • Module: a NixOS module, given as-is by a component or by the environment.

Success Criteria (mandatory)

Measurable Outcomes

  • SC-001: the unit test of the resource passes, and every component check that builds a node with a request for this resource evaluates without error.

Assumptions

  • A component author uses this resource only for settings that no dedicated resource covers.

Known Deviations

None.