all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Guix home mcron help
@ 2022-06-23 16:42 Trev
  2022-06-25  0:57 ` Trev
  0 siblings, 1 reply; 2+ messages in thread
From: Trev @ 2022-06-23 16:42 UTC (permalink / raw)
  To: GUIX Help


[-- Attachment #1.1: Type: text/plain, Size: 1546 bytes --]

Hey guys,

I am trying to appreciate how to set up a guix home mcron using a
separate module that I wrote that exports the job.

My config lives in ~/.config/guix/home/config.scm

My cron module lives in ~/.config/guix/home/cron/mailsync.scm

The mailsync module export this:

#+BEGIN_SRC scheme
(define-public %mailsync-job
  #~(job '(next-minute-from
           (next-minute) (range 0 60 15))
         (lambda ()
           (mailsync-update %mailsync-default-terms)
           (mailsync-notify
            (mailsync-count-new-messages)))
         "mbsync-nm-job"))
#+END_SRC

In my home config I am using it like this:

#+BEGIN_SRC scheme
(home-environment
 (packages
  (specifications->packages
   (append %base-packages
           %emacs
           %multimedia
           %browsers
           %chat-clients
           %devel)))
 (services
  (list (service home-mcron-service-type
                 (home-mcron-configuration
                  (jobs (list %mailsync-job)))))))
#+END_SRC

The command =guix home reconfigure ~/.config/guix/home/config.scm= passes without errors but the resulting cron is unhappy when it runs because it has lost scope of the module it came from and can't find =mailsync-update= (or any other definitions from within said module).

I have attempted to implement =with-imported-modules= from within the module and from within my home configuration and am not having much success.

Can I get a push?

Here's a link to the config and module in full: https://gist.github.com/trev-dev/3312444daa75758822c06db5922aac4f


[-- Attachment #1.2: Type: text/plain, Size: 66 bytes --]

-- 

Trev : 0FB7 D06B 4A2A F07E AD5B  1169 183B 6306 8AA1 D206

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

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

* Re: Guix home mcron help
  2022-06-23 16:42 Guix home mcron help Trev
@ 2022-06-25  0:57 ` Trev
  0 siblings, 0 replies; 2+ messages in thread
From: Trev @ 2022-06-25  0:57 UTC (permalink / raw)
  To: GUIX Help

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

Quick update:

I was able to get my mcron working in a way that seems to be the proper
"guix home" way. It just took a lot of re-reading, trial & error.

The downside to my solution is that I had to wrap my entire mailsync
module in a #~(job #$(program-file)) gexp.

Here's an example of my solution: https://pastebin.com/f12mvpUz

I hate to admit that I struggled a lot with the documentation for what a
gexp is, how they're meant to be implemented, and what a (job) procedure
will allow given the context of a guix home service.

For example, I couldn't figure out how to store my module & an image
file in the guix store so that I could thereafter load and run the file
with a command such as `guile -s` as the cron job. Or better yet, load the module with
`use-modules` from the "program-file" and run the exported functions.

Anyway, I am open to feedback/suggestions. Thanks for reading this :)

Trev <trev@trevdev.ca> writes:

> Hey guys, 
>
> I am trying to appreciate how to set up a guix home mcron using a separate module that I wrote that exports the job. 
>
> My config lives in ~/.config/guix/home/config.scm 
>
> My cron module lives in ~/.config/guix/home/cron/mailsync.scm 
>
> The mailsync module export this: 
>
> (define-public %mailsync-job
>   #~(job '(next-minute-from
>            (next-minute) (range 0 60 15))
>          (lambda ()
>            (mailsync-update %mailsync-default-terms)
>            (mailsync-notify
>             (mailsync-count-new-messages)))
>          "mbsync-nm-job"))
>
> In my home config I am using it like this: 
>
> (home-environment
>  (packages
>   (specifications->packages
>    (append %base-packages
>            %emacs
>            %multimedia
>            %browsers
>            %chat-clients
>            %devel)))
>  (services
>   (list (service home-mcron-service-type
>                  (home-mcron-configuration
>                   (jobs (list %mailsync-job)))))))
>
> The command guix home reconfigure ~/.config/guix/home/config.scm passes without errors but the resulting cron is unhappy when it runs
> because it has lost scope of the module it came from and can't find mailsync-update (or any other definitions from within said module). 
>
> I have attempted to implement with-imported-modules from within the module and from within my home configuration and am not having much
> success. 
>
> Can I get a push? 
>
> Here's a link to the config and module in full: https://gist.github.com/trev-dev/3312444daa75758822c06db5922aac4f 
> -- 
>
> Trev : 0FB7 D06B 4A2A F07E AD5B  1169 183B 6306 8AA1 D206

-- 

Trev : 0FB7 D06B 4A2A F07E AD5B  1169 183B 6306 8AA1 D206

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

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

end of thread, other threads:[~2022-06-25  0:57 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-06-23 16:42 Guix home mcron help Trev
2022-06-25  0:57 ` Trev

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.