feat: setup pre-commit-hooks

This commit is contained in:
Felix Schröter 2020-09-24 12:35:45 +02:00
parent 56fd0a749e
commit 5e0b72ca74
No known key found for this signature in database
GPG key ID: 910ACB9F6BD26F58
4 changed files with 166 additions and 11 deletions

1
.envrc Normal file
View file

@ -0,0 +1 @@
use flake

4
.gitignore vendored
View file

@ -1,2 +1,2 @@
/hardware-configuration.nix .env
/configuration.nix .pre-commit-config.yaml

View file

@ -1,15 +1,112 @@
{ {
"nodes": { "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": { "home-manager": {
"inputs": { "inputs": {
"nixpkgs": "nixpkgs" "nixpkgs": "nixpkgs"
}, },
"locked": { "locked": {
"lastModified": 1600810013, "lastModified": 1600939014,
"narHash": "sha256-Zcvg0/ot+EfV1fOdUF0G/GY2zBq76ksv92cpa2E2xvk=", "narHash": "sha256-KAE8spJnWmnFy1H1QVyRa2fA/09MxbZgjzvilqBhCPY=",
"owner": "nix-community", "owner": "nix-community",
"repo": "home-manager", "repo": "home-manager",
"rev": "a6a3abb295777b1d3ac1ca7f2d47bd0daf7f9638", "rev": "690d93c22a8812c303a52786022f3f0441dfd06a",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -48,13 +145,29 @@
"type": "github" "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": { "nur": {
"locked": { "locked": {
"lastModified": 1600852729, "lastModified": 1600942119,
"narHash": "sha256-vEL7Z+PH0SNa6lxeh5O4L4qXTxbLvgRmOjB1hsuszQM=", "narHash": "sha256-En5A8eFmuGG/GYpFE8rsXUxCNbdjEH0NSmlze4NXbBE=",
"owner": "nix-community", "owner": "nix-community",
"repo": "NUR", "repo": "NUR",
"rev": "7f9f9cc367812895a64648d9942fddf6e7faacf8", "rev": "db2d66991e8068db7a7e1a617901f8e732147fe6",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -64,11 +177,37 @@
"type": "github" "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": { "root": {
"inputs": { "inputs": {
"flake-utils": "flake-utils",
"home-manager": "home-manager", "home-manager": "home-manager",
"nixpkgs": "nixpkgs_2", "nixpkgs": "nixpkgs_2",
"nur": "nur" "nur": "nur",
"pre-commit-hooks": "pre-commit-hooks"
} }
} }
}, },

View file

@ -1,11 +1,17 @@
{ {
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; 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.home-manager.url = "github:nix-community/home-manager/master";
inputs.nur.url = "github:nix-community/NUR/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 let
systemModule = { hostName, hardwareConfig, config }: systemModule = { hostName, hardwareConfig, config }:
({ pkgs, ... }: { ({ pkgs, ... }: {
@ -50,5 +56,14 @@
homeManagerModules.git = import ./home/modules/git.nix; 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; };
});
} }