Use home-manager as a NixOS module produces error

Hi, sorry for the bad title I didn’t know how to describe my problem in one sentence:

I’m new to NixOS and try to use home-manager as a module by following this:
https://nixos.wiki/wiki/Home_Manager

assigning home-mananager = builtins… and import … lets me build it but when I add in the
" home-manager.users.my_username = { … }" I can’t build anymore because I get the error:

error: value is a set while a Boolean was expected

       at /nix/store/6jnjqzbjp65hyrf48wyv7mff57wdl6jv-source/nixos/default.nix:24:37:

           23|           # fontconfig by default.
           24|           fonts.fontconfig.enable = lib.mkDefault cfg.useUserPackages
             |                                     ^
           25|             && config.fonts.fontconfig.enable;

So lib.mkDefault cfg.useUserPackages returnes a set instead of a bool ? the trace is super long and unhelpful does anybody have an idea what could be wrong ?

my configuration.nix :
it builds as long as the “custom stuff” is commented out…

# Edit this configuration file to define what should be installed on
# your system.  Help is available in the configuration.nix(5) man page
# and in the NixOS manual (accessible by running ‘nixos-help’).

{ config, pkgs, ... }:
let
  home-manager = builtins.fetchTarball "https://github.com/nix-community/home-manager/archive/master.tar.gz";
in
{
  imports =
    [ # Include the results of the hardware scan.
      ./hardware-configuration.nix
      (import "${home-manager}/nixos")
    ];


  # Use the systemd-boot EFI boot loader.
  boot.loader.systemd-boot.enable = true;
  boot.loader.efi.canTouchEfiVariables = true;

  networking.hostName = "nixos"; # Define your hostname.
  networking.wireless.enable = true;  # Enables wireless support via wpa_supplicant.

  # Set your time zone.
  time.timeZone = "Europe/Berlin";

  # The global useDHCP flag is deprecated, therefore explicitly set to false here.
  # Per-interface useDHCP will be mandatory in the future, so this generated config
  # replicates the default behaviour.
  networking.useDHCP = false;
  networking.interfaces.wlp2s0.useDHCP = true;

  # Configure network proxy if necessary
  # networking.proxy.default = "http://user:password@proxy:port/";
  # networking.proxy.noProxy = "127.0.0.1,localhost,internal.domain";

  # Select internationalisation properties.
  i18n.defaultLocale = "en_US.UTF-8";
  console = {
    font = "Lat2-Terminus16";
    keyMap = "us";
  };

  fonts.fonts = with pkgs; [
    (nerdfonts.override { fonts = [ "UbuntuMono" "JetBrainsMono" "Mononoki" ]; })
  ];

  # Enable the X11 windowing system.
  services = {
    xserver = {
      enable = true;
      #desktopManager.plasma5.enable = true;
      displayManager.lightdm.enable = false;
      displayManager.startx.enable = true;
      windowManager = { 
        xmonad = {
          enable = true;
          #enableContribAndExtras = true;
          #extraPackages = hpkgs: [
          #  hpkgs.xmobar
          #  hpkgs.xmonad-screenshot
          #];
        };
      };
    };
  };

  

  # Configure keymap in X11
  services.xserver.layout = "de";
  # services.xserver.xkbOptions = "eurosign:e";

  # Enable CUPS to print documents.
  # services.printing.enable = true;

  # Enable sound.
  sound.enable = true;
  hardware.pulseaudio.enable = true;

  # Enable touchpad support (enabled default in most desktopManager).
  services.xserver.libinput.enable = true;

  # Define a user account. Don't forget to set a password with ‘passwd’.
  users.users.nicola = {
    isNormalUser = true;
    extraGroups = [ "wheel" "audio" "sound" ]; # Enable ‘sudo’ for the user.
    initialPassword = "password";
  };

  # List packages installed in system profile. To search, run:
  # $ nix search wget
  environment.systemPackages = with pkgs; [
    vim # Do not forget to add an editor to edit configuration.nix! The Nano editor is also installed by default.
    wget
    curl
    firefox
    brave
    git
    xterm
    dmenu
    feh
    #dev stuff 
    alacritty
  ];
  nixpkgs.config.allowUnfree = true;

  # Some programs need SUID wrappers, can be configured further or are
  # started in user sessions.
  # programs.mtr.enable = true;
  #   programs.gnupg.agent = {
  #     enable = true;
  #     enableSSHSupport = true;
  #  };

  # List services that you want to enable:

  # Enable the OpenSSH daemon.
  # services.openssh.enable = true;

  # Open ports in the firewall.
  # networking.firewall.allowedTCPPorts = [ ... ];
  # networking.firewall.allowedUDPPorts = [ ... ];
  # Or disable the firewall altogether.
  # networking.firewall.enable = false;  
  # 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 = "21.11"; # Did you read the comment?

  #custom stuff begin
  #home manager
  home-manager.users.nicola = 
  {
    home.packages = with pkgs; [
      vim # Do not forget to add an editor to edit configuration.nix! The Nano editor is also installed
      by default.
      wget
      curl
      firefox
      brave
      git
      xterm
      dmenu
      feh
      #dev stuff
      alacritty
     ];
    #programs.neovim = customNeoVim pkgs;
  };
#custom stuff end
}

Ran into the same issue, it’s a bug that got committed earlier but the good news is there is a fix ready to go: nixos: fix fontconfig mkDefault call by andresilva · Pull Request #3021 · nix-community/home-manager · GitHub.

You can check out an older version and you should be fine or wair for the fix to get merged.

1 Like

thx so much, ill let you know if it works :grinning:

perfect, just needed to change

home-manager = builtins.fetchTarball "https://github.com/nix-community/home-manager/archive/master.tar.gz";

to

home-manager = builtins.fetchTarball "https://github.com/nix-community/home-manager/archive/release-22.05.tar.gz";

Glad that worked for you.

The fix got merged, I just tested the latest version and it worked for me so you can switch back safely if you’d like.

With home manager it’s best to line up your versions with whichever channel of nixpkgs you’re following, since the reasese was just a short time ago 22.05 will work with nixos-unstable, and nixos-22.05, but they may diverge at some point.