From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp11.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id TkW8Fk2Tq2OPZgEAbAwnHQ (envelope-from ) for ; Wed, 28 Dec 2022 01:52:29 +0100 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp11.migadu.com with LMTPS id OGAfFk2Tq2NWVAAA9RJhRA (envelope-from ) for ; Wed, 28 Dec 2022 01:52:29 +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 0F5A154E6 for ; Wed, 28 Dec 2022 01:52:29 +0100 (CET) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pAKfX-0008D1-01; Tue, 27 Dec 2022 19:51:43 -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 1pAKfV-0008CF-Ha for guix-devel@gnu.org; Tue, 27 Dec 2022 19:51:41 -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 1pAKfT-00050K-Lj for guix-devel@gnu.org; Tue, 27 Dec 2022 19:51:41 -0500 Received: from smtp.librem.one (unknown [192.241.214.14]) by mx1.librem.one (Postfix) with ESMTPS id 36E2B81E7C; Tue, 27 Dec 2022 16:51:36 -0800 (PST) To: Mekeor Melire , guix-devel@gnu.org Subject: Re: Proof of Concept: Import Emacs' use-packaged packages into Guix' manifest.scm References: <87r0wxbhm5.fsf@posteo.de> Date: Tue, 27 Dec 2022 19:51:31 -0500 In-Reply-To: <87r0wxbhm5.fsf@posteo.de> (Mekeor Melire's message of "Sun, 18 Dec 2022 01:54:06 +0000") Message-ID: <87h6xgwdt8.fsf@librem.one> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux) Content-Type: text/plain Received-SPF: pass client-ip=138.201.176.93; envelope-from=mitchellschmeisser@librem.one; helo=mx1.librem.one X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, 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-Seal: i=1; s=key1; d=yhetil.org; t=1672188749; a=rsa-sha256; cv=none; b=NO1nIQGe5OH5zYtPJmwp2G1noJ9f4Yet58ErPu3uy6b2TGpUSjP3Y0AxyAu2eohbXklqbH BHbQ5udn0kNWyLh4IjE4ARwQ5QfbTG+V9PzmQE9wFQe1LOju5ibcqsh+JSLsR7AW9SW9sb B8HLYfV88OWwd110ny5ob6osJmrcBW7xtX3tp+d1wKn/a3rbsenwYp6RKS0/vwTuTc4yhM OWozGH4c8Ev8slb+Te2axi8YCaerbZdxoVd0AciJdH6e7K6WcBay5qUledu0zFdP5knqrh lVgFXL9hZFDccVao33PTjGYftsK36DVW5h1q5oyxV8YivYeAOHH1VNb+RxBgrA== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=none; 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"; dmarc=pass (policy=none) header.from=gnu.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1672188749; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:content-type:content-type: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=valT/mQHdmgdkey3dxDkURvh7PvXO7fIQd1rl54noMM=; b=B8fVPG+EkmHVOwHIDXkE+6rHQcEDFbGZGgIKH4DqO2M40bTiD5SCFmjMAhbDdhzZOrNMfJ lE03tcYAjZhXb5DYaSzWeMN/3sHZjOsKYFE0+GuXNy4o8CV2BpHki9p7vIVPPAaeOoQgND Y8LPGbstzvYuNFW2e9HrUVLxZN/hBU/epldos998T1/0f0fPBh8wYl7S2zGI4vJpDACVNX DA1zNwdE++XyKj34us+jI5Fqz3uh7fMA41w1+BgOoi2E14vSGCHghpC16v9mjT3GZc8Tas mT3+qAWGP8/RYioP15m9FwomFffl/zGHNvi/CcC4wSQwcOpBmkeF9YMrv2mRHw== X-Spam-Score: -1.13 X-Migadu-Queue-Id: 0F5A154E6 Authentication-Results: aspmx1.migadu.com; dkim=none; 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"; dmarc=pass (policy=none) header.from=gnu.org X-Migadu-Scanner: scn0.migadu.com X-Migadu-Spam-Score: -1.13 X-TUID: m62L1aTMdn7G Mekeor Melire writes: >> Perhaps you are thinking about this upside down? >> >> emacs has support for guix via `emacs-guix`. >> Would it not make more sense to make a drop in replacement for >> `use-package` which is syntactically identical but instead of >> downloading stuff from the emacs package eco-system it installs it from >> guix into a special emacs managed profile. >> >> Then to use it you would just install the `guix-emacs-use-package` >> instead of `emacs-use-package`. >> >> - Mitchell > > That's an interesting idea, thanks for sharing. I think it'd be nice if you shared it not only with me but with the whole mailing-list (guix-devel). Here is a naive implementation which extends use-package to use guix to ensure packages. It turns out `use-package` allows you to customize the ensure function. This is mostly a plagiarized version of the use-package-ensure-elpa. It creates a profile in ~/.emacs.d./guix-profile by default and every package which is marked `:ensure t` will be prompted for install. Set `use-package-ensure-function` to #'use-package-ensure-guix. #+BEGIN_SRC emacs-lisp (require 'use-package) (require 'use-package-guix) (setq use-package-ensure-function #'use-package-ensure-guix) #+END_SRC This is kind of nice because we can now use the `emacs-guix` interfaces for managing our `use-package` specifications i.e. updates/removal It is a bit annoying at first because it prompts for y/n verification for every package but I think this behavior is desirable. This is my first emacs package so I'm sure there are many things which can be improved. #+BEGIN_SRC emacs-lisp (require 'guix) (require 'guix-profiles) (require 'guix-read) (require 'guix-ui-package) (defgroup use-package-guix nil "use-package support for guix" :group 'use-package-ensure) (defcustom use-package-profile (concat (getenv "HOME") "/.emacs.d/guix-profile") "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)) (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) (error (display-warning 'use-package (format "Failed to install %s: %s" name (error-message-string err)) :error))))))))) ;;;###autoload (add-to-list 'load-path (concat use-package-profile "/share/emacs/site-lisp")) (provide 'use-package-guix) #+END_SRC