From 5e0b72ca7408c20a10d3aab80275a9c09dd527c8 Mon Sep 17 00:00:00 2001 From: Felix Tenley Date: Thu, 24 Sep 2020 12:35:45 +0200 Subject: [PATCH] feat: setup pre-commit-hooks --- .envrc | 1 + .gitignore | 4 +- flake.lock | 153 ++++++++++++++++++++++++++++++++++++++++++++++++++--- flake.nix | 19 ++++++- 4 files changed, 166 insertions(+), 11 deletions(-) create mode 100644 .envrc diff --git a/.envrc b/.envrc new file mode 100644 index 0000000..3550a30 --- /dev/null +++ b/.envrc @@ -0,0 +1 @@ +use flake diff --git a/.gitignore b/.gitignore index 34d55f8..4eacba2 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,2 @@ -/hardware-configuration.nix -/configuration.nix +.env +.pre-commit-config.yaml diff --git a/flake.lock b/flake.lock index cebfe09..83beac4 100644 --- a/flake.lock +++ b/flake.lock @@ -1,15 +1,112 @@ { "nodes": { + "cabal-fmt-src": { + "flake": false, + "locked": { + "lastModified": 1598802028, + "narHash": "sha256-5yUORdBD9mtL7vPnqs+MGnHvQ7y7OGx5VeMHx0pIe2U=", + "owner": "phadej", + "repo": "cabal-fmt", + "rev": "0c716667848e0a6f2b5f999b60b067e36b0495ce", + "type": "github" + }, + "original": { + "owner": "phadej", + "ref": "master", + "repo": "cabal-fmt", + "type": "github" + } + }, + "flake-compat": { + "flake": false, + "locked": { + "lastModified": 1600853454, + "narHash": "sha256-EgsgbcJNZ9AQLVhjhfiegGjLbO+StBY9hfKsCwc8Hw8=", + "owner": "edolstra", + "repo": "flake-compat", + "rev": "94cf59784c73ecec461eaa291918eff0bfb538ac", + "type": "github" + }, + "original": { + "owner": "edolstra", + "repo": "flake-compat", + "type": "github" + } + }, + "flake-utils": { + "locked": { + "lastModified": 1600209923, + "narHash": "sha256-zoOWauTliFEjI++esk6Jzk7QO5EKpddWXQm9yQK24iM=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "3cd06d3c1df6879c9e41cb2c33113df10566c760", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "flake-utils_2": { + "locked": { + "lastModified": 1600209923, + "narHash": "sha256-zoOWauTliFEjI++esk6Jzk7QO5EKpddWXQm9yQK24iM=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "3cd06d3c1df6879c9e41cb2c33113df10566c760", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "gitignore-nix-src": { + "flake": false, + "locked": { + "lastModified": 1594969032, + "narHash": "sha256-nbZfz02QoVe1yYK7EtCV7wMi4VdHzZEoPg20ZSDo9to=", + "owner": "hercules-ci", + "repo": "gitignore", + "rev": "c4662e662462e7bf3c2a968483478a665d00e717", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "ref": "master", + "repo": "gitignore", + "type": "github" + } + }, + "hindent-src": { + "flake": false, + "locked": { + "lastModified": 1599403541, + "narHash": "sha256-Js9uf2JSID3Ny5DVJbJ/cAbOPthcb1fKXCfyk+uoLT0=", + "owner": "chrisdone", + "repo": "hindent", + "rev": "a75d4033969ecf7d4d0a5eb985d3d1abb3b9301f", + "type": "github" + }, + "original": { + "owner": "chrisdone", + "ref": "master", + "repo": "hindent", + "type": "github" + } + }, "home-manager": { "inputs": { "nixpkgs": "nixpkgs" }, "locked": { - "lastModified": 1600810013, - "narHash": "sha256-Zcvg0/ot+EfV1fOdUF0G/GY2zBq76ksv92cpa2E2xvk=", + "lastModified": 1600939014, + "narHash": "sha256-KAE8spJnWmnFy1H1QVyRa2fA/09MxbZgjzvilqBhCPY=", "owner": "nix-community", "repo": "home-manager", - "rev": "a6a3abb295777b1d3ac1ca7f2d47bd0daf7f9638", + "rev": "690d93c22a8812c303a52786022f3f0441dfd06a", "type": "github" }, "original": { @@ -48,13 +145,29 @@ "type": "github" } }, + "nixpkgs_3": { + "locked": { + "lastModified": 1600791342, + "narHash": "sha256-rHcPneff0ktF2Jhmh8kd+NqP1SaHa6uU2YJx1kyG1qQ=", + "owner": "NixOS", + "repo": "nixpkgs-channels", + "rev": "6ec10fc77e56b9f848930f129833cfbbac736e4f", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-20.03", + "repo": "nixpkgs-channels", + "type": "github" + } + }, "nur": { "locked": { - "lastModified": 1600852729, - "narHash": "sha256-vEL7Z+PH0SNa6lxeh5O4L4qXTxbLvgRmOjB1hsuszQM=", + "lastModified": 1600942119, + "narHash": "sha256-En5A8eFmuGG/GYpFE8rsXUxCNbdjEH0NSmlze4NXbBE=", "owner": "nix-community", "repo": "NUR", - "rev": "7f9f9cc367812895a64648d9942fddf6e7faacf8", + "rev": "db2d66991e8068db7a7e1a617901f8e732147fe6", "type": "github" }, "original": { @@ -64,11 +177,37 @@ "type": "github" } }, + "pre-commit-hooks": { + "inputs": { + "cabal-fmt-src": "cabal-fmt-src", + "flake-compat": "flake-compat", + "flake-utils": "flake-utils_2", + "gitignore-nix-src": "gitignore-nix-src", + "hindent-src": "hindent-src", + "nixpkgs": "nixpkgs_3" + }, + "locked": { + "lastModified": 1600939022, + "narHash": "sha256-TDyYQGP2x+LDU2hHUtXI9hrwN2iQByLBfq39rXBq1cA=", + "owner": "Myhlamaeus", + "repo": "pre-commit-hooks.nix", + "rev": "8d48a4cd434a6a6cc8f2603b50d2c0b2981a7c55", + "type": "github" + }, + "original": { + "owner": "Myhlamaeus", + "repo": "pre-commit-hooks.nix", + "rev": "8d48a4cd434a6a6cc8f2603b50d2c0b2981a7c55", + "type": "github" + } + }, "root": { "inputs": { + "flake-utils": "flake-utils", "home-manager": "home-manager", "nixpkgs": "nixpkgs_2", - "nur": "nur" + "nur": "nur", + "pre-commit-hooks": "pre-commit-hooks" } } }, diff --git a/flake.nix b/flake.nix index a18ffda..f93d3eb 100644 --- a/flake.nix +++ b/flake.nix @@ -1,11 +1,17 @@ { inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; + inputs.flake-utils.url = "github:numtide/flake-utils"; + inputs.home-manager.url = "github:nix-community/home-manager/master"; inputs.nur.url = "github:nix-community/NUR/master"; - outputs = { self, nixpkgs, home-manager, nur }: + inputs.pre-commit-hooks.url = + # "github:Myhlamaeus/pre-commit-hooks.nix/feat/flake"; + "github:Myhlamaeus/pre-commit-hooks.nix/8d48a4cd434a6a6cc8f2603b50d2c0b2981a7c55"; + + outputs = { self, nixpkgs, flake-utils, home-manager, nur, pre-commit-hooks }: let systemModule = { hostName, hardwareConfig, config }: ({ pkgs, ... }: { @@ -50,5 +56,14 @@ homeManagerModules.git = import ./home/modules/git.nix; - }; + } // flake-utils.lib.eachDefaultSystem (system: + let + pkgs = nixpkgs.legacyPackages.${system}; + pre-commit-check = pre-commit-hooks.defaultPackage.${system} { + src = ./.; + hooks = { nixfmt.enable = true; }; + }; + in { + devShell = pkgs.mkShell { inherit (pre-commit-check) shellHook; }; + }); }