IDE(例如 PyCharm)在fs.inotify.max_user_watches
设置为高级别时工作得更好。如何在 GUIX 中做到这一点?
我记得几个月前 Draketo 的方法还有效: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")))))
在config.scm
。
例如这个最小的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)))
使用时会出现此错误guix system build -n config.scm
:
error: sysctl-service-type: unbound variable
hint: Did you forget `(use-modules (gnu services sysctl))'?
但是,将该行添加到顶部:
(use-modules (gnu))
(use-service-modules desktop xorg)
(use-modules (gnu services sysctl))
(operating-system
...
或这个
(use-modules (gnu))
(use-service-modules desktop xorg sysctl)
(operating-system
...
将导致此错误:
guix system: error: service 'sysctl' provided more than once
Guix 最近:
$ guix -V
guix (GNU Guix) 1b6e7157cd30ffc2b29779fe6d5cb4ddbbc6f331
编辑:
可能相关的错误报告:“ [PATCH] gnu:强化文件系统链接。”https://debbugs.gnu.org/cgi/bugreport.cgi?bug=47013
可能相关的电子邮件主题:“如何编写 sysctl-service-type?”https://lists.gnu.org/archive/html/help-guix/2021-03/msg00066.html
显然过时的文档:https://guix.gnu.org/manual/en/html_node/Miscellaneous-Services.html#Miscellaneous-Services其中有这个损坏的(?)示例
(service sysctl-service-type
(sysctl-configuration
(settings '(("net.ipv4.ip_forward" . "1")))))
有更新的文档https://git.savannah.gnu.org/cgit/guix.git/tree/doc/guix.texi使用以下说明:
由于
sysctl-service-type
在默认服务列表中使用,%base-services
和%desktop-services
,您可以使用modify-services
来更改其配置并添加所需的内核参数。
以此为例
(modify-services %base-services
(sysctl-service-type config =>
(sysctl-configuration
(settings (append '(("net.ipv4.ip_forward" . "1"))
%default-sysctl-settings)))))
但是我不清楚把它放在哪里。把它放在定义之后services
会出现以下错误:
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
答案1
这个最小的例子似乎适用于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)))
这新文档说要修改%base-services
,但在这种情况下,必须修改%desktop-services
,其中似乎包括%base-services
。该modify-services
命令替换了该%desktop-services
行。
已测试可以工作。