From 90e6ae6f67d4d0d28e0c1e12bf95079642ee1198 Mon Sep 17 00:00:00 2001 From: punkfairie Date: Thu, 14 Nov 2024 18:08:36 +0000 Subject: [PATCH] feat(dev): Setup devcontainer --- .devcontainer/Dockerfile | 1 + .devcontainer/devcontainer.json | 51 +++++++++++++++++++++++++++++++++ flake.nix | 3 +- shells/base.nix | 4 --- shells/nix.nix | 8 ++++++ 5 files changed, 61 insertions(+), 6 deletions(-) create mode 100644 .devcontainer/Dockerfile create mode 100644 .devcontainer/devcontainer.json delete mode 100644 shells/base.nix create mode 100644 shells/nix.nix diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile new file mode 100644 index 0000000..c502a45 --- /dev/null +++ b/.devcontainer/Dockerfile @@ -0,0 +1 @@ +FROM ghcr.io/xtruder/nix-devcontainer:v1 \ No newline at end of file diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 0000000..072600d --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,51 @@ +// For format details, see https://aka.ms/vscode-remote/devcontainer.json or the definition README at +// https://github.com/microsoft/vscode-dev-containers/tree/master/containers/docker-existing-dockerfile +{ + "name": "devcontainer-project", + "dockerFile": "Dockerfile", + "context": "${localWorkspaceFolder}", + "build": { + "args": { + "USER_UID": "${localEnv:USER_UID}", + "USER_GID": "${localEnv:USER_GID}" + }, + }, + + // run arguments passed to docker + "runArgs": [ + "--security-opt", "label=disable" + ], + + "containerEnv": { + // extensions to preload before other extensions + "PRELOAD_EXTENSIONS": "arrterian.nix-env-selector" + }, + + // disable command overriding and updating remote user ID + "overrideCommand": false, + "userEnvProbe": "loginShell", + "updateRemoteUserUID": false, + + // build development environment on creation, make sure you already have shell.nix + "onCreateCommand": "nix develop", + + // Add the IDs of extensions you want installed when the container is created. + "customizations": { + "vscode": { + "extensions": [ + // select nix environment + "arrterian.nix-env-selector", + + // extra extensions + //"fsevenm.run-it-on", + "jnoortheen.nix-ide" + ] + } + }, + + // Use 'forwardPorts' to make a list of ports inside the container available locally. + "forwardPorts": [] + + // Use 'postCreateCommand' to run commands after the container is created. + // "postCreateCommand": "go version", + } \ No newline at end of file diff --git a/flake.nix b/flake.nix index 4e36957..2ca5914 100644 --- a/flake.nix +++ b/flake.nix @@ -52,9 +52,8 @@ } ); - # Base dev shell devenv.shells.default = { - imports = [ "${self}/shells/base.nix" ]; + imports = [ "${self}/shells/nix.nix" ]; }; formatter = pkgs.nixfmt-rfc-style; diff --git a/shells/base.nix b/shells/base.nix deleted file mode 100644 index facb35d..0000000 --- a/shells/base.nix +++ /dev/null @@ -1,4 +0,0 @@ -{ ... }: -{ - -} diff --git a/shells/nix.nix b/shells/nix.nix new file mode 100644 index 0000000..44c5083 --- /dev/null +++ b/shells/nix.nix @@ -0,0 +1,8 @@ +{ pkgs, ... }: +{ + languages.nix.enable = true; + + packages = [ + nixfmt-rfc-style + ]; +}