all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* units_cur
@ 2018-03-27 10:11 Pierre Neidhardt
  2018-03-27 21:01 ` units_cur Ludovic Courtès
  0 siblings, 1 reply; 14+ messages in thread
From: Pierre Neidhardt @ 2018-03-27 10:11 UTC (permalink / raw)
  To: help-guix

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


I believe that GNU units ("units" package) needs more patching to
function properly:

> sudo units_cur
Unable to write to output file:
[Errno 30] Read-only file system: '/gnu/store/cqvsljfz81xkwfnd4ln2zk4194wjjcgd-units-2.16/share/units/currency.units'

On other systems, one is supposed to run `sudo units_cur' to update the
exchange rates in the currency.units file.

-- 
Pierre Neidhardt

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

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

* Re: units_cur
  2018-03-27 10:11 units_cur Pierre Neidhardt
@ 2018-03-27 21:01 ` Ludovic Courtès
  2018-03-30 11:15   ` units_cur Pierre Neidhardt
  0 siblings, 1 reply; 14+ messages in thread
From: Ludovic Courtès @ 2018-03-27 21:01 UTC (permalink / raw)
  To: Pierre Neidhardt; +Cc: help-guix

Pierre Neidhardt <pe.neidhardt@googlemail.com> skribis:

> I believe that GNU units ("units" package) needs more patching to
> function properly:
>
>> sudo units_cur
> Unable to write to output file:
> [Errno 30] Read-only file system: '/gnu/store/cqvsljfz81xkwfnd4ln2zk4194wjjcgd-units-2.16/share/units/currency.units'
>
> On other systems, one is supposed to run `sudo units_cur' to update the
> exchange rates in the currency.units file.

We could build it with --localstatedir=/var, but would the initial
‘currency.units’ be picked up?

It would be awesome if you could give it a try and report back.

Thank you,
Ludo’.

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

* Re: units_cur
  2018-03-27 21:01 ` units_cur Ludovic Courtès
@ 2018-03-30 11:15   ` Pierre Neidhardt
  2018-03-30 16:33     ` units_cur Ludovic Courtès
  0 siblings, 1 reply; 14+ messages in thread
From: Pierre Neidhardt @ 2018-03-30 11:15 UTC (permalink / raw)
  To: Ludovic Courtès; +Cc: help-guix

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


Ludovic Courtès <ludo@gnu.org> writes:

> We could build it with --localstatedir=/var, but would the initial
> ‘currency.units’ be picked up?

Hmm, I don't see how that would work considering currency.units is
located at

	PREFIX/share/units/currency.units

Maybe I got you wrong.

What we want to do here is move PREFIX/share/units to a writable location.

With ./configure it's possible to move "datarootdir", but that also
moves the info and the man page.  Thus we need to rectify those 2 locations:

	> ./configure --datarootdir=/var --mandir=/usr/local/share/man --infodir=/usr/local/share/info

Disclaimer: I don't know autoconf very well, I think we should use a
special syntax for PREFIX instead of /usr/local/.

The result should be

	/var/units/currency.units (and 2 other files)

-- 
Pierre Neidhardt

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

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

* Re: units_cur
  2018-03-30 11:15   ` units_cur Pierre Neidhardt
@ 2018-03-30 16:33     ` Ludovic Courtès
  2018-03-31  4:37       ` units_cur Pierre Neidhardt
  2018-03-31  4:51       ` units_cur Pierre Neidhardt
  0 siblings, 2 replies; 14+ messages in thread
From: Ludovic Courtès @ 2018-03-30 16:33 UTC (permalink / raw)
  To: Pierre Neidhardt; +Cc: help-guix

Hi Pierre,

Looking more closely, you might be able to add a ~/.units file with:

  include my-updated-currency.units

Could you check if that works?

Thanks,
Ludo’.

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

* Re: units_cur
  2018-03-30 16:33     ` units_cur Ludovic Courtès
@ 2018-03-31  4:37       ` Pierre Neidhardt
  2018-03-31 16:18         ` units_cur Ludovic Courtès
  2018-03-31  4:51       ` units_cur Pierre Neidhardt
  1 sibling, 1 reply; 14+ messages in thread
From: Pierre Neidhardt @ 2018-03-31  4:37 UTC (permalink / raw)
  To: Ludovic Courtès; +Cc: help-guix

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


Ludovic Courtès <ludo@gnu.org> writes:

> Looking more closely, you might be able to add a ~/.units file with:
>
>   include my-updated-currency.units

Note that the actual command must start with a `!`, so it would be:

   !include my-updated-currency.units

> Could you check if that works?

It does.  This would definitely work, but then what about the failing
`sudo units_cur`?

I think this should be documented.  Either by patching the documentation
of units_cur itself so that if run with `sudo`, it displays the above
hint instead.

What do you think?

--
Pierre Neidhardt

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

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

* Re: units_cur
  2018-03-30 16:33     ` units_cur Ludovic Courtès
  2018-03-31  4:37       ` units_cur Pierre Neidhardt
@ 2018-03-31  4:51       ` Pierre Neidhardt
  2018-03-31  7:01         ` units_cur Pierre Neidhardt
  1 sibling, 1 reply; 14+ messages in thread
From: Pierre Neidhardt @ 2018-03-31  4:51 UTC (permalink / raw)
  To: Ludovic Courtès; +Cc: help-guix

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


I'm also wondering whether an mcron-service would work at the system level.

-- 
Pierre Neidhardt

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

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

* Re: units_cur
  2018-03-31  4:51       ` units_cur Pierre Neidhardt
@ 2018-03-31  7:01         ` Pierre Neidhardt
  2018-03-31 16:16           ` units_cur Ludovic Courtès
  0 siblings, 1 reply; 14+ messages in thread
From: Pierre Neidhardt @ 2018-03-31  7:01 UTC (permalink / raw)
  To: Ludovic Courtès; +Cc: help-guix

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


Pierre Neidhardt <ambrevar@gmail.com> writes:

> I'm also wondering whether an mcron-service would work at the system level.

Well, I guess not, that would defeat the integrity of the store.

-- 
Pierre Neidhardt

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

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

* Re: units_cur
  2018-03-31  7:01         ` units_cur Pierre Neidhardt
@ 2018-03-31 16:16           ` Ludovic Courtès
  0 siblings, 0 replies; 14+ messages in thread
From: Ludovic Courtès @ 2018-03-31 16:16 UTC (permalink / raw)
  To: Pierre Neidhardt; +Cc: help-guix

Pierre Neidhardt <ambrevar@gmail.com> skribis:

> Pierre Neidhardt <ambrevar@gmail.com> writes:
>
>> I'm also wondering whether an mcron-service would work at the system level.
>
> Well, I guess not, that would defeat the integrity of the store.

The store is bind-mounted read-only on GuixSD, so no risk.

Ludo’.

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

* Re: units_cur
  2018-03-31  4:37       ` units_cur Pierre Neidhardt
@ 2018-03-31 16:18         ` Ludovic Courtès
  2018-03-31 16:40           ` units_cur Pierre Neidhardt
  0 siblings, 1 reply; 14+ messages in thread
From: Ludovic Courtès @ 2018-03-31 16:18 UTC (permalink / raw)
  To: Pierre Neidhardt; +Cc: help-guix

Pierre Neidhardt <ambrevar@gmail.com> skribis:

> Ludovic Courtès <ludo@gnu.org> writes:
>
>> Looking more closely, you might be able to add a ~/.units file with:
>>
>>   include my-updated-currency.units
>
> Note that the actual command must start with a `!`, so it would be:
>
>    !include my-updated-currency.units

OK.

>> Could you check if that works?
>
> It does.  This would definitely work, but then what about the failing
> `sudo units_cur`?
>
> I think this should be documented.  Either by patching the documentation
> of units_cur itself so that if run with `sudo`, it displays the above
> hint instead.

Hmm, dunno.  Perhaps we could modify ‘units’ to look for
/var/run/units/currency.units first, and fall back to
/gnu/store/…-units/share/units/currency.units.

We would also arrange for ‘units_cur’ to update the file in /var/run by
default.

WDYT?

I’m not offering to work on the patch, though.  :-)

Ludo’.

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

* Re: units_cur
  2018-03-31 16:18         ` units_cur Ludovic Courtès
@ 2018-03-31 16:40           ` Pierre Neidhardt
  2018-03-31 17:10             ` units_cur Ludovic Courtès
  0 siblings, 1 reply; 14+ messages in thread
From: Pierre Neidhardt @ 2018-03-31 16:40 UTC (permalink / raw)
  To: Ludovic Courtès; +Cc: help-guix

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


Ludovic Courtès <ludo@gnu.org> writes:

> Hmm, dunno.  Perhaps we could modify ‘units’ to look for
> /var/run/units/currency.units first, and fall back to
> /gnu/store/…-units/share/units/currency.units.
>
> We would also arrange for ‘units_cur’ to update the file in /var/run by
> default.
>
> WDYT?

That sounds reasonable to me.  What's the purpose of /var/run on GuixSD?
How is it used?

> I’m not offering to work on the patch, though.  :-)

I'll give it a shot when I'll more time on my hands.

-- 
Pierre Neidhardt

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

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

* Re: units_cur
  2018-03-31 16:40           ` units_cur Pierre Neidhardt
@ 2018-03-31 17:10             ` Ludovic Courtès
  2018-04-01  6:16               ` units_cur Pierre Neidhardt
  0 siblings, 1 reply; 14+ messages in thread
From: Ludovic Courtès @ 2018-03-31 17:10 UTC (permalink / raw)
  To: Pierre Neidhardt; +Cc: help-guix

Pierre Neidhardt <ambrevar@gmail.com> skribis:

> Ludovic Courtès <ludo@gnu.org> writes:
>
>> Hmm, dunno.  Perhaps we could modify ‘units’ to look for
>> /var/run/units/currency.units first, and fall back to
>> /gnu/store/…-units/share/units/currency.units.
>>
>> We would also arrange for ‘units_cur’ to update the file in /var/run by
>> default.
>>
>> WDYT?
>
> That sounds reasonable to me.  What's the purpose of /var/run on GuixSD?
> How is it used?

On GNU/Linux /var/run is the standard location to store “state” files.
See ‘runstatedir’ in
<https://www.gnu.org/prep/standards/html_node/Directory-Variables.html>.

Ludo’.

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

* Re: units_cur
  2018-03-31 17:10             ` units_cur Ludovic Courtès
@ 2018-04-01  6:16               ` Pierre Neidhardt
  2018-04-01 13:06                 ` units_cur Pierre Neidhardt
  0 siblings, 1 reply; 14+ messages in thread
From: Pierre Neidhardt @ 2018-04-01  6:16 UTC (permalink / raw)
  To: Ludovic Courtès; +Cc: help-guix

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


Ludovic Courtès <ludo@gnu.org> writes:

>>> Hmm, dunno.  Perhaps we could modify ‘units’ to look for
>>> /var/run/units/currency.units first, and fall back to
>>> /gnu/store/…-units/share/units/currency.units.
>>>
>>> We would also arrange for ‘units_cur’ to update the file in /var/run by
>>> default.
>>>
>>> WDYT?
>>
>> That sounds reasonable to me.  What's the purpose of /var/run on GuixSD?
>> How is it used?
>
> On GNU/Linux /var/run is the standard location to store “state” files.
> See ‘runstatedir’ in
> <https://www.gnu.org/prep/standards/html_node/Directory-Variables.html>.

So how do you get units to use runstatedir instead?
Is there some autoconf way to do it are do we have to patch the code
directly?

I think it would be worth mentioning the issue upstream then.

-- 
Pierre Neidhardt

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

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

* Re: units_cur
  2018-04-01  6:16               ` units_cur Pierre Neidhardt
@ 2018-04-01 13:06                 ` Pierre Neidhardt
  2018-04-01 13:37                   ` units_cur Mathieu Lirzin
  0 siblings, 1 reply; 14+ messages in thread
From: Pierre Neidhardt @ 2018-04-01 13:06 UTC (permalink / raw)
  To: Ludovic Courtès; +Cc: help-guix

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


I want to update whenever the file is older than 1 day (so that it does
not do anything on reboot for instance) and every 1 day
from then on (so that it keeps updating even if I don't reboot).

For that I need mcron with some condition on the mtime of
currency.units.

Here is my implementation:

	;; -*- mode: Lisp; -*-

	;; This cannot be let-bound within `job'.
	(define currency-file (string-append (getenv "HOME") "/.cache/currency.units"))

	(job
	 (lambda (current-time)
	   (let* ((seconds-in-a-day (* 60 60 24))
	          (currency-time (stat:mtime (stat currency-file))))
	     (if (< currency-time (- current-time seconds-in-a-day))
	         (next-second)
	       ;; TODO: The following does not work while it should.  Report upstream.
	       ;; (next-hour-from (next-day) (list (tm:hour (localtime (current-time)))))
	       (+ (next-second) (- 86400 (- current-time currency-time))))))
	 ;; A string is nicer than Scheme code for `mcron --schedule' output.
	 ;; Other we could return '(system* "units_cur" currency-file)
	 (string-append "units_cur " currency-file))

I start ~mcron~ from my ~.profile~:

	mcron &

Comments are welcome :)


Note: As mentioned in the "TODO:" above, I think there is a bug in
mcron.  The following example taken from the Guix manual does not seem
to work:

     (define idutils-job
       ;; Update the index database as user "charlie" at 12:15PM
       ;; and 19:15PM.  This runs from the user's home directory.
       #~(job '(next-minute-from (next-hour '(12 19)) '(15))
              (string-append #$idutils "/bin/mkid src")
              #:user "charlie"))

Or, at the user level:

	(job '(next-minute-from (next-hour '(12 19)) '(15))
              (string-append (getenv "HOME") "/.guix-profile/bin/mkid src"))

	> mcron -s 1
	mcron: Cannot read files in your ~/.config/cron (or ~/.cron) directory.

More specifically, it seems that mcron fails to take a list as second
argument to the ~next-*~ functions.

Can anyone confirm?

--
Pierre Neidhardt

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

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

* Re: units_cur
  2018-04-01 13:06                 ` units_cur Pierre Neidhardt
@ 2018-04-01 13:37                   ` Mathieu Lirzin
  0 siblings, 0 replies; 14+ messages in thread
From: Mathieu Lirzin @ 2018-04-01 13:37 UTC (permalink / raw)
  To: Pierre Neidhardt; +Cc: help-guix

Hello,

Pierre Neidhardt <ambrevar@gmail.com> writes:

> Or, at the user level:
>
> 	(job '(next-minute-from (next-hour '(12 19)) '(15))
>               (string-append (getenv "HOME") "/.guix-profile/bin/mkid src"))
>
> 	> mcron -s 1
> 	mcron: Cannot read files in your ~/.config/cron (or ~/.cron) directory.
>
> More specifically, it seems that mcron fails to take a list as second
> argument to the ~next-*~ functions.
>
> Can anyone confirm?

I confirm this bug which is present in mcron 1.1

It will be fixed in mcron 1.1.1 which should be released in the
following week.

Thanks.

-- 
Mathieu Lirzin
GPG: F2A3 8D7E EB2B 6640 5761  070D 0ADE E100 9460 4D37

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

end of thread, other threads:[~2018-04-01 13:37 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-03-27 10:11 units_cur Pierre Neidhardt
2018-03-27 21:01 ` units_cur Ludovic Courtès
2018-03-30 11:15   ` units_cur Pierre Neidhardt
2018-03-30 16:33     ` units_cur Ludovic Courtès
2018-03-31  4:37       ` units_cur Pierre Neidhardt
2018-03-31 16:18         ` units_cur Ludovic Courtès
2018-03-31 16:40           ` units_cur Pierre Neidhardt
2018-03-31 17:10             ` units_cur Ludovic Courtès
2018-04-01  6:16               ` units_cur Pierre Neidhardt
2018-04-01 13:06                 ` units_cur Pierre Neidhardt
2018-04-01 13:37                   ` units_cur Mathieu Lirzin
2018-03-31  4:51       ` units_cur Pierre Neidhardt
2018-03-31  7:01         ` units_cur Pierre Neidhardt
2018-03-31 16:16           ` units_cur 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.