forked from extern/flakelight
6d00e0f544
This allows a configuration to be set as a function that will be passed autoloadArgs. This is useful when each configuration is in its own file when autoloading.
37 lines
1.1 KiB
Nix
37 lines
1.1 KiB
Nix
# flakelight -- Framework for simplifying flake setup
|
|
# Copyright (C) 2023 Archit Gupta <archit@accelbread.com>
|
|
# SPDX-License-Identifier: MIT
|
|
|
|
{ config, lib, flakelight, autoloadArgs, ... }:
|
|
let
|
|
inherit (builtins) isAttrs mapAttrs;
|
|
inherit (lib) foldl mapAttrsToList mergeOneOption mkOption mkOptionType mkIf
|
|
recursiveUpdate;
|
|
inherit (lib.types) lazyAttrsOf;
|
|
inherit (flakelight.types) optFunctionTo;
|
|
|
|
homeConfiguration = mkOptionType {
|
|
name = "homeConfiguration";
|
|
description = "homeConfiguration";
|
|
descriptionClass = "noun";
|
|
check = x: isAttrs x && x ? activationPackage;
|
|
merge = mergeOneOption;
|
|
};
|
|
in
|
|
{
|
|
options.homeConfigurations = mkOption {
|
|
type = lazyAttrsOf (optFunctionTo homeConfiguration);
|
|
default = { };
|
|
};
|
|
|
|
config.outputs = mkIf (config.homeConfigurations != { }) {
|
|
homeConfigurations = mapAttrs (_: f: f autoloadArgs)
|
|
config.homeConfigurations;
|
|
checks = foldl recursiveUpdate { } (mapAttrsToList
|
|
(n: v: {
|
|
${v.config.nixpkgs.system}."home-${n}" = v.activationPackage;
|
|
})
|
|
(mapAttrs (_: f: f autoloadArgs) config.homeConfigurations));
|
|
};
|
|
}
|