NixOS / nixpkgs

Nix Packages collection & NixOS
MIT License
17.31k stars 13.55k forks source link

Build failure: flake.nix #322451

Closed mem101296 closed 2 months ago

mem101296 commented 2 months ago

While updating NixOS, this error orccurs:

❯ sudo nixos-rebuild switch  --flake .#unus
warning: creating lock file '/home/exspiravit/nixConfig/flake.lock'
building the system configuration...
error:
       … while calling the 'head' builtin

         at /nix/store/yqy82fn77fy3rv7lpwa9m11w3a2nnqg5-source/lib/attrsets.nix:1575:11:

         1574|         || pred here (elemAt values 1) (head values) then
         1575|           head values
             |           ^
         1576|         else

       … while evaluating the attribute 'value'

         at /nix/store/yqy82fn77fy3rv7lpwa9m11w3a2nnqg5-source/lib/modules.nix:809:9:

          808|     in warnDeprecation opt //
          809|       { value = builtins.addErrorContext "while evaluating the option `${showOption loc}':" value;
             |         ^
          810|         inherit (res.defsFinal') highestPrio;

       (stack trace truncated; use '--show-trace' to show the full trace)

       error: getting status of '/nix/store/yj1wxm9hh8610iyzqnz75kvs6xl8j3my-source': No such file or directory

Here is my flake.nix:

{
  description = "Lucid's NixOS and Home-Manager flake";

  outputs = inputs:
    inputs.flake-parts.lib.mkFlake {inherit inputs;} {
      systems = ["x86_64-linux"];
      imports = [
        ./home/profiles
        ./hosts
      ];

      perSystem = {
        config,
        pkgs,
        system,
        ...
      }:
        { devShells.default = pkgs.mkShell {
          shellHook = ''
            export RUST_SRC_PATH=${pkgs.rustPlatform.rustLibSrc}
          '';
          buildInputs = [
            pkgs.pkg-config
            pkgs.gdb
            pkgs.rust-bin.stable.latest.default
            pkgs.glib
            pkgs.gtk4
            pkgs.gtk3
            pkgs.rust-analyzer
          ];
        };
        _module.args.pkgs = import inputs.nixpkgs {
          inherit system;
          overlays = [ (import inputs.rust-overlay) ];
        };
      };
    };

  inputs = {

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

    flake-parts = {
      url = "github:hercules-ci/flake-parts";
      inputs.nixpkgs-lib.follows = "nixpkgs";
    };

    flake-utils = {
      url = "github:numtide/flake-utils";
    };

    #proton-ge-bin.url = "github:GloriousEggroll/proton-ge-custom";

    helix.url = "github:helix-editor/helix";

    hm = {
      url = "github:nix-community/home-manager";
      inputs.nixpkgs.follows = "nixpkgs";
    };

    hypridle = {
      url = "github:hyprwm/hypridle";
      inputs.hyprlang.follows = "hyprland/hyprlang";
      inputs.nixpkgs.follows = "hyprland/nixpkgs";
    };

    hyprland.url = "git+https://github.com/hyprwm/Hyprland?submodules=1";

    hyprland-contrib = {
      url = "github:hyprwm/contrib";
      inputs.nixpkgs.follows = "nixpkgs";
    };

    hyprland-plugins = {
      url = "github:hyprwm/hyprland-plugins";
      inputs.hyprland.follows = "hyprland";
    };

    hyprlock = {
      url = "github:hyprwm/hyprlock";
      inputs.hyprlang.follows = "hyprland/hyprlang";
      inputs.nixpkgs.follows = "hyprland/nixpkgs";
    };

    hyprpaper = {
      url = "github:hyprwm/hyprpaper";
      inputs.hyprlang.follows = "hyprland/hyprlang";
      inputs.nixpkgs.follows = "hyprland/nixpkgs";
    };

    nix-citizen.url = "github:LovingMelody/nix-citizen";
    nix-citizen.inputs.nix-gaming.follows = "nix-gaming";

    nix-index-db = {
      url = "github:Mic92/nix-index-database";
      inputs.nixpkgs.follows = "nixpkgs";
    };

    nix-gaming = {
      url = "github:fufexan/nix-gaming";
      inputs.nixpkgs.follows = "nixpkgs";
      inputs.flake-parts.follows = "flake-parts";
    };

    rust-overlay.url = "github:oxalica/rust-overlay";

    yazi.url = "github:sxyazi/yazi";
  };
}
eclairevoyant commented 2 months ago

Probably store corruption

mem101296 commented 2 months ago

Ran:

sudo nix-store --repair --verify --check-contents

However the error still persists.

eclairevoyant commented 2 months ago

In that case, please provide a repo to reproduce the issue

mem101296 commented 2 months ago

Heres: https://github.com/mem101296/NixOS-dotfiles

eclairevoyant commented 2 months ago
nixos-rebuild dry-build --option experimental-features "flakes nix-command" --flake github:mem101296/NixOS-dotfiles#unus

seems to work fine on my end. I'm still leaning towards something being broken in your store

mem101296 commented 2 months ago

What should I do to resolve this error?

eclairevoyant commented 2 months ago

If you run the exact command I ran, does that also result in an error?

mem101296 commented 2 months ago

Yes it does, same error.

eclairevoyant commented 2 months ago

Not sure then, honestly. Maybe someone else has more insights.

mem101296 commented 2 months ago

Is there a way for me to tell how it ends up in the flake.lock?

    "systems_7": {
      "locked": {
        "lastModified": 1681028828,
        "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
        "path": "/nix/store/yj1wxm9hh8610iyzqnz75kvs6xl8j3my-source",
        "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
        "type": "path"
      },
      "original": {
        "id": "systems",
        "type": "indirect"
      }
    },
Shawn8901 commented 2 months ago

Is there a way for me to tell how it ends up in the flake.lock?

    "systems_7": {
      "locked": {
        "lastModified": 1681028828,
        "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
        "path": "/nix/store/yj1wxm9hh8610iyzqnz75kvs6xl8j3my-source",
        "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
        "type": "path"
      },
      "original": {
        "id": "systems",
        "type": "indirect"
      }
    },

Seems to be an input of nix-citizen if I read that correctly https://github.com/mem101296/NixOS-dotfiles/blob/b899d1f7538cfae58cf12281390b0e8fd4636b4a/flake.lock#L454

That commit here seems to have override their lock file with a store path https://github.com/LovingMelody/nix-citizen/commit/dcc65e3e76f926fb6cb81bf903a6ffc7bdaa84aa

eclairevoyant commented 2 months ago

Good catch, this is why I avoid using others' flakes when possible. But the linked PR should fix it.

You can also fix it on your end by adding the following to the inputs attrset:

  nix-citizen.inputs.systems.url = "github:nix-systems/default";

followed by nix flake update systems or nix flake lock --update-input systems, depending on your version of nix.