Subject: bug#42289: recursive import does not dort alphabetically

From: Julien Lepiller <[email-masked]>
Date: Thu, 16 Jul 2020 07:41:58 -0400

Le 16 juillet 2020 07:35:23 GMT-04:00, zimoun <[email-masked]> a écrit :
>Dear Hartmut,
>
>On Wed, 15 Jul 2020 at 21:10, Hartmut Goebel
><[email-masked]> 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.

>
>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