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.nixin 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.nixthat correspond to the machines or profiles or users you're managing. -
Run
nix-shell -A <attribute> --run switchto instantly switch to an environment. -
In an existing environment, run
home-manager switchas 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/fricklerhanderk/home-damager/tree/main/example.nix
npins init --bare
npins add github nixos nixpkgs --branch nixos-23.11
npins add github fricklerhandwerk home-damagerRun an interactive NixOS VM test:
nix-shell --run test-interactiveWhen the Python prompt >>> appears, enter:
start_all()When the login prompt appears, login with root.
Then run:
run-testWhen 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.