Error when trying to setup home-manager

Hello, all

I am trying to get home-manager running on NixOS. My configuration.nix contains this for the home-manager section:

{ config, pkgs, lib, ... }:

let
  home-manager = import (builtins.fetchTarball {
    url="https://github.com/nix-community/home-manager/archive/release-25.05.tar.gz";
    sha256="sha256:12246mk1xf1bmak1n36yfnr4b0vpcwlp6q66dgvz8ip8p27pfcw2";
  });
in
{
  imports =
    [ # Include the results of the hardware scan.
      ./hardware-configuration.nix
      (import "${home-manager}/nixos")
    ];
...

And I have this inside of /etc/nixos/home.nix:

{ config, pkgs, ... }:

{
    home.username = "steve";
    home.homeDirectory = "/home/steve";
    home.stateVersion = "25.05";

    programs.bash = {
        enable = true;
        shellAliases = {
            btw = "echo I use nixos btw";
          };
      };
  }

When I try to run nixos-rebuild switch, I get:

...
       … while calling the 'elemAt' builtin
         at /nix/store/syvnmj3hhckkbncm94kfkbl76qsdqqj3-source/lib/lists.nix:345:43:
          344|   */
          345|   imap1 = f: list: genList (n: f (n + 1) (elemAt list n)) (length list);
             |                                           ^
          346|

       … while calling the 'import' builtin
         at /nix/store/qc99izk2blf297yr75pkxmdxcjrpggmx-source/configuration.nix:17:8:
           16|       ./hardware-configuration.nix
           17|       (import "${home-manager}/nixos")
             |        ^
           18|     ];

       … while realising the context of a path

       … while evaluating a path segment
         at /nix/store/qc99izk2blf297yr75pkxmdxcjrpggmx-source/configuration.nix:17:16:
           16|       ./hardware-configuration.nix
           17|       (import "${home-manager}/nixos")
             |                ^
           18|     ];

       error: cannot coerce a function to a string: «lambda @ /nix/store/j9vi4cb7v9g8bsvwxz2v26gxhypr1isr-source/default.nix:1:1»
-  home-manager = import (builtins.fetchTarball {
+  home-manager = builtins.fetchTarball {
     url="https://github.com/nix-community/home-manager/archive/release-25.05.tar.gz";
     sha256="sha256:12246mk1xf1bmak1n36yfnr4b0vpcwlp6q66dgvz8ip8p27pfcw2";
-  });
+  };

If I understand correctly.

Though you probably do not want to provide a hash, when using a “mutable” URL…

Your 2 changes made it work for me. Commenting out the sha256 line though yields:

...
       … while calling the 'import' builtin
         at /nix/store/18flraam1817r85lymiqz2qxdp80lswy-source/configuration.nix:17:8:
           16|       ./hardware-configuration.nix
           17|       (import "${home-manager}/nixos")
             |        ^
           18|     ];

       … while realising the context of a path

       … while calling the 'fetchTarball' builtin
         at /nix/store/18flraam1817r85lymiqz2qxdp80lswy-source/configuration.nix:8:18:
            7| let
            8|   home-manager = builtins.fetchTarball {
             |                  ^
            9|     url="https://github.com/nix-community/home-manager/archive/release-25.05.tar.gz";

       error: in pure evaluation mode, 'fetchTarball' requires a 'sha256' argument

As you are using flakes, why are you using manual fetchTarball? Use flake inputs!

Still learning Nix. I’ve had a working configuration.nix for a few months. Had to make a flake for Hyprpanel. Outside of that, this is my initial setup and dive into home-manager. I’ll switch over to flake inputs before I get too deep into it.

I doubt it…

Flakes are rarely really a necessity, despite being the only documented way for many 3rd parties.

So I should migrate the flake?

Not sure what you mean by that.

I am just saying that often flakes are not necessary, even though that using some 3rd party thing is often documented the flake way by the 3rd party.

And the flake Hyprpanel uses is definitely written in a way, that makes it hard to use without actual flake, but you still can use builtins.getFlake or flake-compat or even manually import the flake.nix and call the outputs function with some input stubs (basically building your own flake-compat).

I am by far no flake hater, nor am I an evangelist, I consider it just another set of flaws compared to legacy nix, both have pros and both have cons. Its a pick your poison. But “I had to use flakes because of $software”, is almost always not true. There is almost always a way to use $softwares flake without using a flake on your own.

I was more getting at the fact that I can migrate the hyprpanel to home-manager now that I have that setup and I need to learn more about flake inputs. Not going to imply that one way is better than the other either, unless a certain way is deprecated…