all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* How can I use ()
@ 2018-01-13 14:32 Alex ter Weele
  2018-01-14 21:27 ` How can I use (guix store)’s build (was “Re: How can I use ()”) Alex ter Weele
  2018-01-16 16:11 ` How can I use () Ludovic Courtès
  0 siblings, 2 replies; 3+ messages in thread
From: Alex ter Weele @ 2018-01-13 14:32 UTC (permalink / raw)
  To: help-guix

(Following this conversion on #guix:
https://gnunet.org/bot/log/guix/2018-01-10#T1600427)

I am trying to use the mcron service to run backups. I have written:

(define (backup-home user)
  #~(begin
      (execl
       (string-append #$borg "/bin/borg")
       "create"
       "--stats" "--list" "--verbose"
       "/mnt/borg::{hostname}-{utcnow}"
       (format "/home/%s" #$user))
      ;; TODO: borg prune.
      ))

(define (backup-home-job user)
  #~(job '(next-hour '(18))
         #$(backup-home user)
         #:user #$user))

I would like to run the gexp (backup-home "alex") from the REPL so that
I can verify it works properly. I looked into what the mcron service
itself does with the gexp in order to run it and found that (gnu
shepherd)'s shepherd-configuration-file uses gexp->file.

Based on this, what I think I want to do is something like:

,enter-store-monad
(build (list (gexp->script "test" (backup-home "alex"))))

And then run the resulting script file. However, doing such gives the
error:

ERROR: In procedure string->utf8:
ERROR: In procedure string->utf8: Wrong type argument in position 1 (expecting string): #<procedure 327b030 at guix/gexp.scm:1128:2 (state)>

At this point I tried putting a string in what I think is the right
place, once again running in the store monad REPL:

(build "foo" (list (gexp->script "test" (backup-home "alex"))))

But this gives:

ERROR: In procedure length:
ERROR: In procedure length: Wrong type argument in position 1: "foo"

At which point I'm stumped. I'd love to know what I'm doing wrong!

Thanks,
Alex

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

* How can I use (guix store)’s build (was “Re: How can I use ()”)
  2018-01-13 14:32 How can I use () Alex ter Weele
@ 2018-01-14 21:27 ` Alex ter Weele
  2018-01-16 16:11 ` How can I use () Ludovic Courtès
  1 sibling, 0 replies; 3+ messages in thread
From: Alex ter Weele @ 2018-01-14 21:27 UTC (permalink / raw)
  To: help-guix

I didn’t proofread my subject. This is what I meant.

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

* Re: How can I use ()
  2018-01-13 14:32 How can I use () Alex ter Weele
  2018-01-14 21:27 ` How can I use (guix store)’s build (was “Re: How can I use ()”) Alex ter Weele
@ 2018-01-16 16:11 ` Ludovic Courtès
  1 sibling, 0 replies; 3+ messages in thread
From: Ludovic Courtès @ 2018-01-16 16:11 UTC (permalink / raw)
  To: Alex ter Weele; +Cc: help-guix

Hi Alex,

Alex ter Weele <alex.ter.weele@gmail.com> skribis:

> Based on this, what I think I want to do is something like:
>
> ,enter-store-monad
> (build (list (gexp->script "test" (backup-home "alex"))))
>
> And then run the resulting script file. However, doing such gives the
> error:
>
> ERROR: In procedure string->utf8:
> ERROR: In procedure string->utf8: Wrong type argument in position 1 (expecting string): #<procedure 327b030 at guix/gexp.scm:1128:2 (state)>

‘gexp->script’ returns a “monadic” value, so you need to “bind” it with
‘mlet’ or similar to actually access that value:

  (mlet %store-monad ((script (gexp->script …)))
    (built-derivations (list script)))

Note that the whole result is again a monadic value.

Alternately, instead of fiddling at the REPL, you could do:

  guix gc -R $(guix system build config.scm) | grep mcron

then pick the right .drv from there, and run:

  guix build ….drv

HTH!

Ludo’.

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

end of thread, other threads:[~2018-01-16 16:11 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-01-13 14:32 How can I use () Alex ter Weele
2018-01-14 21:27 ` How can I use (guix store)’s build (was “Re: How can I use ()”) Alex ter Weele
2018-01-16 16:11 ` How can I use () 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.