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, inputs, outputs, flakelight, ... }:
|
2023-08-25 06:14:55 +02:00
|
|
|
let
|
|
|
|
inherit (lib) isList mkOption mkOrder mapAttrs optionalAttrs;
|
|
|
|
inherit (lib.types) listOf nullOr oneOf str;
|
|
|
|
in
|
|
|
|
{
|
|
|
|
options = {
|
|
|
|
description = mkOption {
|
|
|
|
type = nullOr str;
|
|
|
|
default = null;
|
|
|
|
};
|
|
|
|
|
|
|
|
license = mkOption {
|
|
|
|
type = nullOr (oneOf [ str (listOf str) ]);
|
|
|
|
default = null;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
config.withOverlays = mkOrder 10 (final: prev:
|
|
|
|
let
|
|
|
|
system = prev.stdenv.hostPlatform.system;
|
|
|
|
in
|
|
|
|
{
|
2023-08-27 07:48:57 +02:00
|
|
|
inherit src inputs outputs flakelight system;
|
2023-08-25 06:14:55 +02:00
|
|
|
inputs' = mapAttrs (_: mapAttrs (_: v: v.${system} or { })) inputs;
|
|
|
|
outputs' = mapAttrs (_: v: v.${system} or { }) outputs;
|
|
|
|
|
|
|
|
defaultMeta = {
|
|
|
|
platforms = config.systems;
|
|
|
|
} // optionalAttrs (config.description != null) {
|
|
|
|
inherit (config) description;
|
|
|
|
} // optionalAttrs (config.license != null) {
|
|
|
|
license =
|
|
|
|
let
|
|
|
|
getLicense = license: final.lib.licenses.${license} or
|
|
|
|
(final.lib.meta.getLicenseFromSpdxId license);
|
|
|
|
in
|
|
|
|
if isList config.license then map getLicense config.license
|
|
|
|
else getLicense config.license;
|
|
|
|
};
|
|
|
|
});
|
|
|
|
}
|