all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* How to declare symlinks in the configuration?
@ 2023-05-16 11:14 Marek Paśnikowski
  2023-05-16 13:56 ` Felix Lechner via
  0 siblings, 1 reply; 8+ messages in thread
From: Marek Paśnikowski @ 2023-05-16 11:14 UTC (permalink / raw)
  To: help-guix

Dear All

How can I declare symbolic links in the system configuration?
In this specific case, I wish to be able to declare the following link:
~/.config/guix/channels.scm -> ~/src/izumi/channels.scm

I am aware that system configuration is not the optimal place for
files in the user's home directory.
I wish, however, to be able to define arbitrary files in the future,
and this happens to be the opportunity to learn.

I think the Manual chapter about G-expressions does include the answer,
but the instructions are written on an abstraction level
not accessible to my current understanding.


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

* Re: How to declare symlinks in the configuration?
  2023-05-16 11:14 How to declare symlinks in the configuration? Marek Paśnikowski
@ 2023-05-16 13:56 ` Felix Lechner via
  2023-05-17  6:50   ` Marek Paśnikowski
  0 siblings, 1 reply; 8+ messages in thread
From: Felix Lechner via @ 2023-05-16 13:56 UTC (permalink / raw)
  To: Marek Paśnikowski; +Cc: help-guix

Hi Marek,

On Tue, May 16, 2023 at 4:15 AM Marek Paśnikowski
<marekpasnikowski@protonmail.com> wrote:
>
> How can I declare symbolic links in the system configuration?
> In this specific case, I wish to be able to declare the following link:
> ~/.config/guix/channels.scm -> ~/src/izumi/channels.scm

Guix can appear scary at first, and it's easy to overthink a problem.

It probably does not help that many Guix aficionados are
mathematicians or otherwise talented at abstract thinking. (Sorry,
folks—I'm in recovery.) It's also possible that I misunderstood your
question.

A symbolic link is a symbolic link. You can create it with

  $ ln -s ~/src/izumi/channels.scm ~/.config/guix/channels.scm

I do not see the value of such a link, though. I would instead create
the channel list via the Guix Home service, like this. [1][2]

> I am aware that system configuration is not the optimal place for
> files in the user's home directory.

Actually, I keep my system configurations there as well (and publish
them in Git). [3] I use 'guix deploy' for all my equipment from a
single machine.

> I wish, however, to be able to define arbitrary files in the future,

I believe Guix Home can do that for you. I currently only use the
capability for Bash [4] (which I hardly use anymore). I look forward
to improving my Guix Home setup and perhaps even learning from what
you find out.

The author of Guix Home, Andrew Tropin, even tied it into configuring
Emacs via something called 'rde'. There too, I am behind the times.

> I think the Manual chapter about G-expressions does include the answer,

Somehow, I doubt it. G-Expressions are an abstraction for the Guix
build system. It is necessary because the build environment is
different from the one in which you run Guix. I think you need
G-Expressions only when you package software.

> but the instructions are written on an abstraction level
> not accessible to my current understanding.

I believe you are experiencing a "fight or flight" response. At its
core, Guix is a simple and trusted friend. It just gets complicated
(and a bit symbolic) along the way.

Happy hacking!

Kind regards
Felix

[1] https://codeberg.org/lechner/home-config/src/branch/history/service/channels.scm
[2] https://codeberg.org/lechner/home-config/src/commit/243e6c1c59a23ee9560c5dfdcbf6631eb93fad19/desk.scm#L168
[3] https://codeberg.org/lechner/system-config
[4] https://codeberg.org/lechner/home-config/src/branch/history/service/bash.scm


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

* Re: How to declare symlinks in the configuration?
  2023-05-16 13:56 ` Felix Lechner via
@ 2023-05-17  6:50   ` Marek Paśnikowski
  2023-05-18  2:40     ` Gary Johnson
  0 siblings, 1 reply; 8+ messages in thread
From: Marek Paśnikowski @ 2023-05-17  6:50 UTC (permalink / raw)
  To: Felix Lechner; +Cc: help-guix

Felix Lechner <felix.lechner@lease-up.com>:

> 
> 
> Hi Marek,
> 
> On Tue, May 16, 2023 at 4:15 AM Marek Paśnikowski
> marekpasnikowski@protonmail.com wrote:
> 
> > How can I declare symbolic links in the system configuration?
> > In this specific case, I wish to be able to declare the following link:
> > ~/.config/guix/channels.scm -> ~/src/izumi/channels.scm
> 
> folks—I'm in recovery.) It's also possible that I misunderstood your
> question.

You have.  I wish to be able to declare symlinks,
because my goal is to craft a common core configuration for
all of my future GUIX installations.
A part of this is automation of tasks,
such as redirection of Channel configuration source.
I have a strategy to keep all of my configuration in a single GIT repository.

> 
> A symbolic link is a symbolic link. You can create it with
> 
> $ ln -s ~/src/izumi/channels.scm ~/.config/guix/channels.scm
> 

This is a workaround, and my aim is to pre-program as much as possible.

> 
> > I wish, however, to be able to define arbitrary files in the future,
> 
> 
> I believe Guix Home can do that for you. I currently only use the
> capability for Bash [4] (which I hardly use anymore). I look forward
> to improving my Guix Home setup and perhaps even learning from what
> you find out.
> 
> The author of Guix Home, Andrew Tropin, even tied it into configuring
> Emacs via something called 'rde'. There too, I am behind the times.

I know of those.  I just wished to able to declare symlinks in operating-system.
I am starting to think, that this function is not yet implemented.

I am actually thinking of promoting the literate configuration style,
once I have my first system more or less defined.
You can have a look at my previous question on this list,
regarding filesystem labels, to see the previous state of the art.

> 
> > I think the Manual chapter about G-expressions does include the answer,
> 
> 
> Somehow, I doubt it. G-Expressions are an abstraction for the Guix
> build system. It is necessary because the build environment is
> different from the one in which you run Guix. I think you need
> G-Expressions only when you package software.
> 
> > but the instructions are written on an abstraction level
> > not accessible to my current understanding.
> 
> 
> I believe you are experiencing a "fight or flight" response. At its
> core, Guix is a simple and trusted friend. It just gets complicated
> (and a bit symbolic) along the way.
> 

It is nothing like that - I just know that I have yet to learn this.
After another reading I did understand that G-exps allow me
to declare most arbitrary files, just not symlinks...

My conclusion is to have yet another workaround and just live with this.


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

* Re: How to declare symlinks in the configuration?
  2023-05-17  6:50   ` Marek Paśnikowski
@ 2023-05-18  2:40     ` Gary Johnson
  2023-05-18  3:43       ` Marek Paśnikowski
  0 siblings, 1 reply; 8+ messages in thread
From: Gary Johnson @ 2023-05-18  2:40 UTC (permalink / raw)
  To: Marek Paśnikowski; +Cc: Felix Lechner, help-guix

Marek Paśnikowski <marekpasnikowski@protonmail.com> writes:

> How can I declare symbolic links in the system configuration?
> In this specific case, I wish to be able to declare the following link:
> ~/.config/guix/channels.scm -> ~/src/izumi/channels.scm

Hi Marek,

`guix system` is meant to declare the immutable state of your filesystem
*outside* of your home directory as well as packages and services
installed at the system level.

`guix home` is meant to declare the immutable state of your filesystem
*within* your home directory as well as packages and services installed at
the user level.

Used together, they allow you to declare the immutable state of your
entire filesystem. Then you will just need to back up those parts which
are not immutable in order to be able to recover your system after a
failure or transfer the same configuration to another machine.

Since your question is about creating a symlink to a file in your home
directory, you will want to use `guix home` for this task. First place
this code into a file called `home-config.scm`:

```scheme
(use-modules
 ((gnu home)          #:select (home-environment))
 ((gnu home services) #:select (service home-files-service-type))
 ((guix gexp)         #:select (local-file)))

(home-environment
 (services
  (list
   (service home-files-service-type
            `((".config/guix/channels.scm" ,(local-file "/home/your_username/src/izumi/channels.scm")))))))
```

Next, run this command from your shell (do not use `sudo`):

```sh
guix home reconfigure home-config.scm
```

Once this command exits, you should find a symlink at
`~/.config/guix/channels.scm` that points to a copy of your
`channels.scm` file located under the system-wide immutable `/gnu/store`
directory. Each time you want to update this file, simply edit
`~/src/izumi/channels.scm` and re-run the `guix home` command above.

Good luck and happy hacking!
  Gary

-- 
()  ascii ribbon campaign - against html e-mail
/\  www.asciiribbon.org   - against proprietary attachments

Why is HTML email a security nightmare? See https://useplaintext.email/

Please avoid sending me MS-Office attachments.
See http://www.gnu.org/philosophy/no-word-attachments.html


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

* Re: How to declare symlinks in the configuration?
  2023-05-18  2:40     ` Gary Johnson
@ 2023-05-18  3:43       ` Marek Paśnikowski
  2023-05-18  3:45         ` Felix Lechner via
  2023-05-23 14:40         ` Gary Johnson
  0 siblings, 2 replies; 8+ messages in thread
From: Marek Paśnikowski @ 2023-05-18  3:43 UTC (permalink / raw)
  To: Gary Johnson; +Cc: Felix Lechner, help-guix

------- Original Message -------
czwartek, 18 maja 2023 04:40, Gary Johnson <lambdatronic@disroot.org> napisał(a):


> 
> 
> Marek Paśnikowski marekpasnikowski@protonmail.com writes:
> 
> > How can I declare symbolic links in the system configuration?
> > In this specific case, I wish to be able to declare the following link:
> > ~/.config/guix/channels.scm -> ~/src/izumi/channels.scm
> 
> 
> Hi Marek,
> 
> `guix system` is meant to declare the immutable state of your filesystem
> outside of your home directory as well as packages and services
> installed at the system level.
> 
> `guix home` is meant to declare the immutable state of your filesystem
> within your home directory as well as packages and services installed at
> the user level.


Thank you Gary.

This is the kind of answer I was hoping for.
Could you also share with me the corresponding
service-type for the system configuration?



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

* Re: How to declare symlinks in the configuration?
  2023-05-18  3:43       ` Marek Paśnikowski
@ 2023-05-18  3:45         ` Felix Lechner via
  2023-05-23 14:40         ` Gary Johnson
  1 sibling, 0 replies; 8+ messages in thread
From: Felix Lechner via @ 2023-05-18  3:45 UTC (permalink / raw)
  To: Marek Paśnikowski; +Cc: Gary Johnson, help-guix

Hi Marek,

On Wed, May 17, 2023 at 8:43 PM Marek Paśnikowski
<marekpasnikowski@protonmail.com> wrote:
>
> This is the kind of answer I was hoping for.

Sorry I disappointed you, and thank you for using Guix.

Kind regards
Felix


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

* Re: How to declare symlinks in the configuration?
  2023-05-18  3:43       ` Marek Paśnikowski
  2023-05-18  3:45         ` Felix Lechner via
@ 2023-05-23 14:40         ` Gary Johnson
  2023-05-23 16:11           ` Felix Lechner via
  1 sibling, 1 reply; 8+ messages in thread
From: Gary Johnson @ 2023-05-23 14:40 UTC (permalink / raw)
  To: Marek Paśnikowski; +Cc: help-guix

Marek Paśnikowski <marekpasnikowski@protonmail.com> writes:

> Thank you Gary.
>
> This is the kind of answer I was hoping for. Could you also share with
> me the corresponding service-type for the system configuration?

Hi Marek,

  In the system configuration, most of the files that you would edit by
hand on another distro (e.g., config files under /etc) are not managed
directly by a single service in Guix System. Instead, you typically add
services (e.g., `postgresql-service-type`, `cups-service-type`,
`strongswan-service-type`) to your `operating-system` definition and
declare their configurations within each service's scheme code.

For example, here is how you might edit the config files for a
Postgresql server:

```scheme
(use-modules
 ((gnu packages databases) #:select (postgresql))
 ((gnu packages geo)       #:select (postgis))
 ((gnu services)           #:select (service))
 ((gnu services databases) #:select (postgresql-service-type postgresql-configuration postgresql-config-file))
 ((gnu services desktop)   #:select (%desktop-services))
 ((gnu system)             #:select (operating-system))
 ((guix gexp)              #:select (local-file)))

(operating-system
 ;; ...Eliding all the fields except `services`...
 (services (cons (service postgresql-service-type
                          (postgresql-configuration
                           (postgresql postgresql)
                           (extension-packages (list postgis))
                           (config-file
                            (postgresql-config-file
                             (hba-file (local-file "etcfiles/pg_hba.conf"))
                             (extra-config '(("max_worker_processes" "12")
                                             ("max_parallel_workers" "40")
                                             ("max_parallel_maintenance_workers" "8")
                                             ("max_parallel_workers_per_gather" "4")
                                             ("parallel_leader_participation"
                                             "on")))))))
                 %desktop-services)))
```

In this example, I showed two ways of specifying the contents of a
config file for this service:

1. Using `local-file` to pull in the contents of a text file somewhere
   on disk. In this case, I keep my system-wide service config files
   under a directory called "etcfiles" (in my home directory). For
   config files referenced in my `guix home` configuration, I use a
   directory called "dotfiles".

2. Including the contents of these files directly in the
   `operating-system` declaration. In this case, you see me specifying
   key-value pairs for the main Postgresql config file in a nested list
   under the `extra-config` record parameter.

=======================================================================

Now...having provided the above explanation as the typical usage pattern
for configuring services on Guix System, I will add that there is an
escape hatch that you can use (as a last resort if there isn't an
existing service that controls the files you want to edit).

This is the service called `etc-service-type`. You can use it to declare
any arbitrary files that would like added immutably under the top level
"/etc" directory. You can use it like so:

```scheme
(use-modules
 ((gnu services)           #:select (service etc-service-type))
 ((gnu services desktop)   #:select (%desktop-services))
 ((gnu system)             #:select (operating-system))
 ((guix gexp)              #:select (local-file)))

(operating-system
 ;; ...Eliding all the fields except `services`...
 (services (cons (service etc-service-type
                          `(("resolv.conf" ,(local-file "etcfiles/resolv.conf"))))
                 %desktop-services)))
```

Now you know, and knowing is half the battle. ;)
Have fun and happy hacking on Guix!

  ~Gary

-- 
Protect yourself from surveillance: https://emailselfdefense.fsf.org
=======================================================================
()  ascii ribbon campaign - against html e-mail
/\  www.asciiribbon.org   - against proprietary attachments

Why is HTML email a security nightmare? See https://useplaintext.email/

Please avoid sending me MS-Office attachments.
See http://www.gnu.org/philosophy/no-word-attachments.html


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

* Re: How to declare symlinks in the configuration?
  2023-05-23 14:40         ` Gary Johnson
@ 2023-05-23 16:11           ` Felix Lechner via
  0 siblings, 0 replies; 8+ messages in thread
From: Felix Lechner via @ 2023-05-23 16:11 UTC (permalink / raw)
  To: Gary Johnson; +Cc: Marek Paśnikowski, help-guix

Hi,

On Tue, May 23, 2023 at 8:13 AM Gary Johnson <lambdatronic@disroot.org> wrote:
>
> 2. Including the contents of these files directly in the
>    `operating-system` declaration. In this case, you see me specifying
>    key-value pairs for the main Postgresql config file in a nested list
>    under the `extra-config` record parameter.

A more explicit example via 'plain-file' [1] can be found here. [2]

Kind regards
Felix

[1] https://guix.gnu.org/en/manual/devel/en/guix.html#index-plain_002dfile
[2] https://codeberg.org/lechner/system-config/src/commit/81f867ca39ba6149e1efb49f3c1437614085e970/host/wallace-server/operating-system.scm#L697-L704


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

end of thread, other threads:[~2023-05-23 16:12 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-05-16 11:14 How to declare symlinks in the configuration? Marek Paśnikowski
2023-05-16 13:56 ` Felix Lechner via
2023-05-17  6:50   ` Marek Paśnikowski
2023-05-18  2:40     ` Gary Johnson
2023-05-18  3:43       ` Marek Paśnikowski
2023-05-18  3:45         ` Felix Lechner via
2023-05-23 14:40         ` Gary Johnson
2023-05-23 16:11           ` Felix Lechner via

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.