2024-12-26 20:51:08 +01:00
|
|
|
# SPDX-FileCopyrightText: 2024 Tom Hubrecht <tom.hubrecht@dgnum.eu>
|
|
|
|
#
|
|
|
|
# SPDX-License-Identifier: EUPL-1.2
|
|
|
|
|
2024-11-11 16:29:36 +01:00
|
|
|
{
|
|
|
|
sources ? import ./npins,
|
|
|
|
pkgs ? import sources.nixpkgs { },
|
|
|
|
}:
|
|
|
|
|
|
|
|
let
|
2024-12-30 12:16:26 +01:00
|
|
|
inherit (pkgs) mkShell;
|
|
|
|
|
2025-02-04 09:58:58 +01:00
|
|
|
inherit (pkgs.lib) evalModules getExe recursiveUpdate;
|
2024-11-11 16:29:36 +01:00
|
|
|
|
2024-11-11 17:18:38 +01:00
|
|
|
inherit (pkgs.lib.fileset) gitTracked toSource;
|
|
|
|
|
2024-11-11 16:29:36 +01:00
|
|
|
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" ];
|
|
|
|
};
|
|
|
|
|
2024-12-26 20:51:08 +01:00
|
|
|
reuse = {
|
|
|
|
enable = true;
|
|
|
|
stages = [ "pre-push" ];
|
|
|
|
package = pkgs.reuse;
|
|
|
|
};
|
|
|
|
|
2024-12-30 12:16:00 +01:00
|
|
|
actions-validator = workflows.gitHook { stages = [ "pre-push" ]; };
|
|
|
|
|
2024-11-11 16:29:36 +01:00
|
|
|
commitizen.enable = true;
|
|
|
|
};
|
|
|
|
};
|
2024-12-26 20:51:08 +01:00
|
|
|
|
|
|
|
reuse = (import sources.nix-reuse { inherit pkgs; }).install {
|
|
|
|
defaultCopyright = "Tom Hubrecht <tom.hubrecht@dgnum.eu>";
|
|
|
|
defaultLicense = "EUPL-1.2";
|
|
|
|
|
|
|
|
downloadLicenses = true;
|
|
|
|
|
|
|
|
generatedPaths = [
|
|
|
|
".envrc"
|
2024-12-30 12:16:26 +01:00
|
|
|
".forgejo/workflows/*.yaml"
|
2024-12-26 20:51:08 +01:00
|
|
|
".gitignore"
|
|
|
|
"shell.nix"
|
|
|
|
];
|
|
|
|
|
|
|
|
annotations = [
|
|
|
|
# npins generated files
|
|
|
|
{
|
|
|
|
path = "**/npins/*";
|
|
|
|
license = "EUPL-1.2";
|
|
|
|
copyright = "The [npins](https://github.com/andir/npins) contributors";
|
|
|
|
}
|
|
|
|
];
|
|
|
|
};
|
2024-11-11 16:29:36 +01:00
|
|
|
|
|
|
|
install =
|
2024-11-11 17:18:38 +01:00
|
|
|
{ src, ... }@config:
|
2024-11-11 16:29:36 +01:00
|
|
|
let
|
2024-12-30 12:16:26 +01:00
|
|
|
project = evalModules {
|
2024-11-11 16:29:36 +01:00
|
|
|
modules = [
|
|
|
|
./modules
|
|
|
|
{
|
2024-11-11 17:18:38 +01:00
|
|
|
config = (removeAttrs config [ "src" ]) // {
|
2024-11-11 16:29:36 +01:00
|
|
|
_module.args.pkgs = pkgs;
|
2024-11-11 17:18:38 +01:00
|
|
|
rootSrc = toSource {
|
|
|
|
root = src;
|
|
|
|
fileset = gitTracked src;
|
|
|
|
};
|
2024-11-11 16:29:36 +01:00
|
|
|
};
|
|
|
|
}
|
|
|
|
];
|
|
|
|
};
|
|
|
|
in
|
|
|
|
{
|
|
|
|
shellHook = project.config.installationScript;
|
2024-12-30 12:16:00 +01:00
|
|
|
gitHook = recursiveUpdate {
|
|
|
|
enable = true;
|
|
|
|
name = "Actions validator";
|
|
|
|
entry = getExe pkgs.action-validator;
|
|
|
|
files = "\\.${project.config.platform}/workflows/.*\\.ya?ml";
|
|
|
|
};
|
2024-11-11 16:29:36 +01:00
|
|
|
};
|
2024-11-19 15:56:20 +01:00
|
|
|
|
2024-12-30 12:16:26 +01:00
|
|
|
workflows = install {
|
|
|
|
src = ./.;
|
|
|
|
|
|
|
|
buildCheck = false;
|
|
|
|
|
|
|
|
workflows.pre-commit = {
|
|
|
|
name = "Run pre-commit on all files";
|
|
|
|
on = [
|
|
|
|
"pull_request"
|
|
|
|
"push"
|
|
|
|
];
|
|
|
|
|
|
|
|
jobs.pre-push = {
|
|
|
|
runs-on = "nix";
|
|
|
|
steps = [
|
2025-02-04 10:02:44 +01:00
|
|
|
(lib.steps.checkout { })
|
2024-12-30 12:16:26 +01:00
|
|
|
{
|
|
|
|
name = "Run pre-commit on all files";
|
2025-02-04 10:02:44 +01:00
|
|
|
run = lib.nix-shell {
|
|
|
|
shell = "pre-commit";
|
|
|
|
script = "pre-commit run --all-files --hook-stage pre-push --show-diff-on-failure";
|
|
|
|
};
|
2024-12-30 12:16:26 +01:00
|
|
|
}
|
|
|
|
];
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
2025-02-04 09:58:58 +01:00
|
|
|
|
|
|
|
lib = import ./lib { inherit (pkgs) lib; };
|
2024-12-30 12:16:26 +01:00
|
|
|
in
|
|
|
|
|
|
|
|
{
|
|
|
|
devShell = mkShell {
|
|
|
|
name = "nix-actions.dev";
|
|
|
|
|
|
|
|
packages = git-checks.enabledPackages;
|
|
|
|
|
|
|
|
shellHook = builtins.concatStringsSep "\n" [
|
|
|
|
git-checks.shellHook
|
|
|
|
reuse.shellHook
|
|
|
|
workflows.shellHook
|
|
|
|
];
|
|
|
|
|
|
|
|
passthru.pre-commit = mkShell {
|
|
|
|
name = "pre-commit";
|
|
|
|
inherit (git-checks) shellHook;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2025-02-04 09:58:58 +01:00
|
|
|
inherit lib install;
|
2024-11-11 16:29:36 +01:00
|
|
|
}
|