nixos-config/modules/flake-parts/devcontainers.nix

41 lines
1.1 KiB
Nix
Raw Normal View History

2024-10-26 10:35:21 +00:00
{ config, lib, flake-parts-lib, ... }:
let inherit (flake-parts-lib) mkSubmoduleOptions mkPerSystemOption;
in {
options = {
flake = mkSubmoduleOptions {
devContainers = lib.mkOption {
type = with lib.types; lazyAttrsOf (attrsOf package);
default = { };
description = ''
An attribute set of per-system packages intended to be consumed for
development environments.
'';
};
};
perSystem = mkPerSystemOption {
options = {
devContainers = lib.mkOption {
type = with lib.types; attrsOf package;
default = { };
description = ''
An attribute set of per-system packages intended to be consumed for
development environments.
'';
};
};
};
};
config = {
flake.devContainers = lib.mapAttrs (k: v: v.devContainers)
(lib.filterAttrs (k: v: v.devContainers != { }) config.allSystems);
perInput = system: flake:
lib.optionalAttrs (flake ? devContainers.${system}) {
devContainers = flake.devContainers.${system};
};
};
}