diff --git a/devShells.nix b/devShells.nix index 5bd8539..4a6d6a3 100644 --- a/devShells.nix +++ b/devShells.nix @@ -1,77 +1,88 @@ ################################################################## # Development shells ################################################################## -{ pkgs, precommit }: +{ self, ... }: { - # - # - # $ nix develop github:r17x/nixpkgs - # - # - default = pkgs.mkShell { - description = "r17x/nixpkgs development environment"; - shellHook = precommit.shellHook or ''''; - buildInputs = precommit.buildInputs or [ ]; - packages = precommit.packages or [ ]; - }; + perSystem = { pkgs, ... }: + { + pre-commit.check.enable = true; + pre-commit.devShell = self.devShells.default; + pre-commit.settings.hooks = { + actionlint.enable = true; + shellcheck.enable = true; + stylua.enable = true; + # TODO https://github.com/cachix/pre-commit-hooks.nix/issues/196 + # make override and pass configuration + luacheck.enable = false; - # - # - # $ nix develop github:r17x/nixpkgs#node18 - # - # - node18 = pkgs.mkShell { - description = "Node.js 18 Development Environment"; - buildInputs = with pkgs; [ - nodejs_18 - (nodePackages.yarn.override { nodejs = nodejs_18; }) - ]; - }; + # .nix related + deadnix.enable = true; + nixpkgs-fmt.enable = true; + }; - # - # - # $ nix develop github:r17x/nixpkgs#ocamlorg - # - # - ocamlorg = - let ocamlPackages = pkgs.ocaml-ng.ocamlPackages_4_14; in - pkgs.mkShell { - description = "OCaml.org development environment"; - buildInputs = with ocamlPackages; [ ocaml merlin ]; - nativeBuildInputs = with pkgs; [ - opam - pkg-config - libev - oniguruma - openssl - gmp - ]; - }; - # - # - # $ nix develop github:r17x/nixpkgs#pnpm - # - # - pnpm = pkgs.mkShell { - description = "Nodejs with PNPM"; + devShells = { + default = pkgs.mkShell { }; + # + # + # $ nix develop github:r17x/nixpkgs#node18 + # + # + node18 = pkgs.mkShell { + description = "Node.js 18 Development Environment"; + buildInputs = with pkgs; [ + nodejs_18 + (nodePackages.yarn.override { nodejs = nodejs_18; }) + ]; + }; + + # + # + # $ nix develop github:r17x/nixpkgs#ocamlorg + # + # + ocamlorg = + let ocamlPackages = pkgs.ocaml-ng.ocamlPackages_4_14; in + pkgs.mkShell { + description = "OCaml.org development environment"; + buildInputs = with ocamlPackages; [ ocaml merlin ]; + nativeBuildInputs = with pkgs; [ + opam + pkg-config + libev + oniguruma + openssl + gmp + ]; + }; + + # + # + # $ nix develop github:r17x/nixpkgs#pnpm + # + # + pnpm = pkgs.mkShell { + description = "Nodejs with PNPM"; - buildInputs = with pkgs; [ - nodejs_18 - (nodePackages.pnpm.override { nodejs = nodejs_18; }) - ]; - }; + buildInputs = with pkgs; [ + nodejs_18 + (nodePackages.pnpm.override { nodejs = nodejs_18; }) + ]; + }; - # - # - # $ nix develop github:r17x/nixpkgs#rust-wasm - # - # - rust-wasm = pkgs.mkShell { - # declared ENV variables when starting shell - RUST_SRC_PATH = "${pkgs.rust.packages.stable.rustPlatform.rustLibSrc}"; + # + # + # $ nix develop github:r17x/nixpkgs#rust-wasm + # + # + rust-wasm = pkgs.mkShell { + # declared ENV variables when starting shell + RUST_SRC_PATH = "${pkgs.rust.packages.stable.rustPlatform.rustLibSrc}"; - nativeBuildInputs = with pkgs; [ rustc cargo gcc rustfmt clippy ]; - }; + nativeBuildInputs = with pkgs; [ rustc cargo gcc rustfmt clippy ]; + }; + }; + + }; } diff --git a/flake.lock b/flake.lock index a85b649..46ccfe7 100644 --- a/flake.lock +++ b/flake.lock @@ -58,6 +58,22 @@ "type": "github" } }, + "flake-compat_2": { + "flake": false, + "locked": { + "lastModified": 1696426674, + "narHash": "sha256-kvjfFW7WAETZlt09AgDn1MrtKzP7t90Vf7vypd3OL1U=", + "owner": "edolstra", + "repo": "flake-compat", + "rev": "0f9255e01c2351cc7d116c072cb317785dd33b33", + "type": "github" + }, + "original": { + "owner": "edolstra", + "repo": "flake-compat", + "type": "github" + } + }, "flake-utils": { "locked": { "lastModified": 1637014545, @@ -73,6 +89,27 @@ "type": "github" } }, + "gitignore": { + "inputs": { + "nixpkgs": [ + "precommit", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1709087332, + "narHash": "sha256-HG2cCnktfHsKV0s4XW83gU3F57gaTljL9KNSuG6bnQs=", + "owner": "hercules-ci", + "repo": "gitignore.nix", + "rev": "637db329424fd7e46cf4185293b9cc8c88c95394", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "gitignore.nix", + "type": "github" + } + }, "home": { "inputs": { "nixpkgs": [ @@ -241,6 +278,22 @@ "type": "github" } }, + "nixpkgs-stable": { + "locked": { + "lastModified": 1710695816, + "narHash": "sha256-3Eh7fhEID17pv9ZxrPwCLfqXnYP006RKzSs0JptsN84=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "614b4613980a522ba49f0d194531beddbb7220d3", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-23.11", + "repo": "nixpkgs", + "type": "github" + } + }, "nvim-treesitter": { "flake": false, "locked": { @@ -275,6 +328,29 @@ "type": "github" } }, + "precommit": { + "inputs": { + "flake-compat": "flake-compat_2", + "gitignore": "gitignore", + "nixpkgs": [ + "nixpkgs" + ], + "nixpkgs-stable": "nixpkgs-stable" + }, + "locked": { + "lastModified": 1716213921, + "narHash": "sha256-xrsYFST8ij4QWaV6HEokCUNIZLjjLP1bYC60K8XiBVA=", + "owner": "cachix", + "repo": "pre-commit-hooks.nix", + "rev": "0e8fcc54b842ad8428c9e705cb5994eaf05c26a0", + "type": "github" + }, + "original": { + "owner": "cachix", + "repo": "pre-commit-hooks.nix", + "type": "github" + } + }, "root": { "inputs": { "darwin": "darwin", @@ -289,6 +365,7 @@ "nixpkgs-fmt": "nixpkgs-fmt", "nvim-treesitter": "nvim-treesitter", "parts": "parts", + "precommit": "precommit", "sops": "sops", "stable": "stable", "ts-rescript": "ts-rescript", diff --git a/flake.nix b/flake.nix index b79b415..2b3460e 100644 --- a/flake.nix +++ b/flake.nix @@ -8,6 +8,8 @@ ]; imports = [ + inputs.precommit.flakeModule + ./devShells.nix ./overlays ./modules/parts ./hosts @@ -48,6 +50,10 @@ sops.inputs.nixpkgs.follows = "nixpkgs"; sops.inputs.nixpkgs-stable.follows = "stable"; + # utilities + precommit.url = "github:cachix/pre-commit-hooks.nix"; + precommit.inputs.nixpkgs.follows = "nixpkgs"; + # vimPlugins from flake inputs # prefix "vimPlugins_" # e.g: rescript-nvim to be vimPlugins_rescript-nvim