From 00f3013af0d48af0d291dc91122a8b146860f681 Mon Sep 17 00:00:00 2001 From: Bruno BELANYI Date: Wed, 1 Jun 2022 16:15:54 +0200 Subject: [PATCH] Bootstrap nix flake environment --- flake.lock | 69 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ flake.nix | 68 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 137 insertions(+) create mode 100644 flake.lock create mode 100644 flake.nix diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..004b8e1 --- /dev/null +++ b/flake.lock @@ -0,0 +1,69 @@ +{ + "nodes": { + "flake-utils": { + "locked": { + "lastModified": 1653893745, + "narHash": "sha256-0jntwV3Z8//YwuOjzhV2sgJJPt+HY6KhU7VZUL0fKZQ=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "1ed9fb1935d260de5fe1c2f7ee0ebaae17ed2fa1", + "type": "github" + }, + "original": { + "owner": "numtide", + "ref": "master", + "repo": "flake-utils", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1654007547, + "narHash": "sha256-G812EeXZeGeGjkAvbTleGwcKFCGxdLOQb9aViOWASPc=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "5643714dea562f0161529ab23058562afeff46d0", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "pre-commit-hooks": { + "inputs": { + "flake-utils": [ + "flake-utils" + ], + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1652714503, + "narHash": "sha256-qQKVEfDe5FqvGgkZtg5Pc491foeiDPIOeycHMqnPDps=", + "owner": "cachix", + "repo": "pre-commit-hooks.nix", + "rev": "521a524771a8e93caddaa0ac1d67d03766a8b0b3", + "type": "github" + }, + "original": { + "owner": "cachix", + "ref": "master", + "repo": "pre-commit-hooks.nix", + "type": "github" + } + }, + "root": { + "inputs": { + "flake-utils": "flake-utils", + "nixpkgs": "nixpkgs", + "pre-commit-hooks": "pre-commit-hooks" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..88cdb40 --- /dev/null +++ b/flake.nix @@ -0,0 +1,68 @@ +{ + description = "A tree-sitter grammar for Tiger"; + + inputs = { + flake-utils = { + type = "github"; + owner = "numtide"; + repo = "flake-utils"; + ref = "master"; + }; + + nixpkgs = { + type = "github"; + owner = "NixOS"; + repo = "nixpkgs"; + ref = "nixpkgs-unstable"; + }; + + pre-commit-hooks = { + type = "github"; + owner = "cachix"; + repo = "pre-commit-hooks.nix"; + ref = "master"; + inputs = { + flake-utils.follows = "flake-utils"; + nixpkgs.follows = "nixpkgs"; + }; + }; + }; + + outputs = + { self + , flake-utils + , nixpkgs + , pre-commit-hooks + }: + flake-utils.lib.eachDefaultSystem + (system: + let + pkgs = import nixpkgs { + inherit system; + }; + in + rec { + checks = { + pre-commit = pre-commit-hooks.lib.${system}.run { + src = ./.; + + hooks = { + nixpkgs-fmt = { + enable = true; + }; + }; + }; + }; + + devShells = { + default = pkgs.mkShell { + nativeBuildInputs = with pkgs; [ + nodejs + tree-sitter + ]; + + inherit (checks.pre-commit) shellHook; + }; + }; + }); +}