GNU bug report logs - #41704
[PATCH] services: nix: Set NIX_CONF_DIR environment variable.

Previous Next

Package: guix-patches;

Reported by: Peng Mei Yu <pengmeiyu <at> riseup.net>

Date: Thu, 4 Jun 2020 08:36:01 UTC

Severity: normal

Tags: patch

Done: Peng Mei Yu <pengmeiyu <at> riseup.net>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 41704 in the body.
You can then email your comments to 41704 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to guix-patches <at> gnu.org:
bug#41704; Package guix-patches. (Thu, 04 Jun 2020 08:36:01 GMT) Full text and rfc822 format available.

Acknowledgement sent to Peng Mei Yu <pengmeiyu <at> riseup.net>:
New bug report received and forwarded. Copy sent to guix-patches <at> gnu.org. (Thu, 04 Jun 2020 08:36:01 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Peng Mei Yu <pengmeiyu <at> riseup.net>
To: guix-patches <at> gnu.org
Cc: Peng Mei Yu <pengmeiyu <at> riseup.net>
Subject: [PATCH] services: nix: Set NIX_CONF_DIR environment variable.
Date: Thu,  4 Jun 2020 15:01:03 +0800
* gnu/services/nix.scm (nix-shepherd-service): Set NIX_CONF_DIR environment
variable to "/etc/nix".
---
 gnu/services/nix.scm | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/gnu/services/nix.scm b/gnu/services/nix.scm
index 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





Information forwarded to guix-patches <at> gnu.org:
bug#41704; Package guix-patches. (Thu, 04 Jun 2020 09:10:01 GMT) Full text and rfc822 format available.

Message #8 received at 41704 <at> debbugs.gnu.org (full text, mbox):

From: Peng Mei Yu <pengmeiyu <at> riseup.net>
To: 41704 <at> debbugs.gnu.org
Cc: Peng Mei Yu <pengmeiyu <at> riseup.net>
Subject: [PATCH V2] services: nix: Set NIX_CONF_DIR environment variable.
Date: Thu,  4 Jun 2020 17:09:22 +0800
* gnu/services/nix.scm (nix-shepherd-service): Set NIX_CONF_DIR environment
variable to "/etc/nix".
---
 gnu/services/nix.scm | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/gnu/services/nix.scm b/gnu/services/nix.scm
index 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 <at> gmail.com>
+;;; Copyright © 2020 Peng Mei Yu <pengmeiyu <at> 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





Information forwarded to guix-patches <at> gnu.org:
bug#41704; Package guix-patches. (Tue, 09 Jun 2020 07:53:01 GMT) Full text and rfc822 format available.

Message #11 received at 41704 <at> debbugs.gnu.org (full text, mbox):

From: Ludovic Courtès <ludo <at> gnu.org>
To: Peng Mei Yu <pengmeiyu <at> riseup.net>
Cc: 41704 <at> debbugs.gnu.org
Subject: Re: [bug#41704] [PATCH V2] services: nix: Set NIX_CONF_DIR
 environment variable.
Date: Tue, 09 Jun 2020 09:52:04 +0200
[Message part 1 (text/plain, inline)]
Hi,

Peng Mei Yu <pengmeiyu <at> riseup.net> skribis:

> * 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’.

[Message part 2 (text/x-patch, inline)]
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)

Information forwarded to guix-patches <at> gnu.org:
bug#41704; Package guix-patches. (Sun, 14 Jun 2020 08:11:02 GMT) Full text and rfc822 format available.

Message #14 received at 41704 <at> debbugs.gnu.org (full text, mbox):

From: Peng Mei Yu <pengmeiyu <at> riseup.net>
To: Ludovic Courtès <ludo <at> gnu.org>
Cc: 41704 <at> debbugs.gnu.org
Subject: Re: [bug#41704] [PATCH V2] services: nix: Set NIX_CONF_DIR
 environment variable.
Date: Sun, 14 Jun 2020 16:10:35 +0800
Hi,

Ludovic Courtès writes:

>> * 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 install
phase 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 is
easier.  Perhaps someone can fix the nix package with a clean patch.
That would be better.


--
Peng Mei Yu
https://www.pengmeiyu.com/




Information forwarded to guix-patches <at> gnu.org:
bug#41704; Package guix-patches. (Mon, 15 Jun 2020 11:09:01 GMT) Full text and rfc822 format available.

Message #17 received at 41704 <at> debbugs.gnu.org (full text, mbox):

From: Tobias Geerinckx-Rice <me <at> tobias.gr>
To: Peng Mei Yu <pengmeiyu <at> riseup.net>
Cc: Ludovic Courtès <ludo <at> gnu.org>, 41704 <at> debbugs.gnu.org
Subject: Re: [bug#41704] [PATCH V2] services: nix: Set NIX_CONF_DIR
 environment variable.
Date: Mon, 15 Jun 2020 13:08:44 +0200
[Message part 1 (text/plain, inline)]
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 写道:
> 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.

Kind regards,

T G-R
[signature.asc (application/pgp-signature, inline)]

Reply sent to Peng Mei Yu <pengmeiyu <at> riseup.net>:
You have taken responsibility. (Tue, 16 Jun 2020 10:59:02 GMT) Full text and rfc822 format available.

Notification sent to Peng Mei Yu <pengmeiyu <at> riseup.net>:
bug acknowledged by developer. (Tue, 16 Jun 2020 10:59:02 GMT) Full text and rfc822 format available.

Message #22 received at 41704-done <at> debbugs.gnu.org (full text, mbox):

From: Peng Mei Yu <pengmeiyu <at> riseup.net>
To: Tobias Geerinckx-Rice <me <at> tobias.gr>
Cc: Ludovic Courtès <ludo <at> gnu.org>, 41704-done <at> debbugs.gnu.org
Subject: Re: [bug#41704] [PATCH V2] services: nix: Set NIX_CONF_DIR
 environment variable.
Date: Tue, 16 Jun 2020 18:58:11 +0800
Hi,

Tobias Geerinckx-Rice writes:

> I agree with Ludo' that fixing this at the package level is more ‘appropriate’
> than in the service.

I agree too.

>> 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 my
computer.  Thank you.  Please push this patch.


--
Peng Mei Yu




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Tue, 14 Jul 2020 11:24:04 GMT) Full text and rfc822 format available.

This bug report was last modified 3 years and 287 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.