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

Build fails with nix-darwin: The option `_module.args.inputs' is defined multiple times. #113

Closed
azuwis opened this issue Feb 27, 2022 · 12 comments

Comments

@azuwis
Copy link

azuwis commented Feb 27, 2022

Demo flake.nix https://gist.github.com/azuwis/47a67c40f61afaa02362b79a0496afeb:

{
  description = "Darwin demo";

  inputs = {
    nixpkgs.url = github:nixos/nixpkgs/nixpkgs-unstable;
    utils.url = "github:gytis-ivaskevicius/flake-utils-plus/v1.3.1";

    darwin.url = "github:lnl7/nix-darwin/master";
    darwin.inputs.nixpkgs.follows = "nixpkgs";
  };

  outputs = inputs@{ self, nixpkgs, utils, darwin, ... }:
    utils.lib.mkFlake {
      inherit self inputs;

      hosts.demo.system = "aarch64-darwin";
      hosts.demo.output = "darwinConfigurations";
      hosts.demo.builder = args: darwin.lib.darwinSystem (removeAttrs args [ "system" ]);
    };
}

Error log:

$ nix build 'git+https://gist.github.com/azuwis/47a67c40f61afaa02362b79a0496afeb?ref=main#darwinConfigurations.demo.system'            
trace: warning: literalExample is deprecated, use literalExpression instead, or use literalDocBook for a non-Nix description.
trace: lib.crossLists is deprecated, use lib.cartesianProductOfSets instead
trace: warning: literalExample is deprecated, use literalExpression instead, or use literalDocBook for a non-Nix description.
trace: warning: lib.mkFixStrictness has no effect and will be removed. It returns its argument unmodified, so you can just remove any calls.
trace: `lib.nixpkgsVersion` is deprecated, use `lib.version` instead!
trace: warning: lib.readPathsFromFile is deprecated, use a list instead
trace: Warning: `showVal` is deprecated and will be removed in the next release, please use `traceSeqN`
trace: lib.zip is deprecated, use lib.zipAttrsWith instead
error: The option `_module.args.inputs' is defined multiple times.

       Definition values:
       - In `/nix/store/5m88sbxj815z8bzrij15bp4w4siakw1i-source/eval-config.nix'
       - In `<unknown-file>'
(use '--show-trace' to show detailed location information)
$ nix-info -m    
 - system: `"aarch64-darwin"`
 - host os: `Darwin 21.3.0, macOS 12.2.1`
 - multi-user?: `yes`
 - sandbox: `no`
 - version: `nix-env (Nix) 2.6.1`
 - channels(azuwis): `""`
 - channels(root): `""`
 - nixpkgs: `/nix/store/a94a18pdxp29hggy2v5aij4z11h54y8p-source`
@bbbbbailey
Copy link
Contributor

I implemented a hacky fix and confirmed that my M1 system builds using the fix, I'll take the weekend to clean it up and issue a PR.

@montchr
Copy link
Contributor

montchr commented Mar 11, 2022

@bbuscarino If you track the latest from the master branch in your flake-utils-plus input, do you get different results?

utils.url = "github:gytis-ivaskevicius/flake-utils-plus";

Also, I recall running into some issue recently with Nix 2.6.x on a MBP. Not sure if that's been fixed – I'm still running 2.5.1 at the moment. But I may give the latest version another shot soon.

@montchr
Copy link
Contributor

montchr commented Mar 11, 2022

And, FWIW, I've been using this library with nix-darwin for a while without issue – I don't think LnL7/nix-darwin#319 as mentioned in this project's readme is applicable any longer – see also LnL7/nix-darwin#317.

I've been using the darwin-support branch from https://github.com/divnix/digga for a few weeks now, but that uses this library behind the scenes. But even prior to that, I had been using FUP on darwin without issue.

I was able to use darwin.lib.darwinSystem as a direct input to the builder option using the latest version of flake-utils-plus:

https://github.com/montchr/dotfield/blob/c6bbf0ab1ac38621f67e9bb37ef96e272cf2df3b/flake.nix#L165

What happens if you try something like this:

hosts.demo.builder = darwin.lib.darwinSystem;

@bbbbbailey
Copy link
Contributor

bbbbbailey commented Mar 12, 2022

@montchr The latest master flake-utils-plus and nix-darwin is where this pops up.

Looking through the histories of each repository, it's not clear to me why this didn't break earlier. I recently upgraded to M1 and hit this bug when migrating. flake-utils-plus and nix-darwin both add pkgs and inputs to the module args:

My fix opts to pass inputs and pkgs via the builder function if the output is darwinConfigurations, which solves the problem.
The fix in question.

@gytis-ivaskevicius
Copy link
Owner

Can any of you test it with the latest version of FUP? I've added a little example which seems to evaluate https://github.com/gytis-ivaskevicius/flake-utils-plus/tree/master/examples/darwin

@azuwis
Copy link
Author

azuwis commented Mar 14, 2022

Can any of you test it with the latest version of FUP? I've added a little example which seems to evaluate https://github.com/gytis-ivaskevicius/flake-utils-plus/tree/master/examples/darwin

The example builds fine with:

    nixpkgs.url = github:nixos/nixpkgs/release-21.05;

but not with:

    nixpkgs.url = github:nixos/nixpkgs/nixpkgs-unstable;

error message:

$ nix build .#darwinConfigurations.Hostname1.system
warning: Git tree '/private/tmp/flake-utils-plus' is dirty
trace: lib.crossLists is deprecated, use lib.cartesianProductOfSets instead
trace: warning: literalExample is deprecated, use literalExpression instead, or use literalDocBook for a non-Nix description.
trace: warning: lib.mkFixStrictness has no effect and will be removed. It returns its argument unmodified, so you can just remove any calls.
trace: `lib.nixpkgsVersion` is deprecated, use `lib.version` instead!
trace: warning: lib.readPathsFromFile is deprecated, use a list instead
trace: Warning: `showVal` is deprecated and will be removed in the next release, please use `traceSeqN`
trace: lib.zip is deprecated, use lib.zipAttrsWith instead
error: The option `_module.args.inputs' is defined multiple times.

       Definition values:
       - In `/nix/store/fl382jvr5cjyv0za2nlanz8n5ic52czp-source/eval-config.nix'
       - In `<unknown-file>'
(use '--show-trace' to show detailed location information)

@infinisil
Copy link

Randomly stumbling upon this. NixOS/nixpkgs#160489 is causing this to fail now when it didn't before. The reason it's failing is as the error says, the inputs argument is defined twice, the first of which points to https://github.com/LnL7/nix-darwin/blob/17fbc68a6110edbff67e55f7450230a697ecb17e/eval-config.nix#L17, while the second one is not as clear, but it should point to

_module.args = { inherit inputs; } // host.extraArgs;
. The error message could be improved by adding a _file attribute to the module there.

@azuwis
Copy link
Author

azuwis commented Mar 16, 2022

For anyone interested, you can use:

utils.url = "github:gytis-ivaskevicius/flake-utils-plus/pull/117/head";

as a temporary workaround.

@ForsakenHarmony
Copy link

Any plans for the fix to get merged?

@fufexan
Copy link
Collaborator

fufexan commented Apr 30, 2022

@ForsakenHarmony both PRs adding it (#117 and #119) fail the tests. We can't merge the fix before making sure tests work as well.

@gytis-ivaskevicius planning to fix that PR?

@gytis-ivaskevicius
Copy link
Owner

gytis-ivaskevicius commented May 16, 2022

Fixed in master

@ForsakenHarmony
Copy link

That's great, thanks

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

No branches or pull requests

7 participants