Building home-manager configuration fails on nixos-render-docs

Hi!
I have two laptops: one is running NixOS, and the other is not. My Nix configuration is stored as a flake, the sources are available here: ­­­ / nix · GitLab
I was following some of these examples when creating it, I think: GitHub - Misterio77/nix-starter-configs: Simple and documented config templates to help you get started with NixOS + home-manager + flakes. All the boilerplate you need!

In the root directory, I have two scripts:

  • nix.sh for provisioning the entire NixOS configuration
  • home.sh for provisioning only the home-manager part to the non-NixOS system.

However, running the latter results in this error:

error: builder for '/nix/store/2vmw6rx4b0dgamnrl4rbkrm77hm17nqv-home-configuration-reference-manpage.drv' failed with exit code 2;
       last 6 log lines:
       > usage: nixos-render-docs
       >        [-h]
       >        [-j JOBS]
       >        {options,manual}
       >        ...
       > nixos-render-docs: error: unrecognized arguments: --header --footer /nix/store/d9iz5a8blpd0zv1rld9y7wqz1x1qkysh-options.json/share/doc/nixos/options.json /nix/store/ni1jfjwp0pbwi8ypj9z9cmsdyk6bf1my-home-configuration-reference-manpage/share/man/man5/home-configuration.nix.5
       For full logs, run 'nix-store -l /nix/store/2vmw6rx4b0dgamnrl4rbkrm77hm17nqv-home-configuration-reference-manpage.drv'.
error: 1 dependencies of derivation '/nix/store/5bvknd70hxm0a37s1bl98z5kxzh68akr-home-manager-path.drv' failed to build
error: 1 dependencies of derivation '/nix/store/ymmifidjmbjmls20cy1s29m3hra33zw1-home-manager-generation.drv' failed to build

I’ve switched from unstable channels to stable ones, but the issues persist. I’m out of ideas on how to resolve it.

Any help is greatly appreciated :pray:

i’m a bit confused, why do you need 2 scripts? (nix.sh, home.sh)?
You use home-manager’s nixos module in configuration, so your home-manager is built as part of nixos configuration when you run nixos-rebuild

I’ve never tried running home-manager command in system where home-manager is configured as nixos module, so I’ve no idea if it’s even supposed to work this way.

Or do you run home.sh on non nixos system? then what system is it?

Yes, that’s the idea: nix.sh for NixOS, home.sh for non-NixOS (where nixos-rebuild is not available ofc). Sorry, if it wasn’t clear from my original message.

It’s Arch at the moment, but I’m also planning to run it on Android in termux (or nix-on-droid) at some point, and maybe Ubuntu.

one thing is unclear to me here: you call home-manager flake by name, so it is in your flake registry already, but where does that registry entry point?
I’ve seen a bunch of problems when versions of home-manager and nixpkgs are not matching, so I would first try to check that.
My guess would be that flake in registry is now pointing to a different version of home-manager than your flake. I’m not sure how to ensure you call exactly same version of home-manager from your flake.nix (except for manually typing the correct commit), but when I need something like that - I usually just promote corresponding flake output inside my flake.

So doing something like
packages.${system}.home-manager = home-manager.packages.${system}.home-manager
then you can call
nix run .#home-manager ....
instead of
nix run home-manager
and you are guaranteed that everything you call is from the same exact home-manager version.

Again, this is just something that i’d look at first, and I don’t know if that is the root of your problem

2 Likes

I’m using shebang shenanigans from here to dynamically create a nix-shell environment when the script is called:

#!/usr/bin/env nix-shell
#! nix-shell -i bash --pure
#! nix-shell -p nix git cacert hostname
#! nix-shell -I nixpkgs=https://github.com/NixOS/nixpkgs/archive/refs/tags/23.11.tar.gz
…

So it should be using 23.11 registry snapshot, if I understood correctly what you meant.
The idea was to make bootstrapping on a new system as easy as installing nix and running the script.

yes, but i’m not sure that affects flake registry at all, and even if it did - there’s no home-manager entry set in there

1 Like

This error could be because of a mismatch between nixpkgs and home-manager versions. Try the following:

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

but this is already in the flake, you can see it here: flake.nix · main · bemyak / nix · GitLab

In the flake, the version is pinned to 23.11:

    nixpkgs.url = "github:nixos/nixpkgs/nixos-23.11";

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

This is fine if OP is trying to build for 23.11, but I found a few options in the configs that are for the unstable branch (so there is a mismatch already).

Also, wouldn’t home-manager follow the nixpkgs version anyways? Why would it be necessary to specify the branch?

Thank you for your replies!

I’ve tried adding this, but the error is the same, unfortunately.

With this I’m getting:

trace: warning: You are using

  Home Manager version 24.05 and
  Nixpkgs version 23.11.

Using mismatched versions is likely to cause errors and unexpected
behavior. It is therefore highly recommended to use a release of Home
Manager that corresponds with your chosen release of Nixpkgs.

:thinking:

If you’re targeting 23.11, how does the build evaluate when you’re using unstable options?

# nixos/gui.nix
-   libinput.enable = true;           # unstable
+   xserver.libinput.enable = true;   # 23.11
    ...
-   displayManager = {                # unstable
+   xserver.displayManager = {        # 23.11
# home/gui/_mod.nix
-   with pkgs.kdePackages;  [         # unstable
+   with pkgs.libsForQt5;  [          # 23.11

Also, does disabling the manpages manual make the build pass?

manual.manpages.enable = false;
1 Like

That was it, thank you very-very much!

1 Like

I think this is more of a workaround, the real solution will probably be this, assuming you’re using a mac:

No, I’m on Arch, so probably that’s a different issue :thinking:

1 Like

Ah, good thing it works, then :person_shrugging:

1 Like

After some more poking around, the issue was resolved simply by running nix-channel --update.

What I don’t understand is why it was required to update channels? I thought flake would download the correct snapshot from GitHub automatically :thinking:

1 Like

which channels do you have there? just nixpkgs, or home-manager too?
from the glance of it - it seems that nixpkgs channel should only affect 3 top shebang lines…

There was only nixpkgs-unstable, which I’ve now removed in favour of NIX_PATH right in the shell scripts to remove any confusion :slight_smile:

Yes, I was expecting that #! nix-shell -I nixpkgs=… will only affect the shell dependencies, but home-manager would use inputs.nixpkgs.url from the flake definition, not some channel :thinking: