Skip to content

Commit 8faff20

Browse files
committed
Cross compilation fixes
1 parent 0975269 commit 8faff20

File tree

2 files changed

+21
-12
lines changed

2 files changed

+21
-12
lines changed

default.nix

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,13 @@ let
6262
};
6363
stackage = import stackageSrc;
6464

65-
packages = self: ({
65+
packages = pkgs: self: (rec {
66+
inherit pkgs; # Make pkgs available (it is the underlying nixpkgs)
67+
68+
# Packages built to run on the build platform, not the host platform
69+
buildPackages = pkgs.buildPackages.lib.makeScope pkgs.buildPackages.newScope
70+
(packages pkgs.buildPackages);
71+
6672
# Utility functions for working with the component builder.
6773
haskellLib = let hl = import ./lib { inherit (pkgs) lib; haskellLib = hl; }; in hl;
6874

@@ -123,15 +129,16 @@ let
123129
# Programs for generating Nix expressions from Cabal and Stack
124130
# files. We need to make sure we build this from the buildPackages,
125131
# we never want to actually cross compile nix-tools on it's own.
126-
nix-tools = pkgs.buildPackages.callPackage ./nix-tools {
132+
nix-tools-cross-compiled = pkgs.callPackage ./nix-tools {
127133
inherit fetchExternal cleanSourceHaskell;
128-
hpack = pkgs.buildPackages.haskell.lib.justStaticExecutables
129-
(pkgs.buildPackages.haskellPackages.hpack);
134+
hpack = pkgs.haskell.lib.justStaticExecutables
135+
(pkgs.haskellPackages.hpack);
130136
inherit (self) mkCabalProjectPkgSet;
131137
};
138+
nix-tools = buildPackages.nix-tools-cross-compiled;
132139

133140
# Function to call stackToNix
134-
callStackToNix = self.callPackage ./call-stack-to-nix.nix {};
141+
callStackToNix = buildPackages.callPackage ./call-stack-to-nix.nix {};
135142

136143
# Snapshots of Hackage and Stackage, converted to Nix expressions,
137144
# regularly updated.
@@ -180,11 +187,11 @@ let
180187
# Resulting nix files are added to nix-plan subdirectory.
181188
callCabalProjectToNix = import ./lib/cabalProjectToNix.nix {
182189
index-state-hashes = import indexStateHashesPath;
183-
inherit (self) dotCabal;
184-
inherit pkgs;
185-
inherit (pkgs) runCommand cabal-install ghc symlinkJoin cacert;
186-
inherit (pkgs.haskellPackages) hpack;
187-
inherit (self) nix-tools;
190+
inherit (buildPackages) dotCabal;
191+
pkgs = buildPackages.pkgs; # buildPackages;
192+
inherit (buildPackages.pkgs.haskellPackages) hpack;
193+
inherit (buildPackages.pkgs) runCommand cabal-install ghc symlinkJoin cacert;
194+
inherit (buildPackages) nix-tools;
188195
};
189196

190197
# References to the unpacked sources, for caching in a Hydra jobset.
@@ -194,4 +201,4 @@ let
194201
});
195202

196203
in
197-
pkgs.lib.makeScope pkgs.newScope packages
204+
pkgs.lib.makeScope pkgs.newScope (packages pkgs)

lib/cabalProjectToNix.nix

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,9 @@ let
3131
find . -name package.yaml -exec hpack "{}" \;
3232
export SSL_CERT_FILE=${cacert}/etc/ssl/certs/ca-bundle.crt
3333
export GIT_SSL_CAINFO=${cacert}/etc/ssl/certs/ca-bundle.crt
34-
HOME=${dotCabal { inherit index-state; sha256 = index-sha256; }} cabal new-configure
34+
HOME=${dotCabal { inherit index-state; sha256 = index-sha256; }} cabal new-configure \
35+
--with-ghc=${ghc.targetPrefix}ghc \
36+
--with-ghc-pkg=${ghc.targetPrefix}ghc-pkg
3537
3638
export LANG=C.utf8 # Needed or stack-to-nix will die on unicode inputs
3739
mkdir -p $out

0 commit comments

Comments
 (0)