Home Manager is great. It allows configuring user environments fully declaratively.
But installing Home Manager has always been wrong:
Channels are bad, nix-env
is bad.
And Home Manager dropping a flake.nix
somewhere is also bad.
While Home Manager environments are declarative, installation is not!
In my opinion, installing Home Manager should work like this:
-
Add a
default.nix
in a directory of choice. -
Import the Home Manager Nix library from there.
-
Put your configuration and custom modules wherever you please.
-
Add attributes to
default.nix
that correspond to the machines or profiles or users you're managing. -
Run
nix-shell -A <attribute> --run switch
to instantly switch to an environment. -
In an existing environment, run
home-manager switch
as usual.
This repository implements such a wrapper around Home Manager, which you can use as just described. It will match the Home Manager release to the version of Nixpkgs in use for the given expression.
Check example.nix
for the structure of the entry point to your set of Home Manager configurations.
To use it, get a copy and add remote sources:
nix-shell -p npins wget --run $SHELL
wget https://github.com/fricklerhandwerk/home-damager/blob/main/example.nix
npins init --bare
npins add github nixos nixpkgs --branch nixos-23.11
npins add github fricklerhandwerk home-damager --branch main
Run an interactive NixOS VM test:
nix-shell --run test-interactive
When the Python prompt >>>
appears, enter:
start_all()
When the login prompt appears, login with root
.
Then run:
run-test
When the test succeeds, run poweroff
and then Ctrl
+D
to stop the VM.
Due to the impure fetchTarball
reference used to automatically fetch the right version of Home Manager (the secret sauce to convenience), it's unfortunately impractical to make a hermetic integration test.
This is in fact a strong indication that we're holding it wrong.
Stand-alone Home Manager should be a distribution of Nixpkgs, and therefore ship with its own Nixpkgs as well as conveniences to update itself and its dependencies appropriately.