aoc2021/nix/utils.nix
2021-12-01 03:03:04 +00:00

28 lines
813 B
Nix

{ inputs, pkgs, ... }:
let
fn = root: map (p: "${root}/" + p) (builtins.attrNames (builtins.readDir root));
gn = root:
let items = builtins.readDir root;
fn = file: type:
if type == "regular"
then
(let m = (builtins.match "(.*)\\.cabal" file);
in if !(isNull m)
then { "${builtins.elemAt m 0}" = root; }
else {})
else {};
in builtins.foldl' (x: y: x // y) {} (builtins.attrValues (builtins.mapAttrs fn items));
hn = s:
builtins.filter
(x: (builtins.hasAttr "flake" x) && !x.flake)
s;
packagePaths = builtins.foldl'
(x: y: x // y)
{}
(map gn ((import ./packages.nix) inputs));
in
builtins.mapAttrs
(name: path: pkgs.haskellPackages.callCabal2nix name path {})
packagePaths