Some packages are not installed in devShell using flake

When I download zig_0_15 via “nix-shell -p zig_0_15” everything works, but in flake

{
  description = "A very basic flake";

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

  outputs = {
    self,
    nixpkgs,
  }: let
    pkgs = nixpkgs.legacyPackages."x86_64-linux";
  in {
    devShells."x86_64-linux".default = pkgs.mkShell {
      packages = with pkgs; [
        zig_0_15
        zls
        lldb
      ];

      shellHook = ''
        echo ""
        echo "Zig Dev Env"
        echo ""
        zig version
        echo ""
      '';
    };
  };
}

I get

error:
       … while calling the 'derivationStrict' builtin
         at <nix/derivation-internal.nix>:37:12:
           36|
           37|   strict = derivationStrict drvAttrs;
             |            ^
           38|

       … while evaluating derivation 'nix-shell'
         whose name attribute is located at /nix/store/h2bn031b0fj0ymv9v7bv5rcdjx58y2l9-source/pkgs/stdenv/generic/make-derivation.nix:468:13

       … while evaluating attribute 'nativeBuildInputs' of derivation 'nix-shell'
         at /nix/store/h2bn031b0fj0ymv9v7bv5rcdjx58y2l9-source/pkgs/stdenv/generic/make-derivation.nix:520:13:
          519|             depsBuildBuild = elemAt (elemAt dependencies 0) 0;
          520|             nativeBuildInputs = elemAt (elemAt dependencies 0) 1;
             |             ^
          521|             depsBuildTarget = elemAt (elemAt dependencies 0) 2;

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

       error: undefined variable 'zig_0_15'
       at /nix/store/sinivxfcygi7i1qbss17shmfwka987c8-source/flake.nix:16:9:
           15|       packages = with pkgs; [
           16|         zig_0_15
             |         ^
           17|         zls

Same thing with ty

My first suspicion would be to check the flake.lock.

{
  "nodes": {
    "nixpkgs": {
      "locked": {
        "lastModified": 1751271578,
        "narHash": "sha256-P/SQmKDu06x8yv7i0s8bvnnuJYkxVGBWLWHaU+tt4YY=",
        "owner": "NixOS",
        "repo": "nixpkgs",
        "rev": "3016b4b15d13f3089db8a41ef937b13a9e33a8df",
        "type": "github"
      },
      "original": {
        "owner": "NixOS",
        "ref": "nixos-unstable",
        "repo": "nixpkgs",
        "type": "github"
      }
    },
    "root": {
      "inputs": {
        "nixpkgs": "nixpkgs"
      }
    }
  },
  "root": "root",
  "version": 7
}

That’s June 30, severely outdated. Run nix flake update.

2 Likes

Thanks for your answer