diff options
author | Chloe Brown <chloe.brown.00@outlook.com> | 2024-02-20 16:54:10 +0000 |
---|---|---|
committer | Chloe Brown <chloe.brown.00@outlook.com> | 2024-02-20 16:54:59 +0000 |
commit | 648bb0231966db422d6a32121e1ca5c6dbe98ada (patch) | |
tree | 46bc6c48710399ca683fc81d861fe92d287ec245 | |
parent | 2f396f1fc56bd5bc85df008c8ee26da113c3c348 (diff) |
idris2-api: new package
idris2-collie: new package
-rw-r--r-- | yellowsquid/build-system/idris.scm | 121 | ||||
-rw-r--r-- | yellowsquid/build/idris-build-system.scm | 34 | ||||
-rw-r--r-- | yellowsquid/packages/idris.scm | 51 |
3 files changed, 205 insertions, 1 deletions
diff --git a/yellowsquid/build-system/idris.scm b/yellowsquid/build-system/idris.scm new file mode 100644 index 0000000..135fa83 --- /dev/null +++ b/yellowsquid/build-system/idris.scm @@ -0,0 +1,121 @@ +(define-module (yellowsquid build-system idris) + #:use-module (guix build-system) + #:use-module (guix build-system gnu) + #:use-module (guix gexp) + #:use-module (guix monads) + #:use-module (guix packages) + #:use-module (guix search-paths) + #:use-module (guix store) + #:use-module (guix utils) + #:use-module (ice-9 match) + #:use-module (srfi srfi-1) + #:export (%idris-build-system-modules + %default-modules + idris2-build-system)) + +(define (default-idris) + ;; Lazily resolve the binding to avoid a circular dependency + (let ((idris (resolve-interface '(yellowsquid packages idris)))) + (module-ref idris 'idris2))) + +(define %idris-build-system-modules + `((yellowsquid build idris-build-system) + ,@%gnu-build-system-modules)) + +(define %default-modules + '((yellowsquid build idris-build-system) + (guix build utils))) + +(define* (idris2-build name inputs + #:key + source + (phases '%standard-phases) + ipkg-name + (install-source? #t) + (outputs '("out")) + (search-paths '()) + (system (%current-system)) + (guile #f) + (imported-modules %idris-build-system-modules) + (modules %default-modules)) + (define builder + (with-imported-modules imported-modules + #~(begin + (use-modules #$@(sexp->gexp modules)) + + (idris2-build #:name #$name + #:source #+source + #:system #$system + #:ipkg-name #$ipkg-name + #:install-source? #$install-source? + #:phases #$(if (pair? phases) + (sexp->gexp phases) + phases) + #:outputs #$(outputs->gexp outputs) + #:inputs #$(input-tuples->gexp inputs) + #:search-paths '#$(sexp->gexp + (map search-path-specification->sexp + search-paths)))))) + + + (mlet %store-monad ((guile (package->derivation (or guile (default-guile)) + system #:graft? #f))) + (gexp->derivation name builder + #:system system + ;; #:target #f + #:guile-for-build guile))) + +;; TODO: transitive dependencies +(define (expand-idris-inputs inputs) + (filter-map + (match-lambda + ((label (? package? p)) + (list label (package-source p))) + ((label input) + (list label input))) + inputs)) + +(define* (lower name + #:key source inputs native-inputs outputs system target + (idris (default-idris)) + (idris-inputs '()) + #:allow-other-keys + #:rest arguments) + ;; NOTE: derived from (gnu build-system cargo) + ;; + (define private-keywords + '(#:inputs #:native-inputs #:outputs + #:idris #:idris-inputs + #:target + ;; ,@(if target '() '(#:target)) + )) + + ;; TODO: cross-compilation support + (and (not target) + (bag + (name name) + (system system) + (target target) + (host-inputs `(,@(if source + `(("source" ,source)) + '()) + ,@(expand-idris-inputs idris-inputs) + ,@(if target inputs '()))) + (build-inputs `(("idris2" ,idris) + ,@native-inputs + ,@(if target '() inputs) + ,@(if target + (standard-cross-packages target 'host) + '()))) + (target-inputs `(,@(if target + (standard-cross-packages target 'target) + '()))) + (outputs outputs) + (build idris2-build) + (arguments (strip-keyword-arguments private-keywords arguments))))) + +(define idris2-build-system + (build-system + (name 'idris2) + (description "Idris2 build system") + (lower lower))) diff --git a/yellowsquid/build/idris-build-system.scm b/yellowsquid/build/idris-build-system.scm new file mode 100644 index 0000000..fc7f01b --- /dev/null +++ b/yellowsquid/build/idris-build-system.scm @@ -0,0 +1,34 @@ +(define-module (yellowsquid build idris-build-system) + #:use-module ((guix build gnu-build-system) #:prefix gnu:) + #:use-module (guix build utils) + #:export (%standard-phases idris2-build)) + +(define (invoke-idris command ipkg-name) + (invoke "idris2" command (string-append ipkg-name ".ipkg"))) + +(define* (set-idris-prefix #:key outputs #:allow-other-keys) + (let ((prefix-dir (string-append (assoc-ref outputs "out") "/lib"))) + (mkdir-p prefix-dir) + (setenv "IDRIS2_PREFIX" prefix-dir))) + +(define* (build #:key ipkg-name #:allow-other-keys) + (invoke-idris "--build" ipkg-name)) + +(define* (install #:key ipkg-name install-source? #:allow-other-keys) + (invoke-idris (if install-source? "--install-with-src" "--install") ipkg-name) + ;; TODO: install executables correctly + ) + +(define %standard-phases + (modify-phases gnu:%standard-phases + (delete 'bootstrap) + (delete 'configure) + (add-before 'build 'set-idris-prefix set-idris-prefix) + (replace 'build build) + (delete 'check) + (replace 'install install))) + +(define* (idris2-build #:key inputs (phases %standard-phases) + #:allow-other-keys #:rest args) + "Build the given Idris2 package, applying all of PHASES in order." + (apply gnu:gnu-build #:inputs inputs #:phases phases args)) diff --git a/yellowsquid/packages/idris.scm b/yellowsquid/packages/idris.scm index 642f389..3de4218 100644 --- a/yellowsquid/packages/idris.scm +++ b/yellowsquid/packages/idris.scm @@ -1,4 +1,5 @@ (define-module (yellowsquid packages idris) + #:use-module (gnu packages base) #:use-module (gnu packages chez) #:use-module (gnu packages multiprecision) #:use-module (guix build-system gnu) @@ -9,7 +10,8 @@ #:use-module (guix packages) #:use-module (guix utils) #:use-module (ice-9 regex) - #:use-module (srfi srfi-9)) + #:use-module (srfi srfi-9) + #:use-module (yellowsquid build-system idris)) (define-record-type <idris-source> (idris-source origin version tag guix-version) @@ -275,3 +277,50 @@ (inherit (make-idris2 %idris-source-git idris2-support-git #:bootstrap-idris idris2-root)) (properties '((hidden . #t))))) + +;; Idris packages + +(define-public idris2-api + (package + (name "idris2-api") + (version "0.7.0") + (source + (origin + (method git-fetch) + (uri (git-reference (url + "https://github.com/idris-lang/Idris2.git") + (commit (string-append "v" version)))) + (sha256 (base32 "1b6yvarydyk2m1q82hg96f2rfywda42i4cw66jzbm71fvg84ya2k")))) + (build-system idris2-build-system) + (native-inputs (list gnu-make)) + (arguments + '(#:ipkg-name "idris2api" + #:phases + (modify-phases %standard-phases + (add-before 'build 'make-idris-paths + (lambda* _ + (invoke "make" "src/IdrisPaths.idr")))))) + (synopsis "") + (description "") + (license license:bsd-3) + (home-page "https://www.idris-lang.org"))) + +(define-public idris2-collie + (package + (name "idris2-collie") + (version "0.0.0-1") + (source + (let ((commit "e496277f6dd557d31668b2430cfb07c47e841e2f")) + (origin + (method git-fetch) + (uri (git-reference + (url "https://github.com/ohad/collie.git") + (commit commit))) + (file-name (git-file-name name commit)) + (sha256 (base32 "0ka0yj3f1da0hdm5iwii4y23v32y8cfm0mnrm8f6vvy30xazlj3n"))))) + (build-system idris2-build-system) + (arguments '(#:ipkg-name "collie")) + (synopsis "") + (description "") + (license (license:non-copyleft "file://LICENSE")) + (home-page "https://github.com/ohad/collie.git"))) |