Couldn't allowUnfree for unstable branch

I have setup flakes in such a way that I am able to install both free and unfree packages in configuration.nix file.

Here is my nix flake:

{
  description = "A very basic flake";

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

  outputs = { self, nixpkgs, nixpkgs-unstable, ... } @ inputs : 
  let
    system = "x86_64-linux";
    pkgs = nixpkgs.legacyPackages."${system}";
    pkgs-unstable = nixpkgs-unstable.legacyPackages."${system}";

  in {
      nixosConfigurations.nixos = nixpkgs.lib.nixosSystem {
          specialArgs = {
            inherit pkgs-unstable;
          };
          modules = [
            ./configuration.nix
          ];

        };
      
      };
}

The error i am geeting is that I didn’t set allowUnfree as true for nixpkgs-unstable.
I tried addng the allowUnfree for nixpkgs-unstable but nothing wored for me.

What am i missing here?
is there any specific way I should set allowUnfree for inputs defined in flakes rather than in cinfiguration.nix?

I believe you can use:

pkgs-unstable = import nixpkgs-unstable {
  inherit system;
  config.allowUnfree = true;
};
1 Like