Thanks for your super quick reply! I’ll give it a try. Where do I need to put it? In my configuration.nix or the files that contain programs._1password-gui.enable and spotify respectively?
Edit: The error I got during my previous attempts was just the regular notification about “unfree licenses”.
$ sudo nixos-rebuild boot --flake .#Moon-Presence
Legen Sie Ihren Finger auf den Fingerabdruckleser
building the system configuration...
error:
… while calling the 'head' builtin
at /nix/store/pfi7ix6c1vma70s9bbz94rj0555z5lwk-source/lib/attrsets.nix:922:11:
921| || pred here (elemAt values 1) (head values) then
922| head values
| ^
923| else
… while evaluating the attribute 'value'
at /nix/store/pfi7ix6c1vma70s9bbz94rj0555z5lwk-source/lib/modules.nix:807:9:
806| in warnDeprecation opt //
807| { value = builtins.addErrorContext "while evaluating the option `${showOption loc}':" value;
| ^
808| inherit (res.defsFinal') highestPrio;
(stack trace truncated; use '--show-trace' to show the full trace)
error: Package ‘1password-8.10.24’ in /nix/store/pfi7ix6c1vma70s9bbz94rj0555z5lwk-source/pkgs/applications/misc/1password-gui/default.nix:58 has an unfree license (‘unfree’), refusing to evaluate.
a) To temporarily allow unfree packages, you can use an environment variable
for a single invocation of the nix tools.
$ export NIXPKGS_ALLOW_UNFREE=1
Note: When using `nix shell`, `nix build`, `nix develop`, etc with a flake,
then pass `--impure` in order to allow use of environment variables.
b) For `nixos-rebuild` you can set
{ nixpkgs.config.allowUnfree = true; }
in configuration.nix to override this.
Alternatively you can configure a predicate to allow specific packages:
{ nixpkgs.config.allowUnfreePredicate = pkg: builtins.elem (lib.getName pkg) [
"1password"
];
}
c) For `nix-env`, `nix-build`, `nix-shell` or any other Nix command you can add
{ allowUnfree = true; }
to ~/.config/nixpkgs/config.nix.
I copy-pasted the contents of the file system-apps.nix and just edited out some of the programs that are irrelevant here. 1Password should be pulled from stable:
I think there is currently no way to allow unfree with flake in pure evaluation mode, unless you import nixpkgs { config = ... }. This is why this exists:
Purely speculative: try not passing pkgs in specialArgs and see if unfree packages under pkgs work? I am guessing that the passed pkgs here shadows the module configuration. If this works, then it solves the problem of pkgs but not pkgs-unstable though…
error: Package ‘1password-8.10.24’ in /nix/store/pfi7ix6c1vma70s9bbz94rj0555z5lwk-source/pkgs/applications/misc/1password-gui/default.nix:58 has an unfree license (‘unfree’), refusing to evaluate
That seems to be it! Thanks! Just tried to rebuild with specialArgs = { inherit desktop pkgs-unstable; }; and nixpkgs.config.allowUnfree = true; and it worked. Will investigate allowUnfreePredicate now…
Awesome, now it works as expected! Thank you both very much! I would never have found this error on my own…
Now, I edited my configuration.nix which is located in ~/nixconfig/hosts/Moon-Presence to this
{ config, lib, pkgs, pkgs-unstable, desktop, ... }:
{
/* ---- NixOS SYSTEM CONFIG ---- */
imports = [
./hardware-configuration.nix
./boot.nix
./fprintd.nix
./networking.nix
../../common/system/nix-settings.nix
../../common/system/system-maintenance.nix
../../common/system/users.nix
../../common/system/printing.nix
../../common/system/bluetooth.nix
../../common/system/sound.nix
../../common/system/locale.nix
../../common/desktops/${desktop}.nix
../../common/desktops/fonts.nix
../../common/apps/system-apps.nix
../../common/apps/firefox.nix
];
# Allow certain unfree software
nixpkgs.config.allowUnfreePredicate = pkg: builtins.elem (lib.getName pkg) [
"1password"
"steam"
"steam-original"
"steam-run"
"geogebra"
"spotify"
"libfprint-2-tod1-goodix"
];
# This value determines the NixOS release from which the default
# settings for stateful data, like file locations and database versions
# on your system were taken. It‘s perfectly fine and recommended to leave
# this value at the release version of the first install of this system.
# Before changing this value read the documentation for this option
# (e.g. man configuration.nix or on https://nixos.org/nixos/options.html).
system.stateVersion = "23.05"; # Did you read the comment?
}
and now it builds with no errors! Yay!
I’ll dig into nixpkgs-unfree (and might need help again) later. Since everything is pulled from the stable branch at the moment, I am content with what I’ve got right now. Thanks again for your help!
Wait, what’s the fix here? I noticed that some of the packages I put in allowUnfreePredicate have started requiring the version suffix, which is annoying for obvious reasons. But I’m not understanding if that’s expected or if it means I’ve introduced some issue in my config?
and that’s what caused the issue, because it overshadowed the nixpkgs.config.allowUnfreePredicate.
It should read specialArgs = { inherit desktop pkgs-unstable; }; .
Sounds like your predicate is wrong, given you would literally need to add functionality to require the version yourself? Maybe you match against .name instead of using lib.getName?