Unable to add nixpkgs-unstable to flake.nix

if i add nixpkgs-unstable as an input to my flake.nix config and then run
sudo nixos-rebuild switch -vvv

I return the following error:

$ cat /proc/sys/kernel/hostname
$ nix --extra-experimental-features nix-command flakes build --out-link /tmp/nixos-rebuild.Zs1IoR/nixos-rebuild /etc/nixos#nixosConfigurations."marble".config.system.build.nixos-rebuild -vvv
evaluating file '<nix/derivation-internal.nix>'
evaluating derivation 'path:/etc/nixos#nixosConfigurations."marble".config.system.build.nixos-rebuild'...
copying '/etc/nixos'...
copying '/nix/store/f69065gwl4csl9r98w68c0bnh0mym57h-source/' to the store...
evaluating file '/nix/store/f69065gwl4csl9r98w68c0bnh0mym57h-source/flake.nix'
unpacking 'github:nixos/nixpkgs/eb62e6aa39ea67e0b8018ba8ea077efe65807dc8' into the Git cache...
downloading 'https://github.com/nixos/nixpkgs/archive/eb62e6aa39ea67e0b8018ba8ea077efe65807dc8.tar.gz'...
error:
       … while updating the lock file of flake 'path:/etc/nixos?lastModified=1737074528&narHash=sha256-zUgXV30kJRT2KExoearvlKwA1FiVOdBeXmMYgp3LanE%3D'

       … while updating the flake input 'nixpkgs'

       … while fetching the input 'github:nixos/nixpkgs/nixos-unstable'

       error: adding a file to a tree builder: failed to insert entry: invalid object specified - devcontainer.json

is this an existing issue with nixpkgs-unstable?

Looks like this issue:

It’s a nix issue not a nixpkgs one.
Does it work with an older version of nix like nix 2.18?
Also, can you share your flake.nix and flake.lock?

@waffle8946:
Thanks for the help :slight_smile:

Does it work with an older version of nix like nix 2.18?

It does!

Also, can you share your flake.nix and flake.lock?

flake.nix


{
  description = "cosweb marble nix config";

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

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

    ags.url = "github:aylur/ags";

  };

  outputs = {
    self, nixpkgs, home-manager, ...

  }@inputs: {
    nixosConfigurations."marble" = inputs.nixpkgs.lib.nixosSystem rec {

      system = "x86_64-linux";

      specialArgs = {
          inherit inputs;
          inherit system;

          # Add nixpkgs-stable as an interface-scope
          # pkgs-unstable = import nixpkgs-unstable {
          #   config.allowUnfree = true;
          # };
      };

      modules = [
        ./system/general.nix
        ./system/boot.nix

        ./system/filesystem.nix
        ./system/networking.nix
        ./system/graphics.nix
        ./system/devices.nix
        ./system/sound.nix

        ./system/services.nix
        ./system/users.nix

        ./system/programs.nix

       	home-manager.nixosModules.home-manager {
         	  home-manager.useGlobalPkgs = true;
         	  home-manager.useUserPackages = true;
         	  home-manager.users.cosweb = import ./home/home.nix;
       	}

      ];
    };
  };
}

flake.lock

{
  "nodes": {
    "ags": {
      "inputs": {
        "astal": "astal",
        "nixpkgs": "nixpkgs"
      },
      "locked": {
        "lastModified": 1736677288,
        "narHash": "sha256-Vj3WOLy6o6Zf44Rwg9eLqNRQPlVoDrQ89tsef3l3990=",
        "owner": "aylur",
        "repo": "ags",
        "rev": "90db9b9fecc0f4228440d83107c6c745a35e7d77",
        "type": "github"
      },
      "original": {
        "owner": "aylur",
        "repo": "ags",
        "type": "github"
      }
    },
    "astal": {
      "inputs": {
        "nixpkgs": [
          "ags",
          "nixpkgs"
        ]
      },
      "locked": {
        "lastModified": 1735172721,
        "narHash": "sha256-rtEAwGsHSppnkR3Qg3eRJ6Xh/F84IY9CrBBLzYabalY=",
        "owner": "aylur",
        "repo": "astal",
        "rev": "6c84b64efc736e039a8a10774a4a1bf772c37aa2",
        "type": "github"
      },
      "original": {
        "owner": "aylur",
        "repo": "astal",
        "type": "github"
      }
    },
    "home-manager": {
      "inputs": {
        "nixpkgs": [
          "nixpkgs"
        ]
      },
      "locked": {
        "lastModified": 1736883540,
        "narHash": "sha256-dgPgoPUSg8cGAMqbhQRkww665sZtgzpWXxWjlyqhv94=",
        "owner": "nix-community",
        "repo": "home-manager",
        "rev": "0dfec9deb275854a56c97c356c40ef72e3a2e632",
        "type": "github"
      },
      "original": {
        "owner": "nix-community",
        "repo": "home-manager",
        "type": "github"
      }
    },
    "nixpkgs": {
      "locked": {
        "lastModified": 1734649271,
        "narHash": "sha256-4EVBRhOjMDuGtMaofAIqzJbg4Ql7Ai0PSeuVZTHjyKQ=",
        "owner": "nixos",
        "repo": "nixpkgs",
        "rev": "d70bd19e0a38ad4790d3913bf08fcbfc9eeca507",
        "type": "github"
      },
      "original": {
        "owner": "nixos",
        "ref": "nixos-unstable",
        "repo": "nixpkgs",
        "type": "github"
      }
    },
    "nixpkgs-unstable": {
      "locked": {
        "lastModified": 1737062831,
        "narHash": "sha256-Tbk1MZbtV2s5aG+iM99U8FqwxU/YNArMcWAv6clcsBc=",
        "owner": "nixos",
        "repo": "nixpkgs",
        "rev": "5df43628fdf08d642be8ba5b3625a6c70731c19c",
        "type": "github"
      },
      "original": {
        "owner": "nixos",
        "ref": "nixos-unstable",
        "repo": "nixpkgs",
        "type": "github"
      }
    },
    "nixpkgs_2": {
      "locked": {
        "lastModified": 1736916166,
        "narHash": "sha256-puPDoVKxkuNmYIGMpMQiK8bEjaACcCksolsG36gdaNQ=",
        "owner": "nixos",
        "repo": "nixpkgs",
        "rev": "e24b4c09e963677b1beea49d411cd315a024ad3a",
        "type": "github"
      },
      "original": {
        "owner": "nixos",
        "ref": "nixos-24.11",
        "repo": "nixpkgs",
        "type": "github"
      }
    },
    "root": {
      "inputs": {
        "ags": "ags",
        "home-manager": "home-manager",
        "nixpkgs": "nixpkgs_2",
        "nixpkgs-unstable": "nixpkgs-unstable"
      }
    }
  },
  "root": "root",
  "version": 7
}


So just for reference. Installing an older version of nix and running nixos-rebuild switch fixes the issue.