From c953c3149541c337bcd0000ba547aefe3e73f290 Mon Sep 17 00:00:00 2001 From: Coutinho de Souza Date: Fri, 6 Sep 2024 21:22:29 -0300 Subject: [PATCH] refactor(hare): ensure HAREPATH to be always set 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. --- extra/language/hare.nix | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/extra/language/hare.nix b/extra/language/hare.nix index b548aeb..5a30de1 100644 --- a/extra/language/hare.nix +++ b/extra/language/hare.nix @@ -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; { @@ -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;