Dear Guix, GNU sources are usually shipped as tarballs with some pre-compiled sources included. This can be a bit scary at times, so the question now is, can we skip the tarballs and build everything from human-authored sources?
I first want to emphasize that distributing generated sources is an important feature of a build system. It is necessary for it to boast cross-compilation support, and for packages doing simple forms of introspection (such as using help2man or gobject introspection) it may even be sufficient. There are other nice things as well, so with that in mind, let us open the black box and see what the maintainers are hiding from us. I chose Hello. After a bit of guixing around, it works: guix build -f hello.scm shows the build, and guix build --source -f hello.scm shows the full source distribution (although it is not in a tar because it would have additional reproducibility problems). So, what are the hello maintainers hiding from us? — they use gnulib; — the translations are not in the git repository, so their release process involves fetching stuff from the web and packing it in; — the manpage generation depends on the presence of a ".git" folder; — they have perl installed; — they have a bunch of autotools, included code generators (gperf); — they work in the git repository to have a meaningful version number and commit log (for the ChangeLog); — the manual displays its revision date, but we don’t know how it is computed (I suspect the revision date is the last time the maintainer who did the release edited or git-pulled the texinfo source, which, let’s agree on that, is not very precise). I could not fully recover the release source (I am not attempting bit- reproducibility) because: — the translations were lost; — the ChangeLog was lost; — the manual revision date was lost; — guix’ patched shebangs leaked in the sources. This is a mixed responsibility problem. The big point here is translations. I understand that using translationproject.org means that committing the translations would storm the repository with automated commits, which would be undesirable. Maybe Software Heritage could help? Happy hacking! Vivien
(use-modules ((guix licenses) #:prefix license:) (guix build-system gnu) (guix gexp) (guix packages) (guix git-download) (gnu packages autotools) (gnu packages base) (gnu packages gettext) (gnu packages gperf) (gnu packages man) (gnu packages perl) (gnu packages texlive) (gnu packages texinfo)) (define hello-dist (package (name "hello-dist") (version "2.12.1") (source (origin (method git-fetch) (uri (git-reference (url "https://git.savannah.gnu.org/git/hello.git") (commit (string-append "v" version)) ;; hello uses gnulib as a submodule (recursive? #t))) (file-name (string-append "hello-" version "-checkout")) (sha256 (base32 "0k8ibhlj7v6i0ynzldkfg5r8p78m1mkczci0drr6h9z7n85vfacy")))) (build-system gnu-build-system) (arguments (list #:phases #~(modify-phases %standard-phases (replace 'bootstrap (lambda* (#:key native-inputs inputs #:allow-other-keys) (substitute* "Makefile.am" (("\\$\\(top_srcdir\\)/build-aux/gitlog-to-changelog") ;; This script requires a full git checkout, which we ;; do not provide. FIXME: The source ChangeLog will ;; not be relevant. "true")) (for-each patch-shebang ;; These scripts should be patched early because they ;; are invoked by the bootstrap script (many more will ;; be patched after the bootstrap phase). (list "bootstrap" "gnulib/gnulib-tool" "gnulib/build-aux/prefix-gnulib-mk" "build-aux/git-version-gen")) ;; hello will only build the manual pages if it is run ;; from its git repository (read: if .git is an existing ;; directory, see configure.ac) because the maintainer ;; thinks no cross-compiling can happen in this case ;; presumably. It would be cool if the hello maintainer ;; could precisely identify the dependencies of the ;; manpage so that a manpage template could be ;; distributed. (mkdir-p ".git") (call-with-output-file ".tarball-version" ;; hello would compute the version number from state ;; of the git repository if .tarball-version did not ;; exist. (lambda (port) (format port "~a\n" #$version))) (invoke "sh" "bootstrap" "--no-git" "--gnulib-srcdir=gnulib" ;; FIXME: package the po files separately and ;; change the po_download_command_format ;; definition in bootstrap. For now there is no ;; way to have po files. "--skip-po") (patch-makefile-SHELL "po/Makefile.in.in"))) (replace 'check (lambda* (#:key native-inputs inputs #:allow-other-keys) (invoke "make" "distcheck" (string-append "DISTCHECK_CONFIGURE_FLAGS = SHELL=" (search-input-file (or native-inputs inputs) "bin/sh"))))) (replace 'install (lambda _ ;; FIXME: the manual page is dated for version released 1970-01-01 ;; FIXME: the guix shebangs leak in the source code ;; distribution. I need some sort of reverse-patch-shebangs and ;; reverse-patch-makefile-SHELL. (mkdir-p #$output) ;; Can’t run "make distdir=#$output distdir because the ;; po build system does not expect the distdir to be ;; anything other than ../$(PACKAGE)-$(VERSION)/po. (invoke "tar" "--extract" (string-append "--file=hello-" #$version ".tar.gz") (string-append "--directory=" #$output) "--strip-components=1")))))) (native-inputs ;; All these things are used by the hello maintainer to make a ;; distribution tarball and run `make distcheck'. ;; FIXME: do not use the full texlive. (list autoconf autoconf-archive automake libtool gnu-gettext perl gperf help2man tar texinfo texlive)) (synopsis "Hello, GNU world: An example GNU package") (description "GNU Hello prints the message \"Hello, world!\" and then exits. It serves as an example of standard GNU coding practices. As such, it supports command-line arguments, multiple languages, and so on.") (home-page "https://www.gnu.org/software/hello/") (license license:gpl3+))) (package ;; FIXME: ;; - the ChangeLog is incomplete ;; - no translations ;; - wrong info manual revision date ;; ;; Future works: ;; - regarding the ChangeLog: guix git-download could maybe run a ;; form of gitlog-to-changelog and save the output ;; - regarding the info manual revision date: guix git-download ;; could maybe find the latest commit date touching the manual and save ;; it (bootstrap would then touch the texinfo source at this date) ;; - regarding the translations: propagate the Guix philosophy that ;; you should not download things from the web at build time. Check the ;; translations in to git on releases. (inherit hello-dist) (name "hello") (source hello-dist) (build-system gnu-build-system) (arguments '()) (native-inputs '()))