|
| 1 | +{ |
| 2 | + // Build the base image |
| 3 | + "build": { |
| 4 | + // Docker context to use, relative to this file |
| 5 | + "context": "image/", |
| 6 | + // Dockerfile to use, relative to this file |
| 7 | + "dockerfile": "image/Dockerfile", |
| 8 | + // Build options |
| 9 | + "options": [ |
| 10 | + // Use host network |
| 11 | + "--network=host" |
| 12 | + ] |
| 13 | + }, |
| 14 | + // Tool-specific settings |
| 15 | + "customizations": { |
| 16 | + // VS Code settings |
| 17 | + "vscode": { |
| 18 | + // Extensions to install |
| 19 | + "extensions": [ |
| 20 | + // Nix |
| 21 | + "jnoortheen.nix-ide", |
| 22 | + // Direnv |
| 23 | + "mkhl.direnv", |
| 24 | + // Task |
| 25 | + "task.vscode-task", |
| 26 | + // Trunk |
| 27 | + "Trunk.io" |
| 28 | + ], |
| 29 | + // Settings to override |
| 30 | + "settings": { |
| 31 | + // Set Trunk as the default formatter |
| 32 | + "editor.defaultFormatter": "trunk.io", |
| 33 | + // Use LSP for Nix |
| 34 | + "nix.enableLanguageServer": true, |
| 35 | + // Use nil as the language server |
| 36 | + "nix.serverPath": "nil", |
| 37 | + "nix.serverSettings": { |
| 38 | + "nil": { |
| 39 | + "formatting": { |
| 40 | + // Use 'nix fmt' for formatting |
| 41 | + "command": ["nix", "fmt", "--", "-"] |
| 42 | + } |
| 43 | + } |
| 44 | + }, |
| 45 | + // Don't forward ports automatically |
| 46 | + "remote.autoForwardPorts": false, |
| 47 | + // Use Nix IDE instead of Trunk for Nix files |
| 48 | + "[nix]": { |
| 49 | + "editor.defaultFormatter": "jnoortheen.nix-ide" |
| 50 | + } |
| 51 | + } |
| 52 | + } |
| 53 | + }, |
| 54 | + // Extra features to install to the container |
| 55 | + "features": { |
| 56 | + // Install Nix |
| 57 | + "ghcr.io/devcontainers/features/nix:1.2.0": { |
| 58 | + // Enable experimental features |
| 59 | + "extraNixConfig": "experimental-features = nix-command flakes", |
| 60 | + "version": "2.26.2" |
| 61 | + }, |
| 62 | + // Install Direnv |
| 63 | + "ghcr.io/devcontainers-extra/features/direnv:1.0.2": { |
| 64 | + "version": "2.35.0" |
| 65 | + }, |
| 66 | + // Enable using Docker from within the container |
| 67 | + "ghcr.io/devcontainers/features/docker-in-docker:2.12.0": { |
| 68 | + "version": "27.5.1" |
| 69 | + }, |
| 70 | + // Install Starship |
| 71 | + "ghcr.io/devcontainers-extra/features/starship:1.0.9": { |
| 72 | + "version": "1.22.1" |
| 73 | + } |
| 74 | + }, |
| 75 | + // Volumes |
| 76 | + "mounts": [ |
| 77 | + // Mount secrets (shared) |
| 78 | + "source=devcontainer-shared-secrets,target=/secrets/,type=volume", |
| 79 | + // Mount nix store (not shared) |
| 80 | + "source=devcontainer-${devcontainerId}-nix,target=/nix/,type=volume", |
| 81 | + // Mount shell history (not shared) |
| 82 | + "source=devcontainer-${devcontainerId}-shellhistory-persist,target=/persist/shellhistory/,type=volume", |
| 83 | + // Mount trunk cache (shared) |
| 84 | + "source=devcontainer-shared-trunk-cache,target=/cache/trunk/,type=volume", |
| 85 | + // Mount npm cache (shared) |
| 86 | + "source=devcontainer-shared-npm-cache,target=/cache/npm/,type=volume" |
| 87 | + ], |
| 88 | + // Run a command when the container is created |
| 89 | + "onCreateCommand": "/hooks/create.sh", |
| 90 | + // Environment variables |
| 91 | + "remoteEnv": { |
| 92 | + // Set workspace path |
| 93 | + "WORKSPACE": "${containerWorkspaceFolder}" |
| 94 | + }, |
| 95 | + // Run arguments |
| 96 | + "runArgs": [ |
| 97 | + // Use host UTS namespace |
| 98 | + "--uts=host", |
| 99 | + // Use host IPC |
| 100 | + "--ipc=host", |
| 101 | + // Use host network |
| 102 | + "--network=host", |
| 103 | + // Use host user namespace |
| 104 | + "--userns=host", |
| 105 | + // Use host cgroup namespace |
| 106 | + "--cgroupns=host", |
| 107 | + // Run with elevated privileges |
| 108 | + "--privileged" |
| 109 | + ] |
| 110 | +} |
0 commit comments