This repository has been archived by the owner on Sep 6, 2024. It is now read-only.
forked from hercules-ci/flake-parts
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request hercules-ci#130 from hercules-ci/flakeModule
Flake module
- Loading branch information
Showing
6 changed files
with
245 additions
and
84 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
/* | ||
A module to import into flakes based on flake-parts. | ||
Makes integration into a flake easy and tidy. | ||
See https://flake.parts | ||
*/ | ||
|
||
{ lib, self, flake-parts-lib, ... }: | ||
let | ||
inherit (lib) | ||
mkOption | ||
types | ||
; | ||
in | ||
{ | ||
options = { | ||
perSystem = flake-parts-lib.mkPerSystemOption ({ config, pkgs, ... }: | ||
let cfg = config.pre-commit; | ||
in | ||
{ | ||
options = { | ||
pre-commit = { | ||
check.enable = mkOption { | ||
description = lib.mdDoc '' | ||
Whether to add a derivation to the flake `checks`. | ||
It will perform the pre-commit checks in `nix flake check`. | ||
You can disable this if one of your hooks do not run properly in | ||
the Nix sandbox; for example because it needs network access. | ||
''; | ||
type = types.bool; | ||
default = true; | ||
}; | ||
pkgs = mkOption { | ||
type = types.uniq (types.lazyAttrsOf (types.raw or types.unspecified)); | ||
description = lib.mdDoc '' | ||
Nixpkgs to use in the pre-commit [`settings`](#opt-perSystem.pre-commit.settings). | ||
''; | ||
default = pkgs; | ||
defaultText = lib.literalDocBook "<literal>pkgs</literal> (module argument)"; | ||
}; | ||
settings = mkOption { | ||
type = types.submoduleWith { | ||
modules = [ ./modules/all-modules.nix ]; | ||
specialArgs = { inherit (cfg) pkgs; }; | ||
}; | ||
default = { }; | ||
description = lib.mdDoc '' | ||
The pre-commit-hooks.nix configuration. | ||
''; | ||
}; | ||
installationScript = mkOption { | ||
type = types.str; | ||
description = lib.mdDoc "A bash fragment that sets up [pre-commit](https://pre-commit.com/)."; | ||
default = cfg.settings.installationScript; | ||
defaultText = lib.literalDocBook "bash statements"; | ||
readOnly = true; | ||
}; | ||
}; | ||
}; | ||
config = { | ||
checks = lib.optionalAttrs cfg.check.enable { pre-commit = cfg.settings.run; }; | ||
pre-commit.settings = { pkgs, ... }: { | ||
rootSrc = self.outPath; | ||
package = lib.mkDefault pkgs.pre-commit; | ||
tools = import ./nix/call-tools.nix pkgs; | ||
}; | ||
}; | ||
}); | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.