From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp12.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms9.migadu.com with LMTPS id YMQeA+1TI2TWAAAASxT56A (envelope-from ) for ; Tue, 28 Mar 2023 22:54:05 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp12.migadu.com with LMTPS id SFrdAu1TI2TbbgEAauVa8A (envelope-from ) for ; Tue, 28 Mar 2023 22:54:05 +0200 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 C816017197 for ; Tue, 28 Mar 2023 22:54:04 +0200 (CEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1phGK2-0006o4-9q; Tue, 28 Mar 2023 16:53:38 -0400 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 ) id 1phGK0-0006np-Ji for help-guix@gnu.org; Tue, 28 Mar 2023 16:53:36 -0400 Received: from marioforzanini.com ([107.191.47.35]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1phGJy-0001TN-NI for help-guix@gnu.org; Tue, 28 Mar 2023 16:53:36 -0400 From: Mario Forzanini DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=marioforzanini.com; s=mail; t=1680036811; bh=2AqZQtsgAxp67rAtVlS9IVLuo89vg4Evia8YNCkYvOs=; h=From:To:Subject:Date:From; b=kTnuriZFJiNXCO90ixJlLgpqjiTDRY3/E9iFVxtG3T1HpBQWE+zA0PFKVvKdmSbCJ Is62lq+niyS00zIoilVGcMquaHOzLVnrYozMdTWTZMxur+DgfuWbycpPuEsnhjgOyw q7zVCcyIVXZibzHkBEFrsw2Ry+R4ahQzwLeLpZQ6TFYSxwnc2gIw8SGYszI3OTPP7f Pi6ci1pWp7QrIVB6LggRiJo4uICpsKq7nEa3yCxBqNn+cngaL9jTI9CQofRymjHW3x OKcRLZCaTdPSmenueUqolnRQgG8NnwTwnpGppaTMhLTBl0QWGRo9l528rvO9ncsdCq 0xF7Na9qO+89A== To: help-guix Subject: Home service that serializes into an executable file User-Mail-Address: mf@marioforzanini.com Date: Tue, 28 Mar 2023 22:53:24 +0200 Message-ID: <875yaktx6j.fsf@marioforzanini.com> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Received-SPF: none client-ip=107.191.47.35; envelope-from=mf@marioforzanini.com; helo=marioforzanini.com 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, SPF_HELO_NONE=0.001, SPF_NONE=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-Country: US X-Migadu-Flow: FLOW_IN ARC-Seal: i=1; s=key1; d=yhetil.org; t=1680036844; a=rsa-sha256; cv=none; b=AhnPZFsyvRSuJrGltzR9U8M15w5TS/MXl5fD6KQEq0qPaSATC4TyaUyT08edgjCrFVvx5P OdMToFEJ/Z8HJiR4yR88/wepr818JN6JK2oqjQvLX7omlVVhTEjoZ5MbuxqXFEEkbCxshr hOSz339UrBoQSKO3OJK/Jfvu4V5ijUltzJa0Wzvm/PCGn9PXEHEKafSQiulSQ8Qy8zlDPM wuVaGKSLQ/YLkm8IBhj9mZjrWkXQk3WAQ5o9+ZPaINBv8D/SKyuj244DQ+jfdqr3/NiHwa zCQvZbWl8pXUTk9E3kTLwUr5ss1RQZEezl0zdLJngN2JVoszHaSgE3NdRNDz/g== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=marioforzanini.com header.s=mail header.b=kTnuriZF; dmarc=pass (policy=reject) header.from=marioforzanini.com; 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" ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1680036844; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:list-id:list-help: list-unsubscribe:list-subscribe:list-post:dkim-signature; bh=7ntjwysPyMdPY8I920cu5gpO9IKz8C9Ie3OCvvVnnao=; b=pxpciJQ3cBdjN9mmay6N0lPf5UQbelRmRIIoKhVehC3khwF9Q3Kh0VsIV/7QDpswNc6Gng 8zoPXt6rMLHSMR+NNFAeCKdR8fTQ1tyhCV7+sWksskrNbTznYOk9Q2yf+QasTrAcTpfVJt GxHAWGquHzu/AXmwoxqWjF9hfDSxQH91i+3mIRpX5mhf2BvOowz1bQkoYrTQgxLFkaucNp vqrPC6AglqvCTCJQiz4jfH06LxUue6iM2b857f418TGcuAvKbkdzuCeOqc9+TeeqeZtYEs w+6OxUoT9Net4maBaAwKIFfzhiAKOdSDceVtEmk8pkq+nwc/VJnIp/sxBLcykg== Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=marioforzanini.com header.s=mail header.b=kTnuriZF; dmarc=pass (policy=reject) header.from=marioforzanini.com; 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" X-Migadu-Scanner: scn1.migadu.com X-Migadu-Spam-Score: -2.73 X-Spam-Score: -2.73 X-Migadu-Queue-Id: C816017197 X-TUID: J6UCiMbF/UeA Hello everyone! I've recently tried to write a simple home service that serializes into an ~/.xsession file. As someone pointed out in an older message on this list, this file has to be executable; I used to achieve this including an external file like: (local-file "xsession" #recursive? #t). Is there a procedure that allows changing permission bits while generating a file in the store? This is still in a rough state, but here is the definition of the service: (define (serialize-string field-name val) val) (define (string-join strings delimiter) (if (null? strings) "" (fold (lambda (s so-far) (string-append so-far delimiter s)) (car strings) (cdr strings)))) (define (xsession-serialize-program program args) (if (pair? program) (string-append (string-join (cons* "try" (cdr program) args) " ") "\n") (string-append (string-join (cons* "try" (package-name program) args) " ") "\n"))) (define (serialize-xsession-programs field-name alist) (generic-serialize-alist string-append xsession-serialize-program alist)) (define (serialize-xsession-window-manager field-name window-manager) (string-append "exec " (cdr window-manager) "\n")) (define-configuration home-xsession-configuration (window-manager (pair `(,dwm . "dwm")) "Cons pair of window manager package and executable name." serialize-xsession-window-manager) (programs (alist '()) "Alist of programs to start and arguments to such programs." serialize-xsession-programs) (log-file (string "$HOME/.local/share/xsession.log") "Log file to store errors and info.")) (define (xsession-filter-fields field) (filter-configuration-fields home-xsession-configuration-fields (list= field))) (define (xsession-serialize-field config field) (serialize-configuration config (xsession-filter-fields field))) (define (xsession-file config) (define dot-xsession (mixed-text-file "xsession" "#!/bin/sh try() { pgrep -q $1 || $@ 2>> " (xsession-serialize-field config 'log-file) "\n}\n" (xsession-serialize-field config 'programs) (xsession-serialize-field config 'window-manager))) `((".xsession" ,dot-xsession))) (define (add-xsession-packages config) (cons* (car (home-xsession-configuration-window-manager config)) (map (lambda (association) (if (pair? (car association)) (caar association) (car association))) (home-xsession-configuration-programs config)))) (define home-xsession-service-type (service-type (name 'xsession) (extensions (list (service-extension home-files-service-type xsession-file) (service-extension home-profile-service-type add-xsession-packages))) (compose identity) (default-value (home-xsession-configuration)) (description "Configure the X session via ~/.xsession."= ))) This serializes a configuration such as this: (service home-xsession-service-type (home-xsession-configuration (window-manager `(,mf-dwm . "dwm")) (programs `((,picom . ()) (,dunst . ()) ((,blueman . "blueman-applet") . ()) (,pasystray . ()) ((,network-manager-applet . "nm-applet") . ()) (,mpd . ()) (,cbatticon . ("BAT0")) (,cbatticon . ("BAT1")) (,xsettingsd . ()) (,tmux . ("new-session" "-d")) (,hsetroot . ("-cover" "$HOME/Pictures/forest.jpg")) (,setxkbmap . ("-layout" "us" "-option" "compose:ralt")) ((,emacs-next . "emacs") . ("--daemon")))) (log-file "~/.local/share/xsession.log"))) into: #!/bin/sh try() { pgrep -q $1 || $@ 2>> ~/.local/share/xsession.log } try picom try dunst try blueman-applet try pasystray try nm-applet try mpd try cbatticon BAT0 try cbatticon BAT1 try xsettingsd try tmux new-session -d try hsetroot -cover $HOME/Pictures/forest.jpg try setxkbmap -layout us -option compose:ralt try emacs --daemon exec dwm But the permissions are wrong: =E2=94=8C(22:49:18)=20 =E2=94=94(~) % ls -l ~/.xsession=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20 lrwxrwxrwx 1 mario users 52 Mar 28 22:23 /home/mario/.xsession -> /gnu/= store/p213clvznwrrrasr3mygb6iqqnqsg2ra-xsession =E2=94=8C(22:49:21)=20 =E2=94=94(~) % ls -l /gnu/store/p213clvznwrrrasr3mygb6iqqnqsg2ra-xsessi= on=20 -r--r--r-- 1 root root 342 Jan 1 1970 /gnu/store/p213clvznwrrrasr3myg= b6iqqnqsg2ra-xsession If you spot something wrong, let me know. Thank you in advance :) --=20 Mario