Subject: Re: bug#63427: gdk-pixbuf unable to recognize image formats (JPG, PNG, etc.)

From: Maxim Cournoyer <[email-masked]>
Date: Fri, 17 Jan 2025 12:18:50 +0900

Hi!

Liliana Marie Prikler <[email-masked]> writes:

[...]

> I've attached a patch that allows us to use
> "set if unspecified" semantics – not really sure how meaningful those
> are – but perhaps we would need a GUIX_-prefixed environment variable
> once again.  Barring an upstream change from GDK_PIXBUF_MODULE_FILE to
> GDK_PIXBUF_MODULE_PATH anyway.
>
> WDYT?
>
> diff --git a/guix/build/utils.scm b/guix/build/utils.scm
> index 94714bf397..d48b9112b8 100644
> --- a/guix/build/utils.scm
> +++ b/guix/build/utils.scm
> @@ -1393,6 +1393,9 @@ (define* (wrap-program prog #:key (sh (which "bash")) #:rest vars)
>        ((var sep '= rest)
>         (format #f "export ~a=\"~a\""
>                 var (string-join rest sep)))
> +      ((var sep ':- rest)
> +       (format #f "export ~a=\"${~a:-~a}\""
> +               var var (string-join rest sep)))
>        ((var sep 'prefix rest)
>         (format #f "export ~a=\"~a${~a:+~a}$~a\""
>                 var (string-join rest sep) var sep var))
> @@ -1402,6 +1405,9 @@ (define* (wrap-program prog #:key (sh (which "bash")) #:rest vars)
>        ((var '= rest)
>         (format #f "export ~a=\"~a\""
>                 var (string-join rest ":")))
> +      ((var ':- rest)
> +       (format #f "export ~a=\"${~a:-~a}\""
> +               var var (string-join rest ":")))
>        ((var 'prefix rest)
>         (format #f "export ~a=\"~a${~a:+:}$~a\""
>                 var (string-join rest ":") var var))
> @@ -1470,6 +1476,8 @@ (define wrap-script
>          (match-lambda
>            ((var sep '= rest)
>             `(setenv ,var ,(string-join rest sep)))
> +          ((var sep ':- rest)
> +           `(unless (getenv ,var) (setenv ,var ,(string-join rest sep))))
>            ((var sep 'prefix rest)
>             `(let ((current (getenv ,var)))
>                (setenv ,var (if current
> @@ -1484,6 +1492,8 @@ (define wrap-script
>                                 ,(string-join rest sep)))))
>            ((var '= rest)
>             `(setenv ,var ,(string-join rest ":")))
> +          ((var ':- rest)
> +           `(unless (getenv ,var) (setenv ,var ,(string-join rest ":"))))
>            ((var 'prefix rest)
>             `(let ((current (getenv ,var)))
>                (setenv ,var (if current

I like it!  It's something I've wanted in the past.  Perhaps you could
submit it as its own thing, referencing this issue in the commit message
perhaps.

Longer term, we probably work on an upstream true PATH-like solution,
but in the meantime this would be useful to have here, and probably
useful for other single-entry environment variables.

-- 
Thanks,
Maxim