Your system configures nixpkgs with an externally created instance

Relatively new to nix. I have a working config, but was unsatisfied with the lack of modularity. I have started attempting to use snowfall-lib as an opinionated layout and I really like it, delivering exactly what I was looking for.

However, I’m getting this error and I have no idea what is going on. My web searches haven’t turned this up anywhere, so I’ve turned to y’all!

error:
Failed assertions:
- Your system configures nixpkgs with an externally created instance.
nixpkgs.config options should be passed when creating the instance instead.

Can someone point me in the right direction for what I’ve done wrong somewhere?

Thanks!

The error was introduced in treewide: use `pkgs.config` instead of `config.nixpkgs.config` by K900 · Pull Request #258447 · NixOS/nixpkgs · GitHub

Your nixos config is setting the NixOS module options nixpkgs.config and nixpkgs.pkgs, but you can’t set both of those.

3 Likes

snowfall-lib should update to latest flake-utils-plus which contains a fix for this. CC @jakehamilton.

1 Like

Thanks for the ping @K900! This is pretty good timing as I was about to upgrade flake-utils-plus anyway since another bug was fixed. Will get to that shortly.

@craiggwilson can you share your config files in a GitHub repo? That would make it a bit easier to see what you’re trying to do. Otherwise my only suggestion currently is to configure channels-config in your call to mkFlake instead of using the module option. Here’s an example from my flake: https://github.com/jakehamilton/config/blob/072632650fa85a5b1ca56c6104b80f146eca10df/flake.nix#L180

Thanks all. My repo is here, in a subdirectory for me to play around in without screwing up something that is kinda mostly working.

I’m already effectively doing what you are doing (as I’ve been reading your config files as a model). I am figuring that I mostly locked the nixpkgs repo after the PR indicated above got merged, so bad luck timing. I’ll bet I could update the lock file now that I know the problem, but if you are updating snowfall-lib shortly, I’ll probably just wait.

inputs = {
    # unstable packages are used by default
    nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
    
    # also provide stable packages if unstable are breaking
    nixpkgs-stable.url = "github:nixos/nixpkgs/nixos-23.05";

    # home manager for config files and user installs
    home-manager = {
    	url = "github:nix-community/home-manager";	
    	inputs.nixpkgs.follows = "nixpkgs";
    };

    # disko handles partitioning and applying disk configurations
    disko = {
      url = "github:nix-community/disko";
      inputs.nixpkgs.follows = "nixpkgs";
    };

    # nix-hardware helps set up machine configs
    nixos-hardware.url = "github:NixOS/nixos-hardware/master";

    # snowfall-lib provides structure to the flake
    snowfall-lib = {
      url = "github:snowfallorg/lib";
      inputs.nixpkgs.follows = "nixpkgs";
    };
  };

  outputs = inputs: 
  let 
    lib = inputs.snowfall-lib.mkLib {
      inherit inputs;
      src = ./.;

      snowfall = {
        # access through the modules will be done through hdwlinux and lib.hdwlinux
        namespace = "hdwlinux";
        meta = {
          name = "hdwlinux";
          title = "Half-Dozen Wilsons Linux";
        };
      };
    };
  in 
    lib.mkFlake {
      channels-config = {
        allowUnfree = true;
      };

      systems = {
        modules = {
          nixos = with inputs; [
            home-manager.nixosModules.home-manager
            disko.nixosModules.disko
          ];
        };
      };
    };

Thanks @jakehamilton for updating. All is good now!

1 Like

I happen to have the same issue after upgrading my state from 23.05 to 23.11.

I have already converted to use channels-config while still using 23.05.

I am also using snowfall-lib

My flake: https://github.com/TafkaMax/nix-config/blob/a00ed7b3e254d46823491b0cdc21cca5e8186f96/flake.nix

@TafkaMax have you updated your snowfall-lib input?

Aha I found it. It seems I was using the ‘dev’ branch of snowfal-lib instead of the default ‘main’.

1 Like