diff options
| author | seth <[email protected]> | 2023-11-12 17:06:44 -0500 |
|---|---|---|
| committer | seth <[email protected]> | 2023-11-12 17:06:44 -0500 |
| commit | 9fead8a218a85391221385030d8b1f7bfe62a1d4 (patch) | |
| tree | 5c0e727dde961743c7e17c024135a4c3ab42cc81 /flake.nix | |
| parent | 4b498cef6add2e7342a24f7598ed47b32086ae54 (diff) | |
feat: add nix flake for dev env
Diffstat (limited to 'flake.nix')
| -rw-r--r-- | flake.nix | 81 |
1 files changed, 81 insertions, 0 deletions
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)$"; + }; + }; + }; + }; +} |
