Re: "Command not found" when using `home-mcron-service`

2024-01-15 Thread Tanguy LE CARROUR
Hi Oleg,


Quoting Oleg Pykhalov (2024-01-15 18:13:13)
> Tanguy LE CARROUR  writes:
> > `mcron` can then find `notmuch`, but `notmuch` has some hooks that depend
> > on other commands; `mbsync` and `afew` in my case. For this, I cannot really
> > provide the full path? 🤔 … actually, I could, but then it would be
> > `/home/USER/.guix-home/profile/bin/mbsync`, not the actual path.
> 
> Is the hook a script?  If it is, then the script should have the PATH,
> which can be added to the script itself.

Yes, indeed. Notmuch uses hooks scripts that I provide.
So far, I was relying on `home-xdg-configuration-files-service-type`
to copy them.

```scheme
(service home-xdg-configuration-files-service-type
  `(("notmuch/default/hooks" ,(local-file "tanguy.home/notmuch_hooks" 
#:recursive? #t))
; […]
  ))
```

Now I have to find an easy way to substitute some content in them.
I'll give it a try with `find-files` and `substitute` unless you can
suggest a better way… 🤞


> > This should work, but I can help be find it a bit weird, because it
> > propagates to quite a number of files. 😞
> > And the same goes for `vdirsyncer` that relies on `pass`…
> 
> Is ‘vdirsyncer’ relies on the ‘pass’ by default, or is your
> configuration specific thing?
>
> ‘vdirsyncer’ package recipe should be modified in the first case, to
> make it work for everyone.
> 
> In case of specific configuration a wrapper can be used.

Configuration specific! Fortunately I have a not-yet-submitted home
service for that. So I can easily insert the absolute path! 🥳

Regards,

-- 
Tanguy



Re: "Command not found" when using `home-mcron-service`

2024-01-15 Thread Tanguy LE CARROUR
Hi Nils,


Quoting Nils Landt (2024-01-15 19:11:25)
> 
> > Tanguy LE CARROUR  hat am 15.01.2024 13:30 CET 
> > geschrieben:
> > > If I'm correct, setting the PATH environment variable in the mcron job
> > > should fix it.
> > 
> > You mean inside the `#~(job …)`? Sorry, but… how would you do that? 😅
> 
> Haven't tried it, but something like:
> 
> #~(job '(next-minute (range 0 60 5)) (string-append #$bash " -c 
> \"PATH=$HOME/.guix-home/profile/bin " #$notmuch "/bin/notmuch new\""))

Thanks. I'll give it a try. But based on Oleg's answer, I might go with
modifying all my config files to substitute absolute paths…

Regards,

-- 
Tanguy



Re: "Command not found" when using `home-mcron-service`

2024-01-15 Thread Nils Landt


> Tanguy LE CARROUR  hat am 15.01.2024 13:30 CET 
> geschrieben:
> > If I'm correct, setting the PATH environment variable in the mcron job
> > should fix it.
> 
> You mean inside the `#~(job …)`? Sorry, but… how would you do that? 😅

Haven't tried it, but something like:

#~(job '(next-minute (range 0 60 5)) (string-append #$bash " -c 
\"PATH=$HOME/.guix-home/profile/bin " #$notmuch "/bin/notmuch new\""))

> And this means that I would have to do it for every single job? 🤔

Yes.

> Sounds suboptimal to me.

Agreed! Alternatively, you could install the dependent packages (like pass) in 
guix system, not guix home.

> So I would definitively favour a solution where the PATH is set once and
> for all by Mcron.

I'm pretty sure this does not exist for mcron.



Re: "Command not found" when using `home-mcron-service`

2024-01-15 Thread Oleg Pykhalov
Tanguy LE CARROUR  writes:

> Quoting Oleg Pykhalov (2024-01-15 16:25:27)
>> The Home service matches Guix System in this case, so currently
>> specification of a full path to a binary is required.
>> 
>> It's possible to do in several ways:
>> 
>> 1) Use full path to the binary with ungexp, e.g.
>> 
>> preferred and cleaner:
>> 
>> #$(file-append notmuch "/bin/notmuch")
>> 
>> or:
>> (string-append #$notmuch "/bin/notmuch")
>> 
>> Hint: make sure notmuch is defined, e.g. at the top of a file:
>> 
>> (use-modules (gnu packages mail))
>
> I tried this one! 😁
> The `string-append` version I mean.
>
> `mcron` can then find `notmuch`, but `notmuch` has some hooks that depend
> on other commands; `mbsync` and `afew` in my case. For this, I cannot really
> provide the full path? 🤔 … actually, I could, but then it would be
> `/home/USER/.guix-home/profile/bin/mbsync`, not the actual path.

Is the hook a script?  If it is, then the script should have the PATH,
which can be added to the script itself.

> This should work, but I can help be find it a bit weird, because it
> propagates to quite a number of files. 😞
> And the same goes for `vdirsyncer` that relies on `pass`…

Is ‘vdirsyncer’ relies on the ‘pass’ by default, or is your
configuration specific thing?

‘vdirsyncer’ package recipe should be modified in the first case, to
make it work for everyone.

In case of specific configuration a wrapper can be used.


Oleg.


signature.asc
Description: PGP signature


Re: "Command not found" when using `home-mcron-service`

2024-01-15 Thread Tanguy LE CARROUR
Hi Oleg,

Quoting Oleg Pykhalov (2024-01-15 16:25:27)
> The Home service matches Guix System in this case, so currently
> specification of a full path to a binary is required.
> 
> It's possible to do in several ways:
> 
> 1) Use full path to the binary with ungexp, e.g.
> 
> preferred and cleaner:
> 
> #$(file-append notmuch "/bin/notmuch")
> 
> or:
> (string-append #$notmuch "/bin/notmuch")
> 
> Hint: make sure notmuch is defined, e.g. at the top of a file:
> 
> (use-modules (gnu packages mail))

I tried this one! 😁
The `string-append` version I mean.

`mcron` can then find `notmuch`, but `notmuch` has some hooks that depend
on other commands; `mbsync` and `afew` in my case. For this, I cannot really
provide the full path? 🤔 … actually, I could, but then it would be
`/home/USER/.guix-home/profile/bin/mbsync`, not the actual path.

This should work, but I can help be find it a bit weird, because it
propagates to quite a number of files. 😞
And the same goes for `vdirsyncer` that relies on `pass`…

Oh, actually, I've just figured out that this doesn't actually work,
because my `USER` is not the same on all my computers! 😱
And I cannot rely on `$HOME` because it's not supported by all the
configuration files that are affected.

So I would definitively favour a solution where the PATH is set once and
for all by Mcron.

Regards,

-- 
Tanguy



Re: "Command not found" when using `home-mcron-service`

2024-01-15 Thread Oleg Pykhalov
Tanguy LE CARROUR  writes:

> If I'm correct, setting the PATH environment variable in the mcron job
> should fix it.
>
> You mean inside the `#~(job …)`? Sorry, but… how would you do that? 😅
> And this means that I would have to do it for every single job? 🤔
> Sounds suboptimal to me.



> Quoting Tanguy LE CARROUR (2024-01-15 13:30:35)
>> Quoting Nils Landt (2024-01-15 13:03:06)
>> > > Tanguy LE CARROUR  hat am 15.01.2024 10:38 CET
>> > > geschrieben:
>> > > […]
>> > > `mbsync` is in my profile, but Mcron cannot find it.
>> > > Do I have to declare all the required packages… somehow?! 🤔
>> > 
>> > That sounds like it's related to this issue I reported:
>> > https://issues.guix.gnu.org/65471
>> 
>> It looks like, indeed!
>
> Actually, there's a "small" difference: I'm not using Debian, but… Guix
> System! 🤔

The Home service matches Guix System in this case, so currently
specification of a full path to a binary is required.

It's possible to do in several ways:

1) Use full path to the binary with ungexp, e.g.

preferred and cleaner:

#$(file-append notmuch "/bin/notmuch")

or:
(string-append #$notmuch "/bin/notmuch")

Hint: make sure notmuch is defined, e.g. at the top of a file:

(use-modules (gnu packages mail))


2) Symlink resolving in a Guix profile, e.g.:

"/home/user123/.guix-profile/bin/notmuch"

or

(readlink "/home/user123/.guix-profile/bin/notmuch")


I would recommend for 1) because of reproducibility and easier to track
in future, especially if you have a lot of self managed services.


Oleg.


signature.asc
Description: PGP signature


Re: "Command not found" when using `home-mcron-service`

2024-01-15 Thread Tanguy LE CARROUR
Quoting Tanguy LE CARROUR (2024-01-15 13:30:35)
> Quoting Nils Landt (2024-01-15 13:03:06)
> > > Tanguy LE CARROUR  hat am 15.01.2024 10:38 CET 
> > > geschrieben:
> > > […]
> > > `mbsync` is in my profile, but Mcron cannot find it.
> > > Do I have to declare all the required packages… somehow?! 🤔
> > 
> > That sounds like it's related to this issue I reported:
> > https://issues.guix.gnu.org/65471
> 
> It looks like, indeed!

Actually, there's a "small" difference: I'm not using Debian, but… Guix System! 
🤔

-- 
Tanguy



Re: "Command not found" when using `home-mcron-service`

2024-01-15 Thread Tanguy LE CARROUR
Hi Nils,

Quoting Nils Landt (2024-01-15 13:03:06)
> > Tanguy LE CARROUR  hat am 15.01.2024 10:38 CET 
> > geschrieben:
> >
> > ```scheme
> > (gnu packages dav)  ; vdirsyncer
> > (gnu packages mail)  ; notmuch
> > ; […]
> > (service home-mcron-service-type
> > (home-mcron-configuration
> >  (jobs (list
> >  #~(job '(next-minute (range 0 60 5)) (string-append 
> > #$notmuch "/bin/notmuch new"))
> >  #~(job '(next-hour) (string-append #$vdirsyncer 
> > "/bin/vdirsyncer sync"))
> > ```
> > 
> > And now Mcron finds `notmuch` (and `vdirsyncer`), but… Notmuch has hooks
> > that depend on other commands and I now have the following error message
> > in my logs:
> > 
> > ```
> > 2024-01-15 10:20:00 6198 /gnu/store/[…]-notmuch-0.37/bin/notmuch new: 
> > […]/.config/notmuch/default/hooks/pre-new: line 3: mbsync: command not found
> > ```
> > 
> > `mbsync` is in my profile, but Mcron cannot find it.
> > Do I have to declare all the required packages… somehow?! 🤔
> 
> That sounds like it's related to this issue I reported:
> https://issues.guix.gnu.org/65471

It looks like, indeed!


> If I'm correct, setting the PATH environment variable in the mcron job
> should fix it.

You mean inside the `#~(job …)`? Sorry, but… how would you do that? 😅
And this means that I would have to do it for every single job? 🤔
Sounds suboptimal to me.

I'll ping #65471 to see if a consensus has been reached. 🤞

-- 
Tanguy



Re: "Command not found" when using `home-mcron-service`

2024-01-15 Thread Nils Landt
> Tanguy LE CARROUR  hat am 15.01.2024 10:38 CET 
> geschrieben:
>
> ```scheme
> (gnu packages dav)  ; vdirsyncer
> (gnu packages mail)  ; notmuch
> ; […]
> (service home-mcron-service-type
> (home-mcron-configuration
>  (jobs (list
>  #~(job '(next-minute (range 0 60 5)) (string-append 
> #$notmuch "/bin/notmuch new"))
>  #~(job '(next-hour) (string-append #$vdirsyncer 
> "/bin/vdirsyncer sync"))
> ```
> 
> And now Mcron finds `notmuch` (and `vdirsyncer`), but… Notmuch has hooks
> that depend on other commands and I now have the following error message
> in my logs:
> 
> ```
> 2024-01-15 10:20:00 6198 /gnu/store/[…]-notmuch-0.37/bin/notmuch new: 
> […]/.config/notmuch/default/hooks/pre-new: line 3: mbsync: command not found
> ```
> 
> `mbsync` is in my profile, but Mcron cannot find it.
> Do I have to declare all the required packages… somehow?! 🤔

That sounds like it's related to this issue I reported: 
https://issues.guix.gnu.org/65471

If I'm correct, setting the PATH environment variable in the mcron job should 
fix it.



"Command not found" when using `home-mcron-service`

2024-01-15 Thread Tanguy LE CARROUR
Dear Guix,

I had stop using `home-mcron-service` some times ago, for I had
a problem with my home shepherd. Now that this problem seems to be
fixed 🤞, I've tried to re-enable `home-mcron-service` and, while it runs,
it cannot find the commands to execute!?

I used to have this config:

```scheme
(service home-mcron-service-type
(home-mcron-configuration
 (jobs (list
 #~(job '(next-minute (range 0 60 5)) "notmuch new")
 #~(job '(next-hour) "vdirsyncer sync")
```

But I now have `notmuch new: sh: line 1: notmuch: command not found` in
my logs.

So, I changed it to:

```scheme
(gnu packages dav)  ; vdirsyncer
(gnu packages mail)  ; notmuch
; […]
(service home-mcron-service-type
(home-mcron-configuration
 (jobs (list
 #~(job '(next-minute (range 0 60 5)) (string-append #$notmuch 
"/bin/notmuch new"))
 #~(job '(next-hour) (string-append #$vdirsyncer 
"/bin/vdirsyncer sync"))
```

And now Mcron finds `notmuch` (and `vdirsyncer`), but… Notmuch has hooks
that depend on other commands and I now have the following error message
in my logs:

```
2024-01-15 10:20:00 6198 /gnu/store/[…]-notmuch-0.37/bin/notmuch new: 
[…]/.config/notmuch/default/hooks/pre-new: line 3: mbsync: command not found
```

`mbsync` is in my profile, but Mcron cannot find it.
Do I have to declare all the required packages… somehow?! 🤔

Any help welcome!

Regards,

-- 
Tanguy