diff options
| author | dan <i@dan.games> | 2025-11-12 12:45:24 +0800 |
|---|---|---|
| committer | Hilton Chain <hako@ultrarare.space> | 2026-01-05 18:58:14 +0800 |
| commit | e00694368d261551cdb226e312e944d9901f96a2 (patch) | |
| tree | 70dee6d038e0c3b41cd8ac7b06ba0be70beb12b8 | |
| parent | bba7eb4b822e3d09d356cfa4166066b9e856c73a (diff) | |
nonguix: Add nuget-restore.
* nonguix/download.scm (nuget-restore): New procedure.
Signed-off-by: Hilton Chain <hako@ultrarare.space>
| -rw-r--r-- | nonguix/download.scm | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/nonguix/download.scm b/nonguix/download.scm index caf52c7..df78c39 100644 --- a/nonguix/download.scm +++ b/nonguix/download.scm @@ -1,5 +1,6 @@ ;;; 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) @@ -10,6 +11,7 @@ #:use-module (guix store) #:use-module (ice-9 match) #:export (go-mod-vendor + nuget-restore unredistributable-url-fetch)) (define* (go-mod-vendor #:key go) @@ -53,6 +55,49 @@ to \"vendored-go-dependencies\" and can be specified by NAME." "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)) |
