diff options
author | Vivien Kraus <vivien@planete-kraus.eu> | 2023-03-01 18:22:45 +0100 |
---|---|---|
committer | Vivien Kraus <vivien@planete-kraus.eu> | 2023-03-06 20:15:46 +0100 |
commit | 4ae7dfdcf76be0e49cb8c95e74a0038cf86cb35c (patch) | |
tree | fe450b3d92e1b1e406c33882b20362250906a2e6 /guix.scm |
Hello, world!
Diffstat (limited to 'guix.scm')
-rw-r--r-- | guix.scm | 211 |
1 files changed, 211 insertions, 0 deletions
diff --git a/guix.scm b/guix.scm new file mode 100644 index 0000000..249f88d --- /dev/null +++ b/guix.scm @@ -0,0 +1,211 @@ +(define-module (guix) + #:use-module (gnu packages autotools) + #:use-module (gnu packages base) + #:use-module (gnu packages bash) + #:use-module (gnu packages build-tools) + #:use-module (gnu packages check) + #:use-module (gnu packages code) + #:use-module (gnu packages compression) + #:use-module (gnu packages gettext) + #:use-module (gnu packages gnome) + #:use-module (gnu packages gtk) + #:use-module (gnu packages perl) + #:use-module (gnu packages pkg-config) + #:use-module (gnu packages tex) + #:use-module (gnu packages texinfo) + #:use-module (gnu packages valgrind) + #:use-module (gnu packages version-control) + #:use-module ((guix licenses) #:prefix license:) + #:use-module (guix build utils) + #:use-module (guix build-system gnu) + #:use-module (guix gexp) + #:use-module (guix git-download) + #:use-module (guix git) + #:use-module (guix modules) + #:use-module (guix packages) + #:use-module (guix utils) + #:use-module (guix store) + #:use-module (guix monads) + #:use-module (guix derivations) + #:use-module (guix download) + #:use-module (ice-9 popen) + #:use-module (ice-9 rdelim) + #:use-module (srfi srfi-19)) + +(define git-exec + (run-with-store + (open-connection) + (mlet %store-monad ((git (package->derivation git))) + (mlet %store-monad ((built + (built-derivations + (list git)))) + (return (string-append (derivation->output-path git) + "/bin/git")))))) + +(define disfluid:package-version + (with-directory-excursion + (dirname (current-filename)) + (let ((port (open-pipe* OPEN_READ git-exec "describe" "--tags"))) + (let ((version (read-line port))) + (when (eof-object? version) + (set! version "0.0.0")) + (close-port port) + version)))) + +(define disfluid:commit-date + (with-directory-excursion + (dirname (current-filename)) + (let ((port (open-pipe* OPEN_READ git-exec "log" "-1" "--format=%ci"))) + (let ((date (read-line port))) + (close-port port) + (string->date date "~Y-~m-~d ~H:~M:~S ~z"))))) + +(define disfluid:local-dir + (dirname (current-filename))) + +(define disfluid:package-source + (git-checkout + (url (string-append "file://" disfluid:local-dir)))) + +(define disfluid:translations + (git-checkout + (url (string-append "file://" (dirname (current-filename)))) + (branch "translations"))) + +(define disfluid:raw-source + (computed-file "disfluid-raw-source" + (with-imported-modules + (source-module-closure '((guix build utils))) + #~(begin + (use-modules (guix build utils)) + (mkdir-p #$output) + (with-directory-excursion #$output + (invoke #$(file-append git "/bin/git") "init") + (invoke #$(file-append git "/bin/git") "branch" "-m" "main") + (invoke #$(file-append git "/bin/git") "config" + "user.email" "vivien@planete-kraus.eu") + (invoke #$(file-append git "/bin/git") "config" + "user.name" "Vivien Kraus") + (copy-recursively #$(file-append disfluid:package-source "/.") "." + #:follow-symlinks? #t) + (invoke #$(file-append git "/bin/git") "add" ".") + (invoke #$(file-append git "/bin/git") "commit" + "-m" #$(format #f "Set up disfluid source code for ~a" disfluid:package-version)) + (invoke #$(file-append git "/bin/git") "checkout" "-b" "translations") + (copy-recursively #$(file-append disfluid:translations "/.") "." + #:follow-symlinks? #t) + (invoke #$(file-append git "/bin/git") "add" ".") + (false-if-exception + (invoke #$(file-append git "/bin/git") "commit" + "-m" #$(format #f "Set up disfluid translations for ~a" + disfluid:package-version))) + (invoke #$(file-append git "/bin/git") "checkout" "main") + (invoke #$(file-append git "/bin/git") "tag" "-a" + "-m" #$(format #f "Version ~a" disfluid:package-version) + #$(format #f "v~a" disfluid:package-version))))))) + +(define-public disfluid-boot + (package + (name "disfluid-boot") + (version disfluid:package-version) + (source disfluid:raw-source) + (build-system gnu-build-system) + (arguments + (list + #:phases + #~(modify-phases + %standard-phases + (add-before 'bootstrap 'bootstrap-bootstrap + (lambda _ + (invoke "sh" "bootstrap-bootstrap"))) + (add-after 'bootstrap 'fix-/bin/sh-in-po + (lambda _ + (substitute* + "po/Makefile.in.in" + (("SHELL = /bin/sh") + (format #f "SHELL = ~a" (which "sh")))))) + (add-after 'check 'syntax-check + (lambda _ + (invoke "make" "syntax-check"))) + (replace 'install + (lambda _ + (invoke "git" "checkout" "--" "bootstrap-bootstrap") + (patch-shebang "configure") + (invoke "make" "-j8" "distcheck" + (format #f "DISTCHECK_CONFIGURE_FLAGS=SHELL=~a" (which "sh"))) + (invoke "tar" "xf" #$(format #f "disfluid-~a.tar.gz" disfluid:package-version)) + (with-directory-excursion + #$(format #f "disfluid-~a" disfluid:package-version) + (substitute* "po/Makefile.in.in" + (("SHELL = /gnu/store/.*/bin/sh") + "SHELL = /bin/sh")) + (substitute* "configure" + (("#!/gnu/store/.*/bin/sh") + "#!/bin/sh")) + (substitute* "configure" + (("/gnu/store/.*/bin/file") + "/bin/file")) + (with-directory-excursion "build-aux" + (substitute* '("config.rpath" "git-version-gen" "gitlog-to-changelog" + "install-sh" "do-release-commit-and-tag" + "useless-if-before-free" "test-driver" "depcomp" + "announce-gen" "ltmain.sh" "config.sub" "libtool-reloc" + "missing" "config.libpath" "reloc-ldflags" "ar-lib" + "config.guess" "vc-list-files" "install-reloc") + (("#!/gnu/store/.*/bin/sh") + "#!/bin/sh")))) + (invoke "sh" "-c" "grep '/gnu/store/' -R disfluid-* && exit 1 ; true") + (mkdir-p #$output) + (invoke "tar" + #$(format #f "--mtime=~a" (date->string disfluid:commit-date "~4")) + "--sort=name" + "--owner=0" "--group=0" "--numeric-owner" + "--pax-option=exthdr.name=%d/PaxHeaders/%f,delete=atime,delete=ctime" + "-cvzf" (string-append #$output "/complete-source.tar.gz") + #$(format #f "disfluid-~a" disfluid:package-version))))))) + (native-inputs + (list autoconf autoconf-archive automake libtool gnu-gettext + git valgrind (list glibc "debug") + tar gzip global pkg-config vala + texinfo (texlive-updmap.cfg (list texlive)) + perl gnulib gtk check)) + (inputs + (list gtk check gnu-gettext)) + (home-page "https://labo.planete-kraus.eu/disfluid.git") + (synopsis "Demanding Interoperability to Strengthen the Free/Libre Web: Introducing Disfluid") + (description "This provides tools for web interoperability.") + (license license:agpl3+))) + +(package + (inherit disfluid-boot) + (name "disfluid") + (source #f) + (outputs (list "out" "complete-corresponding-source.tar.gz")) + (arguments + (list + #:phases + #~(modify-phases %standard-phases + (replace 'unpack + (lambda _ + (invoke "tar" "xf" #+(file-append disfluid-boot "/complete-source.tar.gz")) + (chdir #$(format #f "disfluid-~a" disfluid:package-version)))) + (replace 'install-license-files + (lambda _ + ;; Do not try to install COPYING in the + ;; complete-corresponding-source.tar.gz output + (let ((dir (format #f "~a/~a" + #$output + #$(format #f "share/doc/disfluid-~a" + disfluid:package-version)))) + (mkdir-p dir) + (copy-file "COPYING" (string-append dir "/COPYING"))))) + (add-after 'install 'install-complete-corresponding-source + (lambda _ + (mkdir-p (string-append #$output "/share/disfluid")) + (copy-file #+(file-append disfluid-boot "/complete-source.tar.gz") + #$output:complete-corresponding-source.tar.gz)))))) + (native-inputs + (list valgrind (list glibc "debug") pkg-config + texinfo (texlive-updmap.cfg (list texlive)) tar gzip)) + (inputs + (list gnu-gettext gtk check))) |