unofficial mirror of guix-devel@gnu.org 
 help / color / mirror / code / Atom feed
* A public Lisp programming interface provide feature like `guix environment --container`
@ 2020-11-04  3:49 Zhu Zihao
  2020-11-06  9:41 ` Ludovic Courtès
  0 siblings, 1 reply; 6+ messages in thread
From: Zhu Zihao @ 2020-11-04  3:49 UTC (permalink / raw)
  To: guix-devel

[-- Attachment #1: Type: text/plain, Size: 585 bytes --]


"guix environment --container" is a very useful feature for me to
isolate the untrusted software. But sadly it lacks a interface for user
to use it in Lisp programming.

In (guix scripts environment), only `guix-environment` is exported. but
it process unix style command line option.

I'm wondering it's good to expose some interface suitable for Lisp, just
like the internal function `launch-environment/container`. This can
encourage me to port more container entry script from shell to Guile.

-- 
Retrieve my PGP public key: https://meta.sr.ht/~citreu.pgp

Zihao

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 515 bytes --]

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

* A public Lisp programming interface provide feature like `guix environment --container`
@ 2020-11-04  7:38 Leo Prikler
  2020-11-04 10:05 ` Zhu Zihao
  0 siblings, 1 reply; 6+ messages in thread
From: Leo Prikler @ 2020-11-04  7:38 UTC (permalink / raw)
  To: all_but_last; +Cc: guix-devel

Hello,

Am Mittwoch, den 04.11.2020, 11:49 +0800 schrieb Zhu Zihao
> "guix environment --container" is a very useful feature for me to
> isolate the untrusted software. But sadly it lacks a interface for
> user
> to use it in Lisp programming.
> 
> In (guix scripts environment), only `guix-environment` is exported.
> but
> it process unix style command line option.
(guix scripts …) *is* the command line interface, so it makes sense,
that its interface handles command line arguments.

> I'm wondering it's good to expose some interface suitable for Lisp,
> just
> like the internal function `launch-environment/container`. This can
> encourage me to port more container entry script from shell to Guile.
launch-environment/container still assumes the command to be a shell
script, which I think is not quite what you want.  You probably want to
take a look at call-with-container from (guix build linux-container) or
child-hurds.
I currently don't know of any procedure, that "directly" invokes Scheme
code through Guix environments, so you'd have to build that on your
own.  However, given that your stated goal is to port container entry
scripts [I read this as "the script called by the container at entry"]
to Guile, would it not make sense to have

  (guix-environment [ENVIRONMENT OPTIONS] "--" "guile" "entry.scm")

WDYT?

Regards, Leo



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

* Re: A public Lisp programming interface provide feature like `guix environment --container`
  2020-11-04  7:38 Leo Prikler
@ 2020-11-04 10:05 ` Zhu Zihao
  2020-11-04 10:23   ` Leo Prikler
  0 siblings, 1 reply; 6+ messages in thread
From: Zhu Zihao @ 2020-11-04 10:05 UTC (permalink / raw)
  To: Leo Prikler; +Cc: guix-devel

[-- Attachment #1: Type: text/plain, Size: 1084 bytes --]


Leo Prikler writes:

> launch-environment/container still assumes the command to be a shell
> script, which I think is not quite what you want.  You probably want to
> take a look at call-with-container from (guix build linux-container) or
> child-hurds.

I just read the source code of call-with-container. IMO, it just run
code in container, without any settings. It's quite inconvenient for my
usage. For example: I have to setup mount binding of my package closure manually. 

> I currently don't know of any procedure, that "directly" invokes Scheme
> code through Guix environments, so you'd have to build that on your
> own.  However, given that your stated goal is to port container entry
> scripts [I read this as "the script called by the container at entry"]
> to Guile, would it not make sense to have
>
>   (guix-environment [ENVIRONMENT OPTIONS] "--" "guile" "entry.scm")
>
> WDYT?
>
> Regards, Leo

Hmmm, maybe this is the solution, tho it's not very very elegant.


-- 
Retrieve my PGP public key: https://meta.sr.ht/~citreu.pgp

Zihao

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 515 bytes --]

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

* Re: A public Lisp programming interface provide feature like `guix environment --container`
  2020-11-04 10:05 ` Zhu Zihao
@ 2020-11-04 10:23   ` Leo Prikler
  2020-11-04 10:36     ` Zhu Zihao
  0 siblings, 1 reply; 6+ messages in thread
From: Leo Prikler @ 2020-11-04 10:23 UTC (permalink / raw)
  To: Zhu Zihao; +Cc: guix-devel

Am Mittwoch, den 04.11.2020, 18:05 +0800 schrieb Zhu Zihao:
> Leo Prikler writes:
> 
> > launch-environment/container still assumes the command to be a
> > shell
> > script, which I think is not quite what you want.  You probably
> > want to
> > take a look at call-with-container from (guix build linux-
> > container) or
> > child-hurds.
> 
> I just read the source code of call-with-container. IMO, it just run
> code in container, without any settings. It's quite inconvenient for
> my
> usage. For example: I have to setup mount binding of my package
> closure manually. 
Indeed, but in my opinion it also has much of what you'd want for an
entry script, does it not?  You start with zero settings, then
configure the environment in whichever fashion you need, then call some
other function.
I think like this could be a stepping stone for some higher level
abstraction, that you would have to write on your own once, but could
then reuse more or less indefinitely.  Particularly, you would have to
copy the parts of Guix that create the environment and then just figure
out how to securely spawn a function inside it, that can't escape the
container environment, instead of running shell code.

> > I currently don't know of any procedure, that "directly" invokes
> > Scheme
> > code through Guix environments, so you'd have to build that on your
> > own.  However, given that your stated goal is to port container
> > entry
> > scripts [I read this as "the script called by the container at
> > entry"]
> > to Guile, would it not make sense to have
> > 
> >   (guix-environment [ENVIRONMENT OPTIONS] "--" "guile" "entry.scm")
> > 
> > WDYT?
> > 
> > Regards, Leo
> 
> Hmmm, maybe this is the solution, tho it's not very very elegant.
For the record, what you do want is something à la
(call-in-container-environment THUNK MANIFEST . KWARGS)
where manifest is the Guix environment manifest, THUNK is a procedure
to call with 0 arguments and KWARGS is a list of options for things you
might want to set up, e.g. just the GUIX_ENVIRONMENT variable or more
than that.

Is that about right?

Regards, Leo



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

* Re: A public Lisp programming interface provide feature like `guix environment --container`
  2020-11-04 10:23   ` Leo Prikler
@ 2020-11-04 10:36     ` Zhu Zihao
  0 siblings, 0 replies; 6+ messages in thread
From: Zhu Zihao @ 2020-11-04 10:36 UTC (permalink / raw)
  To: Leo Prikler; +Cc: guix-devel

[-- Attachment #1: Type: text/plain, Size: 892 bytes --]


Leo Prikler writes:

> For the record, what you do want is something à la
> (call-in-container-environment THUNK MANIFEST . KWARGS)
> where manifest is the Guix environment manifest, THUNK is a procedure
> to call with 0 arguments and KWARGS is a list of options for things you
> might want to set up, e.g. just the GUIX_ENVIRONMENT variable or more
> than that.
>
> Is that about right?
>
> Regards, Leo

Yes, that's what I want. KWARGS may accept something like user-mappings,
network?, namepsaces etc. like `launch-environment/container`. So I can
create container entry script for different executable in batch with
more confidence in code reuse. It's ugly to 
concatenate string argument (For example: `(string-append "--expose="
xxxx "=" yyy)`) when I want to reuse some path variable.


-- 
Retrieve my PGP public key: https://meta.sr.ht/~citreu.pgp

Zihao

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 515 bytes --]

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

* Re: A public Lisp programming interface provide feature like `guix environment --container`
  2020-11-04  3:49 A public Lisp programming interface provide feature like `guix environment --container` Zhu Zihao
@ 2020-11-06  9:41 ` Ludovic Courtès
  0 siblings, 0 replies; 6+ messages in thread
From: Ludovic Courtès @ 2020-11-06  9:41 UTC (permalink / raw)
  To: Zhu Zihao; +Cc: guix-devel

Hi,

Zhu Zihao <all_but_last@163.com> skribis:

> "guix environment --container" is a very useful feature for me to
> isolate the untrusted software. But sadly it lacks a interface for user
> to use it in Lisp programming.

The interface to containers is in (gnu build linux-container), though
it’s a bit lower-level compared to what ‘guix environment’ does.

See also the example at
<https://lists.gnu.org/archive/html/help-guix/2018-01/msg00118.html>,
which is precisely about your use case.

Thanks,
Ludo’.


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

end of thread, other threads:[~2020-11-06  9:41 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-04  3:49 A public Lisp programming interface provide feature like `guix environment --container` Zhu Zihao
2020-11-06  9:41 ` Ludovic Courtès
  -- strict thread matches above, loose matches on Subject: below --
2020-11-04  7:38 Leo Prikler
2020-11-04 10:05 ` Zhu Zihao
2020-11-04 10:23   ` Leo Prikler
2020-11-04 10:36     ` Zhu Zihao

Code repositories for project(s) associated with this public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).