summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorseth <[email protected]>2023-11-12 17:06:44 -0500
committerseth <[email protected]>2023-11-12 17:06:44 -0500
commit9fead8a218a85391221385030d8b1f7bfe62a1d4 (patch)
tree5c0e727dde961743c7e17c024135a4c3ab42cc81
parent4b498cef6add2e7342a24f7598ed47b32086ae54 (diff)
feat: add nix flake for dev env
-rw-r--r--.editorconfig5
-rw-r--r--.github/workflows/update-flake.yaml31
-rw-r--r--.gitignore1
-rw-r--r--.prettierignore1
-rw-r--r--flake.lock144
-rw-r--r--flake.nix81
6 files changed, 262 insertions, 1 deletions
diff --git a/.editorconfig b/.editorconfig
index d395ba4..cba1b92 100644
--- a/.editorconfig
+++ b/.editorconfig
@@ -10,6 +10,9 @@ charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
-[*.{yml,yaml}]
+[*.{nix,yml,yaml}]
indent_style = space
indent_size = 2
+
+[*.lock]
+indent_style = space
diff --git a/.github/workflows/update-flake.yaml b/.github/workflows/update-flake.yaml
new file mode 100644
index 0000000..3cdc03d
--- /dev/null
+++ b/.github/workflows/update-flake.yaml
@@ -0,0 +1,31 @@
+name: update flake.lock
+
+on:
+ schedule:
+ - cron: "0 0 * * 6"
+ workflow_dispatch:
+
+jobs:
+ update:
+ runs-on: ubuntu-latest
+
+ permissions:
+ contents: write
+ pull-requests: write
+
+ steps:
+ - uses: actions/checkout@v4
+ - uses: nixbuild/nix-quick-install-action@v26
+
+ - name: update lockfile
+ uses: DeterminateSystems/update-flake-lock@v20
+ id: update
+ with:
+ token: ${{ github.token }}
+
+ - name: enable auto-merge
+ shell: bash
+ run: gh pr merge --rebase "$PR_ID"
+ env:
+ GH_TOKEN: ${{ github.token }}
+ PR_ID: ${{ steps.update.outputs.pull-request-number }}
diff --git a/.gitignore b/.gitignore
index 75e65a6..b78ac53 100644
--- a/.gitignore
+++ b/.gitignore
@@ -17,3 +17,4 @@ dist/
.direnv/
result*
repl-result-out*
+.pre-commit-config.yaml
diff --git a/.prettierignore b/.prettierignore
index 972946a..efadaba 100644
--- a/.prettierignore
+++ b/.prettierignore
@@ -1,2 +1,3 @@
pnpm-lock.yaml
+flake.lock
Teawie-Archive/
diff --git a/flake.lock b/flake.lock
new file mode 100644
index 0000000..432c295
--- /dev/null
+++ b/flake.lock
@@ -0,0 +1,144 @@
+{
+ "nodes": {
+ "flake-compat": {
+ "flake": false,
+ "locked": {
+ "lastModified": 1673956053,
+ "narHash": "sha256-4gtG9iQuiKITOjNQQeQIpoIB6b16fm+504Ch3sNKLd8=",
+ "owner": "edolstra",
+ "repo": "flake-compat",
+ "rev": "35bb57c0c8d8b62bbfd284272c928ceb64ddbde9",
+ "type": "github"
+ },
+ "original": {
+ "owner": "edolstra",
+ "repo": "flake-compat",
+ "type": "github"
+ }
+ },
+ "flake-utils": {
+ "inputs": {
+ "systems": "systems"
+ },
+ "locked": {
+ "lastModified": 1685518550,
+ "narHash": "sha256-o2d0KcvaXzTrPRIo0kOLV0/QXHhDQ5DTi+OxcjO8xqY=",
+ "owner": "numtide",
+ "repo": "flake-utils",
+ "rev": "a1720a10a6cfe8234c0e93907ffe81be440f4cef",
+ "type": "github"
+ },
+ "original": {
+ "owner": "numtide",
+ "repo": "flake-utils",
+ "type": "github"
+ }
+ },
+ "gitignore": {
+ "inputs": {
+ "nixpkgs": [
+ "pre-commit",
+ "nixpkgs"
+ ]
+ },
+ "locked": {
+ "lastModified": 1660459072,
+ "narHash": "sha256-8DFJjXG8zqoONA1vXtgeKXy68KdJL5UaXR8NtVMUbx8=",
+ "owner": "hercules-ci",
+ "repo": "gitignore.nix",
+ "rev": "a20de23b925fd8264fd7fad6454652e142fd7f73",
+ "type": "github"
+ },
+ "original": {
+ "owner": "hercules-ci",
+ "repo": "gitignore.nix",
+ "type": "github"
+ }
+ },
+ "nixpkgs": {
+ "locked": {
+ "lastModified": 1699725108,
+ "narHash": "sha256-NTiPW4jRC+9puakU4Vi8WpFEirhp92kTOSThuZke+FA=",
+ "owner": "NixOS",
+ "repo": "nixpkgs",
+ "rev": "911ad1e67f458b6bcf0278fa85e33bb9924fed7e",
+ "type": "github"
+ },
+ "original": {
+ "id": "nixpkgs",
+ "ref": "nixpkgs-unstable",
+ "type": "indirect"
+ }
+ },
+ "parts": {
+ "inputs": {
+ "nixpkgs-lib": [
+ "nixpkgs"
+ ]
+ },
+ "locked": {
+ "lastModified": 1698882062,
+ "narHash": "sha256-HkhafUayIqxXyHH1X8d9RDl1M2CkFgZLjKD3MzabiEo=",
+ "owner": "hercules-ci",
+ "repo": "flake-parts",
+ "rev": "8c9fa2545007b49a5db5f650ae91f227672c3877",
+ "type": "github"
+ },
+ "original": {
+ "owner": "hercules-ci",
+ "repo": "flake-parts",
+ "type": "github"
+ }
+ },
+ "pre-commit": {
+ "inputs": {
+ "flake-compat": "flake-compat",
+ "flake-utils": "flake-utils",
+ "gitignore": "gitignore",
+ "nixpkgs": [
+ "nixpkgs"
+ ],
+ "nixpkgs-stable": [
+ "nixpkgs"
+ ]
+ },
+ "locked": {
+ "lastModified": 1699271226,
+ "narHash": "sha256-8Jt1KW3xTjolD6c6OjJm9USx/jmL+VVmbooADCkdDfU=",
+ "owner": "cachix",
+ "repo": "pre-commit-hooks.nix",
+ "rev": "ea758da1a6dcde6dc36db348ed690d09b9864128",
+ "type": "github"
+ },
+ "original": {
+ "owner": "cachix",
+ "repo": "pre-commit-hooks.nix",
+ "type": "github"
+ }
+ },
+ "root": {
+ "inputs": {
+ "nixpkgs": "nixpkgs",
+ "parts": "parts",
+ "pre-commit": "pre-commit"
+ }
+ },
+ "systems": {
+ "locked": {
+ "lastModified": 1681028828,
+ "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
+ "owner": "nix-systems",
+ "repo": "default",
+ "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
+ "type": "github"
+ },
+ "original": {
+ "owner": "nix-systems",
+ "repo": "default",
+ "type": "github"
+ }
+ }
+ },
+ "root": "root",
+ "version": 7
+}
diff --git a/flake.nix b/flake.nix
new file mode 100644
index 0000000..149dac5
--- /dev/null
+++ b/flake.nix
@@ -0,0 +1,81 @@
+{
+ inputs = {
+ nixpkgs.url = "nixpkgs/nixpkgs-unstable";
+
+ parts = {
+ url = "github:hercules-ci/flake-parts";
+ inputs.nixpkgs-lib.follows = "nixpkgs";
+ };
+
+ pre-commit = {
+ url = "github:cachix/pre-commit-hooks.nix";
+ inputs.nixpkgs.follows = "nixpkgs";
+ inputs.nixpkgs-stable.follows = "nixpkgs";
+ };
+ };
+
+ outputs = {
+ parts,
+ pre-commit,
+ ...
+ } @ inputs:
+ parts.lib.mkFlake {inherit inputs;} {
+ systems = [
+ "x86_64-linux"
+ "aarch64-linux"
+ "x86_64-darwin"
+ "aarch64-darwin"
+ ];
+
+ imports = [pre-commit.flakeModule];
+
+ perSystem = {
+ config,
+ pkgs,
+ ...
+ }: {
+ devShells.default = pkgs.mkShell {
+ shellHook = ''
+ [ ! -d node_modules ] && pnpm install --frozen-lockfile
+ ${config.pre-commit.installationScript}
+ '';
+
+ packages = with pkgs; [
+ nodejs_20
+ (nodePackages_latest.pnpm.override {nodejs = nodejs_20;})
+
+ actionlint
+ editorconfig-checker
+
+ config.formatter
+ deadnix
+ nil
+ statix
+ ];
+ };
+
+ formatter = pkgs.alejandra;
+
+ pre-commit.settings = {
+ hooks = {
+ actionlint.enable = true;
+ editorconfig-checker.enable = true;
+
+ # typescript
+ eslint.enable = true;
+ prettier.enable = true;
+
+ # nix
+ ${config.formatter.pname}.enable = true;
+ deadnix.enable = true;
+ nil.enable = true;
+ statix.enable = true;
+ };
+
+ settings = {
+ eslint.extensions = "\\.(js|jsx|ts|tsx)$";
+ };
+ };
+ };
+ };
+}