2024-08-05 00:12:54 +02:00
|
|
|
{ lib, config, self, inputs, ... }:
|
|
|
|
|
|
|
|
{
|
2024-09-07 19:49:14 +02:00
|
|
|
imports = [
|
|
|
|
../lib
|
|
|
|
];
|
|
|
|
|
2024-08-05 00:12:54 +02:00
|
|
|
options = let
|
2024-09-07 19:49:14 +02:00
|
|
|
inherit (lib)
|
|
|
|
types
|
|
|
|
;
|
|
|
|
inherit (config.lib)
|
|
|
|
createThings
|
|
|
|
;
|
|
|
|
|
|
|
|
createDevShells = baseDir:
|
|
|
|
createThings {
|
|
|
|
inherit baseDir;
|
|
|
|
thingType = "devShell";
|
|
|
|
raw = false;
|
|
|
|
extras.systems = {
|
|
|
|
default = lib.const true;
|
|
|
|
};
|
|
|
|
};
|
2024-08-05 00:12:54 +02:00
|
|
|
in {
|
2024-09-01 03:29:32 +02:00
|
|
|
auto.devShells = lib.mkOption {
|
2024-08-05 00:12:54 +02:00
|
|
|
description = ''
|
|
|
|
Automagically generate devShells from walking directories with Nix files
|
|
|
|
'';
|
|
|
|
type = types.submodule (submodule: {
|
|
|
|
options = {
|
|
|
|
enable = lib.mkEnableOption "Automatic devShells extraction";
|
|
|
|
dir = lib.mkOption {
|
|
|
|
description = ''
|
|
|
|
Base directory of the contained devShells
|
|
|
|
'';
|
|
|
|
type = types.path;
|
|
|
|
default = "${self}/shells";
|
|
|
|
defaultText = ''''${self}/shells'';
|
|
|
|
};
|
|
|
|
result = lib.mkOption {
|
|
|
|
description = ''
|
|
|
|
The resulting automatic devShells
|
|
|
|
'';
|
|
|
|
type = types.attrsOf (types.submodule { options = {
|
|
|
|
devShell = lib.mkOption { type = types.unspecified; };
|
|
|
|
systems = lib.mkOption { type = types.functionTo types.bool; };
|
|
|
|
};});
|
|
|
|
readOnly = true;
|
|
|
|
internal = true;
|
|
|
|
default =
|
|
|
|
lib.optionalAttrs
|
2024-09-01 03:29:32 +02:00
|
|
|
config.auto.devShells.enable
|
|
|
|
(createDevShells config.auto.devShells.dir);
|
2024-08-05 00:12:54 +02:00
|
|
|
};
|
|
|
|
};
|
|
|
|
});
|
|
|
|
default = {};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
config = {
|
|
|
|
perSystem = { lib, pkgs, system, ... }: let
|
|
|
|
devShells =
|
|
|
|
lib.pipe
|
2024-09-01 03:29:32 +02:00
|
|
|
config.auto.devShells.result
|
2024-08-05 00:12:54 +02:00
|
|
|
[
|
|
|
|
(lib.filterAttrs
|
|
|
|
(name: { devShell, systems }:
|
|
|
|
pkgs.callPackage systems {
|
|
|
|
inherit (pkgs) lib hostPlatform targetPlatform;
|
|
|
|
}))
|
|
|
|
(lib.mapAttrs
|
|
|
|
(name: { devShell, systems }:
|
|
|
|
pkgs.callPackage devShell { inherit inputs; }))
|
|
|
|
];
|
|
|
|
in {
|
|
|
|
inherit devShells;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|