services: nix: Add extra-options.

* gnu/services/nix.scm (<nix-configuration>)[extra-options]: New field.
(nix-shepherd-service): Add this.
(nix-activation): Add new line to the end of /etc/nix/nix.conf file.
* doc/guix.texi (Miscellaneous Services)[Nix service]: Document this.
This commit is contained in:
Oleg Pykhalov 2020-07-25 11:51:49 +03:00
parent 3601d802d5
commit 64c6282e7f
No known key found for this signature in database
GPG Key ID: 167F8EA5001AFA9C
2 changed files with 10 additions and 3 deletions

View File

@ -27637,6 +27637,9 @@ This is a list of strings or objects appended to the
This is a list of strings or objects appended to the configuration file. This is a list of strings or objects appended to the configuration file.
It is used to pass extra text to be added verbatim to the configuration It is used to pass extra text to be added verbatim to the configuration
file. file.
@item @code{extra-options} (default: @code{'()})
Extra command line options for @code{nix-service-type}.
@end table @end table
@end deftp @end deftp

View File

@ -56,6 +56,8 @@
(build-sandbox-items nix-configuration-build-sandbox-items ;list of strings (build-sandbox-items nix-configuration-build-sandbox-items ;list of strings
(default '())) (default '()))
(extra-config nix-configuration-extra-config ;list of strings (extra-config nix-configuration-extra-config ;list of strings
(default '()))
(extra-options nix-configuration-extra-options ;list of strings
(default '()))) (default '())))
;; Copied from gnu/services/base.scm ;; Copied from gnu/services/base.scm
@ -116,19 +118,21 @@ GID."
'#$(map references-file '#$(map references-file
(list package))) (list package)))
'#$build-sandbox-items)) '#$build-sandbox-items))
(for-each (cut display <>) '#$extra-config)))))))) (for-each (cut display <>) '#$extra-config)
(newline))))))))
(define nix-shepherd-service (define nix-shepherd-service
;; Return a <shepherd-service> for Nix. ;; Return a <shepherd-service> for Nix.
(match-lambda (match-lambda
(($ <nix-configuration> package _ ...) (($ <nix-configuration> package _ _ _ extra-options)
(list (list
(shepherd-service (shepherd-service
(provision '(nix-daemon)) (provision '(nix-daemon))
(documentation "Run nix-daemon.") (documentation "Run nix-daemon.")
(requirement '()) (requirement '())
(start #~(make-forkexec-constructor (start #~(make-forkexec-constructor
(list (string-append #$package "/bin/nix-daemon")))) (list (string-append #$package "/bin/nix-daemon")
#$@extra-options)))
(respawn? #f) (respawn? #f)
(stop #~(make-kill-destructor))))))) (stop #~(make-kill-destructor)))))))