From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2.migadu.com ([2001:41d0:303:e16b::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms13.migadu.com with LMTPS id 4IYCGYuzL2eP8wAAe85BDQ:P1 (envelope-from ) for ; Sat, 09 Nov 2024 19:10:03 +0000 Received: from aspmx1.migadu.com ([2001:41d0:303:e16b::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2.migadu.com with LMTPS id 4IYCGYuzL2eP8wAAe85BDQ (envelope-from ) for ; Sat, 09 Nov 2024 20:10:03 +0100 X-Envelope-To: larch@yhetil.org Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=wolfsden.cz header.s=mail header.b=d8SgoA+E; dkim=pass header.d=wolfsden.cz header.s=mail header.b=f8EBd13V; spf=pass (aspmx1.migadu.com: domain of "help-guix-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="help-guix-bounces+larch=yhetil.org@gnu.org"; dmarc=pass (policy=none) header.from=wolfsden.cz ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1731179403; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=d575dwe+sAQ4ZqQtPG/hNn9Mht6qnoMjftYRfczxVR0=; b=X1J1USODM1zcu9FgFAxXEsV66J3KUQ6JOkocasV4kYslHmquHxuZiAYX3GFhJ49R5UDbWm tX0sq6dYyqyN+gDihCkn8g46VnHtgoraYnklzk1Zp+CvVd0tFwIxfvm58CA89TGfkWt6zv pDiRIHoIsVnpzw+WOyIv3qc1d67cXKOPo1FHbvq463FIaoZYt5fFq2fN/L15pKOAN/U5Rm 9hjOgwmWNY7GTlI1YcTgTS2OEZoM2yIIiYMqHZh1fyZSjYPzts9qCI/fZl8WVaPRGTXa1S jYHLjFS1CNNWOmiWI+nfoIVa2zdZfHMKh5GOHx0bwmyfv68b96eL2Z+Im7uoSw== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1731179403; a=rsa-sha256; cv=none; b=l/mRYonlDGO5yiYLodtto4WCK0owBiTGQ2Z7PWGSXL+dIx9Xpj5d3jUXQ/hpeNnqw3CWIX kojZNlmtIAoHiO9O9swCUpesJDWAzjhszl+JjtgKBE9VMVzw2oEEuUA/94na/1xvDDWPki vzjWyTbWryaxotlufRgz4gJ0htqJgVUeuEWAhrH4y9EjGgAkwiIfnsmAD2Z93qGxyyL1Rb pE2lgb/oe3LMEEF0rhRD4PLbXosYcUXiuRufK2Q/YB6oMRKZ/+Q1jKJ+PNBvOqYjnayRGt HskTbcawF/989NrrZZqUwrr/moR4hWufMAgofHDrf1D5rUEBHj39S1EPEIutAw== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=wolfsden.cz header.s=mail header.b=d8SgoA+E; dkim=pass header.d=wolfsden.cz header.s=mail header.b=f8EBd13V; spf=pass (aspmx1.migadu.com: domain of "help-guix-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="help-guix-bounces+larch=yhetil.org@gnu.org"; dmarc=pass (policy=none) header.from=wolfsden.cz Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 08F685A39D for ; Sat, 09 Nov 2024 20:10:02 +0100 (CET) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t9qpn-0001UI-L1; Sat, 09 Nov 2024 14:09:23 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <~@wolfsden.cz>) id 1t9qpk-0001PR-IE for help-guix@gnu.org; Sat, 09 Nov 2024 14:09:20 -0500 Received: from wolfsden.cz ([37.205.8.62]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <~@wolfsden.cz>) id 1t9qph-00073Y-Ry for help-guix@gnu.org; Sat, 09 Nov 2024 14:09:20 -0500 Received: by wolfsden.cz (Postfix, from userid 104) id 5AFF1312EE2; Sat, 9 Nov 2024 19:09:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=wolfsden.cz; s=mail; t=1731179353; bh=P6yj6AdaWUL/aYuPdFyHcrowkF14QVF+Ue9EGv07dWw=; h=From:To:Cc:Subject:In-Reply-To:References:Date; b=d8SgoA+E2L3zq87YYqB/YVrqWZGJuGYGzQn5ECzW3Pw1OT3qsFtIK7XKAlAz6FL8M wHZ/Oj0Q+g43rRpFDju4xkLhrdtSXB1pV1Leg9ObyAgwnJo3D9nh9RoFNTMo/Nb0kg l1l+iwsGmg9nqDimy5nsCMKwNQZx68wglG5WGWm1NsDY41RvQFjKxbM7HhapSaBblT xj0O0Qx3Y8H6/jxi7rHnD/fO0f4erED/ZZfAeKK8uY/p0glgWRiFbme0zhJBMb+ku4 2IYQ0Er7QaHFEG4SWXOmI3K8CXW7ph712b6ukHJV1TxlG190Eh0mdFUqItiqLRMBJS uZor5w1LFL8XHKrZ4z/LOGLsFjmv7PuhtrrxTCsJ1YZgSTdCC6hRy3HhdOS0o1aCGM B8h2A/uX3H+O9i3qJTR0d3Y6u1JIbAFxtCCM4zDZncUEPZV7wkbcqIcEzmh9eNgKPK G7jBdW0QQjwZNvAOAELGvJLYQPzZEpPI3ud/gtvBjmBlWbosm2TDSrFJ9dMnfnlLlm 0FM8mKJm9mEZA3EV7+WFSkmsHxoapkStzYUzqEcirkbij/Vr5YvPLvBF6mwmBmbxJs vrdQvj3PQEkNPMaxOZ5HbvejqLfF8l88iLhhhc9jSK9zYu6flDVWdcPnk2mG/SDj3O FZXhx8Kl9di7DvNiHNUTa2e8= Received: from localhost (unknown [128.0.188.242]) by wolfsden.cz (Postfix) with ESMTPSA id 7AC6D314200; Sat, 9 Nov 2024 19:09:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=wolfsden.cz; s=mail; t=1731179352; bh=P6yj6AdaWUL/aYuPdFyHcrowkF14QVF+Ue9EGv07dWw=; h=From:To:Cc:Subject:In-Reply-To:References:Date; b=f8EBd13VeXykAG7dtfkPS6LoghZWilfjm9sJyAYAuiaFAs6M8GOcGhNk5YDOUf2bT jicEn4nmiW/HxLTtvAFbot6JeqKKnTp3J1+JPZ32BP/h/2zacCw0HauuNXYDydSAvM MqdunTXjr53sLYvn/WXxwQzF3KluLkEfkMiE2eNJt00sz/IRu8S4+5KR8nw6qTCBKr NmOGe1yFAQ6w17fpOVuOqUxpeX1yQMOCtdTL+0sfCgh9pgJo2kiBfnzn4Y7J2iR+fw Bh+iDbGCm7eoXtDrsVR/B9GEYZQb/W2xd9qsU+VLgWdI1IhzbKHvL/75nTGiWF6lRd YgQv2YLwAH9VO0AEJuuFO6qLGo4hf5KdpEESrUcTI5bUzRgA9LLaFzZblyBE/iiOcf I2i87hvFUUP2tew6i5BzLxpPFDWnG1zvHuSd6+QMJgmWItOuvNbofc2T0WXPctjBev aqlkaoewrTTEVXXOMLR+BfGzqaJzj6b0brNwZQuXF8ZbmQf38jKpcxCWiZqKk/3JKt VxBAmuHti8IahmXBnhJASO6kIS1vjvlMJ1iTexa6EwOlISWxkG0hgEXJrTY7pkiY/9 F7QHQjWc6vLH/EjGIUA8Houa7azUKNvsxlduU/br/nBMf0qRL8T/lKMMzCsihGSD9W ebTfcj/uN7Rs4aSrobdbbcNs= From: Tomas Volf <~@wolfsden.cz> To: Ian Eure Cc: help-guix@gnu.org Subject: Re: Modular home configuration In-Reply-To: <87y11s1ekj.fsf@meson> (Ian Eure's message of "Sat, 09 Nov 2024 09:35:10 -0800") References: <87y11s1ekj.fsf@meson> Mail-Followup-To: Ian Eure , help-guix@gnu.org Date: Sat, 09 Nov 2024 20:09:12 +0100 Message-ID: <87o72o6x7r.fsf@wolfsden.cz> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha512; protocol="application/pgp-signature" Received-SPF: pass client-ip=37.205.8.62; envelope-from=~@wolfsden.cz; helo=wolfsden.cz X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: help-guix@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-guix-bounces+larch=yhetil.org@gnu.org Sender: help-guix-bounces+larch=yhetil.org@gnu.org X-Migadu-Flow: FLOW_IN X-Migadu-Country: US X-Migadu-Spam-Score: -6.48 X-Spam-Score: -6.48 X-Migadu-Queue-Id: 08F685A39D X-Migadu-Scanner: mx13.migadu.com X-TUID: fgIhXxrtV3/V --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Hello, Ian Eure writes: > Hi folks, > > I=E2=80=99m trying to make my home configuration more modular, so I can b= etter support > system variances. For example, I have a laptop I use interactively, and a > headless machine that runs Cuirass. It=E2=80=99s advantageous to share c= ertain aspects > of the home configuration between the two machines (shell prompt/environm= ent, > GPG agent, etc), but not others (anything X11/graphical stuff shouldn=E2= =80=99t be on > the build machine). One approach to this is to define packages and servi= ces and > reference them in the home configuration. What I dislike about this is t= hat > many things require both packages and services, and I=E2=80=99d prefer to= have a way to > completely encapsulate that -- for example, the mpd-mpc package to contro= l my > music server, plus a home-environment-variables-service-type to set MPD_H= OST. > > I attempted to solve this by writing a procedure: > > (define (+mpd-client home-config) > (home-environment > (inherit home-config) > (packages (cons mpd-mpc (home-environment-packages home-co= nfig))) > (services > (cons > (simple-service > 'mpd-environment-service > home-environment-variables-service-type > '(("MPD_HOST" . "audio.box"))) > (home-environment-services home-config))))) > > Which I can then wrap around a home-environment to add the mpd-mpc packag= e and > environment variable it needs to work: > > (+mpc-client (home-environment ...)) > > Surprisingly, this doesn=E2=80=99t work -- it complains that there=E2=80= =99s more than one > "home" service type. I=E2=80=99m not sure why that is, and I haven=E2=80= =99t been able to see > anything obviously wrong in the REPL -- though I haven=E2=80=99t been abl= e to get my > actual home configuration up in the Emacs-Guix REPL, due to #67290. It is the same as with operating-system. While you are setting the (services) field, the accessor is (home-environment-user-services). (home-environment-services home) returns (at least as far I understand it) something like (append (home-environment-user-services home) (home-environment-essential-services home)). Hence the "more that one home services type", you get it twice, once via the (services) you set in +mpc-client (because it includes essential-services), and once by the essential-services directly. > > Does anyone have a suggestion for a workaround for this issue, explanatio= n of > how two home services are ending up in the config, See above. > or a better approach for building modular home configs? Not sure if better, but different. I am using two variations of the same approach. One is to define a new service type that takes care of adding all necessary bits into the home environment. The following for example defines home-keychain-service-type for starting keychain[0]. =2D-8<---------------cut here---------------start------------->8--- (define-configuration/no-serialization home-keychain-configuration (keychain-package (package keychain) "Package to use keychain from.") (ssh-package (package openssh) "SSH package to add into the profile.") (gpg-package (package gnupg) "GPG package to add into the profile.") (ssh-keys (list-of-strings '()) "Ensure the ssh-agent is started and register the listed keys into it.") (gpg-keys (list-of-strings '()) "Ensure the gpg-agent is started and register the listed keys into it.")) (define (q s) "Quote string into a form suitable for shell." (string-append "'" (string-replace-substring s "'" "'\\'") "'")) (define (home-keychain-configuration->file config) (let* ((ssh-keys (home-keychain-configuration-ssh-keys config)) (ssh? (pair? ssh-keys)) (gpg-keys (home-keychain-configuration-gpg-keys config)) (gpg? (pair? gpg-keys)) (agents (string-join (append (if ssh? '("ssh") '()) (if gpg? '("gpg") '())) ",")) (keys (string-append (string-join (map q ssh-keys) " " 'suffix) (string-join (map q gpg-keys) " " 'suffix)))) (mixed-text-file "keychain-init" "eval $(" keychain "/bin/keychain" " --agents " agents " --eval " " --quiet " " -Q " keys ")"))) (define (home-keychain-bash config) (home-bash-extension (bash-profile (list (home-keychain-configuration->file config))))) (define (home-keychain-profile config) (list (home-keychain-configuration-ssh-package config) (home-keychain-configuration-gpg-package config))) (define home-keychain-service-type (service-type (name 'home-keychain) (extensions (list (service-extension home-bash-service-type home-keychain-bash) (service-extension home-profile-service-type home-keychain-profile))) (description "Start a keychain on login."))) =2D-8<---------------cut here---------------end--------------->8--- The interesting piece here is the `home-profile-service-type', which allows a service to add additional packages into the home environment (same as you would do with (package) field). However the limitation is that some services do not support extensions, so for those case I just have procedure or list (depending on whether configuration is required) with the required services, and use (append). Following is an example from my configuration: =2D-8<---------------cut here---------------start------------->8--- (define* (home-desktop-services #:key (mpv-config %default-mpv-config)) (list (simple-service 'pkgs-desktop home-profile-service-type %desktop-packages) (simple-service 'home-files home-files-service-type `((".xinitrc" ,file/xinitrc) (".Xresources" ,file/Xresources))) (simple-service 'im-env-vars home-environment-variables-service-type '(("GTK_IM_MODULE" . "ibus") ("QT_IM_MODULE" . "ibus") ("XMODIFIERS" . "@im=3Dibus") ("GTK2_RC_FILES" . "$HOME/.config/gtk-2.0/gtkrc") ;; TODO: Are these still required? If yes, try to get rid of th= em. ("GUIX_GTK2_IM_MODULE_FILE" . "$HOME/.guix-home/profile/lib/gtk-2.0/2.10.0/immodules-gtk2.c= ache") ("GUIX_GTK3_IM_MODULE_FILE" . "$HOME/.guix-home/profile/lib/gtk-3.0/3.0.0/immodules-gtk3.ca= che"))) (simple-service 'desktop-xdg-config-files home-xdg-configuration-files-service-type `(("i3/config" ,file/i3/config) ("gtk-2.0/gtkrc" ,file/gtk-2/gtkrc) ("gtk-3.0/settings.ini" ,file/gtk-3/settings.ini) ("gtk-3.0/gtk.css" ,file/gtk-3/gtk.css) ("mpv/mpv.conf" ,(mpv-config->file mpv-config)))) (service home-startx-command-service-type) (service home-dbus-service-type))) =2D-8<---------------cut here---------------end--------------->8--- And then my in my home environment: =2D-8<---------------cut here---------------start------------->8--- (let ((home %basic-home)) (home-environment (inherit home) (packages ...) (services (append (list ...) (home-desktop-services) (home-environment-user-services home))))) =2D-8<---------------cut here---------------end--------------->8--- I am not convinced this approach is the best, originally I had it the same way you had in a functional style with a helper procedure, but rewrote it to this model since Guix already has a concept of "services", so I wanted to try to mirror it. Maybe I will switch back to the functional style. Not sure yet. Hope this helps, Tomas 0: https://www.funtoo.org/Funtoo:Keychain =2D-=20 There are only two hard things in Computer Science: cache invalidation, naming things and off-by-one errors. --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQJCBAEBCgAsFiEEt4NJs4wUfTYpiGikL7/ufbZ/wakFAmcvs1gOHH5Ad29sZnNk ZW4uY3oACgkQL7/ufbZ/waluKQ//RlRncKvtJXNzKHXh/jdn93gKt6UQnimXbb/P ZTkQZWhKXXBwFahu/2hl0W0//qfqDk6zVQqZjgzQlML4ZaoxfbbTaUOonW8u4Lkp ukP0AFtJb+hzGM3rfAiktUJMviYTrNIdheKCM8il7rCjHxD3Z00TOWTSJhEbipFw mH/03sD/lhjMf4+xUdwIoyk1djwHCD2pVsYAGtaIzps+3xJXaFtAX1PHlPnuc7hU XlvxiiYh+bUE9D08qXKXlbnEiQgA37za+HTeFbkbweVOZd+MEmiGSa2WPE/wkG7t mf5am0iHOlH4dVVnzOzXL3fdpibdW9zsc7yeYHpzqpxGLOz3iTOqFn1W04Gq1um5 tZER/uk9CCGYLoddfbG6eaOGCL5aXX25ClO1xqZDpxSdgP/MsvMrh0j9f26y+60a jNZ8DSfrLu7Gmeqa/UNsvVz+ZlUbAclaGBMMZHuXuSjM9xsW8/ic+J0dwCHQggmK 2ZpHYMFxL2GLoKRC6W1NwumfeuAem4g2i4w+5fyeHJNM99VWhEtb15UOyMI5J+RA d3EdWAkLzM8w6PhErammRijYS7OBYWyWZQLj5KjHz8BjkxWTUh3ChkvrLi+bS4cf Dw+e3EK/MSauQAFJQ7IfbmhchuCpjhSf9jdbV3iSMAPp2H00dHWYDyP1hKdRg5im go4PKaU= =cKUp -----END PGP SIGNATURE----- --=-=-=--