Jump to content

Modular Services: Difference between revisions

From Official NixOS Wiki
Ehmry (talk | contribs)
Research Topics: Intra-service dependencies
m fix: references
 
(4 intermediate revisions by 3 users not shown)
Line 1: Line 1:
Modular services are an experimental feature added to NixOS between the 25.05 and 25.11 releases.
{{warning | Work in progress }}


For official documentation see the [https://nixos.org/manual/nixos/unstable/#modular-services NixOS Manual].
Modular Services are a new experimental module system support in Nixpkgs, that aims to expand the module systems (Eg. NixOS, home-manager, nix-darwin, etc) ecosystem with modularity and portability. Modular services is designed to integrate/compose with other modules systems such as NixOS.


This page exists to used to collect experiences and recommendations for using this feature that would not fit well in the NixOS manual.
== Difference between Traditional Module Systems (such as NixOS) vs Modular Services ==


== Do's ==
Modular services are built for composability, re-usability, are not defined in sets of options, portable.
Where as traditional modules are the opposite.


== Do not Do's ==
== How to use ==


== Research Topics ==
* System:


=== "One-shot" services ===
<syntaxhighlight lang="nix">
Some services run to completion and should not be restarted.
  system.services.<name> = {
    # Usage inside of the traditional module system like NixOS...
    imports = [ pkgs.example.services.default ];
    example.allowAll = false;
  };
</syntaxhighlight>


Should these services we be wrapped in scripts that never return?
* User:


=== Secrets management ===
{{warning | Not all module systems support this, like for example NixOS.}}


How to load secrets without depending on specific service managers?
<syntaxhighlight lang="nix">
  system.user.services.<name> = {
    # Usage inside of the traditional module system like NixOS...
    imports = [ pkgs.example.services.default ];
    example.allowAll = false;
  };
</syntaxhighlight>


=== User management ===


How to create new users?
== Resources ==


=== Security hardening ===


Best practices for  privilege de-escalation?
{{Cleanup|reason=More information is needed.}}


=== Intra-service dependencies ===
# {{manual|nixos|modular-services|NixOS Modular Services|subsection=modular-services}}
 
# {{issue | 428084 | Tracking issue}}
How should dependencies within a collection of services be expressed?

Latest revision as of 01:56, 14 July 2026

⚠︎
Warning: Work in progress

Modular Services are a new experimental module system support in Nixpkgs, that aims to expand the module systems (Eg. NixOS, home-manager, nix-darwin, etc) ecosystem with modularity and portability. Modular services is designed to integrate/compose with other modules systems such as NixOS.

Difference between Traditional Module Systems (such as NixOS) vs Modular Services

Modular services are built for composability, re-usability, are not defined in sets of options, portable. Where as traditional modules are the opposite.

How to use

  • System:
  system.services.<name> = {
    # Usage inside of the traditional module system like NixOS...
    imports = [ pkgs.example.services.default ];
    example.allowAll = false;
  };
  • User:
⚠︎
Warning: Not all module systems support this, like for example NixOS.
  system.user.services.<name> = {
    # Usage inside of the traditional module system like NixOS...
    imports = [ pkgs.example.services.default ];
    example.allowAll = false;
  };


Resources

⚟︎
This article or section needs cleanup. More information is needed. Please edit the article, paying special attention to fixing any formatting issues, inconsistencies, grammar, or phrasing. Make sure to consult the Manual of Style for guidance.
  1. 📖︎ NixOS Modular Services
  2. 428084 🚩︎ Tracking issue