Skip to content

Commit c4dace9

Browse files
committed
Rewrite core-channels-package to guile-build-system
Now core-channels-package doesn't require minutes to rebuild, everytime I want to spawn an environment with guix shell containing this package.
1 parent c5168c3 commit c4dace9

File tree

1 file changed

+77
-11
lines changed

1 file changed

+77
-11
lines changed

env/guile/cs6120/packages.scm

Lines changed: 77 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
(define-module (cs6120 packages)
22
#:use-module (cs6120 channels)
33
#:use-module (gnu packages)
4+
#:use-module (gnu packages base)
45
#:use-module (gnu packages package-management)
56
#:use-module (gnu packages guile)
67
#:use-module (gnu packages gcc)
@@ -12,6 +13,7 @@
1213
#:use-module (guix git-download)
1314
#:use-module (guix channels)
1415
#:use-module (guix build-system channel)
16+
#:use-module (guix build-system guile)
1517
#:use-module ((guix licenses) #:prefix license:)
1618
#:use-module (srfi srfi-1)
1719
#:use-module (nonguix build-system binary)
@@ -48,20 +50,84 @@
4850
(inputs (modify-inputs (package-inputs guix)
4951
(replace "guile" guile-next))))))
5052

51-
(define-public (guix-for-channels channels)
52-
"Return a package corresponding to CHANNELS."
53+
(define (channel->git-checkout channel)
54+
(git-checkout
55+
(url (channel-url channel))
56+
(commit (channel-commit channel))))
57+
58+
(define* (channels-union name channels
59+
#:key
60+
(quiet? #f)
61+
(resolve-collision 'resolve-collision/default))
62+
"Return a directory that is the union of CHANNELS sources."
63+
(define log-port
64+
(if quiet?
65+
(gexp (%make-void-port "w"))
66+
(gexp (current-error-port))))
67+
68+
(computed-file
69+
name
70+
(with-imported-modules '((guix build union))
71+
(gexp
72+
(begin
73+
(use-modules (guix build union)
74+
(srfi srfi-1)) ;for 'first' and 'last'
75+
76+
(define (thing->srcs thing)
77+
(with-input-from-file (string-append thing "/.guix-channel")
78+
(lambda ()
79+
(let ((dirs (assoc-ref (cdr (read)) 'directory)))
80+
(if dirs
81+
(map (lambda (x) (string-append thing "/" x)) dirs)
82+
(list thing))))))
83+
84+
(union-build (ungexp output)
85+
(append-map thing->srcs '#$channels)
86+
87+
#:log-port (ungexp log-port)
88+
#:symlink symlink
89+
#:resolve-collision
90+
(ungexp resolve-collision)))))))
91+
92+
(define (channels->combined-source-code channels)
93+
(channels-union
94+
"channels-sources"
95+
(map channel->git-checkout channels)))
96+
97+
(define-public (package-for-channels channels)
5398
(package
54-
(inherit guix-from-core-channels)
55-
(source (find guix-channel? channels))
56-
(build-system channel-build-system)
57-
(arguments
58-
`(#:channels ,(remove guix-channel? channels)))
59-
(inputs '())
60-
(native-inputs '())
61-
(propagated-inputs '())))
99+
(name "channels")
100+
(version "0.1.0")
101+
(source (channels->combined-source-code
102+
(remove guix-channel? channels)))
103+
(build-system guile-build-system)
104+
(arguments
105+
(list
106+
#:source-directory "."
107+
#:phases
108+
#~(modify-phases %standard-phases
109+
(replace 'unpack
110+
(lambda* (#:key source #:allow-other-keys)
111+
(mkdir "source")
112+
(chdir "source")
113+
(copy-recursively source "."
114+
#:keep-mtime? #t
115+
#:follow-symlinks? #t)
116+
(for-each (lambda (f)
117+
(false-if-exception (make-file-writable f)))
118+
(find-files ".")))))))
119+
(inputs `(("guile" ,guile-next)
120+
("guix" ,guix-from-core-channels)))
121+
(home-page "https://git.sr.ht/~abcdw/rde")
122+
(synopsis "Combined package for channel source and bytecode files")
123+
(description "Combined package for channel source and bytecode files.")
124+
(license license:gpl3+)))
62125

63126
(define-public core-channels-package
64-
(guix-for-channels core-channels))
127+
(package-for-channels core-channels))
128+
129+
;; ((@ (rde api store) build-with-store) core-channels-package)
130+
65131

66132
(define-public deno
67133
(package

0 commit comments

Comments
 (0)