tek / hix

Haskell/Nix development build tools
https://tryp.io/hix/index.html
Other
33 stars 2 forks source link

Static compilation? #1

Closed manveru closed 1 year ago

manveru commented 2 years ago

Is there a way to statically compile executables? I can't really find a good way to override the devGhc and the haskellPackages with pkgs.pkgsCross.musl64.haskellPackages.

tek commented 2 years ago

Hi there, thanks for the feedback, I haven't considered that use case before! I added a new option, devGhc.crossPkgs, that allows you to specify a different base set using devGhc.pkgs. I created an example test case using musl64 and static executables: https://github.com/tek/hix/blob/main/test/cross/root/flake.nix Appears to work, but if you have any suggestions for how to improve the API or if you're missing something, I'd be happy to implement that! In that example, you'd have to run nix build .#static to get the desired output.

tek commented 2 years ago

For the record, a more "canonical" way of adding a static package could be:

{
  outputs = { self, hix, ... }:
  hix.lib.flake ({ config, ... }: {
    outputs.packages.static =
      config.pkgs.haskell.lib.justStaticExecutables self.packages.${config.system}.root;
  });
}