build: include the pre-commit hooks in the flake itself

This commit is contained in:
winston 2023-02-10 10:03:16 +01:00
parent c8ade99362
commit 4c08bbd0d9
Signed by: winston
GPG key ID: 3786770EDBC2B481
5 changed files with 178 additions and 60 deletions

2
.envrc
View file

@ -1 +1 @@
use nix use flake

View file

@ -1,20 +0,0 @@
let
nix-pre-commit-hooks =
import (builtins.fetchTarball
"https://github.com/cachix/pre-commit-hooks.nix/tarball/master");
in {
pre-commit-check = nix-pre-commit-hooks.run {
src = ./.;
hooks = {
alejandra.enable = true;
editorconfig-checker.enable = true;
deadnix.enable = true;
shellcheck.enable = true;
stylua.enable = true;
};
settings.deadnix = {
noLambdaPatternNames = true;
noLambdaArg = true;
};
};
}

View file

@ -21,6 +21,73 @@
"type": "github" "type": "github"
} }
}, },
"flake-compat": {
"flake": false,
"locked": {
"lastModified": 1673956053,
"narHash": "sha256-4gtG9iQuiKITOjNQQeQIpoIB6b16fm+504Ch3sNKLd8=",
"owner": "edolstra",
"repo": "flake-compat",
"rev": "35bb57c0c8d8b62bbfd284272c928ceb64ddbde9",
"type": "github"
},
"original": {
"owner": "edolstra",
"repo": "flake-compat",
"type": "github"
}
},
"flake-utils": {
"locked": {
"lastModified": 1667395993,
"narHash": "sha256-nuEHfE/LcWyuSWnS8t12N1wc105Qtau+/OdUAjtQ0rA=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "5aed5285a952e0b949eb3ba02c12fa4fcfef535f",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"flake-utils_2": {
"locked": {
"lastModified": 1667395993,
"narHash": "sha256-nuEHfE/LcWyuSWnS8t12N1wc105Qtau+/OdUAjtQ0rA=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "5aed5285a952e0b949eb3ba02c12fa4fcfef535f",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"gitignore": {
"inputs": {
"nixpkgs": [
"pre-commit-hooks",
"nixpkgs"
]
},
"locked": {
"lastModified": 1660459072,
"narHash": "sha256-8DFJjXG8zqoONA1vXtgeKXy68KdJL5UaXR8NtVMUbx8=",
"owner": "hercules-ci",
"repo": "gitignore.nix",
"rev": "a20de23b925fd8264fd7fad6454652e142fd7f73",
"type": "github"
},
"original": {
"owner": "hercules-ci",
"repo": "gitignore.nix",
"type": "github"
}
},
"home-manager": { "home-manager": {
"inputs": { "inputs": {
"nixpkgs": [ "nixpkgs": [
@ -60,6 +127,22 @@
} }
}, },
"nixpkgs-stable": { "nixpkgs-stable": {
"locked": {
"lastModified": 1673800717,
"narHash": "sha256-SFHraUqLSu5cC6IxTprex/nTsI81ZQAtDvlBvGDWfnA=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "2f9fd351ec37f5d479556cd48be4ca340da59b8f",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixos-22.11",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgs-stable_2": {
"locked": { "locked": {
"lastModified": 1676003493, "lastModified": 1676003493,
"narHash": "sha256-D7al8mRCMBu6eOF62Nlx1jzCSU6odbBK/OJVynqnMHc=", "narHash": "sha256-D7al8mRCMBu6eOF62Nlx1jzCSU6odbBK/OJVynqnMHc=",
@ -92,6 +175,22 @@
} }
}, },
"nixpkgs_2": { "nixpkgs_2": {
"locked": {
"lastModified": 1671271357,
"narHash": "sha256-xRJdLbWK4v2SewmSStYrcLa0YGJpleufl44A19XSW8k=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "40f79f003b6377bd2f4ed4027dde1f8f922995dd",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixos-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgs_3": {
"locked": { "locked": {
"lastModified": 1656817495, "lastModified": 1656817495,
"narHash": "sha256-QEWkUBH4gu6ntNkF+9xIqDM22bto4PB+LSHIL6oWFpM=", "narHash": "sha256-QEWkUBH4gu6ntNkF+9xIqDM22bto4PB+LSHIL6oWFpM=",
@ -123,20 +222,44 @@
"type": "github" "type": "github"
} }
}, },
"pre-commit-hooks": {
"inputs": {
"flake-compat": "flake-compat",
"flake-utils": "flake-utils_2",
"gitignore": "gitignore",
"nixpkgs": "nixpkgs_2",
"nixpkgs-stable": "nixpkgs-stable"
},
"locked": {
"lastModified": 1675688762,
"narHash": "sha256-oit/SxMk0B380ASuztBGQLe8TttO1GJiXF8aZY9AYEc=",
"owner": "cachix",
"repo": "pre-commit-hooks.nix",
"rev": "ab608394886fb04b8a5df3cb0bab2598400e3634",
"type": "github"
},
"original": {
"owner": "cachix",
"repo": "pre-commit-hooks.nix",
"type": "github"
}
},
"root": { "root": {
"inputs": { "inputs": {
"darwin": "darwin", "darwin": "darwin",
"flake-utils": "flake-utils",
"home-manager": "home-manager", "home-manager": "home-manager",
"nixpkgs": "nixpkgs", "nixpkgs": "nixpkgs",
"nixpkgs-unstable": "nixpkgs-unstable", "nixpkgs-unstable": "nixpkgs-unstable",
"nur": "nur", "nur": "nur",
"pre-commit-hooks": "pre-commit-hooks",
"sops": "sops" "sops": "sops"
} }
}, },
"sops": { "sops": {
"inputs": { "inputs": {
"nixpkgs": "nixpkgs_2", "nixpkgs": "nixpkgs_3",
"nixpkgs-stable": "nixpkgs-stable" "nixpkgs-stable": "nixpkgs-stable_2"
}, },
"locked": { "locked": {
"lastModified": 1675872570, "lastModified": 1675872570,

View file

@ -16,12 +16,18 @@
}; };
nur.url = "github:nix-community/NUR/master"; nur.url = "github:nix-community/NUR/master";
sops.url = "github:Mic92/sops-nix/master"; sops.url = "github:Mic92/sops-nix/master";
# dev
pre-commit-hooks.url = "github:cachix/pre-commit-hooks.nix";
flake-utils.url = "github:numtide/flake-utils";
}; };
outputs = { outputs = {
self, self,
darwin, darwin,
home-manager, home-manager,
flake-utils,
pre-commit-hooks,
nixpkgs, nixpkgs,
nixpkgs-unstable, nixpkgs-unstable,
nur, nur,
@ -34,34 +40,56 @@
config.allowUnfree = true; config.allowUnfree = true;
}; };
}; };
in { in
darwinConfigurations = { {
"sashimi-slicer" = darwin.lib.darwinSystem rec { darwinConfigurations = {
system = "aarch64-darwin"; "sashimi-slicer" = darwin.lib.darwinSystem rec {
system = "aarch64-darwin";
modules = [ modules = [
home-manager.darwinModules.home-manager home-manager.darwinModules.home-manager
./darwin.nix ./darwin.nix
({config, ...}: { ({config, ...}: {
config = { config = {
nixpkgs.overlays = [overlay-unstable]; nixpkgs.overlays = [overlay-unstable];
nixpkgs.config.allowUnfree = true; nixpkgs.config.allowUnfree = true;
home-manager = { home-manager = {
useGlobalPkgs = true; useGlobalPkgs = true;
users.winston.imports = [./home.nix]; users.winston.imports = [./home.nix];
extraSpecialArgs = { extraSpecialArgs = {
nur = nur.nixosModules.nur; nur = nur.nixosModules.nur;
sops = sops.homeManagerModules.sops; sops = sops.homeManagerModules.sops;
flakePath = "/Users/winston/.config/nixpkgs"; flakePath = "/Users/winston/.config/nixpkgs";
machine.personal = true; machine.personal = true;
};
}; };
}; };
}; })
}) ];
]; };
}; };
}; }
}; // flake-utils.lib.eachDefaultSystem (system: {
checks = {
pre-commit-check = pre-commit-hooks.lib.${system}.run {
src = ./.;
hooks = {
alejandra.enable = true;
editorconfig-checker.enable = true;
deadnix.enable = true;
shellcheck.enable = true;
stylua.enable = true;
};
settings.deadnix = {
noLambdaPatternNames = true;
noLambdaArg = true;
};
};
};
devShell = nixpkgs.legacyPackages.${system}.mkShell {
inherit (self.checks.${system}.pre-commit-check) shellHook;
};
});
} }

View file

@ -1,13 +0,0 @@
let
pkgs = import <nixpkgs> {};
in
pkgs.mkShell {
buildInputs = with pkgs; [
git
git-secret
just
];
shellHook = ''
${(import ./default.nix).pre-commit-check.shellHook}
'';
}