Skip to content

Commit

Permalink
implement multiple package dirs
Browse files Browse the repository at this point in the history
  • Loading branch information
HariAmoor-professional committed Oct 16, 2022
1 parent c584317 commit 83bdefa
Showing 1 changed file with 42 additions and 1 deletion.
43 changes: 42 additions & 1 deletion flake-module.nix
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,26 @@ in
};
};
};
topLevelPackages = mkOption {
type = types.submodule {
options = {
enableMultiPkgs = mkBoolOption {
description = "Whether or not to use multiple top-level package dirs";
default = false;
};

dirs = mkOption {
type = types.listOf types.str;
description = ''
Subdirs containing a separate Cabal package
Define as nonempty only if enableMultiPkgs is set to `true`
'';
default = [ ];
};
};
};
};
};
});
};
Expand Down Expand Up @@ -151,6 +171,23 @@ in
(pkgs.lib.composeExtensions
(pkgs.haskell.lib.packageSourceOverrides cfg.source-overrides)
cfg.overrides);
hp = hp.extend
(
let
enableMultiPkgs = cfg.topLevelPackages.enableMultiPkgs;
dirs = cfg.topLevelPackages.dirs;
in
if enableMultiPkgs then
(self: _:
listToAttrs (map
(dir: {
name = dir;
value = self.callCabal2nix dir ./${dir} { };
})
dirs)
)
else (_: _: { })
);
defaultBuildTools = hp: with hp; {
inherit
cabal-install
Expand All @@ -161,7 +198,11 @@ in
buildTools = lib.attrValues (defaultBuildTools hp // cfg.buildTools hp);
package = cfg.modifier (hp.callCabal2nixWithOptions cfg.name cfg.root "" { });
devShell = with pkgs.haskell.lib;
(addBuildTools package buildTools).envFunc { withHoogle = true; };
(addBuildTools package buildTools).envFunc {
withHoogle = true;
packages = pkgs: map (pkg: pkgs.${pkg}) cfg.topLevelPackages.dirs;
buildInputs = [ hp.ghcid ];
};
devShellCheck = name: command:
runCommandInSimulatedShell devShell cfg.root "${projectKey}-${name}-check" { } command;
in
Expand Down

0 comments on commit 83bdefa

Please sign in to comment.