In your configuration.nix for nix-darwin or NixOS you can do this to allow unfree software:
{
config,
pkgs,
lib,
...
}:
{
nixpkgs.config.allowUnfreePredicate =
pkg:
builtins.elem (lib.getName pkg) [
"steam"
"steam-original"
"steam-unwrapped"
"steam-run"
"steamcmd"
];
}
But what about in a shell.nix used for an individual project?
You will need to use lib.getName to define the list of packages to allow. Since that requires an instance of nixpkgs, instanciate one just to use that function from the lib.
Store the predicate in an attrset, and instanciate a nixpkgs with the attrset as its configuration. Use that instance as usual:
{
pkgs ? import <nixpkgs> { },
}:
let
config = {
allowUnfreePredicate =
pkg:
builtins.elem (pkgs.lib.getName pkg) [
"packer"
"tart"
];
};
pkgs = import <nixpkgs> { inherit config; };
in
pkgs.mkShellNoCC {
packages = with pkgs; [
packer
tart
];
}