GNU bug report logs - #49169
[PATCH 00/11] Removing input labels from package definitions

Previous Next

Package: guix-patches;

Reported by: Ludovic Courtès <ludo <at> gnu.org>

Date: Tue, 22 Jun 2021 09:03:01 UTC

Severity: normal

Tags: patch

Done: Ludovic Courtès <ludo <at> gnu.org>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Ludovic Courtès <ludo <at> gnu.org>
To: 49169 <at> debbugs.gnu.org
Cc: Ludovic Courtès <ludo <at> gnu.org>
Subject: [bug#49169] [PATCH 00/11] Removing input labels from package definitions
Date: Tue, 22 Jun 2021 11:02:21 +0200
Hello Guix!

This patch series does the ground work to remove input labels
from package definitions.  In other words:

  (package
    ;; …
    (inputs `(("libunistring" ,libunistring)
              ("libffi" ,libffi))))

becomes:

  (package
    ;; …
    (inputs (list libunistring libffi)))

Note that it does not change the value returned by ‘package-inputs’
& co.: that still includes input labels.  Likewise, build-side code
does not see any difference (there are still input alists).

Previous discussions at:

  https://lists.gnu.org/archive/html/guix-devel/2021-05/msg00343.html
  https://lists.gnu.org/archive/html/guix-devel/2021-06/msg00072.html

The main change is the addition of ‘guix style’, based on the script
I posted earlier.  ‘guix style’ is able to systematically preserve
comments (margin comments and line comments).  It recognizes and
“translates” several common idioms.

In the long term, the goal is to remove input labels also from
APIs like ‘package-inputs’.  With an eye on this, I introduced the
‘modify-inputs’ macro as a replacement for idioms such as:

  `(("guile" ,guile-2.2)
    ,@(alist-delete "guile" (package-inputs foo)))

which becomes:

  (modify-inputs (package-inputs foo)
    (replace "guile" guile-2.2))

Code that uses ‘modify-inputs’ does not assume that ‘package-inputs’
returns an alist.  Thus, when we eventually change that, that code
won’t need to be changed.  (‘guix style’ performs this translation,
too.)

‘guix style’ processes all 17K packages in ~3mn, leading to this:

  447 files changed, 33385 insertions(+), 44079 deletions(-)

This does not incur a single rebuild.  Some packages are not
handled by ‘guix style’ because the code pattern is not
recognized or because input labels don’t match package names
(often for no good reason).  I don’t know what fraction of
the packages is left behind; I’d guess less than a third of them.

At this stage we have everything to start the migration and to
even complete it rather quickly.  What’s needed now is to look
at corner cases and idioms that have no obvious translation in
the new style.  But you can help!

  1. Check out the ‘wip-simplified-packages’ branch (based
     on ‘core-updates’).

  2. Run ‘./pre-inst-env guix style’ (you can also list package
     names) and see whether your favorite packages are handled.

  3. If you see packages not handled by ‘guix style’, try to
     convert them by hand.  If you find an idiom that you don’t
     know how to “translate”, let’s discuss it!

Thanks in advance! :-)

Ludo’.

Ludovic Courtès (11):
  records: Support field sanitizers.
  packages: Allow inputs to be plain package lists.
  lint: Add 'input-labels' checker.
  packages: Add 'lookup-package-input' & co.
  packages: Add 'modify-inputs'.
  gnu: Change inputs of core packages to plain lists.
  utils: 'edit-expression' no longer leaks file ports.
  utils: Add 'go-to-location' with source location caching.
  utils: 'edit-expression' modifies the file only if necessary.
  utils: 'edit-expression' copies part of the original source map.
  Add 'guix style'.

 Makefile.am            |   2 +
 doc/guix.texi          | 174 +++++++++++++--
 gnu/packages/base.scm  |  48 ++---
 gnu/packages/guile.scm | 103 +++------
 gnu/packages/mes.scm   |  25 +--
 guix/lint.scm          |  36 ++++
 guix/packages.scm      | 145 ++++++++++++-
 guix/records.scm       |  65 ++++--
 guix/scripts/style.scm | 475 +++++++++++++++++++++++++++++++++++++++++
 guix/utils.scm         | 151 ++++++++++---
 po/guix/POTFILES.in    |   1 +
 tests/lint.scm         |  14 ++
 tests/packages.scm     |  86 ++++----
 tests/records.scm      |  38 ++++
 tests/style.scm        | 328 ++++++++++++++++++++++++++++
 15 files changed, 1455 insertions(+), 236 deletions(-)
 create mode 100644 guix/scripts/style.scm
 create mode 100644 tests/style.scm


base-commit: d1827d5c636adb395153a4ed6064629ed5b7664b
-- 
2.32.0





This bug report was last modified 3 years and 352 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.