Skip to content

Commit

Permalink
refactor(hare): ensure HAREPATH to be always set (#328)
Browse files Browse the repository at this point in the history
Also rework the function for including propagatedBuildInputs on it: The
new function ensures that the same path will not be repeated on the
environment variable.
  • Loading branch information
onemoresuza authored Dec 31, 2024
1 parent 4d062a4 commit 969df24
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions extra/language/hare.nix
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,16 @@ let
cfg = config.language.hare;
strOrPackage = import ../../nix/strOrPackage.nix { inherit lib pkgs; };
makeHareFullPath =
thirdParty:
userHareLibs:
let
allHareThirdPartyPkgs = builtins.attrValues (pkgs.hareThirdParty.packages pkgs);
isPropagatedLib = drv: builtins.any (x: drv == x) allHareThirdPartyPkgs;
pkgsPropagatedBuildInputs = builtins.foldl' (acc: e: acc ++ e.propagatedBuildInputs) [ ] thirdParty;
propagatedLibs = builtins.filter isPropagatedLib pkgsPropagatedBuildInputs;
allHareThirdPartyLibs = builtins.attrValues (pkgs.hareThirdParty.packages pkgs);
propagatedLibs = lib.unique (
builtins.foldl' (
acc: userLib: acc ++ (lib.intersectLists userLib.propagatedBuildInputs allHareThirdPartyLibs)
) [ ] userHareLibs
);
in
lib.makeSearchPath "src/hare/third-party" (thirdParty ++ propagatedLibs);
lib.makeSearchPath "src/hare/third-party" (userHareLibs ++ propagatedLibs);
in
with lib;
{
Expand All @@ -42,10 +44,10 @@ with lib;

config = {
env = [
(mkIf (cfg.thirdPartyLibs != [ ] || cfg.vendoredLibs != [ ]) {
{
name = "HAREPATH";
value = lib.makeSearchPath "src/hare/stdlib" [ cfg.package ];
})
}
(mkIf (cfg.thirdPartyLibs != [ ]) {
name = "HAREPATH";
prefix = makeHareFullPath cfg.thirdPartyLibs;
Expand Down

0 comments on commit 969df24

Please sign in to comment.