Skip to content

Commit

Permalink
Cross compilation fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
hamishmack committed Jul 12, 2019
1 parent 40e670f commit a09ae94
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 12 deletions.
29 changes: 18 additions & 11 deletions default.nix
Expand Up @@ -62,7 +62,13 @@ let
};
stackage = import stackageSrc;

packages = self: ({
packages = pkgs: self: (rec {
inherit pkgs; # Make pkgs available (it is the underlying nixpkgs)

# Packages built to run on the build platform, not the host platform
buildPackages = pkgs.buildPackages.lib.makeScope pkgs.buildPackages.newScope
(packages pkgs.buildPackages);

# Utility functions for working with the component builder.
haskellLib = let hl = import ./lib { inherit (pkgs) lib; haskellLib = hl; }; in hl;

Expand Down Expand Up @@ -127,15 +133,16 @@ let
# Programs for generating Nix expressions from Cabal and Stack
# files. We need to make sure we build this from the buildPackages,
# we never want to actually cross compile nix-tools on it's own.
nix-tools = pkgs.buildPackages.callPackage ./nix-tools {
nix-tools-cross-compiled = pkgs.callPackage ./nix-tools {
inherit fetchExternal cleanSourceHaskell;
hpack = pkgs.buildPackages.haskell.lib.justStaticExecutables
(pkgs.buildPackages.haskellPackages.hpack);
hpack = pkgs.haskell.lib.justStaticExecutables
(pkgs.haskellPackages.hpack);
inherit (self) mkCabalProjectPkgSet;
};
nix-tools = buildPackages.nix-tools-cross-compiled;

# Function to call stackToNix
callStackToNix = self.callPackage ./call-stack-to-nix.nix {};
callStackToNix = buildPackages.callPackage ./call-stack-to-nix.nix {};

# Snapshots of Hackage and Stackage, converted to Nix expressions,
# regularly updated.
Expand Down Expand Up @@ -184,11 +191,11 @@ let
# Resulting nix files are added to nix-plan subdirectory.
callCabalProjectToNix = import ./lib/cabalProjectToNix.nix {
index-state-hashes = import indexStateHashesPath;
inherit (self) dotCabal;
inherit pkgs;
inherit (pkgs) runCommand cabal-install ghc symlinkJoin cacert;
inherit (pkgs.haskellPackages) hpack;
inherit (self) nix-tools;
inherit (buildPackages) dotCabal;
pkgs = buildPackages.pkgs; # buildPackages;
inherit (buildPackages.pkgs.haskellPackages) hpack;
inherit (buildPackages.pkgs) runCommand cabal-install ghc symlinkJoin cacert;
inherit (buildPackages) nix-tools;
};

# References to the unpacked sources, for caching in a Hydra jobset.
Expand All @@ -198,4 +205,4 @@ let
});

in
pkgs.lib.makeScope pkgs.newScope packages
pkgs.lib.makeScope pkgs.newScope (packages pkgs)
4 changes: 3 additions & 1 deletion lib/cabalProjectToNix.nix
Expand Up @@ -137,7 +137,9 @@ let
export GIT_SSL_CAINFO=${cacert}/etc/ssl/certs/ca-bundle.crt
HOME=${dotCabal {
index-state = index-state-found;
sha256 = index-sha256-found; }} cabal new-configure
sha256 = index-sha256-found; }} cabal new-configure \
--with-ghc=${ghc.targetPrefix}ghc \
--with-ghc-pkg=${ghc.targetPrefix}ghc-pkg
export LANG=C.utf8 # Needed or stack-to-nix will die on unicode inputs
mkdir -p $out
Expand Down

0 comments on commit a09ae94

Please sign in to comment.