2024-11-20 15:01:58 -05:00
|
|
|
let
|
|
|
|
inherit (builtins) fetchTarball fromJSON readFile removeAttrs;
|
|
|
|
|
|
|
|
lock = fromJSON (readFile ../flake.lock);
|
|
|
|
lib = import "${fetchTarball {
|
|
|
|
url = "https://github.com/NixOS/nixpkgs/archive/${lock.nodes.nixpkgs.locked.rev}.tar.gz";
|
|
|
|
sha256 = lock.nodes.nixpkgs.locked.narHash;
|
|
|
|
}}/lib";
|
|
|
|
|
2024-09-23 23:52:17 -04:00
|
|
|
inherit (lib) attrValues findFirst foldl' hasAttr matchAttrs optionalAttrs recursiveUpdate;
|
2024-08-07 14:47:32 -04:00
|
|
|
|
|
|
|
recursiveUpdateList = list: foldl' recursiveUpdate {} list;
|
|
|
|
in rec {
|
2024-08-08 23:27:42 -04:00
|
|
|
/*
|
2024-11-20 15:01:58 -05:00
|
|
|
* 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.
|
2024-08-08 23:27:42 -04:00
|
|
|
*
|
2024-11-20 15:01:58 -05:00
|
|
|
* It gets information from the `flake.lock` file and can be used thanks
|
|
|
|
* to flakegen
|
2024-08-07 14:47:32 -04:00
|
|
|
*/
|
|
|
|
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")
|
2024-09-29 16:31:31 -04:00
|
|
|
(mkOverride "flake-parts")
|
|
|
|
(mkOverride "treefmt-nix")
|
2024-08-07 14:47:32 -04:00
|
|
|
(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;});
|
|
|
|
}
|