2024-07-29 00:35:14 +02:00
|
|
|
{ lib, config, self, inputs, ... }:
|
|
|
|
|
|
|
|
let
|
2024-07-29 01:11:32 +02:00
|
|
|
inherit (config.lib)
|
2024-08-04 01:52:04 +02:00
|
|
|
createThings;
|
2024-07-29 00:35:14 +02:00
|
|
|
in
|
|
|
|
let
|
2024-08-04 01:52:04 +02:00
|
|
|
createPackages = baseDir:
|
|
|
|
createThings {
|
|
|
|
inherit baseDir;
|
|
|
|
thingType = "package";
|
|
|
|
raw = false;
|
|
|
|
extras.systems = {
|
|
|
|
default = lib.const true;
|
|
|
|
};
|
|
|
|
};
|
2024-07-29 00:35:14 +02:00
|
|
|
in
|
|
|
|
{
|
|
|
|
options = let
|
|
|
|
inherit (lib) types;
|
|
|
|
in {
|
|
|
|
flake.autoPackages = lib.mkOption {
|
|
|
|
description = ''
|
|
|
|
Automagically generate packages from walking directories with Nix files
|
|
|
|
'';
|
|
|
|
type = types.submodule (submodule: {
|
|
|
|
options = {
|
|
|
|
enable = lib.mkEnableOption "Automatic packages extraction";
|
|
|
|
dir = lib.mkOption {
|
|
|
|
description = ''
|
|
|
|
Base directory of the contained packages
|
|
|
|
'';
|
|
|
|
type = types.path;
|
|
|
|
default = "${self}/pkgs";
|
|
|
|
defaultText = ''''${self}/pkgs'';
|
|
|
|
};
|
|
|
|
result = lib.mkOption {
|
|
|
|
description = ''
|
|
|
|
The resulting automatic packages
|
|
|
|
'';
|
|
|
|
type = types.attrsOf (types.submodule { options = {
|
|
|
|
package = lib.mkOption { type = types.unspecified; };
|
|
|
|
systems = lib.mkOption { type = types.functionTo types.bool; };
|
|
|
|
};});
|
|
|
|
readOnly = true;
|
|
|
|
internal = true;
|
|
|
|
default =
|
|
|
|
lib.optionalAttrs
|
|
|
|
config.flake.autoPackages.enable
|
2024-08-04 01:52:04 +02:00
|
|
|
(createPackages config.flake.autoPackages.dir);
|
2024-07-29 00:35:14 +02:00
|
|
|
};
|
|
|
|
};
|
|
|
|
});
|
|
|
|
default = {};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
config = {
|
|
|
|
perSystem = { lib, pkgs, system, ... }: let
|
|
|
|
packages =
|
|
|
|
lib.pipe
|
|
|
|
config.flake.autoPackages.result
|
|
|
|
[
|
|
|
|
(lib.filterAttrs
|
|
|
|
(name: { package, systems }:
|
|
|
|
pkgs.callPackage systems {
|
|
|
|
inherit (pkgs) lib hostPlatform targetPlatform;
|
|
|
|
}))
|
2024-08-02 09:30:48 +02:00
|
|
|
(lib.mapAttrs
|
|
|
|
(name: { package, systems }:
|
|
|
|
let
|
|
|
|
isDream2Nix = lib.pipe package
|
|
|
|
[
|
|
|
|
builtins.functionArgs
|
|
|
|
builtins.attrNames
|
|
|
|
(builtins.elem "dream2nix")
|
|
|
|
];
|
|
|
|
in
|
|
|
|
if isDream2Nix
|
|
|
|
then inputs.dream2nix.lib.evalModules {
|
|
|
|
packageSets.nixpkgs = pkgs;
|
|
|
|
modules = [
|
|
|
|
package
|
|
|
|
{
|
|
|
|
paths.projectRoot = "${self.outPath}";
|
|
|
|
paths.projectRootFile = "flake.nix";
|
|
|
|
paths.package = "${self.outPath}";
|
|
|
|
}
|
|
|
|
];
|
|
|
|
specialArgs = {
|
|
|
|
# NOTE: for overlayed `maintainers`
|
|
|
|
inherit (pkgs) lib;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
else pkgs.callPackage package { }))
|
2024-07-29 00:35:14 +02:00
|
|
|
];
|
|
|
|
in {
|
|
|
|
inherit packages;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|