Skip to content

Commit

Permalink
Managed to cross-compile for Windows!
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasjm committed Jan 31, 2025
1 parent fe24606 commit acda321
Show file tree
Hide file tree
Showing 5 changed files with 193 additions and 91 deletions.
141 changes: 68 additions & 73 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

65 changes: 56 additions & 9 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,70 @@
inputs.nixpkgs.follows = "nixpkgs";
};
inputs.haskellNix.url = "github:input-output-hk/haskell.nix";
inputs.nixpkgs.url = "github:NixOS/nixpkgs/release-24.05";
inputs.nixpkgs.follows = "haskellNix/nixpkgs-unstable";

outputs = { self, flake-utils, gitignore, haskellNix, nixpkgs }:
flake-utils.lib.eachDefaultSystem (system:
let
overlays = [
haskellNix.overlay
(import ./nix/fix-ghc-pkgs-overlay.nix)
];

pkgs = import nixpkgs { inherit system overlays; inherit (haskellNix) config; };
pkgs = import nixpkgs {
inherit system;
overlays = [
haskellNix.overlay
(import ./nix/fix-ghc-pkgs-overlay.nix)
];
inherit (haskellNix) config;
};

src = gitignore.lib.gitignoreSource ./.;

compilerNixName = "ghc966";

flake = (pkgs.hixProject compilerNixName src).flake {};
flakeStatic = (pkgs.pkgsCross.musl64.hixProject compilerNixName src).flake {};
flake = (pkgs.haskell-nix.hix.project {
inherit src;
evalSystem = "x86_64-linux";
compiler-nix-name = compilerNixName;
projectFileName = "stack.yaml";
modules = [
(import ./nix/fix-ghc-pkgs-module.nix)
{
packages.sauron.components.exes.sauron.configureFlags = [
''--ghc-options="-pgml g++"''
];
packages.sauron.components.exes.sauron.build-tools = [pkgs.gcc];
packages.sauron.components.exes.sauron.dontStrip = false;
}
];
}).flake {};

flakeStatic = (pkgs.pkgsCross.musl64.haskell-nix.hix.project {
inherit src;
evalSystem = "x86_64-linux";
compiler-nix-name = compilerNixName;
projectFileName = "stack.yaml";
modules = [
(import ./nix/fix-ghc-pkgs-module.nix)
{
packages.sauron.components.exes.sauron.configureFlags = [
''--ghc-options="-pgml g++"''
];
packages.sauron.components.exes.sauron.build-tools = [pkgs.gcc];
packages.sauron.components.exes.sauron.dontStrip = false;
}
];
}).flake {};

flakeWindows = (pkgs.pkgsCross.mingwW64.haskell-nix.hix.project {
inherit src;
compiler-nix-name = compilerNixName;
projectFileName = "stack.yaml";
modules = [
{
packages.bitvec.components.library.configureFlags = [
"-f -simd"
];
}
];
}).flake {};

in
{
Expand All @@ -33,6 +79,7 @@

normal = flake.packages."sauron:exe:sauron";
static = flakeStatic.packages."sauron:exe:sauron";
windows = flakeWindows.packages."sauron:exe:sauron";

print-nixpkgs = pkgs.writeShellScriptBin "print-nixpkgs.sh" "echo ${pkgs.path}";
};
Expand Down
44 changes: 44 additions & 0 deletions nix/fix-ghc-pkgs-module.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
{
reinstallableLibGhc = false;
nonReinstallablePkgs = [
"rts"
"ghc-heap"
"ghc-prim"
"integer-gmp"
"integer-simple"
"base"
"deepseq"
"array"
"ghc-boot-th"
"pretty"
"template-haskell"
"ghcjs-prim"
"ghcjs-th"
"ghc-bignum"
"exceptions"
"stm"
"ghc-boot"
"ghc"
"Cabal"
"Win32"
"array"
"binary"
"bytestring"
"containers"
"directory"
"filepath"
"ghc-boot"
"ghc-compact"
"ghc-prim"
"hpc"
"mtl"
"parsec"
"process"
"text"
"time"
"transformers"
"unix"
"xhtml"
"terminfo"
];
}
Loading

0 comments on commit acda321

Please sign in to comment.