diff --git a/src/nix/README.md b/src/nix/README.md new file mode 100644 index 000000000..2924c1ad9 --- /dev/null +++ b/src/nix/README.md @@ -0,0 +1,24 @@ + +# Nix + +Installs the Nix package manager. + +## Example Usage + +```json +"features": { + "ghcr.io/devcontainers/features/nix:1": { + "version": "latest" + } +} +``` + +## Options + +| Options Id | Description | Type | Default Value | +|-----|-----|-----|-----| +| version | Select or enter a Nix version to install | string | latest | + +--- + +_Note: This file was auto-generated from the [devcontainer-feature.json](https://github.com/devcontainers/features/blob/main/src/node/devcontainer-feature.json). Add additional notes to a `NOTES.md`._ diff --git a/src/nix/devcontainer-feature.json b/src/nix/devcontainer-feature.json new file mode 100644 index 000000000..7395c9a7e --- /dev/null +++ b/src/nix/devcontainer-feature.json @@ -0,0 +1,26 @@ +{ + "id": "nix", + "version": "1.0.0", + "name": "Nix", + "documentationURL": "https://github.com/devcontainers/features/tree/main/src/nix", + "description": "Installs Nix which is a tool that takes a unique approach to package management and system configuration", + "options": { + "version": { + "type": "string", + "enum": [ + "latest" + ], + "default": "latest", + "description": "Currently unused." + } + }, + "customizations": { + "vscode": { + "extensions": [ + "bbenoist.Nix" + ] + } + }, + "containerEnv": { + } +} diff --git a/src/nix/install.sh b/src/nix/install.sh new file mode 100755 index 000000000..323485467 --- /dev/null +++ b/src/nix/install.sh @@ -0,0 +1,24 @@ +#!/usr/bin/env bash +#------------------------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See https://go.microsoft.com/fwlink/?linkid=2090316 for license information. +#------------------------------------------------------------------------------------------------------------- +# +# Docs: https://github.com/microsoft/vscode-dev-containers/blob/main/script-library/docs/sshd.md +# Maintainer: The VS Code and Codespaces Teams +# + +set -e + +if [ "$(id -u)" -ne 0 ]; then + echo -e 'Script must be run as root. Use sudo, su, or add "USER root" to your Dockerfile before running this script.' + exit 1 +fi + + +sh <(curl -L https://nixos.org/nix/install) --daemon + +mkdir -p $HOME/.config/nix $HOME/.config/nixpkgs +echo 'sandbox = false' >> $HOME/.config/nix/nix.conf +echo '{ allowUnfree = true; }' >> $HOME/.config/nixpkgs/config.nix +echo '. $HOME/.nix-profile/etc/profile.d/nix.sh' >> $HOME/.bashrc \ No newline at end of file diff --git a/test/nix/test.sh b/test/nix/test.sh new file mode 100755 index 000000000..ef16aede4 --- /dev/null +++ b/test/nix/test.sh @@ -0,0 +1,12 @@ +#!/bin/bash + +set -e + +# Optional: Import test library +source dev-container-features-test-lib + +# Definition specific tests +check "version" nix --version + +# Report result +reportResults \ No newline at end of file