Home Manager does not allowUnfree

I have a few apps that are unfree. I can install them at the system level (environment.systemPackages =) but not in home manager (home.packages =). The error being refusing to evaluate.

I have tried to find the answer on the HM github, official doc, wiki and this forum without a working answer.

My current attempt is:

nixpkgs.config = {
allowUnfree = true;
allowUnfreePredicate = (_: true); # And some forgotten variations on this!
};
The allowUnfreePredicate being suggestions I have read as a solution (I think gleaned from others configs).

I have not tried the error message option:

     { nixpkgs.config.allowUnfreePredicate = pkg: builtins.elem (lib.getName pkg) [
         "obsidian"
       ];
     }

because it seems very clunky doing each app (and also this seems a system approach, not HM). Also it seems equivalent to my current code.

For more background, HM is installed as a module. I then went from a standard config to a flake. I haven’t configured HM much at all. Primarily at the moment I use it to install user-specific (as opposed to system-wide) apps.

Can anyone point me to documentation or the answer?

Can you share more of your configuration? Are you using home-manager.useGlobalPkgs?

The allowUnfreePredicate fix is only relevant for standalone flake installs. When hm is used as a module it shouldn’t be necessary.

Sure. Thanks for taking the time to look
Firstly flake.nix

{
inputs = {
nixpkgs.url = “nixpkgs/nixos-22.11”;

home-manager = {
  url = "github:nix-community/home-manager";
  inputs.nixpkgs.follows = "nixpkgs";
};

};

outputs = { self, nixpkgs, home-manager }@inputs: {
pkgs = import nixpkgs { config = { allowUnfree = true; }; };

# replace nixosConfigurations.Damage with nixosConfigurations.hostname

nixosConfigurations.Damage = nixpkgs.lib.nixosSystem {
  system = "x86_64-linux";
  specialArgs = {inherit inputs;};
  modules = [
    ./configuration.nix
    home-manager.nixosModules.home-manager
  ];
};

};
}

configuration.nix

{ inputs, lib, config, pkgs, … }:

{
imports =
[ # Include the results of the hardware scan and other config files.
./apps.nix
./boot.nix
./desktop-environment.nix
./filesystems.nix
./hardware-configuration.nix
./machine-specific.nix
./printers.nix

./themes.nix

  ./users.nix
];

environment.defaultPackages = [ pkgs.nano ]; #Clean slate on installed packages

nix = {
settings = {
auto-optimise-store = true;
experimental-features = [ “nix-command” “flakes” ];
};
gc = {
automatic = true;
dates = “weekly”;
options = “–delete-older-than 45d”;
};
};

system.autoUpgrade = {
enable = true;
channel = nixos-22.11 release nixos-22.11.4773.ea4c80b39be4;
};

nixpkgs.config = {
allowUnfree = true;
allowUnfreePredicate = (_: true);
};

virtualisation = {
waydroid.enable = true;
lxd.enable = true;
};

Set your time zone.

time.timeZone = “America/New_York”;

the version of this flake used to build the system

nix.registry.activeconfig.flake = self;

environment.etc.“nix/path/activeconfig”.source = self;

Copy the NixOS configuration file and link it from the resulting system

(/run/current-system/configuration.nix). This is useful in case you

accidentally delete configuration.nix.

system.copySystemConfiguration = true;

system.stateVersion = “22.11”; # Did you read the comment?
}

And users.nix - where user-specific HM config lies

{ config, pkgs, … }:

{
users.users.john = {
isNormalUser = true;
description = “Dr John”;
home = “/home/john”;
extraGroups = [ “wheel” “networkmanager” “video” ]; # Enable ‘sudo’ and Networking.
};

home-manager.users.john = { pkgs, … }: {
programs = {
fish.enable = true;
};

home = {
  stateVersion = "22.11";
  homeDirectory = "/home/john";

  packages = with pkgs; [
    ace-of-penguins ' And lots of other apps
  ];
};

};
}

All other config files don’t address HM aspects (I believe)

And apologies for the formatting weirdness - didn’t see that before posting!

Ok, one unrelated note: You need to match your home-manager branch to your nixpkgs branch. If you use nixpkgs’ nixos-unstable, you can use home-manager’s master, but if you use nixpkgs’ nixos-22.11 you need to use home-manager’s release-22.11. You can add the branch as a third component in github urls, like github:nix-community/home-manager/release-22.11. This isn’t the cause of your problem, however.

No worries about the formatting, but for future reference, it’s probably a better idea to blockquote each file in full.

I don’t see you setting the home-manager.useGlobalPkgs option, so home-manager is instantiating its own version of nixpkgs, with its own configuration. You can configure it with identical options to the ones nixos uses, but placed inside the user’s home-manager config area, or you can set useGlobalPkgs in your nixos configuration, which will cause home-manager to use the pkgs from your nixos setup, along with the unfree settings and overlays and such that go with it.

2 Likes

Also, this line in your flake.nix definitely shouldn’t be there… it surely isn’t doing what you think it’s doing.

Thanks @tejing !
I have migrated from noob to numpty…I had useGlobalPkgs originally, and somehow managed to drop it when converting to flakes. I have been trying to solve the wrong issue all this time :blush:

I have fixed the HM branch (I’m sticking to 22.11 rather than unstable to minimise variables while I learn more about Nixos) and removed pkgs = import nixpkgs { config = { allowUnfree = true; }; };

2 Likes

Does anyone know how to handle when useGlobalPkgs appears to be missing? I’m on 23.11 and doing

  programs.home-manager = {
      enable = true;
      useGlobalPkgs = true;
  };

just tells me

       error: The option `programs.home-manager.useGlobalPkgs' does not exist. 

home-manager.useGlobalPkgs is a nixos option, available when using home-manager as a nixos module, not a home-manager option, and not under programs.

1 Like

Can you please format your message a little bit? It’s totally unreadable on mobile.

A well explained problem is more likely to get replies.

Thanks!

That message is from more than a year ago. I doubt they’re still looking for replies. Someone just resurrected the thread.

1 Like

Thanks! Helping me unfog my understanding of nix slowly but surely.

OT: It’s a bit ironic, that this OS that “defines the entire system in a single file” has me stumped with all it’s flake.nix, home.nix, configuration.nix, shell.nix etc. All have their own scopes and conventions, and all the actual nix code depends 100% on the context, which makes it really hard to find my way in.

I really appreciate you taking the time to respond to my silly beginner question with the straight-to-the-point