-
-
Notifications
You must be signed in to change notification settings - Fork 15.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
5,090 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
pkgs/development/interpreters/racket/package-system/build-helpers/hash-shortcuts.rkt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
#lang racket/base | ||
(provide | ||
/. /.* | ||
/? | ||
/: /:& | ||
/_ | ||
) | ||
|
||
(define /. hash-ref) | ||
|
||
(define /.* | ||
(case-lambda | ||
[(ht key) | ||
(hash-ref ht key)] | ||
[(ht key . further) | ||
(apply /.* (hash-ref ht key) further)])) | ||
|
||
(define /? | ||
(case-lambda | ||
[(ht key) | ||
(hash-has-key? ht key)] | ||
[(ht key . further) | ||
(and (hash-has-key? ht key) | ||
(apply /? (hash-ref ht key) further))])) | ||
|
||
(define /: | ||
(case-lambda | ||
[(ht key val) | ||
(hash-set ht key val)] | ||
[(ht key0 key1 . further) | ||
(hash-set | ||
ht key0 | ||
(apply /: | ||
(if (hash-has-key? ht key0) | ||
(hash-ref ht key0) | ||
(hash-clear ht)) | ||
key1 | ||
further))])) | ||
|
||
(define /:& hash-set*) | ||
|
||
(define /_ | ||
(case-lambda | ||
[(ht key) | ||
(hash-remove ht key)] | ||
[(ht key . further) | ||
(if (hash-has-key? ht key) | ||
(hash-set | ||
ht key | ||
(apply /_ (hash-ref ht key) further)) | ||
ht)])) |
55 changes: 55 additions & 0 deletions
55
pkgs/development/interpreters/racket/package-system/build-helpers/install-packages.rkt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
#lang racket/base | ||
(require | ||
racket/file | ||
racket/function | ||
racket/list | ||
racket/path | ||
racket/string | ||
pkg/lib | ||
setup/setup | ||
|
||
"./stdenv.rkt" | ||
) | ||
|
||
(define to-list | ||
(lambda (x) | ||
(if (list? x) | ||
x | ||
(list x)))) | ||
|
||
(current-pkg-scope 'installation) | ||
|
||
(let* ([pkg-dirs | ||
((compose | ||
(curry map some-system-path->string) | ||
(curry filter directory-exists?) | ||
flatten | ||
(curry map (curry directory-list #:build? #t))) | ||
(common-subpath (get-dep-paths) "share/racket-packages-archive"))] | ||
[pkgs | ||
(for/fold ([acc '()]) | ||
([pkg-dir (in-list pkg-dirs)]) | ||
(let* ([checksum | ||
(let ([checksum-file (build-path pkg-dir ".CHECKSUM")]) | ||
(and (file-exists? checksum-file) | ||
(string-trim (file->string checksum-file))))] | ||
[pkg (pkg-desc pkg-dir 'dir #f checksum #f)]) | ||
(cons pkg acc)))] | ||
[install-result | ||
(with-pkg-lock | ||
(pkg-install | ||
pkgs | ||
#:dep-behavior 'force | ||
#:force? #t | ||
#:ignore-checksums? #t | ||
#:use-cache? #f | ||
))]) | ||
(when (not (eq? install-result 'skip)) | ||
(let [(setup-result | ||
(setup | ||
#:collections (and install-result (map to-list install-result)) | ||
#:make-user? #f | ||
#:fail-fast? #t | ||
))] | ||
(when (and (not setup-result) (env-set? "nix_racket_pkgs_strict_setup")) | ||
(error 'install-packages.rkt "fail to setup installation"))))) |
79 changes: 79 additions & 0 deletions
79
pkgs/development/interpreters/racket/package-system/build-helpers/layering.rkt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
#lang racket/base | ||
(require | ||
racket/list | ||
|
||
"./hash-shortcuts.rkt" | ||
) | ||
(provide | ||
expand-config | ||
config-cascade | ||
) | ||
|
||
(define search~main | ||
(hash | ||
'bin-search-dirs 'bin-dir | ||
'doc-search-dirs 'doc-dir | ||
'gui-bin-search-dirs 'gui-bin-dir | ||
'include-search-dirs 'include-dir | ||
'lib-search-dirs 'lib-dir | ||
'links-search-files 'links-file | ||
'man-search-dirs 'man-dir | ||
'pkgs-search-dirs 'pkgs-dir | ||
'share-search-dirs 'share-dir | ||
)) | ||
|
||
(define main~search | ||
(hash-map/copy search~main | ||
(lambda (k v) (values v k)))) | ||
|
||
(define expand-config | ||
(lambda (config) | ||
(for/fold ([acc config]) | ||
([key (in-hash-keys search~main)]) | ||
(let ([val (/. config key '(#f))]) | ||
(if (not (member #f val)) acc | ||
(/: acc | ||
key | ||
(let* ([main-key (/. search~main key)] | ||
[main-val (/. config main-key)]) | ||
(if main-val | ||
(map (lambda (p) (if p p main-val)) val) | ||
(remove #f val))))))))) | ||
|
||
(define config-cascade | ||
(let ([cascade-two | ||
#| | ||
| It is assumed that `prev-config` has been fully expanded before being | ||
| covered. | ||
|# | ||
(lambda (new-config prev-config) | ||
(for/fold ([acc prev-config]) | ||
([(key val) (in-hash new-config)]) | ||
(cond | ||
[(or (/? search~main key) | ||
(memq key '(base-documentation-packages | ||
catalogs | ||
collects-search-dirs | ||
compiled-file-roots | ||
distribution-documentation-packages))) | ||
(/: acc key (append val (/. prev-config key '())))] | ||
#| | ||
| Append the default value (i.e. `(#f)`) if the search entry is | ||
| not set explicitly while its corresponding "main" entry is. | ||
|# | ||
[(and (/? main~search key) | ||
(not (/? new-config (/. main~search key)))) | ||
(let* ([search-key (/. main~search key)] | ||
[search-val (append '(#f) (/. prev-config search-key '()))]) | ||
(/:& acc | ||
key val | ||
search-key search-val))] | ||
[else | ||
(/: acc key val)])))]) | ||
(lambda (config0 . configs) | ||
(hash-map/copy | ||
(foldl cascade-two config0 configs) | ||
(lambda (k v) | ||
(values | ||
k | ||
(if (list? v) (remove-duplicates v) v))))))) |
Oops, something went wrong.