Getting started with home manager - missing inputs argument/attribute

I’m exploring flakes and trying to install home-manager. I am following @ryan4yin’s excellent guide closely on his website. I am stuck at this passage here. While I have copied over most of the sample code verbatim, I made some changes and was mindful to substitute my hostname and username in the appropriate places. When I first ran the rebuild switch command, I encountered some errors, like one involving a duplicate parentheses. I fixed that. But now I am getting an error that I don’t understand. Here is the error in full:

Broken build output
$ sudo nixos-rebuild switch
[sudo] password for evangelist: 
building the system configuration...
error:
       … while calling the 'head' builtin
         at /nix/store/b8l3ndracmly9kyylawrnk32lsrjfy3j-source/lib/attrsets.nix:1574:11:
         1573|         || pred here (elemAt values 1) (head values) then
         1574|           head values
             |           ^
         1575|         else

       … while evaluating the attribute 'value'
         at /nix/store/b8l3ndracmly9kyylawrnk32lsrjfy3j-source/lib/modules.nix:816:9:
          815|     in warnDeprecation opt //
          816|       { value = addErrorContext "while evaluating the option `${showOption loc}':" value;
             |         ^
          817|         inherit (res.defsFinal') highestPrio;

       … while evaluating the option `system.build.toplevel':

       … while evaluating definitions from `/nix/store/b8l3ndracmly9kyylawrnk32lsrjfy3j-source/nixos/modules/system/activation/top-level.nix':

       … while evaluating the option `system.systemBuilderArgs':

       … while evaluating definitions from `/nix/store/b8l3ndracmly9kyylawrnk32lsrjfy3j-source/nixos/modules/system/activation/activatable-system.nix':

       … while evaluating the option `system.activationScripts.etc.text':

       … while evaluating definitions from `/nix/store/b8l3ndracmly9kyylawrnk32lsrjfy3j-source/nixos/modules/system/etc/etc-activation.nix':

       … while evaluating definitions from `/nix/store/b8l3ndracmly9kyylawrnk32lsrjfy3j-source/nixos/modules/system/etc/etc.nix':

       … while evaluating the option `environment.etc.dbus-1.source':

       … while evaluating the option `environment.systemPackages':

       … while evaluating definitions from `/nix/store/8fz1r15nggmbaflr6v3wrdkf3h10zqpp-source/configuration.nix':

       … while evaluating the module argument `inputs' in "/nix/store/8fz1r15nggmbaflr6v3wrdkf3h10zqpp-source/configuration.nix":

       (stack trace truncated; use '--show-trace' to show the full, detailed trace)

       error: attribute 'inputs' missing
       at /nix/store/b8l3ndracmly9kyylawrnk32lsrjfy3j-source/lib/modules.nix:515:28:
          514|         addErrorContext (context name)
          515|           (args.${name} or config._module.args.${name})
             |                            ^
          516|       ) (functionArgs f);

What can you people make of that? What is it refering to?

Here are the relevant files I am workin with:

/etc/nixos/configuration.nix
# 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, lib, inputs, ... }:

{
  imports =
    [ # Include the results of the hardware scan.
      ./hardware-configuration.nix
    ];

  nixpkgs.config.allowUnfree = true;

  # Bootloader
  boot.loader.systemd-boot.enable = true;
  boot.loader.efi.canTouchEfiVariables = true;

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

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

  # Enable networking
  networking.networkmanager.enable = true;

  # Set your time zone.
  time.timeZone = "America/New_York";

  # Select internationalisation properties.
  i18n.defaultLocale = "en_US.UTF-8";

  i18n.extraLocaleSettings = {
    LC_ADDRESS = "en_US.UTF-8";
    LC_IDENTIFICATION = "en_US.UTF-8";
    LC_MEASUREMENT = "en_US.UTF-8";
    LC_MONETARY = "en_US.UTF-8";
    LC_NAME = "en_US.UTF-8";
    LC_NUMERIC = "en_US.UTF-8";
    LC_PAPER = "en_US.UTF-8";
    LC_TELEPHONE = "en_US.UTF-8";
    LC_TIME = "en_US.UTF-8";
  };

  # Enable the X11 windowing system.
  services.xserver.enable = true;

  # Enable the GNOME Desktop Environment.
  services.xserver.displayManager.gdm.enable = true;
  services.xserver.desktopManager.gnome.enable = true;

  # Configure keymap in X11
  services.xserver.xkb = {
    layout = "us";
    variant = "";
  };

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

  # Enable sound with pipewire.
  hardware.pulseaudio.enable = false;
  security.rtkit.enable = true;
  services.pipewire = {
    enable = true;
    alsa.enable = true;
    alsa.support32Bit = true;
    pulse.enable = true;
    # If you want to use JACK applications, uncomment this
    #jack.enable = true;

    # use the example session manager (no others are packaged yet so this is enabled by default,
    # no need to redefine it in your config for now)
    #media-session.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.evangelist = {
    isNormalUser = true;
    description = "Paul";
    extraGroups = [ "networkmanager" "wheel" ];
    packages = with pkgs; [
    #  thunderbird
    ];
  };
  programs.zsh.enable = true;
  users.defaultUserShell = pkgs.zsh;

  # Install firefox.
  programs.firefox.enable = true;
  
  programs.sway.enable = true;
  programs.waybar.enable = true;  
  
  nix.settings.experimental-features = [ "nix-command" "flakes" ];
   
  # 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.
  neovim
  wl-clipboard
  # wayclip
  # waypaste # Unnecessary, included in wayclip
  xclip
  neovim-gtk
  wget
  google-chrome
  gotop
  foot
  radeontop
  git
  nerdfonts
  gnome-terminal
  # locate
  python3
  curl
  vscode
  fastfetch
  signal-desktop
  openssh
  gedit
  # alacritty
  starship
  element-desktop
  gotop 
  irssi 
  sway
  oh-my-posh
  libgcc
  libgccjit
  binutils
  musl
  gcc
  btop

  #inputs.helix.packages."${pkgs.system}".helix # in flake
  inputs.helix.packages."${pkgs.system}".helix


];

  # 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 = "24.11"; # Did you read the comment?

}
/etc/nixos/flake.nix
{
  description = "A simple NixOS flake";

  inputs = {
    # NixOS official package source, using the nixos-24.11 branch here
    nixpkgs.url = "github:NixOS/nixpkgs/nixos-24.11";
  
    # helix editor, use the master branch
    helix.url = "github:helix-editor/helix/master";
    
    home-manager = {
      url = "github:nix-community/home-manager/release-24.11";
      # The `follows` keyword in inputs is used for inheritance.
      # Here, `inputs.nixpkgs` of home-manager is kept consistent with
      # the `inputs.nixpkgs` of the current flake,
      # to avoid problems caused by different versions of nixpkgs.
      inputs.nixpkgs.follows = "nixpkgs";
     };

  };
  outputs = inputs@{ nixpkgs, home-manager, ... }: {
    nixosConfigurations = {
      # TODO please change the hostname to your own
      nixoslaptop = nixpkgs.lib.nixosSystem {
        system = "x86_64-linux";
        modules = [
          ./configuration.nix

          # make home-manager as a module of nixos
          # so that home-manager configuration will be deployed automatically when executing `nixos-rebuild switch`
          home-manager.nixosModules.home-manager
          {
            home-manager.useGlobalPkgs = true;
            home-manager.useUserPackages = true;

            # TODO replace ryan with your own username
            home-manager.users.evangelist = import ./home.nix;

            # Optionally, use home-manager.extraSpecialArgs to pass arguments to home.nix
          }
        ];
      };
    };
  };
}
/etc/nixos/home.nix
{ config, pkgs, ... }:

{
  # TODO please change the username & home directory to your own
  home.username = "evangelist";
  home.homeDirectory = "/home/evangelist";

  # link the configuration file in current directory to the specified location in home directory
  # home.file.".config/i3/wallpaper.jpg".source = ./wallpaper.jpg;

  # link all files in `./scripts` to `~/.config/i3/scripts`
  # home.file.".config/i3/scripts" = {
  #   source = ./scripts;
  #   recursive = true;   # link recursively
  #   executable = true;  # make all files executable
  # };

  # encode the file content in nix configuration file directly
  # home.file.".xxx".text = ''
  #     xxx
  # '';

  # set cursor size and dpi for 4k monitor
  xresources.properties = {
    "Xcursor.size" = 16;
    "Xft.dpi" = 172;
  };

  # Packages that should be installed to the user profile.
  home.packages = with pkgs; [
    # here is some command line tools I use frequently
    # feel free to add your own or remove some of them

    neofetch
    nnn # terminal file manager

    # archives
    zip
    xz
    unzip
    p7zip

    # utils
    ripgrep # recursively searches directories for a regex pattern
    jq # A lightweight and flexible command-line JSON processor
    yq-go # yaml processor https://github.com/mikefarah/yq
    eza # A modern replacement for ‘ls’
    fzf # A command-line fuzzy finder

    # networking tools
    mtr # A network diagnostic tool
    iperf3
    dnsutils  # `dig` + `nslookup`
    ldns # replacement of `dig`, it provide the command `drill`
    aria2 # A lightweight multi-protocol & multi-source command-line download utility
    socat # replacement of openbsd-netcat
    nmap # A utility for network discovery and security auditing
    ipcalc  # it is a calculator for the IPv4/v6 addresses

    # misc
    cowsay
    file
    which
    tree
    gnused
    gnutar
    gawk
    zstd
    gnupg

    # nix related
    #
    # it provides the command `nom` works just like `nix`
    # with more details log output
    nix-output-monitor

    # productivity
    hugo # static site generator
    glow # markdown previewer in terminal

    btop  # replacement of htop/nmon
    iotop # io monitoring
    iftop # network monitoring

    # system call monitoring
    strace # system call monitoring
    ltrace # library call monitoring
    lsof # list open files

    # system tools
    sysstat
    lm_sensors # for `sensors` command
    ethtool
    pciutils # lspci
    usbutils # lsusb
  ];

  # basic configuration of git, please change to your own
  programs.git = {
    enable = true;
    userName = "Bob Wilcock";
    userEmail = "drone4four@gmail.com";
  };

  # starship - an customizable prompt for any shell
  # programs.starship = {
  #  enable = true;
    # custom settings
  #  settings = {
  #    add_newline = false;
  #    aws.disabled = true;
  #    gcloud.disabled = true;
  #    line_break.disabled = true;
  #  };
  # };

  # alacritty - a cross-platform, GPU-accelerated terminal emulator
  programs.alacritty = {
    enable = true;
    # custom settings
    settings = {
      env.TERM = "xterm-256color";
      font = {
        size = 12;
        draw_bold_text_with_bright_colors = true;
      };
      scrolling.multiplier = 5;
      selection.save_to_clipboard = true;
    };
  };

  #programs.bash = {
  #  enable = true;
  #  enableCompletion = true;
  #  # TODO add your custom bashrc here
  #  bashrcExtra = ''
  #    export PATH="$PATH:$HOME/bin:$HOME/.local/bin:$HOME/go/bin"
  #  '';
  #
    # set some aliases, feel free to add more or remove some
  #  shellAliases = {
  #    k = "kubectl";
  #    urldecode = "python3 -c 'import sys, urllib.parse as ul; print(ul.unquote_plus(sys.stdin.read()))'";
  #    urlencode = "python3 -c 'import sys, urllib.parse as ul; print(ul.quote_plus(sys.stdin.read()))'";
  #  };
  # };

  # This value determines the home Manager release that your
  # configuration is compatible with. This helps avoid breakage
  # when a new home Manager release introduces backwards
  # incompatible changes.
  #
  # You can update home Manager without changing this value. See
  # the home Manager release notes for a list of state version
  # changes in each release.
  home.stateVersion = "24.11";

  # Let home Manager install and manage itself.
  programs.home-manager.enable = true;
}

edit: grammar

You need to pass inputs to nixosSystem with specialArgs:

nixoslaptop = nixpkgs.lib.nixosSystem {
  ...
  specialArgs = {inherit inputs;};
}

Also, you don’t need to pass system to nixosSystem. Your hardware-configuration.nix should have hostPlatform.

1 Like

Thank you. This resolved the error. But as with programming in general, sometimes when we solve one problem, two more are created. When I updated my flake.nix with your suggested change, I am getting a new error suggesting that home-manager is exiting without completing the switch run.

Here is my new error message and basic flake:

Home-manager error
$ sudo nixos-rebuild switch
building the system configuration...
stopping the following units: accounts-daemon.service
activating the configuration...
setting up /etc...
reloading user units for evangelist...
restarting sysinit-reactivation.target
reloading the following units: dbus.service
restarting the following units: polkit.service
starting the following units: accounts-daemon.service
warning: the following units failed: home-manager-evangelist.service
× home-manager-evangelist.service - Home Manager environment for evangelist
     Loaded: loaded (/etc/systemd/system/home-manager-evangelist.service; enabled; preset: ignored)
     Active: failed (Result: exit-code) since Mon 2024-12-30 03:29:56 EST; 317ms ago
 Invocation: fd22124606364ce4af607bd0d27a8223
    Process: 182673 ExecStart=/nix/store/m91h9kmjw78swvldfb9px8qnv1nb23ax-hm-setup-env /nix/store/hlpkiypbd52kyvvkrw20d13p96n7039i-home-manager-generation (code=exited, status=1/FAILURE)
   Main PID: 182673 (code=exited, status=1/FAILURE)
         IP: 0B in, 0B out
         IO: 240K read, 0B written
   Mem peak: 6.3M
        CPU: 93ms

Dec 30 03:29:56 nixoslaptop hm-activate-evangelist[182801]: Please do one of the following:
Dec 30 03:29:56 nixoslaptop hm-activate-evangelist[182801]: - Move or remove the above files and try again.
Dec 30 03:29:56 nixoslaptop hm-activate-evangelist[182801]: - In standalone mode, use 'home-manager switch -b backup' to back up
Dec 30 03:29:56 nixoslaptop hm-activate-evangelist[182801]:   files automatically.
Dec 30 03:29:56 nixoslaptop hm-activate-evangelist[182801]: - When used as a NixOS or nix-darwin module, set
Dec 30 03:29:56 nixoslaptop hm-activate-evangelist[182801]:     'home-manager.backupFileExtension'
Dec 30 03:29:56 nixoslaptop hm-activate-evangelist[182801]:   to, for example, 'backup' and rebuild.
Dec 30 03:29:56 nixoslaptop systemd[1]: home-manager-evangelist.service: Main process exited, code=exited, status=1/FAILURE
Dec 30 03:29:56 nixoslaptop systemd[1]: home-manager-evangelist.service: Failed with result 'exit-code'.
Dec 30 03:29:56 nixoslaptop systemd[1]: Failed to start Home Manager environment for evangelist.
warning: error(s) occurred while switching to the new configuration
$
Latest (updated) /etc/nixos/flake.nix
{
  description = "A simple NixOS flake";

  inputs = {
    # NixOS official package source, using the nixos-24.11 branch here
    nixpkgs.url = "github:NixOS/nixpkgs/nixos-24.11";
  
    # helix editor, use the master branch
    helix.url = "github:helix-editor/helix/master";
    
    home-manager = {
      url = "github:nix-community/home-manager/release-24.11";
      # The `follows` keyword in inputs is used for inheritance.
      # Here, `inputs.nixpkgs` of home-manager is kept consistent with
      # the `inputs.nixpkgs` of the current flake,
      # to avoid problems caused by different versions of nixpkgs.
      inputs.nixpkgs.follows = "nixpkgs";
     };

  };
  outputs = inputs@{ nixpkgs, home-manager, ... }: {
    nixosConfigurations = {
      # TODO please change the hostname to your own
      nixoslaptop = nixpkgs.lib.nixosSystem {
        system = "x86_64-linux";
        modules = [
          ./configuration.nix

          # make home-manager as a module of nixos
          # so that home-manager configuration will be deployed automatically when executing `nixos-rebuild switch`
          home-manager.nixosModules.home-manager
          {
            home-manager.useGlobalPkgs = true;
            home-manager.useUserPackages = true;

            # TODO replace ryan with your own username
            home-manager.users.evangelist = import ./home.nix;

            # Optionally, use home-manager.extraSpecialArgs to pass arguments to home.nix
          }
        ];
      
      specialArgs = {inherit inputs;};


      };
    };
  };
}

There are one or more files that home-manager doesn’t want to override. It’s asking you to remove them or back them up. I can’t see the list of files in the error message. Try journalctl to get the logs.

You could also do what the error message suggests when using home-manager as a nixos module which would automatically backup the files. I don’t do that myself because I want to know which files home-manager wants to change. This is part of the risk of using home-manager the project warns about (however personally I haven’t seen this error in a long time).

You mentioned backups. It is mentioned in the traceback as well. I did append .bak to the end of my original flake.nix before experimenting with some new changes. Git really is the tool I need for this but the guide I am following hasn’t got to managing nix configuration files with GIt and GitHub yet.

To test if my misnamed backup flake was the source of the issue, I created a new directory named: backups and moved that backup flake in there. I tried to rebuild and switch, but the same traceback appears.

Here is my /etc/nixos/ now:

$ cd /etc/nixos/backups 
$ ls
flake.nix.bak2k24Dec30
$ cd ..
$ ls
backups flake.lock  hardware-configuration.nix
configuration.nix  flake.nix   home.nix
$ 

I generated a text file to collect the output of journalctl. It’s hundreds of thousands of characters too large. The forum won’t let me post all of it. Pastebin says the max text file size can sum to 512 KB. It’s ~7.5 MBs. Any suggestions on how I could better communicate the output of journalctl?

You need to remove/backup one or more dotfiles (files in your home directory). Not your nix config.

journalctl -xeu home-manager-evangelist.service should give you the home-manager logs. Have a look for the files home-manager wants to backup.

Be careful with home-manager. It doesn’t support rollbacks. If your home directory gets messed up you’ll have to fix it yourself: words of warning

1 Like

Noted with thanks.

Ryan does warn that Flakes are experimental and users always run the risk of wrecking their system but Ryan doesn’t make it quite as clear as you have. The fact that Flakes does not support roll backs is pretty significant.

Having said that, I decided to back out of my current effort to learn how to use Flakes. I was originally going to experiment with just Hyprland and it’s ecosystem with Flakes and keep the rest of the system on the stable or unstable channel. I will shelve these plans for now and return to Ryan’s guide at some point in the future when I have learned more about nix.

Thank you @dtannock.

There’s been some confusion here. Flakes do support rollbacks. The home-manager tool (which has nothing to do with flakes) does not support rollbacks. Please, continue your learning journey with flakes - I believe it’s worth the effort.

Home Manager is a tool that leverages the nix ecosystem to assist with managing a user environment (i.e. files/programs in your /home/[user] directory). It’s actually not needed at all to use NixOS, however it’s very popular and you’ll likely come across it on your journey.

Hyprland’s Home Manager module is optional, but (I think) the easiest way to configure it in a user’s environment. Hyprland’s documentation is great: Hyprland on NixOS – Hyprland Wiki

Can I suggest you continue learning about the nix ecosystem (including flakes) before jumping into Home Manager (that’s also suggested by the Home Manager project)? I like Vimjoyer’s video about the ecosystem: https://youtu.be/X_jMqi-0SrM?si=vu0_nk_Pu3EwzxL4.

2 Likes