How can I install a single unstable package while being on stable?

So I actually managed to install an unstable app. I just added the unstable channel, updated, put it in my configuration.nix (as pkg.name, no unstable declaration etc), and then ran sudo nixos-rebuild switch

This isn’t ideal, because now I think I’m probably going to pull unstable stuff across the board?

I tried putting it as unstable in various ways. I’ll show the error first and then I’ll put my config/examples at the bottom.

 error: attempt to call something which is not a function but a set

       at /etc/nixos/configuration.nix:12:1:

           11| in
           12| {
             | ^
           13|   environment.systemPackages = with pkgs; [

I’ve tried various stuff from others and still get the same error. See comments etc.

Error, not a function but a set…

in
{ 
  #blah blah

Idk if I’m following it right, but it seems that … in {<set here, function expected>} is what’s causing the issue? I know functional stuff can be finicky, although it’s not saying that it doesn’t support sets - just that it wasn’t expecting one?

Anyways. Couple of things I tried in my config that gave me this error:

{ config, pkgs, ... }:

#{   # This requires inputs to be added in the above { }, but it is illegally calling a set ... may be missing part of the original
#  environment.systemPackages = [
#    inputs.nixpkgs-unfree-master.legacyPackages.${pkgs.system}.name
#  ];
#}


# For installing unstable packages (from unstable branch)
#let
 # unstable = import (builtins.fetchTarball https://github.com/nixos/nixpkgs/tarball/nixos-unst>
  #{ config = config.nixpkgs.config; };
#in
#{
#  environment.systemPackages = with pkgs; [  
#    # Unstable packages go here
#    unstable.name
#  ];
#}

I’ve tried some other stuff that isn’t listed here from googling around.

hi the easiest way is to add unstable as extra channel as root

nix-channel --add nixpkgs-unstable release nixpkgs-25.05pre708996.c69a9bffbecd unstable

dont forget to run

nix-channel --update

after that you can import the channel into your configuration.nix

nixpkgs.config = {
    allowUnfree = true;
    packageOverrides = pkgs: {
      unstable = import <unstable> {
        config = config.nixpkgs.config;
      };
    };
  };

and then you can just decide for every program if you want to use unstable or normal default channel

packages = with pkgs;
    [
      kitty
      unstable.vscodium
    ];
1 Like

Thanks, I think we’re getting somewhere.

When I run nixos-rebuild switch as a normal user, it seems to evaluate the configuration.nix etc fine but ultimately breaks due to not being privileged (obvs).

When I run it as with sudo nixos-rebuild switch, I get this error however?

error: file 'unstable' was not found in the Nix search path (add it using $NIX_PATH or -I)

Normal user can see unstable.package but sudo can’t lol.

did you add the unstable channel on root level light i mentioned?