-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add nix flake and .devcontainer.json (#594)
Co-authored-by: Kalle Ahlström <[email protected]> Co-authored-by: Mikael Siidorow <[email protected]>
- Loading branch information
1 parent
a364758
commit 06696a6
Showing
7 changed files
with
557 additions
and
72 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
{ | ||
"customizations": { | ||
"vscode": { | ||
"extensions": [ | ||
"mkhl.direnv", | ||
"esbenp.prettier-vscode", | ||
"dbaeumer.vscode-eslint", | ||
"bradlc.vscode-tailwindcss", | ||
"yoavbls.pretty-ts-errors", | ||
"github.vscode-github-actions", | ||
"ms-vscode.vscode-typescript-next" | ||
], | ||
"settings": { | ||
"editor.tabSize": 2, | ||
"editor.defaultFormatter": "esbenp.prettier-vscode", | ||
"editor.formatOnSave": true, | ||
"editor.codeActionsOnSave": { | ||
"source.fixAll": "explicit", | ||
"source.fixAll.eslint": "explicit", | ||
"source.fixAll.stylelint": "explicit" | ||
}, | ||
"eslint.validate": [ | ||
"javascript", | ||
"javascriptreact", | ||
"typescript", | ||
"typescriptreact" | ||
], | ||
"eslint.runtime": "node_modules/.bin/eslint", | ||
"typescript.tsdk": "node_modules/typescript/lib", | ||
"eslint.workingDirectories": [ | ||
{ | ||
"mode": "auto" | ||
} | ||
], | ||
"tailwindCSS.experimental.classRegex": [ | ||
["cva\\(([^)]*)\\)", "[\"'`]([^\"'`]*).*?[\"'`]"] | ||
] | ||
} | ||
} | ||
}, | ||
"image": "ghcr.io/cachix/devenv:latest", | ||
"overrideCommand": false, | ||
"updateContentCommand": "direnv reload", | ||
"remoteEnv": { "LOCAL_WORKSPACE_FOLDER": "${localWorkspaceFolder}" }, | ||
"features": { | ||
"ghcr.io/devcontainers/features/docker-in-docker:2": {} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
if ! has nix_direnv_version || ! nix_direnv_version 2.2.1; then | ||
source_url "https://raw.githubusercontent.com/nix-community/nix-direnv/2.2.1/direnvrc" "sha256-zelF0vLbEl5uaqrfIzbgNzJWGmLzCmYAkInj/LNxvKs=" | ||
fi | ||
|
||
watch_file flake.nix | ||
watch_file flake.lock | ||
if ! use flake . --no-pure-eval --accept-flake-config | ||
then | ||
echo "devenv could not be built. The devenv environment was not loaded. Make the necessary changes to devenv.nix and hit enter to try again." >&2 | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,3 +15,6 @@ public/dist | |
!.vscode/extensions.json | ||
.idea | ||
/payload.config.ts | ||
.devenv | ||
.direnv | ||
.pnpm-store |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
{ | ||
inputs = { | ||
nixpkgs.url = "github:cachix/devenv-nixpkgs/rolling"; | ||
systems.url = "github:nix-systems/default"; | ||
devenv.url = "github:cachix/devenv"; | ||
devenv.inputs.nixpkgs.follows = "nixpkgs"; | ||
}; | ||
|
||
nixConfig = { | ||
extra-trusted-public-keys = "devenv.cachix.org-1:w1cLUi8dv3hnoSPGAuibQv+f9TZLr6cv/Hm9XgU50cw="; | ||
extra-substituters = "https://devenv.cachix.org"; | ||
}; | ||
|
||
outputs = { | ||
self, | ||
nixpkgs, | ||
devenv, | ||
systems, | ||
... | ||
} @ inputs: let | ||
forEachSystem = nixpkgs.lib.genAttrs (import systems); | ||
in { | ||
packages = forEachSystem (system: { | ||
devenv-up = self.devShells.${system}.default.config.procfileScript; | ||
devenv-test = self.devShells.${system}.default.config.test; | ||
}); | ||
|
||
devShells = | ||
forEachSystem | ||
(system: let | ||
pkgs = nixpkgs.legacyPackages.${system}; | ||
bun = pkgs.bun.overrideAttrs (oldAttrs: { | ||
buildInputs = oldAttrs.buildInputs or [] ++ [pkgs.makeWrapper]; | ||
postInstall = | ||
oldAttrs.postInstall | ||
or "" | ||
+ '' | ||
wrapProgram $out/bin/bun \ | ||
--set LD_LIBRARY_PATH "${pkgs.stdenv.cc.cc.lib}/lib/:$LD_LIBRARY_PATH" | ||
''; | ||
}); | ||
in { | ||
default = devenv.lib.mkShell { | ||
inherit inputs pkgs; | ||
modules = [ | ||
{ | ||
packages = with pkgs; [bash mongodb-tools docker bun]; | ||
|
||
# FIXME: this is only required within the dev container | ||
enterShell = '' | ||
export PATH="$PATH:/usr/local/bin" | ||
''; | ||
|
||
languages.javascript = { | ||
enable = true; | ||
package = pkgs.nodejs-slim_22; | ||
pnpm.enable = true; | ||
pnpm.install.enable = true; | ||
}; | ||
} | ||
]; | ||
}; | ||
}); | ||
}; | ||
} |
Oops, something went wrong.