1
1
mirror of https://github.com/divnix/digga.git synced 2024-11-27 17:36:06 +03:00
digga/lib/flake.nix
David Arnold be924bcb27 ref: reduce exposure to callLibs
for clarity's sake, expose which function uses final and prev, so that
people can have a clearer understanding how they relate to each other
in terms of dependencies.

also a simple `{ lib = final; }` probably does not warrant a complete
callLibs obscurization.
2021-04-18 22:16:53 -05:00

93 lines
2.0 KiB
Nix

{
description = "DevOS environment configuriguration library.";
inputs =
{
deploy.url = "github:serokell/deploy-rs";
deploy.inputs = {
utils.follows = "utils";
};
devshell.url = "github:numtide/devshell";
utils.url = "github:numtide/flake-utils";
};
outputs = inputs@{ self, nixpkgs, deploy, devshell, utils, ... }: let
inherit (nixpkgs) lib;
# We work with a combined lib, internally ...
combinedLib = lib.extend (final: prev:
let callLibs = file: import file
({
lib = final;
userFlakeNixos = {};
userFlakeSelf = {};
userFlakeInputs = {}; # TODO: Erm, theese must become proper arguments to mkFlake
} // inputs);
in
with final;
let
attrs = import ./attrs.nix { lib = prev; };
lists = import ./lists.nix { lib = prev; };
strings = import ./strings.nix { lib = prev; };
in
utils.lib
//
{
inherit callLibs;
os = import ./devos { lib = final; };
mkFlake = {
__functor = callLibs ./mkFlake;
evalArgs = callLibs ./mkFlake/evalArgs.nix;
evalOldArgs = callLibs ./mkFlake/evalOldArgs.nix;
};
pkgs-lib = import ./pkgs-lib {
lib = final;
inherit nixpkgs deploy devshell;
};
inherit (attrs) mapFilterAttrs genAttrs' safeReadDir
pathsToImportedAttrs concatAttrs filterPackages;
inherit (lists) pathsIn;
inherit (strings) rgxToString;
}
);
in
{
# ... but don't force that choice onto the user
lib = utils.lib // {
mkFlake = combinedLib.mkFlake;
pkgs-lib = combinedLib.pkgs-lib;
};
}
//
utils.lib.eachDefaultSystem (system:
let
nixpkgs' = import nixpkgs { inherit system; overlays = []; config = {}; };
in
{
checks = {
tests = import ./tests {
inherit (nixpkgs') pkgs;
lib = combinedLib;
};
};
}
);
}