help-guix
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: License compliance when redistributing images built with 'guix syste


From: Denis 'GNUtoo' Carikli
Subject: Re: License compliance when redistributing images built with 'guix system'.
Date: Sat, 23 Nov 2024 00:56:06 +0100

On Mon, 18 Nov 2024 13:38:43 +0100
Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org> wrote:

> On Mon, 18 Nov 2024 09:41:41 +0100
> Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org> 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 <GNUtoo@cyberdimension.org>
;;;
;;; 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.

Attachment: pgpu4nmlEo17t.pgp
Description: OpenPGP digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]