[PATCH] services: nix: Set NIX_CONF_DIR environment variable.

DoneSubmitted by Peng Mei Yu.
Details
3 participants
  • Ludovic Courtès
  • Tobias Geerinckx-Rice
  • Peng Mei Yu
Owner
unassigned
Severity
normal
P
P
Peng Mei Yu wrote on 4 Jun 09:01 +0200
(address . guix-patches@gnu.org)(name . Peng Mei Yu)(address . pengmeiyu@riseup.net)
20200604070103.2548-1-pengmeiyu@riseup.net
* gnu/services/nix.scm (nix-shepherd-service): Set NIX_CONF_DIR environmentvariable to "/etc/nix".--- gnu/services/nix.scm | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
Toggle diff (17 lines)diff --git a/gnu/services/nix.scm b/gnu/services/nix.scmindex dfe33991d0..2cdddd8866 100644--- a/gnu/services/nix.scm+++ b/gnu/services/nix.scm@@ -96,7 +96,9 @@ GID." (documentation "Run nix-daemon.") (requirement '()) (start #~(make-forkexec-constructor- (list (string-append #$nix "/bin/nix-daemon"))))+ (list (string-append #$nix "/bin/nix-daemon"))+ #:environment-variables+ '("NIX_CONF_DIR=/etc/nix"))) (respawn? #f) (stop #~(make-kill-destructor))))) -- 2.26.2
P
P
Peng Mei Yu wrote on 4 Jun 11:09 +0200
[PATCH V2] services: nix: Set NIX_CONF_DIR environment variable.
(address . 41704@debbugs.gnu.org)(name . Peng Mei Yu)(address . pengmeiyu@riseup.net)
20200604090922.19352-1-pengmeiyu@riseup.net
* gnu/services/nix.scm (nix-shepherd-service): Set NIX_CONF_DIR environmentvariable to "/etc/nix".--- gnu/services/nix.scm | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
Toggle diff (24 lines)diff --git a/gnu/services/nix.scm b/gnu/services/nix.scmindex dfe33991d0..d5a057d2ee 100644--- a/gnu/services/nix.scm+++ b/gnu/services/nix.scm@@ -1,5 +1,6 @@ ;;; GNU Guix --- Functional package management for GNU ;;; Copyright © 2019 Oleg Pykhalov <go.wigust@gmail.com>+;;; Copyright © 2020 Peng Mei Yu <pengmeiyu@riseup.net> ;;; ;;; This file is part of GNU Guix. ;;;@@ -96,7 +97,9 @@ GID." (documentation "Run nix-daemon.") (requirement '()) (start #~(make-forkexec-constructor- (list (string-append #$nix "/bin/nix-daemon"))))+ (list (string-append #$nix "/bin/nix-daemon"))+ #:environment-variables+ '("NIX_CONF_DIR=/etc/nix"))) (respawn? #f) (stop #~(make-kill-destructor))))) -- 2.26.2
L
L
Ludovic Courtès wrote on 9 Jun 09:52 +0200
(name . Peng Mei Yu)(address . pengmeiyu@riseup.net)(address . 41704@debbugs.gnu.org)
878sgwoevv.fsf@gnu.org
Hi,
Peng Mei Yu <pengmeiyu@riseup.net> skribis:
Toggle quote (3 lines)> * gnu/services/nix.scm (nix-shepherd-service): Set NIX_CONF_DIR environment> variable to "/etc/nix".
Does the (untested) patch below solve the problem for you?
Perhaps it’s more appropriate than setting NIX_CONF_DIR.
Thanks,Ludo’.
Toggle diff (12 lines)diff --git a/gnu/packages/package-management.scm b/gnu/packages/package-management.scmindex b1c96f18e7..b3c21473ed 100644--- a/gnu/packages/package-management.scm+++ b/gnu/packages/package-management.scm@@ -551,6 +551,7 @@ out) and returning a package that uses that as its 'source'." (base32 "1hbqsrp1ii2sfq8x2mahjrl2182qck76n8blrl1jfz3xq99m6i15")))) (build-system gnu-build-system)+ (arguments '(#:configure-flags '("--sysconfdir=/etc"))) (native-inputs `(("pkg-config" ,pkg-config))) (inputs `(("boost" ,boost) ("brotli" ,brotli)
P
P
Peng Mei Yu wrote on 14 Jun 10:10 +0200
(name . Ludovic Courtès)(address . ludo@gnu.org)(address . 41704@debbugs.gnu.org)
87r1ui1337.fsf@pengmeiyu.com
Hi,
Ludovic Courtès writes:
Toggle quote (23 lines)>> * gnu/services/nix.scm (nix-shepherd-service): Set NIX_CONF_DIR environment>> variable to "/etc/nix".>> Does the (untested) patch below solve the problem for you?>> Perhaps it’s more appropriate than setting NIX_CONF_DIR.>> Thanks,> Ludo’.>> diff --git a/gnu/packages/package-management.scm b/gnu/packages/package-management.scm> index b1c96f18e7..b3c21473ed 100644> --- a/gnu/packages/package-management.scm> +++ b/gnu/packages/package-management.scm> @@ -551,6 +551,7 @@ out) and returning a package that uses that as its 'source'."> (base32> "1hbqsrp1ii2sfq8x2mahjrl2182qck76n8blrl1jfz3xq99m6i15"))))> (build-system gnu-build-system)> + (arguments '(#:configure-flags '("--sysconfdir=/etc")))> (native-inputs `(("pkg-config" ,pkg-config)))> (inputs `(("boost" ,boost)> ("brotli" ,brotli)
No. I should have mentioned earlier. With this patch, the installphase will fail.
#+begin_example MKDIR /etc/profile.d/ install: cannot change permissions of ‘/etc/profile.d/’: No such file or directory make: *** [scripts/local.mk:10: /etc/profile.d/] Error 1 command "make" "install" failed with status 2 builder for `/gnu/store/c2lw5faljg1zh5ng4nb0inslq4b0fh9c-nix-2.3.5.drv' failed with exit code 1 build of /gnu/store/c2lw5faljg1zh5ng4nb0inslq4b0fh9c-nix-2.3.5.drv failed View build log at '/var/log/guix/drvs/c2/lw5faljg1zh5ng4nb0inslq4b0fh9c-nix-2.3.5.drv.bz2'. guix build: error: build of `/gnu/store/c2lw5faljg1zh5ng4nb0inslq4b0fh9c-nix-2.3.5.drv' failed#+end_example
There is no obvious way to fix the error, so setting NIX_CONF_DIR iseasier. Perhaps someone can fix the nix package with a clean patch.That would be better.

--Peng Mei Yuhttps://www.pengmeiyu.com/
T
T
Tobias Geerinckx-Rice wrote on 15 Jun 13:08 +0200
(name . Peng Mei Yu)(address . pengmeiyu@riseup.net)
87bllkoabn.fsf@nckx
Hi Peng Mei Yu,
I agree with Ludo' that fixing this at the package level is more ‘appropriate’ than in the service.
Peng Mei Yu 写道:
Toggle quote (6 lines)> There is no obvious way to fix the error, so setting > NIX_CONF_DIR is> easier. Perhaps someone can fix the nix package with a clean > patch.> That would be better.
Obvious is different things to different people, but here's my go-to approach. Override the relevant variables during the install phase without changing any run-time settings:
#+begin_example
Toggle diff (35 lines)diff --git a/gnu/packages/package-management.scm b/gnu/packages/package-management.scmindex c1e6657dff..fefa17a162 100644--- a/gnu/packages/package-management.scm+++ b/gnu/packages/package-management.scm@@ -551,6 +551,19 @@ out) and returning a package that uses that as its 'source'." (base32 "1hbqsrp1ii2sfq8x2mahjrl2182qck76n8blrl1jfz3xq99m6i15")))) (build-system gnu-build-system)+ (arguments+ `(#:configure-flags+ (list "--sysconfdir=/etc")+ #:phases+ (modify-phases %standard-phases+ (replace 'install+ (lambda* (#:key (make-flags '()) outputs #:allow-other-keys)+ (let* ((out (assoc-ref outputs "out"))+ (etc (string-append out "/etc")))+ (apply invoke "make" "install"+ (string-append "sysconfdir=" etc)+ (string-append "profiledir=" etc "/profile.d")+ make-flags))))))) (native-inputs `(("pkg-config" ,pkg-config))) (inputs `(("boost" ,boost) ("brotli" ,brotli)#+end_example
It installs correctly. I didn't test the service.
Kind regards,
T G-R
-----BEGIN PGP SIGNATURE-----
iHUEARYKAB0WIQT12iAyS4c9C3o4dnINsP+IT1VteQUCXudWvAAKCRANsP+IT1VteWu8AP0Wz60B9gdeHfMWjEczPiLX/6TqB8y8Ybr0sf8AAYjSrAD/VA88qv3S0UPE3SU294xElJFwOXvOCVWIXYnmH/r/sQg==C6R6-----END PGP SIGNATURE-----
P
P
Peng Mei Yu wrote on 16 Jun 12:58 +0200
(name . Tobias Geerinckx-Rice)(address . me@tobias.gr)
87ftavl1ly.fsf@pengmeiyu.com
Hi,
Tobias Geerinckx-Rice writes:
Toggle quote (3 lines)> I agree with Ludo' that fixing this at the package level is more ‘appropriate’> than in the service.
I agree too.
Toggle quote (39 lines)>> There is no obvious way to fix the error, so setting NIX_CONF_DIR is>> easier. Perhaps someone can fix the nix package with a clean patch.>> That would be better.>> Obvious is different things to different people, but here's my go-to approach.> Override the relevant variables during the install phase without changing any> run-time settings:>> #+begin_example> diff --git a/gnu/packages/package-management.scm> b/gnu/packages/package-management.scm> index c1e6657dff..fefa17a162 100644> --- a/gnu/packages/package-management.scm> +++ b/gnu/packages/package-management.scm> @@ -551,6 +551,19 @@ out) and returning a package that uses that as its> 'source'."> (base32> "1hbqsrp1ii2sfq8x2mahjrl2182qck76n8blrl1jfz3xq99m6i15"))))> (build-system gnu-build-system)> + (arguments> + `(#:configure-flags> + (list "--sysconfdir=/etc")> + #:phases> + (modify-phases %standard-phases> + (replace 'install> + (lambda* (#:key (make-flags '()) outputs #:allow-other-keys)> + (let* ((out (assoc-ref outputs "out"))> + (etc (string-append out "/etc")))> + (apply invoke "make" "install"> + (string-append "sysconfdir=" etc)> + (string-append "profiledir=" etc "/profile.d")> + make-flags)))))))> (native-inputs `(("pkg-config" ,pkg-config)))> (inputs `(("boost" ,boost)> ("brotli" ,brotli)> #+end_example>> It installs correctly. I didn't test the service.
This is the clean patch I was asking for. The service works well on mycomputer. Thank you. Please push this patch.

--Peng Mei Yu
Closed
?