According to the Shepherd Services documentation, the start and stop fields of shepherd-service take G-Expressions. But what's a g-expression? Well, because Guix uses Scheme for both higher-level actions–like defining packages–and lower-level actions–like building derivations generated by packages– it needs a faculty for embedding lower-level code in higher-level code. So in the start field of wesnoth-shepherd-service: (start #~(make-forkexec-constructor/container (list #$(file-append package "/bin/wesnothd") "-p" #$(number->string port)) #:user "wesnothd" #:group "wesnothd")) Some lower-level code is passed with #~(...), within which higher-level code is escaped with #$(...) which the compiler is able to "lower" to lower-level code. Looking at the source for make-forkexec-constructor/container, we see: This is a variant of 'make-forkexec-constructor' that starts COMMAND in NAMESPACES, a list of Linux namespaces such as '(mnt ipc). MAPPINGS is the list of <file-system-mapping> to make in the case of a separate mount namespace, in addition to essential bind-mounts such /proc. And the documentation for make-forkexec-contructor reads: Return a procedure that forks a child process, closes all file descriptors except the standard output and standard error descriptors, sets the current directory to directory, sets the umask to file-creation-mask unless it is #f, changes the environment to environment-variables (using the environ procedure), sets the current user to user and the current group to group unless they are #f, and executes command (a list of strings.) The result of the procedure will be the PID of the child process. Note that this will not work as expected if the process “daemonizes” (forks); in that case, you will need to pass #:pid-file, as explained below. When pid-file is true, it must be the name of a PID file associated with the process being launched; the return value is the PID once that file has been created. If pid-file does not show up in less than pi...
First seen: 2025-08-03 05:17
Last seen: 2025-08-03 13:18