Home Manager is a basic system for managing a user environment using the Nix package manager together with the Nix libraries found in nixpkgs.
Home Manager works anywhere that Nix does and populates a ~/.nix-profile ~/.nix-profile which is added to various environment PATHs to expose a bunch of Nix packaged programs to the rest of my system. I plan to slowly fork all of my Ansible automation in to this system and when the bulk of it is moved I can evaluate building fully idempotent systems with NixOS and NixOps. oh what fun! See below a cool method to generate some foot-gun shaped code!
Generating home-manager.nix dynamically with noweb Literate Programming
Desktop/Laptop home-manager configuration
home-dot-nix-srcnix source: :tangle ~/nix/home-manager.nix :noweb tangle{ config, pkgs, lib, ... }: { imports = [ <<generate_imports("endpoint")>> ]; programs.home-manager.enable = true; home.stateVersion = "21.05"; home.file.".config/nixpkgs/home.nix".source = ./home-manager.nix; # this file manual.html.enable = true; manual.json.enable = true; news.display = "silent"; home.username = "rrix"; home.homeDirectory = "/home/rrix"; # set to UTF-8 or python shit breaks home.language.base = "en_US.UTF-8"; home.language.time = "en_GB.UTF-8"; # for KDE # https://userbase.kde.org/Session_Environment_Variables home.file.".config/plasma-workspace/env/profile.sh".text = '' source $HOME/.profile ''; }
Server home-manager configuration
nix source: :tangle ~/nix/home-manager-server.nix :noweb tangle{ config, pkgs, lib, ... }: { imports = [ <<generate_imports("server")>> ]; programs.home-manager.enable = true; home.stateVersion = "21.05"; home.file.".config/nixpkgs/home.nix".source = ./home-manager-server.nix; manual.html.enable = true; manual.json.enable = true; news.display = "silent"; home.username = "rrix"; home.homeDirectory = "/home/rrix"; home.language.base = "en_US.UTF-8"; home.language.time = "en_GB.UTF-8"; home.file.".config/plasma-workspace/env/profile.sh".text = '' source $HOME/.profile ''; }
Literate Programming helpers
generate_importslua source: :eval arroyo :results raw :var role="endpoint"local modules = arroyo.home_modules(role) return table.concat(modules, "\n")
Support home-manager in My NixOS configuration
This file is added to imports to get a home manager install in My NixOS configuration .
nix source: :tangle ~/nix/nixos/home-manager.nix{ inputs, system, pkgs, ...}: { home-manager.useGlobalPkgs = true; home-manager.backupFileExtension = "hm-bak"; home-manager.extraSpecialArgs = { inherit inputs; inherit system; }; home-manager.users.rrix = ../home-manager.nix; }
This one is used in The Wobserver :
nix source: :tangle ~/nix/nixos/home-manager-server.nix{ inputs, system, pkgs, ...}: { imports = [ inputs.home-manager.nixosModules.home-manager ]; home-manager.useGlobalPkgs = true; home-manager.backupFileExtension = "hm-bak"; home-manager.extraSpecialArgs = { inherit inputs; inherit system; }; home-manager.users.rrix = ../home-manager-server.nix; }
Support for it in my Arroyo System Flake Generator
Home Manager is included as an input:
nix source: :tangle ~/nix/snippets/home-manager-input.nix :mkdirp yeshome-manager = { url = "github:nix-community/home-manager/release-26.05"; inputs.nixpkgs.follows = "nixpkgs"; };