export module as system-independent flake output

Flake outputs are a mixture of system-dependent and system-independent
sets, and flake-utils doesn't do much to distinguish one from the other.
Because of that, the `age` NixOS module currently has to be acessed as
`agenix.nixosModules.${system}.age`, rather than the documented
`agenix.nixosModules.age`.

To remedy that, (conceptually) split `outputs` in two, let flake-utils
handle the system-dependent half, and merge them to form the actual
outputs.  The names for the two halves were taken from [1].

[1]: https://github.com/NixOS/nix/issues/3843#issuecomment-661720562
This commit is contained in:
Aluísio Augusto Silva Gonçalves 2020-12-19 00:39:25 -03:00
parent 8af97149b2
commit c1cbfe75b0
No known key found for this signature in database
GPG Key ID: DA6EA2FACDB1CBD2
1 changed files with 7 additions and 3 deletions

View File

@ -4,10 +4,14 @@
inputs.flake-utils.url = "github:numtide/flake-utils";
outputs = { self, nixpkgs, flake-utils }:
flake-utils.lib.eachDefaultSystem (system:
{
let
exports = {
nixosModules.age = import ./modules/age.nix;
packages = nixpkgs.legacyPackages.${system}.callPackage ./default.nix {};
};
outputs = flake-utils.lib.eachDefaultSystem (system: {
packages = nixpkgs.legacyPackages.${system}.callPackage ./default.nix { };
defaultPackage = self.packages.${system}.agenix;
});
in
exports // outputs;
}