aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorNick Hu <me@nickhu.co.uk>2022-11-12 21:33:16 +0300
committerGitHub <noreply@github.com>2022-11-12 21:33:16 +0300
commita2b1c19a51b2528af4a7e75e3e1546da56b4c96c (patch)
tree234dc634a390ed881bc9b9267a7c9993eeb2dc7f /src
parentf7f05f76fabda70f4fbcaefd55e6fe6fd09a8145 (diff)
Nix feature: allow extra configuration of /etc/nix/nix.conf (#277)
Diffstat (limited to 'src')
-rw-r--r--src/nix/devcontainer-feature.json5
-rwxr-xr-xsrc/nix/install.sh11
2 files changed, 16 insertions, 0 deletions
diff --git a/src/nix/devcontainer-feature.json b/src/nix/devcontainer-feature.json
index ffd3dc9..9ab519b 100644
--- a/src/nix/devcontainer-feature.json
+++ b/src/nix/devcontainer-feature.json
@@ -25,6 +25,11 @@
"type": "string",
"default": "",
"description": "Optional URI to a Nix Flake to install in profile."
+ },
+ "extraNixConfig": {
+ "type": "string",
+ "default": "",
+ "description": "Optional comma separated list of extra lines to add to /etc/nix/nix.conf."
}
},
"installsAfter": [
diff --git a/src/nix/install.sh b/src/nix/install.sh
index 2fc4367..6141d7e 100755
--- a/src/nix/install.sh
+++ b/src/nix/install.sh
@@ -9,6 +9,7 @@ VERSION="${VERSION:-"latest"}"
MULTIUSER="${MULTIUSER:-"true"}"
PACKAGES="${PACKAGES//,/ }"
FLAKEURI="${FLAKEURI:-""}"
+EXTRANIXCONFIG="${EXTRANIXCONFIG:-""}"
USERNAME="${USERNAME:-"${_REMOTE_USER:-"automatic"}"}"
# Nix keys for securly verifying installer download signature per https://nixos.org/download.html#nix-verify-installation
@@ -99,6 +100,16 @@ create_or_update_file /etc/nix/nix.conf 'sandbox = false'
if [ ! -z "${FLAKEURI}" ] && [ "${FLAKEURI}" != "none" ]; then
create_or_update_file /etc/nix/nix.conf 'experimental-features = nix-command flakes'
fi
+# Extra nix config
+if [ ! -z "${EXTRANIXCONFIG}" ]; then
+ OLDIFS=$IFS
+ IFS=","
+ read -a extra_nix_config <<< "$EXTRANIXCONFIG"
+ for line in "${extra_nix_config[@]}"; do
+ create_or_update_file /etc/nix/nix.conf "$line"
+ done
+ IFS=$OLDIFS
+fi
# Create entrypoint if needed
if [ ! -e "/usr/local/share/nix-entrypoint.sh" ]; then