nix-reuse/default.nix

102 lines
1.8 KiB
Nix
Raw Normal View History

2024-12-12 10:17:26 +01:00
# SPDX-FileCopyrightText: 2024 Tom Hubrecht <tom.hubrecht@dgnum.eu>
#
# SPDX-License-Identifier: EUPL-1.2
{
sources ? import ./npins,
pkgs ? import sources.nixpkgs { },
}:
let
inherit (pkgs) lib mkShell;
hook = lib.recursiveUpdate {
name = "reuse lint";
entry = "${pkgs.reuse}/bin/reuse lint";
enable = true;
stages = [ "pre-push" ];
};
install = config: {
shellHook =
(lib.evalModules {
modules = [
./modules
{ inherit config; }
{
config._module.args = {
inherit pkgs;
};
}
];
}).config.installationScript;
};
git-checks = (import sources.git-hooks).run {
src = ./.;
hooks = {
statix = {
enable = true;
stages = [ "pre-push" ];
settings.ignore = [ "npins" ];
};
deadnix = {
enable = true;
stages = [ "pre-push" ];
};
nixfmt-rfc-style = {
enable = true;
stages = [ "pre-push" ];
};
reuse = hook {
enable = true;
stages = [ "pre-push" ];
};
commitizen.enable = true;
};
};
reuse = install {
defaultLicense = "EUPL-1.2";
defaultCopyright = "2024 Tom Hubrecht <tom.hubrecht@dgnum.eu>";
downloadLicenses = true;
2024-12-12 10:17:26 +01:00
annotations = [
# Basic paths
{
path = [
".envrc"
".gitignore"
"REUSE.toml"
];
}
{
path = "npins/*";
license = "EUPL-1.2";
copyright = "The [npins](https://github.com/andir/npins) contributors";
}
];
};
in
{
devShell = mkShell {
name = "nix-reuse.dev";
packages = [ pkgs.reuse ];
shellHook = ''
${git-checks.shellHook}
${reuse.shellHook}
'';
};
inherit hook install;
}