guix-devel
[Top][All Lists]
Advanced

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

Re: Storing serialised graph along with packages


From: Ricardo Wurmus
Subject: Re: Storing serialised graph along with packages
Date: Sun, 23 Jul 2017 11:30:46 +0200
User-agent: mu4e 0.9.18; emacs 25.2.1

Ricardo Wurmus <address@hidden> writes:

> What do you think about storing the serialised subset of the package
> graph in a separate output of the package?

Here’s a simple and stupid way of getting a little closer to this idea.
This is serialize.scm:

--8<---------------cut here---------------start------------->8---
(use-modules (system base language)
             (system base compile)
             (ice-9 match))

(match-let (((_ expr target) (command-line)))
  (with-input-from-string
      (format #f "~a" `(begin (use-modules (guix packages))
                              ,expr))
    (lambda _
      (call-with-output-file target
        (lambda (out)
          ((language-printer (lookup-language 'bytecode))
           (read-and-compile (current-input-port)
                             #:env (default-environment 'scheme)
                             #:from 'scheme #:to 'bytecode
                             #:opts (list #:to-file? #t))
           out))))))
--8<---------------cut here---------------end--------------->8---

You run it like this:

--8<---------------cut here---------------start------------->8---
    ./pre-inst-env guile --no-auto-compile serialize.scm \
        '(@@ (gnu packages statistics) r)' \
        /tmp/foo.go
--8<---------------cut here---------------end--------------->8---

You end up with /tmp/foo.go, a little binary which appears to contain
everything you need to play with the closure of the “r” package.

--8<---------------cut here---------------start------------->8---
rekado in guix: guile
GNU Guile 2.2.2
Copyright (C) 1995-2017 Free Software Foundation, Inc.

Guile comes with ABSOLUTELY NO WARRANTY; for details type `,show w'.
This program is free software, and you are welcome to redistribute it
under certain conditions; type `,show c' for details.

Enter `,help' for help.
scheme@(guile-user)> (load-compiled "/tmp/foo.go")
$1 = #<package address@hidden gnu/packages/statistics.scm:577 21c9000>
scheme@(guile-user)> (package-inputs $1)
$2 = (("pango" #<package address@hidden gnu/packages/gtk.scm:210 1f6bb40>) 
("coreutils" #<package address@hidden gnu/packages/base.scm:286 1ed96c0>) 
("curl" #<package address@hidden gnu/packages/curl.scm:41 1c29240>) ("openblas" 
#<package address@hidden gnu/packages/maths.scm:2281 1cb5600>) ("gfortran" 
#<package address@hidden gnu/packages/gcc.scm:488 206a000>) ("icu4c" #<package 
address@hidden gnu/packages/icu4c.scm:33 1927840>) ("libjpeg" #<package 
address@hidden gnu/packages/image.scm:193 20f5f00>) ("libpng" #<package 
address@hidden gnu/packages/image.scm:67 20e1240>) ("libtiff" #<package 
address@hidden gnu/packages/image.scm:334 20f5b40>) ("libxt" #<package 
address@hidden gnu/packages/xorg.scm:5223 20d2240>) ("pcre" #<package 
address@hidden gnu/packages/pcre.scm:34 1742e40>) ("readline" #<package 
address@hidden gnu/packages/readline.scm:43 16c50c0>) ("zlib" #<package 
address@hidden gnu/packages/compression.scm:62 157d900>))
scheme@(guile-user)> (cadar $2)
$3 = #<package address@hidden gnu/packages/gtk.scm:210 2bd9b40>
scheme@(guile-user)> (package-description $3)
$4 = "Pango is the core text and font handling library used in 
GNOME\napplications.  It has extensive support for the different writing 
systems\nused throughout the world."
scheme@(guile-user)>
--8<---------------cut here---------------end--------------->8---

 “/tmp/foo.go” in the above example is 68K in size.  It is not stripped
and I cannot find what options I can pass to the compiler to get it
smaller.

What do you think?  Is this useful or is it silly?  I’m pretty excited
about it.  The only limitation for future exploration is that one may
need a legacy version of Guile in order to read the possibly outdated
elf format currently used by Guile 2.2.2.

--
Ricardo

GPG: BCA6 89B6 3655 3801 C3C6  2150 197A 5888 235F ACAC
https://elephly.net




reply via email to

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