1
1
forked from extern/flakelight
flakelight/builtinModules/autoInputs.nix
Archit Gupta cecfafe9a4 Set defaults for inputs from flake.lock
If the `src` passed to flakelight contains a flake.lock, it will now be
read and used to set defaults for `inputs`. Explicitly passed inputs
will override this.
2024-03-10 19:26:37 -07:00

14 lines
473 B
Nix

# flakelight -- Framework for simplifying flake setup
# Copyright (C) 2023 Archit Gupta <archit@accelbread.com>
# SPDX-License-Identifier: MIT
{ lib, src, ... }:
let
inherit (builtins) mapAttrs pathExists;
inherit (lib) mkOverride;
lock2inputs = import ../misc/lock2inputs.nix { inherit lib; };
lockFound = pathExists (src + "/flake.lock");
autoInputs = if lockFound then lock2inputs src else { };
in
{ config.inputs = mapAttrs (_: mkOverride 950) autoInputs; }