Skip to content

Fully declarative Home Manager installation

Notifications You must be signed in to change notification settings

fricklerhandwerk/home-damager

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

About

Fully declarative Home Manager installation

Topics

Resources

Stars

Watchers

Forks

Languages