Skip to content

Instantly share code, notes, and snippets.

@yorickvP
Created December 1, 2019 13:38
Show Gist options
  • Save yorickvP/c89f8e7597049a5a1dda4035e63584cb to your computer and use it in GitHub Desktop.
Save yorickvP/c89f8e7597049a5a1dda4035e63584cb to your computer and use it in GitHub Desktop.
let
haskell-nix = import (builtins.fetchTarball https://github.com/input-output-hk/haskell.nix/archive/master.tar.gz);
pkgs-native = import <nixpkgs> haskell-nix;
pkgs-musl = import <nixpkgs> (haskell-nix // { crossSystem = pkgs-native.lib.systems.examples.musl64; });
stackProjectCross = {crossPkgs, pkgs, ...}@args: with crossPkgs.haskell-nix;
let stack = importAndFilterProject (pkgs.haskell-nix.callStackToNix args);
pkg-set = mkStackPkgSet
{ stack-pkgs = stack.pkgs;
pkg-def-extras = (args.pkg-def-extras or []);
modules = (args.modules or [])
++ pkgs.lib.optional (args ? ghc) { ghc.package = args.ghc; }
++ pkgs.lib.optional (args ? cache) (mkCacheModule args.cache);
};
p = { inherit (pkg-set.config) hsPkgs; stack-nix = stack.nix; };
in p.hsPkgs // {
inherit (p) stack-nix;
shells.ghc = p.hsPkgs.shellFor {};
};
args = {
src = pkgs-native.haskell-nix.haskellLib.cleanGit { src = ./.; };
};
in stackProjectCross (args // { pkgs = pkgs-native; crossPkgs = pkgs-musl; })
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment