From 53ab84476eb968ec960054c850a86634765d2849 Mon Sep 17 00:00:00 2001 From: Andreas Herrmann Date: Tue, 8 Oct 2019 16:35:06 +0200 Subject: [PATCH] Use buildEnv and stdenv.initialPath https://github.com/tweag/rules_haskell/pull/1117#discussion_r332375860 https://github.com/tweag/rules_haskell/pull/1117#discussion_r332381715 --- haskell/private/unix/unix_nixpkgs.bzl | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/haskell/private/unix/unix_nixpkgs.bzl b/haskell/private/unix/unix_nixpkgs.bzl index a8638099a8..65db7c0d0b 100644 --- a/haskell/private/unix/unix_nixpkgs.bzl +++ b/haskell/private/unix/unix_nixpkgs.bzl @@ -11,9 +11,14 @@ def _unix_nixpkgs(name, packages, **kwargs): with import {{ config = {{}}; overlays = []; }}; let - cmd_glob = - builtins.concatStringsSep " " - (builtins.map (x: "${{x}}/bin/*") [ {} ]); + # `packages` might include lists, e.g. `stdenv.initialPath` is a list itself, + # so we need to flatten `packages`. + flatten = builtins.concatMap (x: if builtins.isList x then x else [x]); + env = buildEnv {{ + name = "unix-toolchain"; + paths = flatten [ {} ]; + }}; + cmd_glob = "${{env}}/bin/*"; os = if stdenv.isDarwin then "osx" else "linux"; in @@ -93,7 +98,7 @@ _unix_nixpkgs_toolchain = repository_rule( }, ) -def unix_nixpkgs(name, packages = ["bash", "coreutils", "gnused", "gnugrep", "gawk"], **kwargs): +def unix_nixpkgs(name, packages = ["stdenv.initialPath"], **kwargs): """Create a unix toolchain from nixpkgs. Loads the given Nix packages, scans them for standard Unix tools, and