Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

export module as system-independent flake output #8

Merged
merged 1 commit into from
Dec 19, 2020

Conversation

AluisioASG
Copy link
Contributor

The example in the README uses agenix.nixosModules.age as the NixOS module, but that causes an "attribute 'age' missing" error for me. I've had to use agenix.nixosModules.x86_64-linux.age instead. nix flake show sees no module in there either:

nix flake show 'github:ryantm/agenix'
github:ryantm/agenix/8af97149b28adaf28699af923c35633310d52edf
[…]
├───nixosModules
│   ├───aarch64-linux: NixOS module
│   ├───i686-linux: NixOS module
│   ├───x86_64-darwin: NixOS module
│   └───x86_64-linux: NixOS module
[…]

This is because flake-utils doesn't try to distinguish outputs with ${system} keys from those without.

In my own flakes I've been using a pattern inspired by this idea for system-dependent and system-independent outputs, and it's the same pattern I'm using in this PR.

Because someone may already be using the current paths, I've kept nixosModules as is, and added a singular nixosModule output, which isn't recognized by nix flake show but is documented in the wiki. Alternatively I can change nixosModules to match the documentation,

I'm marking this as WIP because the README needs to be updated based on the previous paragraph.

@ryantm
Copy link
Owner

ryantm commented Dec 19, 2020

I'm okay breaking a handful of people now to get the output to be standard.

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]: NixOS/nix#3843 (comment)
@AluisioASG AluisioASG marked this pull request as ready for review December 19, 2020 04:54
@AluisioASG
Copy link
Contributor Author

Done. It should match the README now.

@ryantm
Copy link
Owner

ryantm commented Dec 19, 2020

Thanks.

When I run nix flake show on the repo after checking out your branch, I get an error message:

$ nix --version
nix (Nix) 2.4pre20201102_550e11f
$ nix flake show
warning: unknown setting 'extra-sandbox-paths'
git+file:///home/ryantm/p/agenix?ref=flake-nixos-module&rev=c1cbfe75b0e2b26fa0918c5634d13c8364d04599
├───defaultPackage
│   ├───aarch64-linux: package 'agenix'
│   ├───i686-linux: package 'agenix'
│   ├───x86_64-darwin: package 'agenix'
│   └───x86_64-linux: package 'agenix'
├───nixosModules
│   └───age: NixOS module
└───packages
    ├───aarch64-linux
    │   ├───agenix: package 'agenix'
error: --- Error ---------------------------------------------------------------------------------------------------------------------------- nix
expected a derivation

Do you get this error? I'll try upgrading my version of Nix.

@ryantm
Copy link
Owner

ryantm commented Dec 19, 2020

Still happens on a later version

$ nix --version
nix (Nix) 2.4pre20201201_5a6ddb3

[ryantm@home1:~/p/agenix]$ nix flake show --show-trace
git+file:///home/ryantm/p/agenix?ref=flake-nixos-module&rev=c1cbfe75b0e2b26fa0918c5634d13c8364d04599
├───defaultPackage
│   ├───aarch64-linux: package 'agenix'
│   ├───i686-linux: package 'agenix'
│   ├───x86_64-darwin: package 'agenix'
│   └───x86_64-linux: package 'agenix'
├───nixosModules
│   └───age: NixOS module
└───packages
    ├───aarch64-linux
    │   ├───agenix: package 'agenix'
error: --- Error --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- nix
expected a derivation

@AluisioASG
Copy link
Contributor Author

Yeah, it already happened before this PR. I elided it from my original post because it wasn't relevant to the module thing.

Replicating the packages line from flake.nix:

nix-repl> (import <nixpkgs> { system = "x86_64-linux"; }).callPackage ./default.nix {}
{ agenix = «derivation /nix/store/261y133fid9pmv7q6rnkjnznss503wkk-agenix.drv»; override = { ... }; overrideDerivation = «lambda @ /nix/store/2vjfc00qrhm648x2rzb3gfqxammif8mp-source/lib/customisation.nix:84:32»; }

I suspect Nix is choking on override/overrideDerivation.

@AluisioASG
Copy link
Contributor Author

(As far I can tell it works fine, just not when doing nix flake show or nix flake check.)

@ryantm ryantm merged commit 553d1f5 into ryantm:master Dec 19, 2020
@ryantm
Copy link
Owner

ryantm commented Dec 19, 2020

Okay, I'm glad it isn't just me. Merged!

@AluisioASG AluisioASG deleted the flake-nixos-module branch December 19, 2020 18:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants