[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Service definitions: create a symlink in /etc???
From: |
Edouard Klein |
Subject: |
Re: Service definitions: create a symlink in /etc??? |
Date: |
Sat, 03 Aug 2024 16:26:13 +0200 |
User-agent: |
mu4e 1.10.2; emacs 28.2 |
Hi,
An quicker and dirtier solution is to create an activation service that will
create a
symlink:
(extend-service
activation
#~(begin
(unless (stat "/etc/whatever" #f)
(symlink "/etc/hostname"
"/etc/whatever"))))
This is using beaverlabs's functional syntax
https://guix-hosting.com/docs/tuto/getting-started.html
but you can easily enough deduce the non sweetened version from the
macro definition
https://gitlab.com/edouardklein/guix/-/blob/beaverlabs/beaver/functional-services.scm?ref_type=heads#L60
Cheers,
Marek Paśnikowski <marek@marekpasnikowski.pl> writes:
> "Zack Weinberg" <zack@owlfolio.org> writes:
>
>> There doesn't seem to be an analogue of local-file or plain-file for
>> symlinks, and I just spent half an hour poking at the guix repl trying
>> to get the daemon to cough up /gnu/store/xxxxxxxx-hostname as a thing
>> I could put into a gexp, without any luck.
>>
>> How would you suggest that this be done?
>>
>
> I was also stumped on this question in the past. The key insight is
> that any declared file is a symlink to the Gnu Store itself. Further,
> it does not really matter what kind of file type the daemon
> configuration is in. All it wants is A file with the hostname, right?
>
> You could specify a (plain-file "filename" "hostname") in the
> [extra-special-file service][1] for a quick solution, but that would
> complicate any future hostname changes. The proper solution is to
> define a variable holding the hostname externally to the
> operating-system record, and use this variable in both the
> (operating-system (host-name)) field and a (mixed-text-file "filename"
> hostname) [procedure][2]
>
> [1]: https://guix.gnu.org/manual/devel/en/html_node/Base-Services.html
>
> [2]: https://guix.gnu.org/manual/devel/en/html_node/G_002dExpressions.html