flake-utils-plus/flake.nix
Ben Buscarino 0e0cc7b28d Fix tests
2022-05-13 12:52:06 -04:00

57 lines
1.8 KiB
Nix

{
description = "Pure Nix flake utility functions";
inputs.flake-utils.url = "github:numtide/flake-utils";
outputs = { self, flake-utils }:
let
inherit (builtins) isList isAttrs mapAttrs;
inherit (flake-utils.lib) defaultSystems eachSystemMap;
fupArgs = { flake-utils-plus = self; };
mkFlake = import ./lib/mkFlake.nix fupArgs;
exportModules = import ./lib/exportModules.nix fupArgs;
exportOverlays = import ./lib/exportOverlays.nix fupArgs;
exportPackages = import ./lib/exportPackages.nix fupArgs;
genPkgOverlay = import ./lib/genPkgOverlay.nix;
internal-functions = import ./lib/internal-functions.nix;
overlay = import ./lib/overlay.nix;
in
rec {
inherit overlay;
nixosModules.autoGenFromInputs = import ./lib/options.nix;
darwinModules.autoGenFromInputs = import ./lib/options.nix;
devShell = eachSystemMap defaultSystems (system: import ./devShell.nix { inherit system; });
lib = flake-utils.lib // {
inherit mkFlake exportModules exportOverlays exportPackages genPkgOverlay;
# DO NOT USE - subject to change without notice
internal = internal-functions;
# merge nested attribute sets and lists
mergeAny = lhs: rhs:
lhs // mapAttrs
(name: value:
if isAttrs value then lhs.${name} or { } // value
else if isList value then lhs.${name} or [ ] ++ value
else value
)
rhs;
patchChannel = system: channel: patches:
if patches == [ ] then channel else
(import channel { inherit system; }).pkgs.applyPatches {
name = if channel ? shortRev then "nixpkgs-patched-${channel.shortRev}" else "nixpkgs-patched";
src = channel;
patches = patches;
};
};
};
}