refactor: move inputs nix code to folder

This commit is contained in:
matt1432 2024-11-20 15:01:58 -05:00
parent c648667ef3
commit 4f38557364
4 changed files with 26 additions and 18 deletions

View file

@ -16,6 +16,5 @@
capitalise = str: (toUpper (substring 0 1 str) + (concatStringsSep "" (tail (stringToCharacters str))));
in
{inherit lib mkVersion capitalise;}
// (import ./inputs.nix lib lock)
// optionalAttrs (inputs != {}) (import ./flake-lib.nix inputs)
// optionalAttrs (pkgs != {}) (import ./pkgs.nix {inherit pkgs mkVersion capitalise self;})

View file

@ -1,42 +0,0 @@
lib: lock: let
inherit (lib) attrValues findFirst foldl' hasAttr matchAttrs optionalAttrs recursiveUpdate;
inherit (builtins) removeAttrs;
recursiveUpdateList = list: foldl' recursiveUpdate {} list;
in rec {
/*
*
From an attrset, returns a flake input that has its type defaulted
to `github` and has some of its inputs following this flake's input
of the same name.
It gets information from the `flake.lock` file and can be used thanks
to flakegen
*/
mkInput = {type ? "github", ...} @ info: let
input =
findFirst
(x: matchAttrs (removeAttrs info ["inputs"]) (x.original or {})) {}
(attrValues lock.nodes);
mkOverride = i:
optionalAttrs
(hasAttr i (input.inputs or {}))
{inputs.${i}.follows = i;};
in
recursiveUpdateList [
info
{inherit type;}
(mkOverride "systems")
(mkOverride "flake-utils")
(mkOverride "flake-parts")
(mkOverride "treefmt-nix")
(mkOverride "lib-aggregate")
];
mkDep = info: mkInput (recursiveUpdate info {inputs.nixpkgs.follows = "nixpkgs";});
mkHyprDep = info: mkInput (recursiveUpdate info {inputs.hyprland.follows = "hyprland";});
mkSrc = info: mkInput (info // {flake = false;});
}