summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorseth <[email protected]>2024-11-05 10:43:59 -0500
committerGitHub <[email protected]>2024-11-05 15:43:59 +0000
commit459cbfa0da30ee118a95c61ccad781464011a488 (patch)
tree83123be011d6a8237c54453ad49cbc1c38f7b7b7
parent5bda16aba3c448ba9fd25f3dae81909b3ed5bbe1 (diff)
flake-parts/checks: init module (#122)
-rw-r--r--flake.nix8
-rw-r--r--modules/flake/checks.nix66
2 files changed, 74 insertions, 0 deletions
diff --git a/flake.nix b/flake.nix
index 0e67260..7bb62bd 100644
--- a/flake.nix
+++ b/flake.nix
@@ -70,6 +70,14 @@
);
flakeModules = {
+ checks = mkModule {
+ name = "checks";
+ type = "flake";
+ imports = [ ./modules/flake/checks.nix ];
+ key = "${self.outPath}/flake.nix#flakeModules.checks";
+ _class = "flake";
+ };
+
configs = mkModule {
name = "configs";
type = "flake";
diff --git a/modules/flake/checks.nix b/modules/flake/checks.nix
new file mode 100644
index 0000000..63a85fe
--- /dev/null
+++ b/modules/flake/checks.nix
@@ -0,0 +1,66 @@
+{ flake-parts-lib, ... }:
+{
+ options = {
+ perSystem = flake-parts-lib.mkPerSystemOption (
+ {
+ config,
+ lib,
+ pkgs,
+ ...
+ }:
+ let
+ namespace = "quickChecks";
+ cfg = config.${namespace};
+
+ checkSubmodule =
+ { config, name, ... }:
+ {
+ options = {
+ name = lib.mkOption {
+ type = lib.types.str;
+ default = "check-" + name;
+ description = "Name of the derivation used for the script.";
+ };
+
+ dependencies = lib.mkOption {
+ type = lib.types.listOf lib.types.package;
+ default = [ ];
+ description = "Packages used in the script.";
+ };
+
+ script = lib.mkOption {
+ type = lib.types.lines;
+ description = "Script to run as the check.";
+ };
+
+ package = lib.mkOption {
+ type = lib.types.package;
+ readOnly = true;
+ description = "Package that runs the check.";
+ };
+ };
+
+ config = {
+ package = pkgs.runCommand config.name { nativeBuildInputs = config.dependencies; } (
+ lib.concatLines [
+ config.script
+ "touch $out"
+ ]
+ );
+ };
+ };
+ in
+ {
+ options.${namespace} = lib.mkOption {
+ type = lib.types.attrsOf (lib.types.submodule checkSubmodule);
+ default = { };
+ description = "An attribute set of check scripts.";
+ };
+
+ config = {
+ checks = lib.mapAttrs (lib.const (lib.getAttr "package")) cfg;
+ };
+ }
+ );
+ };
+}