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
|
|
|
|
|
2024-01-15 09:07:59 +01:00
|
|
|
{ config, options, src, lib, flakelight, ... }:
|
2023-08-25 06:14:55 +02:00
|
|
|
let
|
2024-01-15 09:07:59 +01:00
|
|
|
inherit (builtins) attrNames;
|
|
|
|
inherit (lib) genAttrs mkIf mkOption subtractLists;
|
|
|
|
inherit (lib.types) attrsOf listOf str;
|
|
|
|
inherit (flakelight) autoImport;
|
2023-08-27 07:48:57 +02:00
|
|
|
inherit (flakelight.types) path;
|
2023-08-25 06:14:55 +02:00
|
|
|
in
|
|
|
|
{
|
2024-01-15 09:07:59 +01:00
|
|
|
options = {
|
|
|
|
nixDir = mkOption {
|
|
|
|
type = path;
|
|
|
|
default = src + /nix;
|
|
|
|
};
|
|
|
|
|
|
|
|
nixDirAliases = mkOption {
|
|
|
|
type = attrsOf (listOf str);
|
|
|
|
default = { };
|
|
|
|
};
|
2023-08-25 06:14:55 +02:00
|
|
|
};
|
|
|
|
|
2024-01-15 09:07:59 +01:00
|
|
|
config = genAttrs (subtractLists [ "_module" "nixDir" ] (attrNames options))
|
|
|
|
(name:
|
|
|
|
let
|
|
|
|
internal = options.${name}.internal or false;
|
|
|
|
val = autoImport config.nixDir
|
|
|
|
(if name == "nixDirAliases" then name else
|
|
|
|
([ name ] ++ config.nixDirAliases.${name} or [ ]));
|
|
|
|
cond = !internal && (val != null);
|
|
|
|
in
|
|
|
|
mkIf cond (if cond then val else { }));
|
2023-08-25 06:14:55 +02:00
|
|
|
}
|