diff options
author | Chuck Lantz <clantz@microsoft.com> | 2022-11-12 22:12:21 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-11-12 22:12:21 +0300 |
commit | 1c61d1a0390ad52355e59df898f80a10f683bd12 (patch) | |
tree | 360bf34c0b2c9efddd2e1a919099738ca12b2924 | |
parent | a2b1c19a51b2528af4a7e75e3e1546da56b4c96c (diff) |
Add test, bump version for extraNixConfig (#280)
-rw-r--r-- | src/nix/devcontainer-feature.json | 2 | ||||
-rw-r--r-- | test/nix/extra-config.sh | 35 | ||||
-rw-r--r-- | test/nix/scenarios.json | 9 |
3 files changed, 45 insertions, 1 deletions
diff --git a/src/nix/devcontainer-feature.json b/src/nix/devcontainer-feature.json index 9ab519b..68ccdf7 100644 --- a/src/nix/devcontainer-feature.json +++ b/src/nix/devcontainer-feature.json @@ -1,6 +1,6 @@ { "id": "nix", - "version": "1.0.0", + "version": "1.1.0", "name": "Nix Package Manager", "documentationURL": "https://github.com/devcontainers/features/tree/main/src/nix", "description": "Installs the Nix package manager and optionally a set of packages.", diff --git a/test/nix/extra-config.sh b/test/nix/extra-config.sh new file mode 100644 index 0000000..724213b --- /dev/null +++ b/test/nix/extra-config.sh @@ -0,0 +1,35 @@ +#!/bin/bash +set -e + +# Optional: Import test library bundled with the devcontainer CLI +source dev-container-features-test-lib + +uid="$(id -u)" +echo "Current user UID is ${uid}." +if [ "${uid}" != "1000" ]; then + echo "Current user UID was adjusted." +fi +set +e +vscode_uid="$(id -u vscode)" +set -e +if [ "${vscode_uid}" != "" ]; then + echo "User vscode UID is ${vscode_uid}." + if [ "${vscode_uid}" != "1000" ]; then + echo "User vscode UID was adjusted." + fi +fi +nix_uid="$(stat /nix -c "%u")" +echo "/nix UID is ${nix_uid}." + +cat /etc/os-release +cat /etc/nix/nix.conf + +# Feature-specific tests +# The 'check' command comes from the dev-container-features-test-lib. +check "nix-env" type nix-env +check "First added line" grep -E '^extra-substituters = https://foo\.cachix\.org$' /etc/nix/nix.conf +check "Second added line" grep -E '^extra-trusted-public-keys = foo\.cachix\.org-1:bar=$' /etc/nix/nix.conf + +# Report result +# If any of the checks above exited with a non-zero exit code, the test will fail. +reportResults &2>1
\ No newline at end of file diff --git a/test/nix/scenarios.json b/test/nix/scenarios.json index 72ad993..c287f58 100644 --- a/test/nix/scenarios.json +++ b/test/nix/scenarios.json @@ -89,5 +89,14 @@ "flakeUri": "github:nixos/nixpkgs/nixpkgs-unstable#hello" } } + }, + "extra-config": { + "image": "mcr.microsoft.com/devcontainers/base:ubuntu", + "remoteUser": "vscode", + "features": { + "nix": { + "extraNixConfig": "extra-substituters = https://foo.cachix.org,extra-trusted-public-keys = foo.cachix.org-1:bar=" + } + } } }
\ No newline at end of file |