This is about composition of NixOS modules provided by seperate flakes. I want to create a new flake which provides NixOS modules upstream to its consumer.
Say I have a nix flake A, which provides a package A.defaultPackage
and a NixOS module in that flake nixosModules.a
. How do I pass through
that NixOS module in another flake B which is consumed in a NixOS
configuration?
When I start a repl in repo B I cannot see that inputs.A “exports” a
a NixOS module (as it is visible for packages); The package is there,
which is fine (1).
Host
- configuration based on Flake B:
Flake B
- provides: NixOS module
- depends-on:
Flake-A:
- provides: package
- provides: NixOS module
So in summary:
-
I have 3 flakes in seperate Git repositories
-
Host configuration needs flake B and packages which it should
propagate, and also NixOS modules -
Flake B should provide its own NixOS module (works) and it should
propagate the input package from Flake A (works). It should also
provide the NixOS module from Flake A to its consumers (i.e. host, doesnt work). -
Flake A provides a package (works) and provides a NixOS module
(works if directly consumed in a host configuration, but not as
passthrough in flake B).
Another formulation of my problem could be:
- Say I have multiple NixOS modules in seperate flakes
- How do I create a new flake which aggregates these NixOS modules?
Example nix repl session (1):
$ nix repl
Welcome to Nix 2.6.0pre20211217_6e6e998. Type :? for help.
nix-repl> :lf .#
Added 11 variables.
nix-repl> inputs.A
{ defaultPackage = { ... }; inputs = { ... }; lastModified = 1645565462; lastModifiedDate = "20220222213102"; narHash = "sha256-VIhwPpgiX7s7Vz3lPnVULXZFViZmh1csDeGzfAayoE0="; outPath = "/nix/store/36davbc584ar1784p7q9a2jh8mknfll2-source"; outputs = { ... }; packages = { ... }; rev = "2219497c9b85b0fb07c6c6b112b9e226509ba02d"; revCount = 2; shortRev = "2219497"; sourceInfo = { ... }; submodules = false; }
nix-repl> inputs.A.outputs
{ defaultPackage = { ... }; packages = { ... }; }
Looking Forward