recursive import does not dort alphabetically

  • Open
  • quality assurance status badge
Details
4 participants
  • Hartmut Goebel
  • Julien Lepiller
  • Leo Famulari
  • zimoun
Owner
unassigned
Submitted by
Hartmut Goebel
Severity
normal
H
H
Hartmut Goebel wrote on 9 Jul 2020 09:53
(name . bug-guix)(address . bug-guix@gnu.org)
e71b3b30-c81a-bc64-d7e9-409d588ebde6@crazy-compilers.com
In most gnu/packages/*.scm files are (expected to be) sorted alphabetically.

Now when importing some packages recursivly, packages are output in
order of the dependency graph, thus authors need to sort them manually.

Example (requires the hex.pm importer from

$ ./pre-inst-env guix import hexpm -r idna | grep define-public
(define-public erlang-unicode-util-compat
(define-public erlang-idna
$ ./pre-inst-env guix import hexpm -r idna | grep define-public |
LC_ALL=C sort --check
sort: -:2: disorder: (define-public erlang-idna

--
Regards
Hartmut Goebel

| Hartmut Goebel | h.goebel@crazy-compilers.com |
| www.crazy-compilers.com | compilers which you thought are impossible |
Z
Z
zimoun wrote on 9 Jul 2020 11:36
86zh89av3c.fsf@gmail.com
Dear,

On Thu, 09 Jul 2020 at 09:53, Hartmut Goebel <h.goebel@crazy-compilers.com> wrote:
Toggle quote (3 lines)
> In most gnu/packages/*.scm files are (expected to be) sorted
> alphabetically.

Do you mean the package definitions in gnu/packages/foo.scm?
Because they are generally not alphabetically sorted. Well, it really
depends on which module, from what I see.


All the best,
simon
H
H
Hartmut Goebel wrote on 9 Jul 2020 13:26
87692d5d-0650-c2bd-1533-54b38677d97e@crazy-compilers.com
Am 09.07.20 um 11:36 schrieb zimoun:
Toggle quote (2 lines)
> Do you mean the package definitions in gnu/packages/foo.scm?

Yes.

Toggle quote (2 lines)
> Because they are generally not alphabetically sorted.

Most file I've been working on ask for sorting alphabetically. (And IMHO
this is a good recommendation to follow.)

--
Regards
Hartmut Goebel

| Hartmut Goebel | h.goebel@crazy-compilers.com |
| www.crazy-compilers.com | compilers which you thought are impossible |
Z
Z
zimoun wrote on 9 Jul 2020 16:02
(name . Hartmut Goebel)(address . h.goebel@crazy-compilers.com)(address . 42289@debbugs.gnu.org)
CAJ3okZ3TZE44ATmQQyw4XSajMPoBqvcEKmdDwgyDbbSeUCRgpw@mail.gmail.com
On Thu, 9 Jul 2020 at 13:26, Hartmut Goebel
<h.goebel@crazy-compilers.com> wrote:

Toggle quote (5 lines)
> > Because they are generally not alphabetically sorted.
>
> Most file I've been working on ask for sorting alphabetically. (And IMHO
> this is a good recommendation to follow.)

Well, I get:

295 gnu/packages/unsorted-file.scm
204 gnu/packages/sorted-file.scm

And the top 10 bigger files are unsorted:

Toggle snippet (22 lines)
crates-io.scm
sort: -:6: disorder: (define-public rust-afl-0.4
emacs-xyz.scm
sort: -:2: disorder: (define-public emacs-ac-geiser
cran.scm
sort: -:3: disorder: (define-public r-dot
python-xyz.scm
sort: -:2: disorder: (define-public python-colorlog
bioinformatics.scm
sort: -:9: disorder: (define-public blasr-libcpp
haskell-xyz.scm
sort: -:238: disorder: (define-public ghc-llvm-hs
java.scm
sort: -:2: disorder: (define-public drip
games.scm
sort: -:13: disorder: (define-public foobillard++
lisp-xyz.scm
sort: -:2: disorder: (define-public cl-alexandria
perl.scm
sort: -:17: disorder: (define-public perl-b-hooks-endofscope

BTW, I agree that alphabetical sorting is a good recommendation.

All the best,
simon
L
L
Leo Famulari wrote on 9 Jul 2020 19:39
(name . Hartmut Goebel)(address . h.goebel@crazy-compilers.com)
20200709173955.GA22616@jasmine.lan
On Thu, Jul 09, 2020 at 01:26:03PM +0200, Hartmut Goebel wrote:
Toggle quote (3 lines)
> Most file I've been working on ask for sorting alphabetically. (And IMHO
> this is a good recommendation to follow.)

What are the benefits of sorting packages?

The ordering of packages is not usually important to the machine, and
humans can search for the package names.

I think that sorting the packages is not necessarily desired, especially
for modules where a lot of packages may be imported (e.g. Rust). It
makes the Git diffs harder to understand and work with when merging or
rebasing, compared to just adding the new packages at the end of the
file.

In cases where packages are inherited to create multiple package
versions, alphanumerical sorting breaks the inheritance [0], although
inheritance is problematic in its own right and we should probably stop
using it.

H
H
Hartmut Goebel wrote on 15 Jul 2020 21:10
(name . Leo Famulari)(address . leo@famulari.name)
a297d058-7973-9ba7-34e6-1341d0eeee2a@crazy-compilers.com
Am 09.07.20 um 19:39 schrieb Leo Famulari:
Toggle quote (2 lines)
> What are the benefits of sorting packages?

Many modules are sorted and some packages even contain a comment asking
for being sorted. So I had the impression this is good practice.

Also scanning through the file is easier for humans if packages are
sorted - depends on personal work style.


--
Regards
Hartmut Goebel

| Hartmut Goebel | h.goebel@crazy-compilers.com |
| www.crazy-compilers.com | compilers which you thought are impossible |
Z
Z
zimoun wrote on 16 Jul 2020 13:35
(address . 42289@debbugs.gnu.org)
86wo33y9ok.fsf@gmail.com
Dear Hartmut,

On Wed, 15 Jul 2020 at 21:10, Hartmut Goebel <h.goebel@crazy-compilers.com> wrote

Toggle quote (3 lines)
> Many modules are sorted and some packages even contain a comment asking
> for being sorted. So I had the impression this is good practice.

I am not sure by the "many". :-)
Even gnu/packages/crate-io.scm which explicitly asks:

;;; Please: Try to add new module packages in alphabetic order.

and it is not really sorted. :-)

cat crates-io.scm | grep 'define-public' | sort --check
sort: -:6: disorder: (define-public rust-afl-0.5


Toggle quote (3 lines)
> Also scanning through the file is easier for humans if packages are
> sorted - depends on personal work style.

It appears to me as a "good practise" too. On the other hand,
personally I always scan the packages with "ag" (inside Emacs).


However, it is not the point since your initial request is about
alphabetical sort of "guix import"; which seems better than arbitrary
order (dependency order). Whatever if gnu/packages/foo.scm is sorted or
not.

If "guix import" returns an alphanumerical sorted list, it is easier and
it does not bother the unsorted modules since the packages are new.

All the best,
simon
J
J
Julien Lepiller wrote on 16 Jul 2020 13:41
(address . 42289@debbugs.gnu.org)
C1AEC1AB-B5B6-40F0-92C6-FDB0CBC9E6A5@lepiller.eu
Le 16 juillet 2020 07:35:23 GMT-04:00, zimoun <zimon.toutoune@gmail.com> a écrit :
Toggle quote (33 lines)
>Dear Hartmut,
>
>On Wed, 15 Jul 2020 at 21:10, Hartmut Goebel
><h.goebel@crazy-compilers.com> wrote
>
>> Many modules are sorted and some packages even contain a comment
>asking
>> for being sorted. So I had the impression this is good practice.
>
>I am not sure by the "many". :-)
>Even gnu/packages/crate-io.scm which explicitly asks:
>
>;;; Please: Try to add new module packages in alphabetic order.
>
>and it is not really sorted. :-)
>
> cat crates-io.scm | grep 'define-public' | sort --check
> sort: -:6: disorder: (define-public rust-afl-0.5
>
>
>> Also scanning through the file is easier for humans if packages are
>> sorted - depends on personal work style.
>
>It appears to me as a "good practise" too. On the other hand,
>personally I always scan the packages with "ag" (inside Emacs).
>
>
>However, it is not the point since your initial request is about
>alphabetical sort of "guix import"; which seems better than arbitrary
>order (dependency order). Whatever if gnu/packages/foo.scm is sorted
>or
>not.

The advantage of dependency-sorting is that it makes it easier to add packages one by one without breaking anything. If they are alphabetically sorted, which package do you add first? What if the first one depends on another imported package? Your first commit will be broken because of a reference to an unexisting package.

Toggle quote (7 lines)
>
>If "guix import" returns an alphanumerical sorted list, it is easier
>and
>it does not bother the unsorted modules since the packages are new.
>
>All the best,
>simon
L
L
Leo Famulari wrote on 16 Jul 2020 20:23
(name . Hartmut Goebel)(address . h.goebel@crazy-compilers.com)
20200716182351.GA26195@jasmine.lan
On Wed, Jul 15, 2020 at 09:10:45PM +0200, Hartmut Goebel wrote:
Toggle quote (6 lines)
> Many modules are sorted and some packages even contain a comment asking
> for being sorted. So I had the impression this is good practice.
>
> Also scanning through the file is easier for humans if packages are
> sorted - depends on personal work style.

To clarify, I don't think that sorting packages alphanumerically is bad
or good. It's largely a matter of taste, and I don't think we need to
make a policy either way.
Z
Z
zimoun wrote on 8 Mar 2022 10:19
(name . Hartmut Goebel)(address . h.goebel@crazy-compilers.com)(address . 42289@debbugs.gnu.org)
87r17c4xa2.fsf@gmail.com
Hi Hartmut,

On jeu., 09 juil. 2020 at 09:53, Hartmut Goebel <h.goebel@crazy-compilers.com> wrote:
Toggle quote (2 lines)
> In most gnu/packages/*.scm files are (expected to be) sorted alphabetically.

While I agree with this recommendation to sort alphabetically
gnu/packages/*.scm...

Toggle quote (3 lines)
> Now when importing some packages recursivly, packages are output in
> order of the dependency graph, thus authors need to sort them manually.

...I think it is not a good idea to sort alphabetically the output of
the importers, because:

1. the packages have to be added dependency-sorted,
2. since each imported package is not alphabetically adjacent in the
larger collection of already available packages, the user still needs
to find the correct location.

Therefore, I am in favor to close this issue as wontfix notabug. WDYT?


Cheers,
simon
?
Your comment

Commenting via the web interface is currently disabled.

To comment on this conversation send an email to 42289@debbugs.gnu.org

To respond to this issue using the mumi CLI, first switch to it
mumi current 42289
Then, you may apply the latest patchset in this issue (with sign off)
mumi am -- -s
Or, compose a reply to this issue
mumi compose
Or, send patches to this issue
mumi send-email *.patch