Subject: [bug#66801] ['PATCH v2' 01/14] build-system: Add mix-build-system.

From: Liliana Marie Prikler <[email-masked]>
Date: Wed, 15 Nov 2023 19:36:12 +0100

Am Mittwoch, dem 15.11.2023 um 10:57 +0100 schrieb Pierre-Henry
Fröhring:
> > No.  Look at all the other build systems.  None of them use
> > submodules of (gnu
> > packages), for a good reason.
> 
> Ok, I see. It would introduce circular dependencies. By "resolve,"
> you
> mean something like: ~(resolve-interface '(gnu packages yyy))~. So,
> in
> our case it means:
> #+begin_src scheme
> (define (default-glibc-utf8-locales)
>   (let* ((base (resolve-interface '(gnu packages base)))
>          (glibc (module-ref base 'glibc))
>          (make-glibc-utf8-locales (module-ref base 'make-glibc-utf8-
> locales)))
>     (make-glibc-utf8-locales glibc #:locales (list "en_US"))))
> 
> (define (default-elixir-hex)
>   (let ((elixir (resolve-interface '(gnu packages elixir))))
>     (module-ref elixir 'elixir-hex)))
> 
> (define (default-rebar3)
>   (let ((erlang (resolve-interface '(gnu packages erlang))))
>     (module-ref erlang 'rebar3)))
> #+end_src
> 
> Then:
> #+begin_src scheme
> (define* (lower name
>                 #:key
>                 (elixir (default-elixir))
>                 (elixir-hex (default-elixir-hex))
>                 (glibc-utf8-locales (default-glibc-utf8-locales))
>                 (rebar3 (default-rebar3))
>                 …
>                 #:allow-other-keys #:rest arguments)
>   …)
> #+end_src
> 
> Is this correct?
You shouldn't need to provide glibc-utf8-locales this way (there's
already a variable for it IIRC), but yeah.

> > Not necessarily, but you want a different way of building
> > $out/lib/elixir/X.Y/
> > that doesn't leak through the function signature.
> 
> Following ~python-build-system.scm~, it means something like:
> #+begin_src scheme
> (define (elixir-version elixir)
>   (let* ((version     (last (string-split elixir #\-)))
>          (components  (string-split version #\.))
>          (major+minor (take components 2)))
>     (string-join major+minor ".")))
> 
> (define (install-dir inputs outputs)
>   "Return the path of the current output's Elixir library."
>   (let ((out (assoc-ref outputs "out"))
>         (elixir (assoc-ref inputs "elixir")))
>     (string-append out "/lib/elixir/" (elixir-version elixir) "/site-
> packages")))
> #+end_src
> 
> Is this correct?
LGTM.

> > Btw. I think that you're resolving transitive inputs twice; once on
> > the build system code and once by fattening the outputs.  You
> > probably only need either of those, not both.
> 
> Ah. Propagated inputs are propagated. Who would have thought? So,
> this is not necessary:
> #+begin_src scheme
> (define* (lower …)
>   …
>   (define all-propagated-inputs
>     ((compose
>       (cut delete-duplicates <> equal?)
>       (cut filter erlang-or-elixir-input? <>)
>       (cut append-map package-transitive-propagated-inputs <>)
>       (cut map cadr <>))
>      (append inputs native-inputs)))
> 
>   (define build-inputs
>     `(…
>       ,@all-propagated-inputs
>       ,@inputs
>       ,@native-inputs))
> 
>   (bag …
>        (build-inputs build-inputs)
>        …))
> #+end_src
> I've just removed ~all-propagated-inputs~ and all packages build just
> fine.
> 
> Is this what you meant?
Yep.  I assume this makes your packages way lighter.

Note that propagated inputs have become a (not great) default for
interpreted languages such as Python or Emacs Lisp.

> > Yep, that would work.  Note that delete-duplicates is O(n^2),
> > though.  We have a little bit of code where it's done in (I assume)
> > O(n*log(n)) with vhashes.
> 
> If ~all-propagated-inputs~ is removed, then the discussion of this
> comment is closed.
Sure.