diff options
Diffstat (limited to 'guix/build-system')
| -rw-r--r-- | guix/build-system/ant.scm | 2 | ||||
| -rw-r--r-- | guix/build-system/cargo.scm | 135 | ||||
| -rw-r--r-- | guix/build-system/clojure.scm | 4 | ||||
| -rw-r--r-- | guix/build-system/composer.scm | 166 | ||||
| -rw-r--r-- | guix/build-system/gnu.scm | 7 | ||||
| -rw-r--r-- | guix/build-system/guile.scm | 8 | ||||
| -rw-r--r-- | guix/build-system/meson.scm | 16 | ||||
| -rw-r--r-- | guix/build-system/mix.scm | 186 | ||||
| -rw-r--r-- | guix/build-system/perl.scm | 4 | ||||
| -rw-r--r-- | guix/build-system/r.scm | 2 | ||||
| -rw-r--r-- | guix/build-system/vim.scm | 170 | ||||
| -rw-r--r-- | guix/build-system/zig.scm | 119 |
12 files changed, 766 insertions, 53 deletions
diff --git a/guix/build-system/ant.scm b/guix/build-system/ant.scm index e191fd3c99..84bf951fab 100644 --- a/guix/build-system/ant.scm +++ b/guix/build-system/ant.scm @@ -103,6 +103,7 @@ (build-target "jar") (jar-name #f) (main-class #f) + (use-java-modules? #f) (test-include (list "**/*Test.java")) (test-exclude (list "**/Abstract*.java")) (source-dir "src") @@ -131,6 +132,7 @@ #:build-target #$build-target #:jar-name #$jar-name #:main-class #$main-class + #:use-java-modules? #$use-java-modules? #:test-include (list #$@test-include) #:test-exclude (list #$@test-exclude) #:source-dir #$source-dir diff --git a/guix/build-system/cargo.scm b/guix/build-system/cargo.scm index 912400a191..c029cc1dda 100644 --- a/guix/build-system/cargo.scm +++ b/guix/build-system/cargo.scm @@ -55,12 +55,18 @@ to NAME and VERSION." (string-append crate-url name "/" version "/download")) -(define (default-rust) +(define (default-rust target) "Return the default Rust package." ;; Lazily resolve the binding to avoid a circular dependency. (let ((rust (resolve-interface '(gnu packages rust)))) (module-ref rust 'rust))) +(define (default-rust-sysroot target) + "Return the default Rust sysroot for <target>." + ;; Lazily resolve the binding to avoid a circular dependency. + (let ((module (resolve-interface '(gnu packages rust)))) + (module-ref module 'make-rust-sysroot))) + (define %cargo-utils-modules ;; Build-side modules imported by default. `((guix build cargo-utils) @@ -126,6 +132,69 @@ to NAME and VERSION." #:graft? #f #:guile-for-build guile)) +(define* (cargo-cross-build name + #:key + source target + build-inputs target-inputs host-inputs + (tests? #f) + (test-target #f) + (vendor-dir "guix-vendor") + (cargo-build-flags ''("--release")) + (cargo-test-flags ''("--release")) + (cargo-package-flags ''("--no-metadata" "--no-verify")) + (features ''()) + (skip-build? #f) + (install-source? (not (target-mingw? target))) + (phases '%standard-phases) + (outputs '("out")) + (search-paths '()) + (native-search-paths '()) + (system (%current-system)) + (guile #f) + (imported-modules %cargo-build-system-modules) + (modules '((guix build cargo-build-system) + (guix build utils)))) + "Cross-build SOURCE using CARGO, and with INPUTS." + + (define builder + (with-imported-modules imported-modules + #~(begin + (use-modules #$@(sexp->gexp modules)) + + (cargo-build #:name #$name + #:source #+source + #:target #+target + #:system #$system + #:test-target #$test-target + #:vendor-dir #$vendor-dir + #:cargo-build-flags #$(sexp->gexp cargo-build-flags) + #:cargo-test-flags #$(sexp->gexp cargo-test-flags) + #:cargo-package-flags #$(sexp->gexp cargo-package-flags) + #:features #$(sexp->gexp features) + #:skip-build? #$skip-build? + #:install-source? #$install-source? + #:tests? #$(and tests? (not skip-build?)) + #:phases #$(if (pair? phases) + (sexp->gexp phases) + phases) + #:outputs #$(outputs->gexp outputs) + #:inputs (append #$(input-tuples->gexp host-inputs) + #+(input-tuples->gexp target-inputs)) + #:native-inputs #+(input-tuples->gexp build-inputs) + #:make-dynamic-linker-cache? #f ;cross-compiling + #:search-paths '#$(sexp->gexp + (map search-path-specification->sexp + search-paths)) + #:native-search-paths '#$(sexp->gexp + (map search-path-specification->sexp + native-search-paths)))))) + + (gexp->derivation name builder + #:system system + #:target target + #:graft? #f + #:guile-for-build guile)) + (define (package-cargo-inputs p) (apply (lambda* (#:key (cargo-inputs '()) #:allow-other-keys) @@ -235,7 +304,8 @@ any dependent crates. This can be a benefits: (define* (lower name #:key source inputs native-inputs outputs system target - (rust (default-rust)) + (rust (default-rust target)) + (rust-sysroot (default-rust-sysroot target)) (cargo-inputs '()) (cargo-development-inputs '()) #:allow-other-keys @@ -243,28 +313,49 @@ any dependent crates. This can be a benefits: "Return a bag for NAME." (define private-keywords - '(#:target #:rust #:inputs #:native-inputs #:outputs - #:cargo-inputs #:cargo-development-inputs)) + `(#:rust #:inputs #:native-inputs #:outputs + #:cargo-inputs #:cargo-development-inputs + #:rust-sysroot + ,@(if target '() '(#:target)))) + + (bag + (name name) + (system system) + (target target) + (host-inputs `(,@(if source + `(("source" ,source)) + '()) + + ;,@(if target '() inputs) + ,@(if target inputs '()) + + ,@(expand-crate-sources cargo-inputs cargo-development-inputs))) + (build-inputs `(("cargo" ,rust "cargo") + ("rustc" ,rust) + + ,@native-inputs + ;,@(if target inputs '()) + ,@(if target '() inputs) + ;,@inputs - (and (not target) ;; TODO: support cross-compilation - (bag - (name name) - (system system) - (target target) - (host-inputs `(,@(if source - `(("source" ,source)) - '()) - ,@inputs + ,@(if target + ;; Use the standard cross inputs of + ;; 'gnu-build-system'. + (standard-cross-packages target 'host) + '()) + ;; Keep the standard inputs of 'gnu-build-system' + ,@(standard-packages))) + (target-inputs `(,@(if target + (standard-cross-packages target 'target) + '()) - ;; Keep the standard inputs of 'gnu-build-system' - ,@(standard-packages))) - (build-inputs `(("cargo" ,rust "cargo") - ("rustc" ,rust) - ,@(expand-crate-sources cargo-inputs cargo-development-inputs) - ,@native-inputs)) - (outputs outputs) - (build cargo-build) - (arguments (strip-keyword-arguments private-keywords arguments))))) + ;; This provides a separate sysroot for the regular rustc + ,@(if target + `(("rust-sysroot" ,(rust-sysroot target))) + '()))) + (outputs outputs) + (build (if target cargo-cross-build cargo-build)) + (arguments (strip-keyword-arguments private-keywords arguments)))) (define cargo-build-system (build-system diff --git a/guix/build-system/clojure.scm b/guix/build-system/clojure.scm index fb897356bc..037fcaf21d 100644 --- a/guix/build-system/clojure.scm +++ b/guix/build-system/clojure.scm @@ -83,8 +83,8 @@ #:clojure #:jdk #:zip))) (if target - (error "No cross-compilation for clojure-build-system yet: LOWER" - target) ; FIXME + #f ; FIXME: No cross-compilation for + ; clojure-build-system yet (bag (name name) (system system) (host-inputs `(,@(if source diff --git a/guix/build-system/composer.scm b/guix/build-system/composer.scm new file mode 100644 index 0000000000..2ad7bbb36a --- /dev/null +++ b/guix/build-system/composer.scm @@ -0,0 +1,166 @@ +;;; GNU Guix --- Functional package management for GNU +;;; Copyright © 2019 Julien Lepiller <julien@lepiller.eu> +;;; +;;; This file is part of GNU Guix. +;;; +;;; GNU Guix is free software; you can redistribute it and/or modify it +;;; under the terms of the GNU General Public License as published by +;;; the Free Software Foundation; either version 3 of the License, or (at +;;; your option) any later version. +;;; +;;; GNU Guix is distributed in the hope that it will be useful, but +;;; WITHOUT ANY WARRANTY; without even the implied warranty of +;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;;; GNU General Public License for more details. +;;; +;;; You should have received a copy of the GNU General Public License +;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>. + +(define-module (guix build-system composer) + #:use-module (guix store) + #:use-module (guix utils) + #:use-module (guix derivations) + #:use-module (guix search-paths) + #:use-module (guix build-system) + #:use-module (guix build-system gnu) + #:use-module (guix gexp) + #:use-module (guix packages) + #:use-module (gnu packages) + #:use-module (ice-9 match) + #:use-module (srfi srfi-1) + #:export (%composer-build-system-modules + lower + composer-build + composer-build-system)) + +;; Commentary: +;; +;; Standard build procedure for PHP packages using Composer. This is implemented +;; as an extension of `gnu-build-system'. +;; +;; Code: + +(define (default-php) + "Return the default PHP package." + + ;; Do not use `@' to avoid introducing circular dependencies. + (let ((module (resolve-interface '(gnu packages php)))) + (module-ref module 'php))) + +(define (default-findclass) + "Return the default findclass script." + (search-auxiliary-file "findclass.php")) + +(define (default-composer-classloader) + "Return the default composer-classloader package." + + ;; Do not use `@' to avoid introducing circular dependencies. + (let ((module (resolve-interface '(gnu packages php-xyz)))) + (module-ref module 'composer-classloader))) + +(define %composer-build-system-modules + ;; Build-side modules imported by default. + `((guix build composer-build-system) + (guix build union) + ,@%gnu-build-system-modules)) + +(define* (lower name + #:key source inputs native-inputs outputs system target + (php (default-php)) + (composer-classloader (default-composer-classloader)) + (findclass (default-findclass)) + #:allow-other-keys + #:rest arguments) + "Return a bag for NAME." + (define private-keywords + '(#:target #:php #:composer-classloader #:findclass #:inputs #:native-inputs)) + + (and (not target) ;XXX: no cross-compilation + (bag + (name name) + (system system) + (host-inputs `(,@(if source + `(("source" ,source)) + '()) + ,@inputs + + ;; Keep the standard inputs of 'gnu-build-system'. + ,@(standard-packages))) + (build-inputs `(("php" ,php) + ("findclass.php" ,findclass) + ("composer-classloader" ,composer-classloader) + ,@native-inputs)) + (outputs outputs) + (build composer-build) + (arguments (strip-keyword-arguments private-keywords arguments))))) + +(define* (composer-build name inputs + #:key + guile source + (outputs '("out")) + (configure-flags ''()) + (search-paths '()) + (out-of-source? #t) + (composer-file "composer.json") + (tests? #t) + (test-target "test") + (test-flags ''()) + (install-target "install") + (validate-runpath? #t) + (patch-shebangs? #t) + (strip-binaries? #t) + (strip-flags #~'("--strip-debug")) + (strip-directories #~'("lib" "lib64" "libexec" + "bin" "sbin")) + (phases '(@ (guix build composer-build-system) + %standard-phases)) + (system (%current-system)) + (imported-modules %composer-build-system-modules) + (modules '((guix build composer-build-system) + (guix build utils)))) + "Build SOURCE using PHP, and with INPUTS. This assumes that SOURCE provides +a 'composer.json' file as its build system." + (define guile-json + (module-ref (resolve-interface '(gnu packages guile)) + 'guile-json-4)) + + (define builder + (with-extensions (list guile-json) + (with-imported-modules imported-modules + #~(begin + (use-modules #$@(sexp->gexp modules)) + + #$(with-build-variables inputs outputs + #~(composer-build + #:source #$source + #:system #$system + #:outputs %outputs + #:inputs %build-inputs + #:search-paths '#$(map search-path-specification->sexp + search-paths) + #:phases #$phases + #:out-of-source? #$out-of-source? + #:composer-file #$composer-file + #:tests? #$tests? + #:test-target #$test-target + #:test-flags #$test-flags + #:install-target #$install-target + #:validate-runpath? #$validate-runpath? + #:patch-shebangs? #$patch-shebangs? + #:strip-binaries? #$strip-binaries? + #:strip-flags #$strip-flags + #:strip-directories #$strip-directories)))))) + + (gexp->derivation name builder + #:system system + #:target #f + #:graft? #f + #:guile-for-build guile)) + +(define composer-build-system + (build-system + (name 'composer) + (description "The standard Composer build system") + (lower lower))) + +;;; composer.scm ends here diff --git a/guix/build-system/gnu.scm b/guix/build-system/gnu.scm index c1aa187c42..cdbb547773 100644 --- a/guix/build-system/gnu.scm +++ b/guix/build-system/gnu.scm @@ -460,10 +460,13 @@ is one of `host' or `target'." `(("cross-gcc" ,(gcc target #:xbinutils (binutils target) #:libc libc)) - ("cross-libc" ,libc) + ;; Some targets don't have a libc. (e.g. *-elf targets). + ,@(if libc + `(("cross-libc" ,libc)) + '()) ;; MinGW's libc doesn't have a "static" output. - ,@(if (member "static" (package-outputs libc)) + ,@(if (and libc (member "static" (package-outputs libc))) `(("cross-libc:static" ,libc "static")) '())))))))) diff --git a/guix/build-system/guile.scm b/guix/build-system/guile.scm index 1bd292e267..bd3bb1c870 100644 --- a/guix/build-system/guile.scm +++ b/guix/build-system/guile.scm @@ -88,7 +88,8 @@ (compile-flags %compile-flags) (imported-modules %guile-build-system-modules) (modules '((guix build guile-build-system) - (guix build utils)))) + (guix build utils))) + (substitutable? #t)) "Build SOURCE using Guile taken from the native inputs, and with INPUTS." (define builder (with-imported-modules imported-modules @@ -114,6 +115,7 @@ #:system system #:target #f #:graft? #f + #:substitutable? substitutable? #:guile-for-build guile))) (define* (guile-cross-build name @@ -133,7 +135,8 @@ (compile-flags %compile-flags) (imported-modules %guile-build-system-modules) (modules '((guix build guile-build-system) - (guix build utils)))) + (guix build utils))) + (substitutable? #t)) (define builder (with-imported-modules imported-modules #~(begin @@ -173,6 +176,7 @@ #:system system #:target target #:graft? #f + #:substitutable? substitutable? #:guile-for-build guile))) (define guile-build-system diff --git a/guix/build-system/meson.scm b/guix/build-system/meson.scm index 7c617bffb0..bf9ca15ecc 100644 --- a/guix/build-system/meson.scm +++ b/guix/build-system/meson.scm @@ -49,11 +49,13 @@ for TRIPLET." `((system . ,(cond ((target-hurd? triplet) "gnu") ((target-linux? triplet) "linux") ((target-mingw? triplet) "windows") + ((target-avr? triplet) "none") (#t (error "meson: unknown operating system")))) (cpu_family . ,(cond ((target-x86-32? triplet) "x86") ((target-x86-64? triplet) "x86_64") ((target-arm32? triplet) "arm") ((target-aarch64? triplet) "aarch64") + ((target-avr? triplet) "avr") ((target-mips64el? triplet) "mips64") ((target-powerpc? triplet) (if (target-64bit? triplet) @@ -66,6 +68,7 @@ for TRIPLET." ((target-x86-64? triplet) "x86_64") ((target-aarch64? triplet) "armv8-a") ((target-arm32? triplet) "armv7") + ((target-avr? triplet) "avr") ;; According to #mesonbuild on OFTC, there does not appear ;; to be an official-ish list of CPU types recognised by ;; Meson, the "cpu" field is not used by Meson itself and @@ -89,6 +92,13 @@ TRIPLET." (ld . ,(string-append triplet "-ld")) (strip . ,(string-append triplet "-strip")))) +(define (make-built-in-options-alist triplet) + (if (target-avr? triplet) + `((b_pie . #f) + (b_staticpic . #f) + (default_library . "static")) + '())) + (define (make-cross-file triplet) (computed-file "cross-file" (with-imported-modules '((guix build meson-configuration)) @@ -99,7 +109,9 @@ TRIPLET." (write-section-header port "host_machine") (write-assignments port '#$(make-machine-alist triplet)) (write-section-header port "binaries") - (write-assignments port '#$(make-binaries-alist triplet)))))))) + (write-assignments port '#$(make-binaries-alist triplet)) + (write-section-header port "built-in options") + (write-assignments port '#$(make-built-in-options-alist triplet)))))))) (define %meson-build-system-modules ;; Build-side modules imported by default. @@ -182,6 +194,7 @@ TRIPLET." (imported-modules %meson-build-system-modules) (modules '((guix build meson-build-system) (guix build utils))) + (substitutable? #t) allowed-references disallowed-references) "Build SOURCE using MESON, and with INPUTS, assuming that SOURCE @@ -266,6 +279,7 @@ has a 'meson.build' file." (imported-modules %meson-build-system-modules) (modules '((guix build meson-build-system) (guix build utils))) + (substitutable? #t) allowed-references disallowed-references) "Cross-build SOURCE for TARGET using MESON, and with INPUTS, assuming that diff --git a/guix/build-system/mix.scm b/guix/build-system/mix.scm new file mode 100644 index 0000000000..1b04053d70 --- /dev/null +++ b/guix/build-system/mix.scm @@ -0,0 +1,186 @@ +;;; GNU Guix --- Functional package management for GNU +;;; Copyright © 2023 Pierre-Henry Fröhring <contact@phfrohring.com> +;;; +;;; This file is part of GNU Guix. +;;; +;;; GNU Guix is free software; you can redistribute it and/or modify it +;;; under the terms of the GNU General Public License as published by +;;; the Free Software Foundation; either version 3 of the License, or (at +;;; your option) any later version. +;;; +;;; GNU Guix is distributed in the hope that it will be useful, but +;;; WITHOUT ANY WARRANTY; without even the implied warranty of +;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;;; GNU General Public License for more details. +;;; +;;; You should have received a copy of the GNU General Public License +;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>. + +;; Commentary: +;; +;; Standard build procedure for Elixir packages using 'mix'. This is +;; implemented as an extension of 'gnu-build-system'. +;; +;; Code: + +(define-module (guix build-system mix) + #:use-module (guix build mix-build-system) + #:use-module (guix build-system gnu) + #:use-module (guix build-system) + #: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) + #:use-module (srfi srfi-26) + #:export (mix-build-system hexpm-uri)) + +;; Lazily resolve bindings to avoid circular dependencies. +(define (default-glibc-utf8-locales) + (let* ((base (resolve-interface '(gnu packages base)))) + (module-ref base 'glibc-utf8-locales))) + +(define (default-elixir-hex) + (let ((elixir (resolve-interface '(gnu packages elixir)))) + (module-ref elixir 'elixir-hex))) + +(define (default-rebar3) + (let ((erlang (resolve-interface '(gnu packages erlang)))) + (module-ref erlang 'rebar3))) + +(define (default-elixir) + (let ((elixir (resolve-interface '(gnu packages elixir)))) + (module-ref elixir 'elixir))) + +(define* (strip-prefix name #:optional (prefix "elixir-")) + "Return NAME without the prefix PREFIX." + (if (string-prefix? prefix name) + (string-drop name (string-length prefix)) + name)) + +(define (hexpm-uri name version) + "Return the URI where to fetch the sources of a Hex package NAME at VERSION. +NAME is the name of the package which should look like: elixir-pkg-name-X.Y.Z +See: https://github.com/hexpm/specifications/blob/main/endpoints.md" + ((compose + (cute string-append "https://repo.hex.pm/tarballs/" <> "-" version ".tar") + (cute string-replace-substring <> "-" "_") + strip-prefix) + name)) + +;; A number of environment variables specific to the Mix build system are +;; reflected here. They are documented at +;; https://hexdocs.pm/mix/1.15.7/Mix.html#module-environment-variables. Other +;; parameters located in mix.exs are defined at +;; https://hexdocs.pm/mix/1.15.7/Mix.Project.html#module-configuration +(define* (mix-build name + inputs + #:key + source + (tests? #t) + (mix-path #f) ;See MIX_PATH. + (mix-exs "mix.exs") ;See MIX_EXS. + (build-per-environment #t) ;See :build_per_environment. + (phases '%standard-phases) + (outputs '("out")) + (search-paths '()) + (system (%current-system)) + (guile #f) + (imported-modules `((guix build mix-build-system) + ,@%gnu-build-system-modules)) + (modules '((guix build mix-build-system) + (guix build utils)))) + "Build SOURCE using Elixir, and with INPUTS." + + ;; Check the documentation of :build_per_environment here: + ;; https://hexdocs.pm/mix/1.15.7/Mix.Project.html#module-configuration And + ;; "Environments" here: + ;; https://hexdocs.pm/mix/1.15.7/Mix.html#module-environments + (define mix-environments + (if build-per-environment + `("prod" ,@(if tests? '("test") '())) + '("shared"))) + + (define builder + (with-imported-modules imported-modules + #~(begin + + (use-modules #$@(sexp->gexp modules)) + + #$(with-build-variables inputs outputs + #~(mix-build #:name #$name + #:source #+source + #:system #$system + #:tests? #$tests? + #:mix-path #$mix-path + #:mix-exs #$mix-exs + #:mix-environments '#$mix-environments + #:build-per-environment #$build-per-environment + #:phases #$(if (pair? phases) + (sexp->gexp phases) + phases) + #:outputs %outputs + #:search-paths '#$(sexp->gexp + (map + search-path-specification->sexp + search-paths)) + #:inputs + %build-inputs))))) + + (mlet %store-monad ((guile (package->derivation (or guile (default-guile)) + system + #:graft? #f))) + (gexp->derivation name + builder + #:system system + #:graft? #f ;consistent with 'gnu-build' + #:target #f + #:guile-for-build guile))) + +(define* (lower name + #:key + (elixir (default-elixir)) + (elixir-hex (default-elixir-hex)) + (glibc-utf8-locales (default-glibc-utf8-locales)) + (inputs '()) + (native-inputs '()) + (propagated-inputs '()) + (rebar3 (default-rebar3)) + (tests? #t) + outputs + source + system + target + #:allow-other-keys #:rest arguments) + "Return a bag for NAME." + (let ((private-keywords + '(#:inputs #:native-inputs + #:outputs #:system #:target + #:elixir #:elixir-hex #:glibc-utf8-locales + #:rebar3 #:erlang)) + (build-inputs + `(,@(standard-packages) + ("glibc-utf8-locales" ,glibc-utf8-locales) + ("erlang" ,(lookup-package-input elixir "erlang")) + ("rebar3" ,rebar3) + ("elixir" ,elixir) + ("elixir-hex" ,elixir-hex) + ,@inputs + ,@native-inputs))) + (bag (name name) + (system system) + (build-inputs build-inputs) + (host-inputs (if target inputs '())) + (outputs outputs) + (build mix-build) + (arguments (strip-keyword-arguments private-keywords arguments))))) + +(define mix-build-system + (build-system (name 'mix) + (description "The standard Mix build system") + (lower lower))) + +;;; mix.scm ends here diff --git a/guix/build-system/perl.scm b/guix/build-system/perl.scm index 7c6deb34bf..0d5493ab90 100644 --- a/guix/build-system/perl.scm +++ b/guix/build-system/perl.scm @@ -133,7 +133,9 @@ provides a `Makefile.PL' file as its build system." search-paths)) #:make-maker? #$make-maker? #:make-maker-flags #$make-maker-flags - #:module-build-flags #$(sexp->gexp module-build-flags) + #:module-build-flags #$(if (pair? module-build-flags) + (sexp->gexp module-build-flags) + module-build-flags) #:phases #$(if (pair? phases) (sexp->gexp phases) phases) diff --git a/guix/build-system/r.scm b/guix/build-system/r.scm index 657346bea3..7ab4db82b6 100644 --- a/guix/build-system/r.scm +++ b/guix/build-system/r.scm @@ -60,7 +60,7 @@ release corresponding to NAME and VERSION." "/src/contrib/" name "_" version ".tar.gz") ;; TODO: use %bioconductor-version from (guix import cran) - (string-append "https://bioconductor.org/packages/3.17" + (string-append "https://bioconductor.org/packages/3.18" type-url-part "/src/contrib/" name "_" version ".tar.gz")))) diff --git a/guix/build-system/vim.scm b/guix/build-system/vim.scm new file mode 100644 index 0000000000..dddf7ea14b --- /dev/null +++ b/guix/build-system/vim.scm @@ -0,0 +1,170 @@ +;;; GNU Guix --- Functional package management for GNU +;;; Copyright © 2022 Jonathan Scoresby <me@jonscoresby.com> +;;; Copyright © 2023 Efraim Flashner <efraim@flashner.co.il> +;;; +;;; This file is part of GNU Guix. +;;; +;;; GNU Guix is free software; you can redistribute it and/or modify it +;;; under the terms of the GNU General Public License as published by +;;; the Free Software Foundation; either version 3 of the License, or (at +;;; your option) any later version. +;;; +;;; GNU Guix is distributed in the hope that it will be useful, but +;;; WITHOUT ANY WARRANTY; without even the implied warranty of +;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;;; GNU General Public License for more details. +;;; +;;; You should have received a copy of the GNU General Public License +;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>. + +(define-module (guix build-system vim) + #:use-module (guix store) + #:use-module (guix utils) + #:use-module (guix gexp) + #:use-module (guix monads) + #:use-module (guix packages) + #:use-module (guix search-paths) + #:use-module (guix build-system) + #:use-module (guix build-system copy) + #:use-module (guix build-system gnu) + #:export (%vim-build-system-modules vim-build vim-build-system)) + +;; Commentary: +;; +;; Standard package installer for vim and neovim plugins. +;; This is implemented as an extension of the `copy-build-system' +;; and takes advantage of vim and neovim's built-in package manager. +;; It extends the installation procedure from the copy-build-system +;; to put files in the correct place and then generates help tags. +;; +;; Code: + +(define %vim-build-system-modules + ;; Build-side modules imported by default. + `((guix build vim-build-system) + ,@%copy-build-system-modules)) + +(define (default-vim) + "Return the default Vim package." + ;; Lazily resolve the binding to avoid a circular dependency. + (let ((vim (resolve-interface '(gnu packages vim)))) + (module-ref vim 'vim))) + +(define (default-neovim) + "Return the default Neovim package." + (let ((vim (resolve-interface '(gnu packages vim)))) + (module-ref vim 'neovim))) + +(define* (lower name + #:key source + inputs + native-inputs + outputs + system + target + (vim? #f) + (neovim? #f) + (plugin-name name) + (vim (default-vim)) + (neovim (default-neovim)) + #:allow-other-keys #:rest arguments) + "Return a bag for NAME." + (let* ((private-keywords '(#:target #:vim #:neovim #:inputs #:native-inputs)) + (vim? (or (string-prefix? "vim-" name) + vim?)) + (neovim? (or (string-prefix? "neovim-" name) + neovim?)) + (vim-inputs (append (if vim? + `(("vim" ,vim)) + '()) + (if neovim? + `(("neovim" ,neovim)) + '()))) + (vim-arguments (append arguments + `(#:vim? ,vim? + #:neovim? ,neovim?)))) + (bag (name name) + (system system) + (host-inputs `(,@(if source + `(("source" ,source)) + '()) ,@inputs + + ;; Keep the standard inputs of 'gnu-build-system'. + ,@(standard-packages))) + (build-inputs `(,@vim-inputs ,@native-inputs)) + (outputs outputs) + (build vim-build) + (arguments (strip-keyword-arguments private-keywords vim-arguments))))) + +(define* (vim-build name inputs + #:key guile + source + (vim? #f) + (neovim? #f) + (mode "start") + (plugin-name name) + (install-plan ''()) + (phases '(@ (guix build vim-build-system) %standard-phases)) + (outputs '("out")) + (out-of-source? #t) + (tests? #t) + (validate-runpath? #t) + (patch-shebangs? #t) + (strip-binaries? #t) + (strip-flags %strip-flags) + (strip-directories %strip-directories) + (search-paths '()) + (system (%current-system)) + (substitutable? #t) + (imported-modules %vim-build-system-modules) + (modules '((guix build vim-build-system) + (guix build utils)))) + + (define build + (with-imported-modules imported-modules + #~(begin + (use-modules #$@modules) + #$(with-build-variables inputs outputs + #~(vim-build #:name #$name + #:vim? #$vim? + #:neovim? #$neovim? + #:mode #$mode + #:plugin-name #$plugin-name + #:install-plan #$(if (pair? install-plan) + (sexp->gexp install-plan) + install-plan) + #:source #+source + #:system #$system + #:phases #$(if (pair? phases) + (sexp->gexp phases) + phases) + #:outputs %outputs + #:search-paths '#$(sexp->gexp + (map search-path-specification->sexp + search-paths)) + #:inputs %build-inputs + #:out-of-source? #$out-of-source? + #:tests? #$tests? + #:validate-runpath? #$validate-runpath? + #:patch-shebangs? #$patch-shebangs? + #:strip-binaries? #$strip-binaries? + #:strip-flags #$strip-flags + #:strip-directories #$strip-directories))))) + + (mlet %store-monad + ((guile (package->derivation (or guile (default-guile)) + system #:graft? #f))) + (gexp->derivation name + build + #:system system + #:target #f + #:graft? #f + #:substitutable? substitutable? + #:guile-for-build guile))) + +(define vim-build-system + (build-system (name 'vim) + (description "The standard Vim build system") + (lower lower))) + +;;; vim.scm ends here diff --git a/guix/build-system/zig.scm b/guix/build-system/zig.scm index 16b8a712cc..1fa4782a2e 100644 --- a/guix/build-system/zig.scm +++ b/guix/build-system/zig.scm @@ -39,7 +39,6 @@ (define %zig-build-system-modules ;; Build-side modules imported by default. `((guix build zig-build-system) - (guix build syscalls) ,@%gnu-build-system-modules)) (define* (zig-build name inputs @@ -84,6 +83,79 @@ #:system system #:guile-for-build guile))) +(define* (zig-cross-build name + #:key + source target + build-inputs target-inputs host-inputs + (phases '%standard-phases) + (outputs '("out")) + (search-paths '()) + (native-search-paths '()) + (tests? #t) + (test-target #f) + (zig-build-flags ''()) + (zig-test-flags ''()) + (zig-destdir "out") + (zig-test-destdir "test-out") + (zig-release-type #f) + (system (%current-system)) + (guile #f) + (imported-modules %zig-build-system-modules) + (modules '((guix build zig-build-system) + (guix build utils)))) + "Build SOURCE using Zig, and with INPUTS." + (define builder + (with-imported-modules imported-modules + #~(begin + (use-modules #$@(sexp->gexp modules)) + + (define %build-host-inputs + #+(input-tuples->gexp build-inputs)) + + (define %build-target-inputs + (append #$(input-tuples->gexp host-inputs) + #+(input-tuples->gexp target-inputs))) + + (define %build-inputs + (append %build-host-inputs %build-target-inputs)) + + (define %outputs + #$(outputs->gexp outputs)) + + (zig-build #:name #$name + #:source #+source + #:system #$system + #:phases #$phases + #:outputs %outputs + #:target #$target + #:test-target #$test-target + #:inputs %build-target-inputs + #:native-inputs %build-host-inputs + #:search-paths '#$(map search-path-specification->sexp + search-paths) + #:native-search-paths '#$(map + search-path-specification->sexp + native-search-paths) + #:zig-build-flags #$zig-build-flags + #:zig-test-flags #$zig-test-flags + #:zig-release-type #$zig-release-type + #:zig-destdir #$zig-destdir + #:zig-test-destdir #$zig-test-destdir + #:tests? #$tests? + #: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 target + #:graft? #f + #:substitutable? substitutable? + #:guile-for-build guile))) + + (define* (lower name #:key source inputs native-inputs outputs system target (zig (default-zig)) @@ -94,27 +166,30 @@ (define private-keywords '(#:target #:zig #:inputs #:native-inputs #:outputs)) - ;; TODO: support cross-compilation - ;; It's as simple as adding some build flags to `zig-build-flags` - ;; -Dtarget=aarch64-linux-musl, for example. - (and (not target) - (bag - (name name) - (system system) - (target target) - (host-inputs `(,@(if source - `(("source" ,source)) - '()) - ,@inputs - - ;; Keep the standard inputs of 'gnu-build-system' - ;; TODO: do we need this? - ,@(standard-packages))) - (build-inputs `(("zig" ,zig) - ,@native-inputs)) - (outputs outputs) - (build zig-build) - (arguments (strip-keyword-arguments private-keywords arguments))))) + (bag + (name name) + (system system) + (target target) + (build-inputs `(,@(if source + `(("source" ,source)) + '()) + ,@`(("zig" ,zig)) + ,@native-inputs + ,@(if target '() inputs) + ,@(if target + ;; Use the standard cross inputs of + ;; 'gnu-build-system'. + (standard-cross-packages target 'host) + '()) + ;; Keep the standard inputs of 'gnu-build-system'. + ,@(standard-packages))) + (host-inputs (if target inputs '())) + (target-inputs (if target + (standard-cross-packages target 'target) + '())) + (outputs outputs) + (build (if target zig-cross-build zig-build)) + (arguments (strip-keyword-arguments private-keywords arguments)))) (define zig-build-system (build-system |
