blob: df78c3943cb3c1e39e2e84e343ebf575427c0fe7 (
about) (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
|
;;; SPDX-License-Identifier: GPL-3.0-or-later
;;; Copyright © 2019 Julien Lepiller <julien@lepiller.eu>
;;; Copyright © 2025 dan <i@dan.games>
(define-module (nonguix download)
#:use-module (guix build-system gnu)
#:use-module (guix derivations)
#:use-module (guix gexp)
#:use-module (guix monads)
#:use-module (guix packages)
#:use-module (guix store)
#:use-module (ice-9 match)
#:export (go-mod-vendor
nuget-restore
unredistributable-url-fetch))
(define* (go-mod-vendor #:key go)
(lambda* (src hash-algo hash #:optional name #:key (system (%current-system)))
"Return a fixed-output derivation to run \"go mod vendor\" against SRC and
use the produced \"vendor\" directory as the result. The derivation is expected
to have HASH of type HASH-ALGO (a symbol). File name of the derivation defaults
to \"vendored-go-dependencies\" and can be specified by NAME."
(define nss-certs
(module-ref (resolve-interface '(gnu packages nss)) 'nss-certs))
(gexp->derivation
(or name "vendored-go-dependencies")
(with-imported-modules %default-gnu-imported-modules
#~(begin
(use-modules (guix build gnu-build-system)
(guix build utils))
;; Support Unicode in file name.
(setlocale LC_ALL "C.UTF-8")
;; Use our bundled Go toolchain.
(setenv "GOTOOLCHAIN" "local")
;; HTTPS support.
(setenv "SSL_CERT_DIR" #+(file-append nss-certs "/etc/ssl/certs"))
((assoc-ref %standard-phases 'unpack) #:source #+src)
(invoke #+(file-append go "/bin/go") "mod" "vendor")
(copy-recursively "vendor" #$output)))
#:system system
#:hash-algo hash-algo
#:hash hash
;; Is a directory.
#:recursive? #t
#:env-vars
'(("GOCACHE" . "/tmp/go-cache")
("GOPATH" . "/tmp/go"))
;; Honor the user's proxy and locale settings.
#:leaked-env-vars
'("GOPROXY"
"http_proxy" "https_proxy"
"LC_ALL" "LC_MESSAGES" "LANG"
"COLUMNS"))))
(define* (nuget-restore #:key dotnet (solutions '()))
(lambda* (src hash-algo hash #:optional name #:key (system (%current-system)))
"Return a fixed-output derivation to run \"dotnet restore\" against SRC
and use the produced \"nuget-packages\" directory as the result. The
derivation is expected to have HASH of type HASH-ALGO (a symbol). File name
of the derivation defaults to \"restored-nuget-dependencies\" and can be
specified by NAME."
(define nss-certs
(module-ref (resolve-interface '(gnu packages nss)) 'nss-certs))
(gexp->derivation
(or name "restored-nuget-dependencies")
(with-imported-modules %default-gnu-imported-modules
#~(begin
(use-modules (guix build gnu-build-system)
(guix build utils))
;; HTTPS support.
(setenv "SSL_CERT_DIR" #+(file-append nss-certs "/etc/ssl/certs"))
;; dotnet fails to run without a HOME directory.
(mkdir "/tmp/dotnet-home")
((assoc-ref %standard-phases 'unpack) #:source #+src)
(if (nil? (list #$@solutions))
(invoke #+(file-append dotnet "/bin/dotnet") "restore")
(for-each (lambda (solution)
(invoke #+(file-append dotnet "/bin/dotnet") "restore" solution))
(list #$@solutions)))
(copy-recursively "/tmp/dotnet-home/.nuget/packages"
(string-append #$output "/nuget-packages"))))
#:system system
#:hash-algo hash-algo
#:hash hash
;; Is a directory.
#:recursive? #t
#:env-vars
'(("HOME" . "/tmp/dotnet-home"))
;; Honor the user's proxy and locale settings.
#:leaked-env-vars
'("http_proxy" "https_proxy"
"LC_ALL" "LC_MESSAGES" "LANG"
"COLUMNS"))))
(define* (unredistributable-url-fetch url hash-algo hash
#:optional name
#:key (system (%current-system))
(guile (default-guile)))
"Return a fixed-output derivation that fetches URL (a string) which is expected
to have HASH of type HASH-ALGO (a symbol). By default, the file name is the base
name of URL; optionally, NAME can specify a different file name.
This is a simpler version of url-fetch from Guix, that doesn't support mirror://
or file:// uris. It is specifically designed to prevent substitution of the
source, for the purpose of downloading copyrighted content you have access to,
but you don't have the right to redistribute. By marking the derivation as non
substitutable, this fetch prevents you from giving others access to the source
if you run a substitute server on your machine."
(define file-name
(match url
((head _ ...)
(basename head))
(_
(basename url))))
(mlet %store-monad ()
(raw-derivation (or name file-name) "builtin:download" '()
#:system system
#:hash-algo hash-algo
#:hash hash
;; Honor the user's proxy and locale settings.
#:leaked-env-vars '("http_proxy" "https_proxy"
"LC_ALL" "LC_MESSAGES" "LANG"
"COLUMNS")
#:env-vars `(("url" . ,(object->string url)))
;; Do not offload because the remote daemon may not support
;; the 'download' builtin.
#:local-build? #t
;; Do not substitute copyrighted material
#:substitutable? #f)))
|