summaryrefslogtreecommitdiff
path: root/flake/ci.nix
diff options
context:
space:
mode:
Diffstat (limited to 'flake/ci.nix')
-rw-r--r--flake/ci.nix142
1 files changed, 63 insertions, 79 deletions
diff --git a/flake/ci.nix b/flake/ci.nix
index 30cbd06..79c3828 100644
--- a/flake/ci.nix
+++ b/flake/ci.nix
@@ -1,97 +1,81 @@
-{
- config,
- lib,
- withSystem,
- self,
- ...
-}:
+{ self, ... }:
{
perSystem =
- { config, pkgs, ... }:
-
{
- quickChecks = {
- actionlint = {
- dependencies = [ pkgs.actionlint ];
- script = "actionlint ${self}/.github/workflows/**";
- };
-
- deadnix = {
- dependencies = [ pkgs.deadnix ];
- script = "deadnix --fail ${self}";
- };
-
- hclfmt = {
- dependencies = [ pkgs.hclfmt ];
- script = "hclfmt -require-no-change ${self}/terraform/*.tf";
- };
+ config,
+ lib,
+ pkgs,
+ self',
+ system,
+ ...
+ }:
- just = {
- dependencies = [ pkgs.just ];
- script = ''
- cd ${self}
- just --check --fmt --unstable
- just --summary
- '';
- };
+ let
+ collectNestedDerivations = self.lib.collectNestedDerivationsFor system;
+ in
- nixfmt = {
- dependencies = [ pkgs.nixfmt-rfc-style ];
- script = "nixfmt --check ${self}/**/*.nix";
+ lib.mkMerge [
+ {
+ checks = collectNestedDerivations {
+ inherit (self)
+ nixosConfigurations
+ homeConfigurations
+ darwinConfigurations
+ ;
};
- statix = {
- dependencies = [ pkgs.statix ];
- script = "statix check ${self}";
+ legacyPackages = {
+ tflint = config.quickChecks.tflint.package;
};
+ }
- tflint = {
- dependencies = [ pkgs.tflint ];
- script = ''
- tflint --chdir=${self}/terraform --format=sarif |& tee $out || true
- '';
- };
- };
+ # I don't really care to run these on other systems
+ (lib.mkIf (system == "x86_64-linux") {
+ checks = collectNestedDerivations { inherit (self') devShells; };
- legacyPackages = {
- tflint = config.quickChecks.tflint.package;
- };
- };
+ quickChecks = {
+ actionlint = {
+ dependencies = [ pkgs.actionlint ];
+ script = "actionlint ${self}/.github/workflows/**";
+ };
- flake.hydraJobs =
+ deadnix = {
+ dependencies = [ pkgs.deadnix ];
+ script = "deadnix --fail ${self}";
+ };
- let
- # Architecture of "main" CI machine
- ciSystem = "x86_64-linux";
+ hclfmt = {
+ dependencies = [ pkgs.hclfmt ];
+ script = "hclfmt -require-no-change ${self}/terraform/*.tf";
+ };
- derivFromCfg = deriv: deriv.config.system.build.toplevel or deriv.activationPackage;
- mapCfgsToDerivs = lib.mapAttrs (lib.const derivFromCfg);
- in
+ just = {
+ dependencies = [ pkgs.just ];
+ script = ''
+ cd ${self}
+ just --check --fmt --unstable
+ just --summary
+ '';
+ };
- lib.genAttrs config.systems (
- lib.flip withSystem (
- {
- system,
- self',
- ...
- }:
+ nixfmt = {
+ dependencies = [ pkgs.nixfmt-rfc-style ];
+ script = "nixfmt --check ${self}/**/*.nix";
+ };
- let
- mapCfgsForSystem =
- cfgs: lib.filterAttrs (lib.const (deriv: deriv.system == system)) (mapCfgsToDerivs cfgs);
- in
+ statix = {
+ dependencies = [ pkgs.statix ];
+ script = "statix check ${self}";
+ };
- {
- darwinConfigurations = mapCfgsForSystem self.darwinConfigurations;
- homeConfigurations = mapCfgsForSystem self.homeConfigurations;
- nixosConfigurations = mapCfgsForSystem self.nixosConfigurations;
- }
- # I don't care to run these for each system, as they should be the same
- # and don't need to be cached
- // lib.optionalAttrs (system == ciSystem) {
- inherit (self') checks devShells;
- }
- )
- );
+ tflint = {
+ dependencies = [ pkgs.tflint ];
+ script = ''
+ tflint --chdir=${self}/terraform --format=sarif |& tee $out || true
+ '';
+ };
+ };
+ })
+ ];
}