Skip to content

Latest commit

 

History

History
68 lines (44 loc) · 2.53 KB

README.md

File metadata and controls

68 lines (44 loc) · 2.53 KB

Fully declarative Home Manager installation

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:

  1. Add a default.nix in a directory of choice.

  2. Import the Home Manager Nix library from there.

  3. Put your configuration and custom modules wherever you please.

  4. Add attributes to default.nix that correspond to the machines or profiles or users you're managing.

  5. Run nix-shell -A <attribute> --run switch to instantly switch to an environment.

  6. 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.

Example

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

Development

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.