complete-computing-environment/home-manager.org

396 lines
17 KiB
Org Mode

:PROPERTIES:
:ID: cce/home-manager
:ROAM_ALIASES: home-manager "Nix Home Manager"
:END:
#+TITLE: Generate a Dynamic Home Manager Configuration
#+filetags: :Project:CCE:
#+ARROYO_MODULE_WANTS: arroyo/arroyo.org
#+PROPERTY: header-args :mkdirp yes
#+PROPERTY: header-args:yaml :tangle cce/roles/endpoint/tasks/home-manager.yml
#+ARCOLOGY_KEY: cce/home-manager
#+ARCOLOGY_ALLOW_CRAWL: t
#+ARROYO_EMACS_MODULE: home-manager
#+ARROYO_SYSTEM_EXCLUDE: waterboy
#+AUTO_TANGLE: t
#+begin_quote
Home Manager is a basic system for managing a user environment using the [[id:c75d20e6-8888-4c5a-ac97-5997e2f1c711][Nix]] package manager together with the Nix libraries found in nixpkgs.
#+end_quote
• [[https://github.com/nix-community/home-manager/blob/master/README.md][readme]] • [[https://nixos.wiki/wiki/Home_Manager][Wiki]] • [[https://nix-community.github.io/home-manager/][Manual]] •
Home Manager works anywhere that Nix does and populates a [[file:~/.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 [[id:c75d20e6-8888-4c5a-ac97-5997e2f1c711][NixOS]] and NixOps. oh what fun! See below a cool method to generate some foot-gun shaped code!
* [[id:cce/emacs][Emacs]] scaffolding via [[id:cce/cce][CCE]]
~This document relies on some [[id:e050ed03-044f-4a48-912d-72579bef9a26][org-roam keyword caching]]~ this is handled by [[id:arroyo/emacs][Arroyo Emacs]] now.
#+begin_src emacs-lisp :tangle home-manager.el :results none :tangle no
(with-eval-after-load 'org-roam-keywords
(dolist (kw '("CCE_HOME_MODULE" "CCE_HOME_PACKAGES" "CCE_HOME_DERIVATIONS" "CCE_HOME_EPKGS"))
(add-to-list 'org-roam-cached-keywords kw nil #'equal)))
(provide 'cce/home-manager)
#+end_src
* CCE Modules Which This Loads
:PROPERTIES:
:ID: 9ac10d78-8ec7-438b-a913-21591f7f3c08
:END:
Here are files which will be included by =home-manager=:
#+NAME: home-manager-toc
#+begin_src emacs-lisp :export results :results raw
(->>
(org-roam-db-query [:select [file title]
:from keywords
:join titles :using [[file]]
:where (= keyword "CCE_HOME_MODULE")
:group-by file])
(seq-map (lambda (item) (format "- [[file:%s][%s]]\n" (file-relative-name (first item) cce-directory) (second item))))
(apply #'concat))
#+end_src
#+results: home-manager-toc
- [[id:daddc4e9-1e5a-44b1-b3a3-839b9c873049][AxiDraw]]
- [[id:cce/applications_i_use][Applications I Use]]
- [[id:cce/beets][Music Library Management with beets]]
- [[id:cce/deadgrep][Deadgrep is a Great Grep Interface]]
- [[id:cce/emacs][Emacs]]
- [[id:cce/firefox_nix][Managing Firefox with Nix home-manager]]
- [[id:cce/flyspell_mode][Spell-checking with Flyspell Mode]]
- [[id:cce/gnupg_configuration][GnuPG Configuration]]
- [[id:cce/magit][Git in Emacs with Magit]]
- [[id:cce/mbsync][mbsync for local mail storage]]
- [[id:cce/mkactivationlocallink][Creating Activation Scripts for Home Manager]]
- [[id:cce/mpd][Listening to Music with MPD]]
- [[id:cce/nixops][NixOps]]
- [[id:cce/org-roam][org-roam]]
- [[id:cce/picom][Picom on EXWM startup]]
- [[id:cce/sending_mail_in_gnus][Sending Mail in Gnus]]
- [[id:cce/ssh_configuration][SSH Configuration]]
- [[id:cce/syncthing][Nearly Stateless Computing Using Syncthing]]
- [[id:cce/the_standard_unix_password_manager][The Standard UNIX Password Manager]]
- [[id:45fc2a02-fcd0-40c6-a29e-897c0ee7b1c7][direnv]]
- [[id:0b5cc6cd-97c1-4dc1-aa4d-f331dbb040b7][Installing Occluded Files]]
- [[id:printrbot_simple_metal][PrintrBot Simple Metal]]
- [[id:a8fc50ea-63ff-4c0e-925a-cf0147cf4c0c][TidalCycles]]
* Quickly Install it
:PROPERTIES:
:ID: home-manager-install
:END:
With a working [[id:c75d20e6-8888-4c5a-ac97-5997e2f1c711][Nix]] installation run this to install home-manager:
#+begin_src shell :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
#+end_src
Additionally, [[https://app.cachix.org/cache/nix-community][Cachix]] can be used to skip compiling the [[id:cce/emacs][Emacs]] GCC branch on NixOS systems. Here it's not so helpful
#+begin_src shell :async t
nix-env -iA cachix -f https://cachix.org/api/v1/install
cachix use nix-community
#+end_src
* Generating =home-manager.nix= dynamically with [[id:09779ac0-4d5f-40db-a340-49595c717e03][noweb]] [[id:cce/literate_programming][Literate Programming]]
:PROPERTIES:
:ID: home-dot-nix
:ROAM_ALIASES: home-configuration
:END:
This uses my [[id:e050ed03-044f-4a48-912d-72579bef9a26][org-roam keyword caching]] patch and the [[id:cce/shared_cce_helpers][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 [[id:cce/cce][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 [[id:cce/shared_cce_helpers][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 [[id:fedora_linux][Fedora Linux]] that is reliant on this =home.nix=, but i want nodes managed with [[id:cce/nixops][NixOps]] to have access to this during a bootstrap.*
#+NAME: home-dot-nix-src
#+begin_src nix :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
'';
}
#+end_src
** [[id:cce/literate_programming][Literate Programming]] helpers
:PROPERTIES:
:ID: f32b616e-ede6-461e-8bae-b5f1c717a05e
:END:
This uses [[id:arroyo/home-manager][Arroyo Home Manager]].
#+NAME: generate_imports
#+begin_src emacs-lisp
(arroyo-home-manager-imports)
#+end_src
#+results: generate_imports
#+begin_example
hm/3d-printing.nix
hm/applications.nix
hm/atuin.nix
hm/audio.nix
hm/axidraw.nix
hm/bandcamp-dl.nix
hm/beets.nix
hm/bitwarden.nix
hm/cogmind.nix
hm/contacts.nix
hm/cpmtools.nix
hm/datasette.nix
hm/deadgrep.nix
hm/defexpr.nix
hm/direnv.nix
hm/dovecot-shell-access.nix
hm/drawingbot.nix
hm/emacs-helpers.nix
hm/emacs.nix
hm/emacs-pager.nix
hm/fehbg.nix
hm/firefox.nix
hm/git.nix
hm/gnupg.nix
hm/i3wm.nix
hm/kde-config-appearance.nix
hm/kde-config-basics.nix
hm/mbsync-endpoint.nix
hm/morph.nix
hm/mpd.nix
hm/msmtp.nix
hm/nix-update.nix
hm/occluded_files.nix
hm/org-fc.nix
hm/org-protocol.nix
hm/org-roam.nix
hm/pantalaimon.nix
hm/pass.nix
hm/picom.nix
hm/profile.nix
hm/prompt.nix
hm/python.nix
hm/qud.nix
hm/ruby.nix
hm/shell-helpers.nix
hm/smac.nix
hm/spell-check.nix
hm/ssh_client.nix
hm/supercollider.nix
hm/syncthing.nix
hm/syncthing-tray.nix
hm/tabfs.nix
hm/vsketch.nix
hm/xmonad.nix
#+end_example
* Task list to port =CCE_ANSIBLE= to =CCE_HOME_MODULE=
[[id:91dee035-a7fb-4286-bcf1-88a41f98a616][Now This Is Podracing!]]
#+begin_src emacs-lisp :results raw
(apply #'concat
(seq-map (lambda (row)
(message "%s" row)
(format "** NEXT port [[%s][%s]] to home-manager :CCE:Dev:Nix:\n" (first row) (second row)))
(org-roam-db-query [:select [file value]
:from keywords
:where (= keyword $s1)]
"CCE_ANSIBLE")))
#+end_src
#+results:
** DONE port [[/home/rrix/org/cce/the_standard_unix_password_manager.org][pass]] to home-manager :CCE:Dev:Nix:
- State "DONE" from "NEXT" [2021-03-12 Fri 20:09]
** DONE port [[/home/rrix/org/cce/applications_i_use.org][applications]] to home-manager :CCE:Dev:Nix:
- State "DONE" from "INPROGRESS" [2021-04-03 Sat 17:34]
- State "INPROGRESS" from "NEXT" [2021-03-13 Sat 18:07]
** DONE port [[/home/rrix/org/cce/gnupg_configuration.org][gnupg]] to home-manager :CCE:Dev:Nix:
- State "DONE" from "NEXT" [2021-03-20 Sat 00:39]
** DONE port [[/home/rrix/org/cce/deadgrep.org][deadgrep]] to home-manager :CCE:Dev:Nix:
- State "DONE" from "NEXT" [2021-03-20 Sat 00:42]
** DONE port [[id:cce/picom][picom]] to home-manager :CCE:Dev:Nix:
- State "DONE" from "NEXT" [2021-03-20 Sat 01:06]
** DONE port [[/home/rrix/org/cce/magit.org][git]] to home-manager :CCE:Dev:Nix:
- State "DONE" from "NEXT" [2021-03-20 Sat 01:22]
** DONE port [[/home/rrix/org/axidraw.org][axidraw]] to home-manager :CCE:Dev:Nix:
- Note taken on [2021-03-21 Sun 01:19] \\
axicli is basically uninstallable in [[id:c75d20e6-8888-4c5a-ac97-5997e2f1c711][NixOS]] lol
- State "DONE" from "INPROGRESS" [2021-03-21 Sun 01:19]
- State "INPROGRESS" from "NEXT" [2021-03-21 Sun 01:18]
** DONE port [[/home/rrix/org/cce/basic_emacs_coding_config.org][code-base]] to home-manager :CCE:Dev:Nix:
- Note taken on [2021-03-21 Sun 01:34] \\
this only had git which i installed in [[id:cce/magit][Magit]]. probably could stand to include more later on.
- State "DONE" from "NEXT" [2021-03-21 Sun 01:34]
** DONE port [[/home/rrix/org/cce/org-roam.org][org-roam]] to home-manager :CCE:Dev:Nix:
- State "DONE" from "NEXT" [2021-03-26 Fri 00:26]
** DONE port [[id:cce/syncthing][syncthing]] to home-manager :CCE:Dev:Nix:
- State "DONE" from "INPROGRESS" [2021-03-26 Fri 00:56]
- State "INPROGRESS" from "NEXT" [2021-03-21 Sun 01:27]
** DONE port [[/home/rrix/org/cce/sending_mail_in_gnus.org][msmtp]] to home-manager :CCE:Dev:Nix:
- State "DONE" from "NEXT" [2021-03-26 Fri 00:57]
** CANCELLED port [[/home/rrix/org/cce/emacs_sqlite3_installation.org][emacs-sqlite3]] to home-manager :CCE:Dev:Nix:
- State "CANCELLED" from "NEXT" [2021-03-26 Fri 00:57]
** CANCELLED port [[/home/rrix/org/ansible_bender.org][ansible-bender]] to home-manager :CCE:Dev:Nix:
:LOGBOOK:
- State "CANCELLED" from "NEXT" [2021-09-18 Sat 13:22]
:END:
** DONE port [[/home/rrix/org/shell_environment_loader.org][shell-loader]] to home-manager :CCE:Dev:Nix:
:LOGBOOK:
- State "DONE" from "NEXT" [2021-09-18 Sat 13:22]
:END:
** CANCELLED port [[/home/rrix/org/cce/using_yubikey_as_a_gpg_key.org][yubikeys]] to home-manager :CCE:Dev:Nix:
:LOGBOOK:
- State "CANCELLED" from "NEXT" [2021-09-18 Sat 13:23]
:END:
** NEXT port [[id:cce/ruby_and_rails_in_emacs][ruby]] to home-manager :CCE:Dev:Nix:
** DONE port [[id:cce/firefox_user_chrome][firefox-cust]] to home-manager :CCE:Dev:Nix:
:LOGBOOK:
- State "DONE" from "NEXT" [2021-09-18 Sat 13:22]
:END:
** DONE port [[/home/rrix/org/cce/org_protocol.org][org-protocol]] to home-manager :CCE:Dev:Nix:
:LOGBOOK:
- State "DONE" from "NEXT" [2021-09-18 Sat 13:22]
:END:
** DONE port [[/home/rrix/org/cce/vulfpeck_fonts_are_fun.org][vulfpeck]] to home-manager :CCE:Dev:Nix:
:LOGBOOK:
- State "DONE" from "NEXT" [2021-06-21 Mon 11:05]
:END:
** DONE port [[id:cce/gnus][gnus]] to home-manager :CCE:Dev:Nix:
:LOGBOOK:
- State "DONE" from "NEXT" [2021-06-21 Mon 11:05]
:END:
** NEXT port [[/home/rrix/org/cce/kobo_aura_one.org][hpi-kobo]] to home-manager :CCE:Dev:Nix:
** DONE port [[/home/rrix/org/cce/basic_language_coverage.org][code-modes]] to home-manager :CCE:Dev:Nix:
:LOGBOOK:
- State "DONE" from "NEXT" [2021-09-18 Sat 13:22]
:END:
** CANCELLED port [[/home/rrix/org/cce/weechat_for_matrix.org][weechat]] to home-manager :CCE:Dev:Nix:
:LOGBOOK:
- State "CANCELLED" from "NEXT" [2021-06-21 Mon 11:05]
:END:
** NEXT port [[/home/rrix/org/cce/pam_u2f.org][pam-u2f]] to home-manager :CCE:Dev:Nix:
** NEXT port [[/home/rrix/org/cce/programming_common_lisp_in_emacs.org][common-lisp]] to home-manager :CCE:Dev:Nix:
** DONE port [[/home/rrix/org/cce/warm_computing_with_redshift.org][redshift]] to home-manager :CCE:Dev:Nix:
:LOGBOOK:
- State "DONE" from "NEXT" [2021-06-21 Mon 11:05]
:END:
** DONE port [[/home/rrix/org/cce/configure_packaging.org][packaging]] to home-manager :CCE:Dev:Nix:
:LOGBOOK:
- State "DONE" from "NEXT" [2021-06-21 Mon 11:05]
:END:
** NEXT port [[id:cce/obs-v4l2sink][obs-v4l2sink]] to home-manager :CCE:Dev:Nix:
** NEXT port [[/home/rrix/org/cce/using_yubikey_as_an_otp_key.org][yubikey-otp]] to home-manager :CCE:Dev:Nix:
** DONE port [[/home/rrix/org/cce/python.org][python]] to home-manager :CCE:Dev:Nix:
:LOGBOOK:
- State "DONE" from "NEXT" [2021-09-18 Sat 13:22]
:END:
** DONE port [[/home/rrix/org/cce/use_emacs_as_a_pager.org][emacs-pager]] to home-manager :CCE:Dev:Nix:
:LOGBOOK:
- State "DONE" from "NEXT" [2021-09-18 Sat 13:22]
:END:
** DONE port [[/home/rrix/org/cce/universal_aggregator.org][universal-aggregator]] to home-manager :CCE:Dev:Nix:
:LOGBOOK:
- State "DONE" from "NEXT" [2021-09-18 Sat 13:22]
:END:
** DONE port [[/home/rrix/org/cce/elixir.org][elixir]] to home-manager :CCE:Dev:Nix:
:LOGBOOK:
- State "DONE" from "NEXT" [2021-09-18 Sat 13:22]
:END:
** CANCELLED port [[/home/rrix/org/cce/podman.org][podman]] to home-manager :CCE:Dev:Nix:
:LOGBOOK:
- State "CANCELLED" from "NEXT" [2021-06-21 Mon 11:05]
:END:
** DONE port [[/home/rrix/org/cce/keyboardio_atreus.org][atreus]] to home-manager :CCE:Dev:Nix:
:LOGBOOK:
- State "DONE" from "NEXT" [2021-09-18 Sat 13:22]
:END:
** CANCELLED port [[/home/rrix/org/cce/encumbered_media_support.org][rpmfusion]] to home-manager :CCE:Dev:Nix:
:LOGBOOK:
- State "CANCELLED" from "NEXT" [2021-06-21 Mon 11:05]
:END:
** DONE port [[/home/rrix/org/cce/kde_is_a_base_for_my_emacs_desktop.org][kde-desktop]] to home-manager :CCE:Dev:Nix:
:LOGBOOK:
- State "DONE" from "NEXT" [2021-09-18 Sat 13:22]
:END:
** DONE port [[/home/rrix/org/cce/firefox_can_use_kde_file_dialogs.org][firefox-portal]] to home-manager :CCE:Dev:Nix:
:LOGBOOK:
- State "DONE" from "NEXT" [2021-09-18 Sat 13:22]
:END:
** NEXT port [[/home/rrix/org/cce/sitelen_pona_pona.org][sitelen-pona-pona]] to home-manager :CCE:Dev:Nix:
** DONE port [[/home/rrix/org/cce/mbsync.org][mbsync]] to home-manager :CCE:Dev:Nix:
:LOGBOOK:
- State "DONE" from "NEXT" [2021-06-21 Mon 11:06]
:END:
** DONE port [[/home/rrix/org/cce/a_basic_firefox_installation.org][firefox]] to home-manager :CCE:Dev:Nix:
:LOGBOOK:
- State "DONE" from "NEXT" [2021-06-21 Mon 11:06]
:END:
** NEXT port [[/home/rrix/org/hpi.org][hpi]] to home-manager :CCE:Dev:Nix:
** CANCELLED port [[/home/rrix/org/cce_nixos_core.org][nixos]] to home-manager :CCE:Dev:Nix:
:LOGBOOK:
- State "CANCELLED" from "NEXT" [2021-06-21 Mon 11:06]
:END:
* Support home-manaer in [[id:cce/my_nixos_configuration][My NixOS configuration]]
:PROPERTIES:
:ID: ef5a177a-9d72-4f03-8113-5782140cfaed
:END:
This file is added to =imports= to get a home manager install in [[id:cce/my_nixos_configuration][My NixOS configuration]].
#+ARROYO_NIXOS_MODULE: nixos/home-manager.nix
#+begin_src nix :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;
# 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")
];
}
#+end_src