On Mon, 18 Nov 2024 13:38:43 +0100 Denis 'GNUtoo' Carikli wrote: > On Mon, 18 Nov 2024 09:41:41 +0100 > Denis 'GNUtoo' Carikli wrote: > > But now I have another problem: some of the paths don't exist. For > > instance the code above lists > > /gnu/[...]-ath9k-htc-firmware-1.4.0-checkout which doesn't exist. > I've found an idea for working around that: I can get the file name > and loop over all the packages, match a package's > origin-actual-file-name against the name above, and once we have the > package we can simply run guix build --sources=transitive with it. This turned out to take way too long. I've talked again to Simon Tournier in a Guix even and he pointed to me the missing part: guix build can build a lot of things, including derivations and all, all I needed to do was to pass the right path to guix build and it would figure out what it is and build it (if it can). So at the end this gave this small source code: ;;; Copyright © 2024 Denis 'GNUtoo' Carikli ;;; ;;; 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. (use-modules (guix build utils) (guix derivations) (guix scripts build)) (let ((drv-from-file (read-derivation-from-file (list-ref (program-arguments) 1)))) (map (lambda (drv-prerequisite) (map (lambda (drv-output) (if (derivation-output-hash (cdr drv-output)) ((lambda _ (let ((source-path (derivation-output-path (cdr drv-output)))) (if (not (file-exists? source-path)) (guix-build source-path)) (if (not (elf-file? source-path)) (display (string-append source-path "\n")))))))) (derivation-outputs (derivation-input-derivation drv-prerequisite)))) (derivation-prerequisites drv-from-file))) It can be used with something like that: $ cp $(guix gc --derivers $(guix system image minimal-system.scm)) image.drv $ tar cf sources.tar $(guix repl get-sources.scm image.drv) There might still be room for testing and improvements though but we now at least have something that can be used to easily publish complete and corresponding source code of images in a safe and easy way. Thanks a lot to Simon for all the help as this help has been extremely useful in pointing me in the right direction multiple times. Denis.