-
Notifications
You must be signed in to change notification settings - Fork 0
/
flake.nix
71 lines (62 loc) · 2.52 KB
/
flake.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
{
description = "Vulnix pre-commit hook";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
# Adds flake compatability to start removing the vestiges of
# shell.nix and move us towards the more modern nix develop
# setting while tricking some services/plugins to still be able to
# use the shell.nix file.
flake-compat = {
url = "github:edolstra/flake-compat";
flake = false;
};
flake-utils.url = "github:numtide/flake-utils";
# Adds configurable pre-commit options to our flake :)
pre-commit-hooks = {
url =
"github:cachix/pre-commit-hooks.nix/a8f7e8c2f2c8a428e2844c99ee5aa4718db61698";
inputs = {
nixpkgs.follows = "nixpkgs";
flake-utils.follows = "flake-utils";
flake-compat.follows = "flake-compat";
gitignore.follows = "nixpkgs";
};
};
};
outputs = { self, flake-utils, ... }:
flake-utils.lib.eachSystem [
"aarch64-linux"
"aarch64-darwin"
"x86_64-darwin"
"x86_64-linux"
] (system:
let
# Note that the below use of pkgs will by implication mean that
# our dev dependencies for local packages as well as part of our
# devShell are pinned to stable - this is intended to ensure
# backwards compatability & reduced pain when managing deps
# in these spaces
pkgs = self.inputs.nixpkgs.legacyPackages.${system};
checks = {
pre-commit-check = self.inputs.pre-commit-hooks.lib.${system}.run
(import ./pre-commit-checks.nix { inherit self pkgs system; });
};
devShell = let packages = with pkgs; [ nixfmt statix vulnix nil ];
in pkgs.mkShell {
name = "nix-config-dev-shell";
inherit packages;
# Self reference to make the default shell hook that which generates
# a suitable pre-commit hook installation
inherit (self.checks.${system}.pre-commit-check) shellHook;
};
# Self reference the dev shell for our system to resolve the lacking
# devShells.${system}.default recommended structure
devShells.default = self.outputs.devShell.${system};
# Import local packages passing system relevnet pkgs through
# for dependencies.
localPackages = import ./packages { inherit pkgs; };
packages = (flake-utils.lib.flattenTree localPackages) // {
default = self.outputs.packages.${system}.vulnix-pre-commit;
};
in { inherit devShell devShells packages checks; });
}