From 712a66158c8652a0a654651980eb4fd39217ae3c Mon Sep 17 00:00:00 2001 From: Archit Gupta Date: Wed, 13 Sep 2023 22:54:25 -0700 Subject: [PATCH] Add lib option --- builtinModules/lib.nix | 19 +++++++++++++++++++ flake.nix | 2 +- 2 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 builtinModules/lib.nix diff --git a/builtinModules/lib.nix b/builtinModules/lib.nix new file mode 100644 index 0000000..a25c2f4 --- /dev/null +++ b/builtinModules/lib.nix @@ -0,0 +1,19 @@ +# flakelight -- Framework for simplifying flake setup +# Copyright (C) 2023 Archit Gupta +# SPDX-License-Identifier: MIT + +{ config, lib, ... }: +let + inherit (lib) mkOption mkIf; + inherit (lib.types) attrsOf raw; +in +{ + options.lib = mkOption { + type = attrsOf raw; + default = { }; + }; + + config.outputs = mkIf (config.lib != { }) { + inherit (config) lib; + }; +} diff --git a/flake.nix b/flake.nix index 958b644..5eb3d97 100644 --- a/flake.nix +++ b/flake.nix @@ -9,7 +9,7 @@ outputs = { nixpkgs, ... }: let lib = import ./. nixpkgs; in lib.mkFlake ./. { - outputs = { inherit lib; }; + inherit lib; functor = _: lib.mkFlake; templates = import ./templates; checks.statix = pkgs: "${pkgs.statix}/bin/statix check";