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 ms5.migadu.com with LMTPS id Q+fjKY1x3GPNVgAAbAwnHQ (envelope-from ) for ; Fri, 03 Feb 2023 03:29:33 +0100 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 EBk8J41x3GPhkwAAauVa8A (envelope-from ) for ; Fri, 03 Feb 2023 03:29:33 +0100 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 64927E39F for ; Fri, 3 Feb 2023 03:29:33 +0100 (CET) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pNlot-0004lr-Qe; Thu, 02 Feb 2023 21:28:55 -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 ) id 1pNlos-0004lg-Ds for guix-devel@gnu.org; Thu, 02 Feb 2023 21:28:54 -0500 Received: from mx1.librem.one ([138.201.176.93]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pNloq-0003kH-6z for guix-devel@gnu.org; Thu, 02 Feb 2023 21:28:54 -0500 Received: from smtp.librem.one (unknown [192.241.214.14]) by mx1.librem.one (Postfix) with ESMTPS id D19A581E8A; Thu, 2 Feb 2023 18:20:26 -0800 (PST) Message-ID: Date: Thu, 2 Feb 2023 21:20:22 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.6.0 Subject: Re: Proof of Concept: Import Emacs' use-packaged packages into Guix' manifest.scm To: Mekeor Melire Cc: guix-devel@gnu.org References: <87r0wxbhm5.fsf@posteo.de> <87h6xgwdt8.fsf@librem.one> <87wn50xu5i.fsf@posteo.de> Content-Language: en-US In-Reply-To: <87wn50xu5i.fsf@posteo.de> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=138.201.176.93; envelope-from=mitchellschmeisser@librem.one; helo=mx1.librem.one X-Spam_score_int: -19 X-Spam_score: -2.0 X-Spam_bar: -- X-Spam_report: (-2.0 / 5.0 requ) BAYES_00=-1.9, NICE_REPLY_A=-0.09, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: guix-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Development of GNU Guix and the GNU System distribution." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-to: Mitchell Schmeisser From: Mitchell Schmeisser via "Development of GNU Guix and the GNU System distribution." Errors-To: guix-devel-bounces+larch=yhetil.org@gnu.org Sender: guix-devel-bounces+larch=yhetil.org@gnu.org X-Migadu-Country: US X-Migadu-Flow: FLOW_IN ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1675391373; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=/PahWcXKoQLLf6wqaWpaY/lLH3bxD1nBx6zDHlYOLTw=; b=iyZTAVWVGsRhKSkbZKDPh1nnbohuErOGo2rv7qSWfjzIcQU6TpIqjsCq+m5HD0ZmI9Zb49 iIzgVoMkRABSOgRROJFmI822BGbfyGLz0ExTR9pj/IBmXMsfzpWiJ10nscJJStk7vUqnp2 rvykP+1gQmds9ewqg5ORtp9OHy90xj19n4dE5D1yo9FT+WdzuydXkemfRslNv2ojS7Zq56 axaYVYb7s+RIVW+BfuUsLXIqRXmqd2FZsjQVBZqfLVMRZMdpdV4xmWQFu99v10wxMH8rk6 yBbdvhWF6vhc4dYcZ0KeBkiUa+iikpuXyGIyG+3sLuwkhtTzXVIf6YxeVdoN6A== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=none; dmarc=pass (policy=none) header.from=gnu.org; spf=pass (aspmx1.migadu.com: domain of "guix-devel-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-devel-bounces+larch=yhetil.org@gnu.org" ARC-Seal: i=1; s=key1; d=yhetil.org; t=1675391373; a=rsa-sha256; cv=none; b=CtKj7BRfR/tt4IuUlHTvRags4RjobZOVmM4Wqs9Lb63u6gOZo+tDujdbVxoASxLeGbEPq0 u6FCEvEjuZaAr/n7XjgQCMzSjD3vifBBddOJq897AHpFZ2mUVljmQjF84Sz/PnbeORBbeG KYoXfjKWIpVdG7by9IGFdKr1HOe9TYFLciFbjkq54LAsjvrlvDFXYdmq/4erkWLUIll0QB IgWu4u4p/vlpfHJRFfkq+nrjnOWG292rawlTleuF41ihGLv/+5Mbv21lRz7yPUyBCv9hwe q7QJKshxpIIVuSCz6vN9npUImaP2FsK+ZRNu3VE0m2ve/M2t5mGS/AhPYcGhyA== X-Migadu-Spam-Score: -1.18 X-Spam-Score: -1.18 X-Migadu-Queue-Id: 64927E39F Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=pass (policy=none) header.from=gnu.org; spf=pass (aspmx1.migadu.com: domain of "guix-devel-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-devel-bounces+larch=yhetil.org@gnu.org" X-Migadu-Scanner: scn0.migadu.com X-TUID: Hz6tU9D+W73Q https://github.com/paperclip4465/use-package-ensure-guix Thank you for your kind words, I continued working on it and the repository is here. > What do you think about naming this package/feature > "use-package-ensure-guix" and using that as a prefix for all other > functions and variables -- except for use-package-ensure-guix? I think > "use-package-ensure-guix" would be a good package name because it's > pretty much the only (important) function which this packages aims to > offer. So, … I ended up going with `use-package-guix` but you are probably right about using the longer name. I didn't realize that emacs was really a single namespace lisp and not prefixing your functions was bad practice. > What is the purpose of this long (progn …)? Could we instead simply > write (guix-install-package package)? You are correct, I copied use-package-ensure-elpa to get started and I didn't know what those extra functions did. It works just as well without it. On 2/2/23 04:44, Mekeor Melire wrote: > 2022-12-27 19:51 mitchellschmeisser@librem.one: > >> Mekeor Melire writes: >> >> Here is a naive implementation which extends use-package to use guix >> to ensure packages. > > Thank you very much for this great snippet of code. I just > successfully set it up locally and I'm very happy. > > Would you like to create a public Git repository for this > elisp-package so that we can collaborate on it? If you don't have time > to do it, I can create a public Git repository (with your copyright > note; under GPLv3+?; formally owned by an "organization"). > > Personally, I'm also very much of a noob in things elisp. But > intuitively, I'd suggest these changes: > >> It is a bit annoying at first because it prompts for y/n verification >> for every package but I think this behavior is desirable. > > Personally, I found that behaviour a little tidyous. I'd suggest to > make it at least configurable. > >> #+BEGIN_SRC emacs-lisp >> (require 'guix) >> (require 'guix-profiles) >> (require 'guix-read) >> (require 'guix-ui-package) >> >> >> (defgroup use-package-guix nil > > What do you think about naming this package/feature > "use-package-ensure-guix" and using that as a prefix for all other > functions and variables -- except for use-package-ensure-guix? I think > "use-package-ensure-guix" would be a good package name because it's > pretty much the only (important) function which this packages aims to > offer. So, … > >>   "use-package support for guix" :group 'use-package-ensure) >> >> (defcustom use-package-profile (concat (getenv "HOME") >> "/.emacs.d/guix-profile") > > … this variable would then perhaps be renamed into > "use-package-ensure-guix-profile" or so. > >>   "Location of use-package guix profile" :type 'string :group >> 'use-package-guix) >> >> (defun guix-package-installed-p (package) >>   (bui-assoc-value package 'installed)) >> >> (defun canonicalize-name (package-name) >>   "Make sure package name has \"emacs-\" prefix" >>   (if (string-match "^emacs-.+" package-name) >>       package-name >>     (concat "emacs-" package-name))) >> >> (defun emacs-package->guix-package (package) >>   "Return guix package from package name" >>   (car (guix-output-list-get-entries use-package-profile 'name >>                                      (canonicalize-name >>                                      package)))) >> >> (defun guix-package-id (package) >>   (bui-entry-non-void-value package 'id)) > > (This function could be removed, I think.) > >> (defun guix-install-package (package) >>   (if (guix-package-installed-p package) >>       t >>     (guix-process-package-actions >>      use-package-profile >>      `((install (,(string-to-number (car (split-string (bui-entry-id >> package) ":"))) "out")))) >>      (current-buffer))) >> >> (defun guix-installed-packages () >>   (guix-output-list-get-entries use-package-profile 'installed)) >> >> >> (defun use-package-ensure-guix (name args _state &optional _no-refresh) >>   (dolist (ensure args) >>     (let ((package >>            (or (and (eq ensure t) >>                     (use-package-as-symbol name)) >>                ensure))) >>       (when package >>         (when (consp package) >>           (use-package-pin-package (car package) (cdr package)) >>           (setq package (car package))) >> >>         (let ((package (emacs-package->guix-package >> (use-package-as-string package)))) >>           (unless (guix-package-installed-p package) >>             (condition-case-unless-debug err >>                 (progn >>                   (when (assoc package (bound-and-true-p >> package-pinned-packages)) >>                     (package-read-all-archive-contents)) >>                   (if (assoc package package-archive-contents) >>                       (package-install package) >>                     (package-refresh-contents) >>                     (when (assoc package (bound-and-true-p >> package-pinned-packages)) >>                       (package-read-all-archive-contents)) >>                     (guix-install-package package)) >>                   t) > > What is the purpose of this long (progn …)? Could we instead simply > write (guix-install-package package)? > >> >>               (error (display-warning 'use-package (format >>               "Failed to >>         install %s: %s" name (error-message-string err)) >>         :error))))))))) > > I'd suggest to miss the "error" label on this message, and rather > label it as "warning" (which is the default). We could also suggest to > add ":ensure nil" if it's a built-in feature. (E.g. in case of > (use-package recentf).) > >> ;;;###autoload >> (add-to-list 'load-path (concat use-package-profile >> "/share/emacs/site-lisp")) >> >> (provide 'use-package-guix) >> #+END_SRC > > Finally, I'm not sure if installing packages from my custom local > guix-channel succeeded. I need to retry and investigate more.