Subject: bug#58084: guix deploy fails, leaving the newly installed system generation active

From: Maxim Cournoyer <[email-masked]>
Date: Mon, 26 Sep 2022 13:46:20 -0400

Hi,

Ludovic Courtès <[email-masked]> writes:

[...]

> We can run it manually to get debugging data:
>
> ludo@overdrive1 ~$ sudo -E env -i COLUMNS=100  "/gnu/store/xv7j4im9ap92mv0mbsm1wa4px93zxrms-switch-to-system.scm"
> making '/gnu/store/kifxq4hmp4ihn6nb06ia8wms33qrndxn-system' the current system...
> WARNING: (guile-user): imported module (guix build utils) overrides core binding `delete'
> setting up setuid programs in '/run/setuid-programs'...
> populating /etc from /gnu/store/hf3qxlaiajvapwis0lq20avgl2whfa5w-etc...
> Backtrace:
>            6 (primitive-load "/gnu/store/xv7j4im9ap92mv0mbsm1wa4px93zxrms-switch-to-system.scm")
>            5 (primitive-load "/gnu/store/1wdwlaqkmixb1d7by7fj23lxppw8x44r-activate.scm")
> In ice-9/boot-9.scm:
>    260:13  4 (for-each #<procedure primitive-load (_)> _)
> In unknown file:
>            3 (primitive-load "/gnu/store/v03vaksmkpj7wv4dhm0yrd3y65lzbixz-activate-service.scm")
> In srfi/srfi-1.scm:
>     634:9  2 (for-each #<procedure ffffaaff10e0 at gnu/build/activation.scm:257:12 (file)> _)
> In gnu/build/activation.scm:
>    267:20  1 (_ "modprobe.d")
> In unknown file:
>            0 (symlink "/etc/static/modprobe.d" "/etc/modprobe.d")
>
> ERROR: In procedure symlink:
> In procedure symlink: File exists
>
>
> This is because ‘zram-device-service-type’ contributes a file to
> /etc/modprobe.d:
>
> (define %zram-device-config
>   `("modprobe.d/zram.conf"
>     ,(plain-file "zram.conf"
>                  "options zram num_devices=1")))
>
> (define zram-device-service-type
>   (service-type
>     (name 'zram)
>     (default-value (zram-device-configuration))
>     (extensions
>       (list (service-extension kernel-module-loader-service-type
>                                (const (list "zram")))
>             (service-extension etc-service-type
>                                (const (list %zram-device-config)))
>             (service-extension udev-service-type
>                                (compose list zram-device-udev-rule))))
>     (description "Creates a zram swap device.")))
>
>
> … which is fine, except that there was already a pre-existing
> /etc/modprobe.d directory (coming from openSuSE, the distro that was
> initially installed on this machine), which caused this activation code
> to break:

Oh wow! Should we be extra careful and always rm files before linking to
their location?  Or define our own 'symlink' procedure that'd take care
of it?  That's not very elegant but better than obscure crashes like
this.

What do you think?

Thanks for the debugging!

Maxim