all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#60106: [Shepherd 0.9.3] ‘system*’ replacement cannot be passed environment variables
@ 2022-12-15 22:47 Ludovic Courtès
  2022-12-22 16:17 ` Adam Faiz via Bug reports for GNU Guix
  0 siblings, 1 reply; 3+ messages in thread
From: Ludovic Courtès @ 2022-12-15 22:47 UTC (permalink / raw)
  To: 60106

As we found out while debugging <https://issues.guix.gnu.org/60010>, the
Shepherd 0.9.3, with its ‘system*’ replacement (aka. ‘spawn-command’),
makes it very hard to spawn a command with different environment
variables.

The following options don’t work:

  • Changing shepherd’s own environment variables with ‘setenv’ for
    instance: ‘spawn-command’ calls ‘fork+exec-command’, whose default
    #:environment-variables is provided by the
    ‘default-environment-variables’ parameter, which gets its default
    value at when shepherd starts.  There’s no environment variable
    inheritance, contrary to the real ‘system*’.

  • Parameterizing ‘default-environment-variables’:

       (parameterize ((default-environment-variables …))
         (system* …))

    That won’t work because ‘spawn-command’ delegates to the process
    monitoring fiber, which has a different dynamic state and thus
    doesn’t see this change.

  • Even a plain (set! default-environment-variables …) won’t work,
    probably due to inlining within (shepherd services).

I think we’ll have to add a parameter to ‘spawn-command’ to specify
environment variables.

Ludo’.




^ permalink raw reply	[flat|nested] 3+ messages in thread

* bug#60106: [Shepherd 0.9.3] ‘system*’ replacement cannot be passed environment variables
  2022-12-15 22:47 bug#60106: [Shepherd 0.9.3] ‘system*’ replacement cannot be passed environment variables Ludovic Courtès
@ 2022-12-22 16:17 ` Adam Faiz via Bug reports for GNU Guix
  2022-12-22 16:47   ` Ludovic Courtès
  0 siblings, 1 reply; 3+ messages in thread
From: Adam Faiz via Bug reports for GNU Guix @ 2022-12-22 16:17 UTC (permalink / raw)
  To: 60106; +Cc: ludovic.courtes

> I think we’ll have to add a parameter to ‘spawn-command’ to specify
> environment variables.
> 
> Ludo’.
If you do this, can you add an #:append? flag which adds environment 
variables to the inherited environment instead of specifying the 
variables declaratively? It can be #f by default.

It would be very useful for me using the shepherd as init on a foreign 
distro, so I don't have to use the `env` command.




^ permalink raw reply	[flat|nested] 3+ messages in thread

* bug#60106: [Shepherd 0.9.3] ‘system*’ replacement cannot be passed environment variables
  2022-12-22 16:17 ` Adam Faiz via Bug reports for GNU Guix
@ 2022-12-22 16:47   ` Ludovic Courtès
  0 siblings, 0 replies; 3+ messages in thread
From: Ludovic Courtès @ 2022-12-22 16:47 UTC (permalink / raw)
  To: Adam Faiz; +Cc: 60106

Adam Faiz <adam.faiz@disroot.org> skribis:

>> I think we’ll have to add a parameter to ‘spawn-command’ to specify
>> environment variables.
>> Ludo’.
> If you do this, can you add an #:append? flag which adds environment
> variables to the inherited environment instead of specifying the
> variables declaratively? It can be #f by default.
>
> It would be very useful for me using the shepherd as init on a foreign
> distro, so I don't have to use the `env` command.

You could always write something like:

  #:environment-variables `("EXTRA_VARIABLE=something" ,@(environ))

to append ‘EXTRA_VARIABLE’ to those of the environment.

So I don’t think we need #:append.

Thanks for your feedback,
Ludo’.




^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-12-22 21:22 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-12-15 22:47 bug#60106: [Shepherd 0.9.3] ‘system*’ replacement cannot be passed environment variables Ludovic Courtès
2022-12-22 16:17 ` Adam Faiz via Bug reports for GNU Guix
2022-12-22 16:47   ` Ludovic Courtès

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/guix.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.