1

IDE's like PyCharm work better when fs.inotify.max_user_watches is set to a high level. How to do that in GUIX?

I recall that the approach by Draketo used to work up to a few months ago: https://www.draketo.de/software/guix-config.html

             (service sysctl-service-type
                      (sysctl-configuration
                       (settings '(("fs.file-max" . "500000")
                                   ("fs.inotify.max_user_watches" . "524288")))))

in config.scm.

E.g. this minimal config.scm

(use-modules (gnu))
(use-service-modules desktop xorg)

(operating-system
  (locale "en_US.utf8")
  (timezone "Europe/Amsterdam")
  (keyboard-layout
    (keyboard-layout "us" "us-intl"))
  (host-name "abcd")
  (services
    (append
      (list (service gnome-desktop-service-type)
             (service sysctl-service-type
                      (sysctl-configuration
                       (settings '(("fs.file-max" . "500000")
                                   ("fs.inotify.max_user_watches" . "524288")))))
      )
      %desktop-services))
  (bootloader
    (bootloader-configuration
      (bootloader grub-efi-bootloader)
      (target "/boot/efi")
      (keyboard-layout keyboard-layout)))
  (file-systems
    (cons* (file-system
             (mount-point "/")
             (device
               (uuid "11111111-1111-1111-1111-111111111111"
                     'btrfs))
             (type "btrfs"))
           (file-system
             (mount-point "/boot/efi")
             (device (uuid "1111-1111" 'fat32))
             (type "vfat"))
           %base-file-systems)))

will give this error when using guix system build -n config.scm:

error: sysctl-service-type: unbound variable
hint: Did you forget `(use-modules (gnu services sysctl))'?

However, adding that line to the top:

(use-modules (gnu))
(use-service-modules desktop xorg)
(use-modules (gnu services sysctl))
(operating-system
...

or this

(use-modules (gnu))
(use-service-modules desktop xorg sysctl)
(operating-system
...

will lead to this error:

guix system: error: service 'sysctl' provided more than once

Guix is recent:

$ guix -V
guix (GNU Guix) 1b6e7157cd30ffc2b29779fe6d5cb4ddbbc6f331

Edit:

Possibly related bug report: " [PATCH] gnu: Harden filesystem links." https://debbugs.gnu.org/cgi/bugreport.cgi?bug=47013

Possibly related email thread: "How to compose sysctl-service-type?" https://lists.gnu.org/archive/html/help-guix/2021-03/msg00066.html

Apparently outdated documentation: https://guix.gnu.org/manual/en/html_node/Miscellaneous-Services.html#Miscellaneous-Services which has this broken(?) example

(service sysctl-service-type
         (sysctl-configuration
           (settings '(("net.ipv4.ip_forward" . "1")))))

There is newer documentation https://git.savannah.gnu.org/cgit/guix.git/tree/doc/guix.texi with these instructions:

Since sysctl-service-type is used in the default lists of services, %base-services and %desktop-services, you can use modify-services to change its configuration and add the kernel parameters that you want.

with this example

(modify-services %base-services
  (sysctl-service-type config =>
                       (sysctl-configuration
                         (settings (append '(("net.ipv4.ip_forward" . "1"))
                                           %default-sysctl-settings)))))

However it is unclear to me where to put that. Putting it after the services definition gives this error:

error: (modify-services %base-services (sysctl-service-type config => (sysctl-configuration (settings (append (quote (("net.ipv4.ip_forward" . "1"))) %default-sysctl-settings))))): invalid field specifier
BlackShift
  • 587
  • 2
  • 7
  • 18
  • Hmm, perhaps should have asked this on the Unix & Linux StackExchange; is it possible to move the question? – BlackShift Apr 06 '21 at 08:54

1 Answers1

0

This minimal example seems to work with guix system build -n:

(use-modules (gnu))
(use-service-modules desktop xorg sysctl)
(operating-system
  (locale "en_US.utf8")
  (timezone "Europe/Amsterdam")
  (keyboard-layout
    (keyboard-layout "us" "us-intl"))
  (host-name "abcd")
  (services
    (append
      (list (service gnome-desktop-service-type)
      )

      (modify-services %desktop-services
        (sysctl-service-type config =>
          (sysctl-configuration
            (settings (append '(("fs.file-max" . "500000")
                                ("fs.inotify.max_user_watches" . "524288"))
                               %default-sysctl-settings)))))

      ))

  (bootloader
    (bootloader-configuration
      (bootloader grub-efi-bootloader)
      (target "/boot/efi")
      (keyboard-layout keyboard-layout)))
  (file-systems
    (cons* (file-system
             (mount-point "/")
             (device
               (uuid "11111111-1111-1111-1111-111111111111"
                     'btrfs))
             (type "btrfs"))
           (file-system
             (mount-point "/boot/efi")
             (device (uuid "1111-1111" 'fat32))
             (type "vfat"))
           %base-file-systems)))

The new documentation says to modify %base-services, but in this case it is necessary to modify %desktop-services, which seems to include %base-services. The modify-services command replaces the %desktop-services line.

Tested to work.

BlackShift
  • 587
  • 2
  • 7
  • 18