nix: fix applying nix.conf by using correct env var

According to this line from the docs:

>The system-wide configuration file sysconfdir/nix/nix.conf (i.e. /etc/nix/nix.conf),
>or $NIX_CONF_DIR/nix.conf if NIX_CONF_DIR is set. Values loaded in this file are not
>forwarded to the Nix daemon. The client assumes that the daemon has already loaded them.

https://nixos.org/manual/nix/stable/command-ref/conf-file.html#description

Our usage of `NIX_CONF_DIR` has been wrong for a while now.
The correct way of applying this config is using `NIX_USER_CONF_FILES`.

In addition the `extra-substituters` no longer exists in the docs.
Use of `trusted-substituters` is necessary according to:

>At least one of the following conditions must be met for Nix to use a substituter:
>
>- the substituter is in the trusted-substituters list
>- the user calling Nix is in the trusted-users list

https://nixos.org/manual/nix/stable/command-ref/conf-file.html#conf-substituters

Signed-off-by: Jakub Sokołowski <jakub@status.im>
This commit is contained in:
Jakub Sokołowski 2023-06-15 19:00:53 +02:00
parent e08d3bd78d
commit 6f8dc27282
No known key found for this signature in database
GPG Key ID: FE65CD384D5BF7B4
3 changed files with 17 additions and 4 deletions

View File

@ -42,7 +42,7 @@ export NODE_OPTIONS += --openssl-legacy-provider
export KEYSTORE_PATH ?= $(HOME)/.gradle/status-im.keystore
# Our custom config is located in nix/nix.conf
export NIX_CONF_DIR = $(PWD)/nix
export NIX_USER_CONF_FILES = $(PWD)/nix/nix.conf
# Location of symlinks to derivations that should not be garbage collected
export _NIX_GCROOTS = /nix/var/nix/gcroots/per-user/$(USER)/status-mobile
# Defines which variables will be kept for Nix pure shell, use semicolon as divider

View File

@ -1,5 +1,18 @@
# Known Issues
## Ignoring Untrusted Substituter on NixOS
When using our setup on NixOS users can see this warning:
```
warning: ignoring untrusted substituter 'https://nix-cache.status.im/', you are not a trusted user.
```
Which is due to incorrect `trusted-users` setting:
```
> grep trusted-users /etc/nix/nix.conf
trusted-users = root
```
Which can be extended using the [`nix.settings.trusted-users`](https://search.nixos.org/options?channel=23.05&show=nix.settings.trusted-users) option.
## Too many open files
### Single-User Installation

View File

@ -1,6 +1,6 @@
# NOTE: If you are in Asia you might want to add https://nix-cache-cn.status.im/ to extra-substituters
extra-substituters = https://nix-cache.status.im/
substituters = https://cache.nixos.org/
# NOTE: If you are in Asia you might want to add https://nix-cache-cn.status.im/ to substituters.
substituters = https://nix-cache.status.im/ https://cache.nixos.org/
trusted-substituters = https://nix-cache.status.im/ https://cache.nixos.org/
trusted-public-keys = nix-cache.status.im-1:x/93lOfLU+duPplwMSBR+OlY4+mo+dCN7n0mr4oPwgY= cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY=
# Some downloads are multiple GB, default is 5 minutes
stalled-download-timeout = 3600