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

flake-parts module breaks nix flake show #78

Open
zarelit opened this issue May 20, 2023 · 4 comments
Open

flake-parts module breaks nix flake show #78

zarelit opened this issue May 20, 2023 · 4 comments
Labels
bug Something isn't working

Comments

@zarelit
Copy link

zarelit commented May 20, 2023

Describe the bug

When imported, nix flake show throws an error like: error: The option `perSystem.x86_64-linux.treefmt' is used but not defined.
Running nix flake show again says error: 'checks.x86_64-linux' is not an attribute set

To Reproduce

This is a minimal flake.nix triggering the issue

{
  description = "Description for the project";

  inputs = {
    nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
    treefmt-nix.url = "github:numtide/treefmt-nix";
  };

  outputs = inputs@{ flake-parts, ... }:
    flake-parts.lib.mkFlake { inherit inputs; } {
      imports = [
        inputs.treefmt-nix.flakeModule
      ];
      systems = ["x86_64-linux"];
    };
}

Error is encountered by running nix flake show or also by running nix fmt

Expected behavior

If there's a mandatory option to set in order to not have errors, have it printed in the error message or documented in the flake-parts website

System information

These are the commits in the lockfile at the moment of writing as obtained with nix flake metadata

treefmt-nix: github:numtide/treefmt-nix/42045102f90cfd23ca44ae4ef8362180fefcd7fd
flake-parts: github:hercules-ci/flake-parts/006c75898cf814ef9497252b022e91c946ba8e17

Running on x86_64-linux

@zarelit zarelit added the bug Something isn't working label May 20, 2023
@zimbatm
Copy link
Member

zimbatm commented Jul 17, 2023

I think this was fixed. At least I couldn't repro.

I'll close the issue but let me know if you still have that problem.

@zimbatm zimbatm closed this as completed Jul 17, 2023
@zarelit
Copy link
Author

zarelit commented Jul 19, 2023

@zimbatm this is still happening with these inputs:

Inputs:
├───flake-parts: github:hercules-ci/flake-parts/8e8d955c22df93dbe24f19ea04f47a74adbdc5ec
│   └───nixpkgs-lib: github:NixOS/nixpkgs/4bc72cae107788bf3f24f30db2e2f685c9298dc9?dir=lib
├───nixpkgs: github:NixOS/nixpkgs/6cee3b5893090b0f5f0a06b4cf42ca4e60e5d222
└───treefmt-nix: github:numtide/treefmt-nix/719c2977f958c41fa60a928e2fbc50af14844114
    └───nixpkgs: github:nixos/nixpkgs/d9f759f2ea8d265d974a6e1259bd510ac5844c5d

The weird thing it that some nix caching is involved because it returns two different errors if I run nix flake show twice:

[zarel@playa:~/code/nix examples/linting]$ nix flake show
path:/home/zarel/code/nix examples/linting?lastModified=1689771602&narHash=sha256-l2k02g4W%2fh0c2MdgBYRwDxYqVk4Xq2%2fQjX1sP2ab%2fWc=
├───apps
│   └───x86_64-linux
├───checks
│   └───x86_64-linux
error: The option `perSystem.x86_64-linux.treefmt' is used but not defined.
(use '--show-trace' to show detailed location information)

[zarel@playa:~/code/nix examples/linting]$ nix flake show
path:/home/zarel/code/nix examples/linting?lastModified=1689771602&narHash=sha256-l2k02g4W%2fh0c2MdgBYRwDxYqVk4Xq2%2fQjX1sP2ab%2fWc=
├───apps
│   └───x86_64-linux
├───checks
│   └───x86_64-linux
error: 'checks.x86_64-linux' is not an attribute set

I'm going to open a repository for you to try this out, if it's not reproducible then I don't know what's happening since I don't have any special configuration (it's Nix 2.13.3 with sandbox and flakes enabled) and that's it

@zarelit
Copy link
Author

zarelit commented Jul 19, 2023

This is the minimal example that breaks the show for me
https://github.com/zarelit/repro-treefmt-issue-78

@zimbatm
Copy link
Member

zimbatm commented Jul 19, 2023

I'm getting a different error on your repo:

$ nix flake show
git+file:///home/zimbatm/go/src/github.com/zarelit/repro-treefmt-issue-78?ref=refs/heads/main&rev=c4f05b1b50f3b7376169f5e91dd79626a0881a76
├───checks
│   └───x86_64-linux
error: 'checks.x86_64-linux' is not an attribute set

@zimbatm zimbatm reopened this Jul 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants