Skip to content

Commit

Permalink
feat(nixos.org): Add feature.
Browse files Browse the repository at this point in the history
  • Loading branch information
sebst committed Oct 13, 2024
1 parent 3b66459 commit 2c55ef1
Show file tree
Hide file tree
Showing 5 changed files with 102 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ jobs:
- bun.sh
- chezmoi.io
- deno.com
- nixos.org
- pkgx.sh
- smallstep.com
- starship.rs
Expand Down Expand Up @@ -50,6 +51,7 @@ jobs:
- bun.sh
- chezmoi.io
- deno.com
- nixos.org
- pkgx.sh
- smallstep.com
- starship.rs
Expand Down
24 changes: 24 additions & 0 deletions src/nixos.org/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@

# asdf-vm.com (asdf-vm.com)

Install "asdf" binary to the HOME folder of the REMOTE user

## Example Usage

```json
"features": {
"ghcr.io/devcontainer-community/devcontainer-features/asdf-vm.com:1": {}
}
```

## Options

| Options Id | Description | Type | Default Value |
|-----|-----|-----|-----|
| version | Version of "asdf" to install. | string | latest |



---

_Note: This file was auto-generated from the [devcontainer-feature.json](https://github.com/devcontainer-community/devcontainer-features/blob/main/src/asdf-vm.com/devcontainer-feature.json). Add additional notes to a `NOTES.md`._
22 changes: 22 additions & 0 deletions src/nixos.org/devcontainer-feature.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"name": "nixos.org",
"id": "nixos.org",
"version": "1.0.0",
"description": "Install \"nix\" binary.",
"documentationURL": "https://github.com/devcontainer-community/devcontainer-features/tree/main/src/nixos.org",
"options": {
"version": {
"type": "string",
"default": "latest",
"proposals": [
"latest"
],
"description": "Currently unused."
},
"extra_options": {
"type": "string",
"default": "--init none",
"description": "Extra options to pass to the installer."
}
}
}
36 changes: 36 additions & 0 deletions src/nixos.org/install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/bin/bash
set -o errexit
set -o pipefail
set -o noclobber
set -o nounset
set -o allexport
readonly name="nix"
apt_get_update() {
if [ "$(find /var/lib/apt/lists/* | wc -l)" = "0" ]; then
echo "Running apt-get update..."
apt-get update -y
fi
}
apt_get_checkinstall() {
if ! dpkg -s "$@" >/dev/null 2>&1; then
apt_get_update
DEBIAN_FRONTEND=noninteractive apt-get -y install --no-install-recommends --no-install-suggests --option 'Debug::pkgProblemResolver=true' --option 'Debug::pkgAcquire::Worker=1' "$@"
fi
}
apt_get_cleanup() {
apt-get clean
rm -rf /var/lib/apt/lists/*
}
echo_banner() {
local text="$1"
echo -e "\e[1m\e[97m\e[41m$text\e[0m"
}
install() {
apt_get_checkinstall curl ca-certificates
su $_REMOTE_USER -c "curl --proto '=https' --tlsv1.2 -sSf -L https://install.determinate.systems/nix | sh -s -- install linux --extra-conf 'sandbox = false' ${EXTRA_OPTIONS} --no-confirm"
apt_get_cleanup
}
echo_banner "devcontainer.community"
echo "Installing $name..."
install "$@"
echo "(*) Done!"
18 changes: 18 additions & 0 deletions test/nixos.org/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/bash


set -e

# Optional: Import test library bundled with the devcontainer CLI
# See https://github.com/devcontainers/cli/blob/HEAD/docs/features/test.md#dev-container-features-test-lib
# Provides the 'check' and 'reportResults' commands.
source dev-container-features-test-lib

# Feature-specific tests
# The 'check' command comes from the dev-container-features-test-lib. Syntax is...
# check <LABEL> <cmd> [args...]
check "execute command" bash -c "nix --version | grep 'nix'"

# Report results
# If any of the checks above exited with a non-zero exit code, the test will fail.
reportResults

0 comments on commit 2c55ef1

Please sign in to comment.