1
0
mirror of https://codeberg.org/hako/Rosenthal.git synced 2025-07-05 00:05:22 +00:00

utils: Add helper procedures from my dotfiles.

* modules/rosenthal/utils/packages.scm (delete-package-from-list, pkg)
(pkg+out, pkgs, pkgs+out): New procedures.
* modules/rosenthal/utils/file.scm (computed-substitution-with-inputs)
(file-content): New procedures.
This commit is contained in:
Hilton Chain 2025-06-10 22:46:30 +08:00
parent 78aa289f23
commit 0ab2a7eb1a
No known key found for this signature in database
GPG Key ID: ACC66D09CA528292
2 changed files with 49 additions and 8 deletions
modules/rosenthal/utils

View File

@ -0,0 +1,22 @@
;;; SPDX-License-Identifier: GPL-3.0-or-later
;;; Copyright © 2025 Hilton Chain <hako@ultrarare.space>
(define-module (rosenthal utils file)
#:use-module (ice-9 textual-ports)
#:use-module (guix gexp)
#:export (computed-substitution-with-inputs
file-content))
(define (computed-substitution-with-inputs name file inputs)
(with-imported-modules '((guix build utils))
(computed-file
name
#~(begin
(use-modules (guix build utils))
(copy-file #$file #$output)
(substitute* #$output
(("\\$\\$([^\\$]+)\\$\\$" _ path)
(search-path '#$inputs path)))))))
(define (file-content file)
(call-with-input-file (canonicalize-path file) get-string-all))

View File

@ -1,6 +1,7 @@
;;; SPDX-License-Identifier: GPL-3.0-or-later
;;; Copyright © 2015, 2018 Ludovic Courtès <ludo@gnu.org>
;;; Copyright © 2025 Maxim Cournoyer <maxim.cournoyer@gmail.com>
;;; Copyright © 2025 Hilton Chain <hako@ultrarare.space>
(define-module (rosenthal utils packages)
#:use-module (gnu packages)
@ -17,15 +18,13 @@
#:export (rosenthal-patches
%rosenthal-package-module-path
all-rosenthal-packages
rosenthal-disable-updater?))
;;; Commentary:
;;;
;;; This module refines the default value of some parameters from (gnu
;;; packages) and the syntax/procedures using those. This allows
;;; 'search-paths' and friends to work without any user intervention.
;;;
;;; Code:
rosenthal-disable-updater?
delete-package-from-list
pkg
pkg+out
pkgs
pkgs+out))
(define %rosenthal-root-directory
;; This is like %distro-root-directory from (gnu packages), with adjusted
@ -101,5 +100,25 @@ packages, excluding superseded packages."
;; Dismiss deprecated packages but keep hidden packages.
#:select? (negate package-superseded))))
(define (rosenthal-disable-updater? p)
(assq-ref (package-properties p) 'disable-updater?))
(define (delete-package-from-list name lst)
"Return a copy of package list LST, removing packages named NAME."
(filter (lambda (pkg)
(not (string=? name (package-name pkg))))
lst))
(define (pkg spec)
(specification->package spec))
(define (pkg+out spec)
(specification->package+output spec))
(define (pkgs . specs)
(map pkg specs))
(define (pkgs+out . specs)
(map pkg+out specs))