The Complete Computer

Generate a Dynamic Home Manager Configuration

LifeTechEmacsArcology

Home Manager is a basic system for managing a user environment using the Nix package manager together with the Nix libraries found in nixpkgs.

readmeWikiManual

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!

NEXT CCE Modules Which This Loads

Generating home-manager.nix dynamically with noweb Literate Programming

This uses my org-roam keyword caching patch and the Shared CCE Helpers to dynamically generate a home.nix. some neat and tidy roam:ELisp is nice to see. Every page with home manager code in it will carry a CCE_HOME_MODULE keyword with the location of the .nix file for that CCE module which will be inserted in to the home.nix template.

It's complicated because I need to define home.packages only in one place and I can't figure out a better way to compose this file. This relies on some implied code standards to work: home.packages will be populated with things hidden under lib.mypkgs.FOO, a list of packages concatenated with all the other lib.mypkgs but reliant on very particular shape and naming. Inherent limitation to the craft, I guess.

I also should define program modules for a lot of these over the long term so that they're more simple to harness and my configurations can become more stable. This references a lot of code in the Shared CCE Helpers , consider reading that if you're interested in understanding this.

for now, this is going to be kind of awkward. I have a Fedora Linux that is reliant on this home.nix, but i want nodes managed with NixOps to have access to this during a bootstrap.

 home-dot-nix-srcnix source: :tangle ~/arroyo-nix/home-manager.nix :noweb tangle
{ config, pkgs, lib, ... }: { imports = [ <<generate_imports()>> ]; 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 ''; }

Literate Programming helpers

This uses Arroyo Home Manager .

 generate_importsemacs-lisp source: 
(arroyo-home-manager-imports "endpoint")

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 ~/arroyo-nix/nixos/home-manager.nix
{ pkgs, ...}: let opts = (import ../versions.nix {}).homeManager; hm = opts false; in { # this makes home-manager.users.rrix work imports = [ "${hm}/nixos" ]; home-manager.useGlobalPkgs = true; home-manager.backupFileExtension = "hm-bak"; # this makes pkgs.home-manager track my pins, i.e "home-manager build" uses the same version as nixos's home-manager-rrix service nixpkgs.overlays = [ (import "${hm}/overlay.nix") ]; }

Quickly Install it

With a working Nix installation run this to install home-manager:

shell source: :async t
nix-channel --add https://github.com/nix-community/home-manager/archive/master.tar.gz home-manager nix-channel --update nix-shell '<home-manager>' -A install

Additionally, Cachix can be used to skip compiling the Emacs GCC branch on NixOS systems. Here it's not so helpful

shell source: :async t
nix-env -iA cachix -f https://cachix.org/api/v1/install cachix use nix-community