2023-08-27 07:48:57 +02:00
|
|
|
# flakelight -- Framework for simplifying flake setup
|
2023-08-25 06:14:55 +02:00
|
|
|
# Copyright (C) 2023 Archit Gupta <archit@accelbread.com>
|
|
|
|
# SPDX-License-Identifier: MIT
|
|
|
|
|
2023-10-24 05:21:36 +02:00
|
|
|
{ config, lib, flakelight, autoloadArgs, ... }:
|
2023-08-25 06:14:55 +02:00
|
|
|
let
|
2023-10-24 05:21:36 +02:00
|
|
|
inherit (builtins) isAttrs mapAttrs;
|
2023-08-25 06:14:55 +02:00
|
|
|
inherit (lib) foldl mapAttrsToList mergeOneOption mkIf mkOption mkOptionType
|
|
|
|
recursiveUpdate;
|
|
|
|
inherit (lib.types) lazyAttrsOf;
|
2023-10-24 05:21:36 +02:00
|
|
|
inherit (flakelight.types) optFunctionTo;
|
2023-08-25 06:14:55 +02:00
|
|
|
|
|
|
|
nixosConfiguration = mkOptionType {
|
|
|
|
name = "nixosConfiguration";
|
|
|
|
description = "nixosConfiguration";
|
|
|
|
descriptionClass = "noun";
|
|
|
|
check = x: isAttrs x
|
|
|
|
&& x ? config.nixpkgs.system
|
|
|
|
&& x ? config.system.build.toplevel;
|
|
|
|
merge = mergeOneOption;
|
|
|
|
};
|
|
|
|
in
|
|
|
|
{
|
|
|
|
options.nixosConfigurations = mkOption {
|
2023-10-24 05:21:36 +02:00
|
|
|
type = lazyAttrsOf (optFunctionTo nixosConfiguration);
|
2023-08-25 06:14:55 +02:00
|
|
|
default = { };
|
|
|
|
};
|
|
|
|
|
|
|
|
config.outputs = mkIf (config.nixosConfigurations != { }) {
|
2023-10-24 05:21:36 +02:00
|
|
|
nixosConfigurations = mapAttrs (_: f: f autoloadArgs)
|
|
|
|
config.nixosConfigurations;
|
2023-08-25 06:14:55 +02:00
|
|
|
checks = foldl recursiveUpdate { } (mapAttrsToList
|
|
|
|
(n: v: {
|
|
|
|
${v.config.nixpkgs.system}."nixos-${n}" =
|
|
|
|
v.config.system.build.toplevel;
|
|
|
|
})
|
2023-10-24 05:21:36 +02:00
|
|
|
(mapAttrs (_: f: f autoloadArgs) config.nixosConfigurations));
|
2023-08-25 06:14:55 +02:00
|
|
|
};
|
|
|
|
}
|