diff --git a/all-modules.nix b/all-modules.nix
index 03439a0..42bfdf2 100644
--- a/all-modules.nix
+++ b/all-modules.nix
@@ -15,6 +15,7 @@
./modules/overlays.nix
./modules/packages.nix
./modules/perSystem.nix
+ ./modules/transposition.nix
./modules/withSystem.nix
];
}
diff --git a/modules/apps.nix b/modules/apps.nix
index 7e92fef..e411fd6 100644
--- a/modules/apps.nix
+++ b/modules/apps.nix
@@ -81,15 +81,6 @@ in
};
config = {
- flake.apps =
- mapAttrs
- (k: v: v.apps)
- config.allSystems;
-
- perInput = system: flake:
- optionalAttrs (flake?apps.${system}) {
- apps = flake.apps.${system};
- };
-
+ transposition.apps = { };
};
}
diff --git a/modules/checks.nix b/modules/checks.nix
index de515e8..4fbb0af 100644
--- a/modules/checks.nix
+++ b/modules/checks.nix
@@ -39,15 +39,6 @@ in
};
config = {
- flake.checks =
- mapAttrs
- (k: v: v.checks)
- config.allSystems;
-
- perInput = system: flake:
- optionalAttrs (flake?checks.${system}) {
- checks = flake.checks.${system};
- };
-
+ transposition.checks = { };
};
}
diff --git a/modules/devShells.nix b/modules/devShells.nix
index 7cbcc12..ecc53b3 100644
--- a/modules/devShells.nix
+++ b/modules/devShells.nix
@@ -40,14 +40,6 @@ in
});
};
config = {
- flake.devShells =
- mapAttrs
- (k: v: v.devShells)
- config.allSystems;
-
- perInput = system: flake:
- optionalAttrs (flake?devShells.${system}) {
- devShells = flake.devShells.${system};
- };
+ transposition.devShells = { };
};
}
diff --git a/modules/legacyPackages.nix b/modules/legacyPackages.nix
index 69d1baf..eedc075 100644
--- a/modules/legacyPackages.nix
+++ b/modules/legacyPackages.nix
@@ -38,15 +38,6 @@ in
};
config = {
- flake.legacyPackages =
- mapAttrs
- (k: v: v.legacyPackages)
- config.allSystems;
-
- perInput = system: flake:
- optionalAttrs (flake?legacyPackages.${system}) {
- legacyPackages = flake.legacyPackages.${system};
- };
-
+ transposition.legacyPackages = { };
};
}
diff --git a/modules/packages.nix b/modules/packages.nix
index 3c06d0b..05fea46 100644
--- a/modules/packages.nix
+++ b/modules/packages.nix
@@ -40,15 +40,6 @@ in
});
};
config = {
- flake.packages =
- mapAttrs
- (k: v: v.packages)
- config.allSystems;
-
- perInput = system: flake:
- optionalAttrs (flake?packages.${system}) {
- packages = flake.packages.${system};
- };
-
+ transposition.packages = { };
};
}
diff --git a/modules/transposition.nix b/modules/transposition.nix
new file mode 100644
index 0000000..d030857
--- /dev/null
+++ b/modules/transposition.nix
@@ -0,0 +1,56 @@
+{ config, lib, flake-parts-lib, ... }:
+
+let
+ inherit (lib)
+ filterAttrs
+ mapAttrs
+ mkOption
+ types
+ ;
+ inherit (flake-parts-lib)
+ mkSubmoduleOptions
+ mkPerSystemOption
+ ;
+in
+{
+ options = {
+ transposition = lib.mkOption {
+ description = ''
+ A helper that defines transposed attributes in the flake outputs.
+
+ Transposition is the operation that swaps the indices of a data structure.
+ Here it refers specifically to the transposition between
+
+
+ perSystem: .''${system}.''${attribute}
+ outputs: .''${attribute}.''${system}
+
+
+ It also defines the reverse operation in .
+ '';
+ type =
+ types.lazyAttrsOf
+ (types.submoduleWith { modules = [ ]; });
+ };
+ };
+
+ config = {
+ flake =
+ lib.mapAttrs
+ (attrName: attrConfig:
+ mapAttrs
+ (system: v: v.${attrName})
+ config.allSystems
+ )
+ config.transposition;
+
+ perInput =
+ system: flake:
+ mapAttrs
+ (attrName: attrConfig: flake.${attrName}.${system})
+ (filterAttrs
+ (attrName: attrConfig: flake?${attrName}.${system})
+ config.transposition
+ );
+ };
+}