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-08-27 07:48:57 +02:00
|
|
|
{ config, src, lib, flakelight, ... }@args:
|
2023-08-25 06:14:55 +02:00
|
|
|
let
|
2023-08-27 09:01:48 +02:00
|
|
|
inherit (lib) mkOption mkIf mkMerge optionalAttrs;
|
|
|
|
inherit (flakelight) autoImport autoImportArgs;
|
2023-08-27 07:48:57 +02:00
|
|
|
inherit (flakelight.types) path;
|
2023-08-25 06:14:55 +02:00
|
|
|
in
|
|
|
|
{
|
|
|
|
options.nixDir = mkOption {
|
|
|
|
type = path;
|
|
|
|
default = src + /nix;
|
|
|
|
};
|
|
|
|
|
|
|
|
config =
|
|
|
|
let
|
|
|
|
autoImport' = autoImport config.nixDir;
|
2023-08-27 09:01:48 +02:00
|
|
|
autoImportArgs' = autoImportArgs config.nixDir args;
|
|
|
|
outputs = autoImportArgs' "outputs";
|
2023-08-25 06:14:55 +02:00
|
|
|
perSystem = autoImport' "perSystem";
|
|
|
|
withOverlays = autoImport' "withOverlays";
|
|
|
|
package = autoImport' "package";
|
2023-08-27 09:01:48 +02:00
|
|
|
packages = autoImportArgs' "packages";
|
|
|
|
overlays = autoImportArgs' "overlays";
|
|
|
|
devShell = autoImportArgs' "devShell";
|
|
|
|
devShells = autoImportArgs' "devShells";
|
2023-08-25 06:14:55 +02:00
|
|
|
app = autoImport' "app";
|
|
|
|
apps = autoImport' "apps";
|
|
|
|
checks = autoImport' "checks";
|
|
|
|
nixosModule = autoImport' "nixosModule";
|
2023-08-27 09:01:48 +02:00
|
|
|
nixosModules = autoImportArgs' "nixosModules";
|
|
|
|
nixosConfigurations = autoImportArgs' [ "nixosConfigurations" "nixos" ];
|
2023-08-25 06:14:55 +02:00
|
|
|
homeModule = autoImport' "homeModule";
|
2023-08-27 09:01:48 +02:00
|
|
|
homeModules = autoImportArgs' "homeModules";
|
|
|
|
homeConfigurations = autoImportArgs' [ "homeConfigurations" "home" ];
|
|
|
|
template = autoImportArgs' "template";
|
|
|
|
templates = autoImportArgs' "templates";
|
2023-08-25 06:14:55 +02:00
|
|
|
formatters = autoImport' "formatters";
|
|
|
|
in
|
|
|
|
mkMerge [
|
|
|
|
(mkIf (outputs != null) { inherit outputs; })
|
|
|
|
(mkIf (perSystem != null) { inherit perSystem; })
|
|
|
|
(mkIf (withOverlays != null) { inherit withOverlays; })
|
|
|
|
(mkIf (package != null) { inherit package; })
|
|
|
|
(mkIf (packages != null) { inherit packages; })
|
|
|
|
(mkIf (overlays != null) { inherit overlays; })
|
|
|
|
(mkIf (devShell != null) {
|
|
|
|
devShell = optionalAttrs (devShell ? inputsFrom)
|
|
|
|
{ inherit (devShell) inputsFrom; }
|
|
|
|
// optionalAttrs (devShell ? packages)
|
|
|
|
{ inherit (devShell) packages; }
|
|
|
|
// optionalAttrs (devShell ? shellHook)
|
|
|
|
{ inherit (devShell) shellHook; }
|
|
|
|
// optionalAttrs (devShell ? env)
|
|
|
|
{ inherit (devShell) env; };
|
|
|
|
})
|
|
|
|
(mkIf (devShells != null) { inherit devShells; })
|
|
|
|
(mkIf (app != null) { inherit app; })
|
|
|
|
(mkIf (apps != null) { inherit apps; })
|
|
|
|
(mkIf (checks != null) { inherit checks; })
|
|
|
|
(mkIf (nixosModule != null) { inherit nixosModule; })
|
|
|
|
(mkIf (nixosModules != null) { inherit nixosModules; })
|
|
|
|
(mkIf (nixosConfigurations != null) { inherit nixosConfigurations; })
|
|
|
|
(mkIf (homeModule != null) { inherit homeModule; })
|
|
|
|
(mkIf (homeModules != null) { inherit homeModules; })
|
|
|
|
(mkIf (homeConfigurations != null) { inherit homeConfigurations; })
|
|
|
|
(mkIf (template != null) { inherit template; })
|
|
|
|
(mkIf (templates != null) { inherit templates; })
|
|
|
|
(mkIf (formatters != null) { inherit formatters; })
|
|
|
|
];
|
|
|
|
}
|