!tQOOewZWVcFfpzaVMb:matrix.org

static-haskell-nix

29 Members
Haskell static executable building with nix - https://github.com/nh2/static-haskell-nix/6 Servers

Load older messages


SenderMessageTime
23 Jun 2022
@better_sleeping:converser.eu@better_sleeping:converser.eu left the room.23:44:56
19 Jul 2022
@imdoor:ilgt.lvimdoor joined the room.20:01:26
31 Jul 2022
@imdoor:ilgt.lvimdoorHi, i haven't followed along static Haskell Nix stuff for a while now. Generally, how far along is this project currently? I saw that the Github repo hasn't seen any changes in a while now, should it still be used? I'm asking because i wanted to distribute a some CLI tool I've created as a static binary and was wondering what's the best place to start currently. I was thinking of maybe targeting Windows, is it possible using static Haskell Nix? Also, are there any examples for building Cabal projects available (like there is for Stack)?20:24:44
@nh2:matrix.orgnh2

Hi imdoor, I am currently quite busy so I haven't yet had the chance to review the current open PRs to update static-haskell-nix's nixpkgs pin to a later version.
You can still use it; there's not really anything holding it back beyond the updates being general drudge work :D

It is not possible to target Windows (not possible with nixpkgs in general).

All Haskell packages are "cabal projects". The special thing for the stack support is that stack2nix is used to turn a stackage snapshot into a nix package set. Without stackage, you will have to use the packages from your nixpkgs version (which should also be fine).
The way you get your package to build is to add it to survey/default.nix, and then build it. From the README, the example

NIX_PATH=nixpkgs=nixpkgs nix-build --no-link survey/default.nix -A working

builds all cabal packages in the working set; similarly you could build -A haskellPackages.pandoc or -A haskellPackages.yourpackage.
After you managed to build your package by adding it into the code of survey/default.nix, you can do it using an overlay instead.

20:37:58
@nh2:matrix.orgnh2Hope that helps!20:38:01
@imdoor:ilgt.lvimdooryup, thanks! :)20:47:56
1 Aug 2022
@cdepillabout:matrix.orgcdepillabout imdoor: A few months ago static linking for Haskell executables was fixed in Nixpkgs, so now things like pkgsStatic.haskellPackages.foobar are much more likely to just work. 03:00:48
@cdepillabout:matrix.orgcdepillaboutAlthough the approach is slightly different than taken in static-haskell-nix, and I'm under the impression that there are Haskell packages where static-haskell-nix will work, but the stuff in Nixpkgs won't.03:01:42
2 Aug 2022
@imdoor:ilgt.lvimdoor cdepillabout: oh, cool. then i guess i'll just start with using pkgsStatic and maybe that's all i need 15:30:06
@imdoor:ilgt.lvimdoor * cdepillabout: oh, cool. then i guess i'll just start with trying pkgsStatic and maybe that's all i need 15:30:20
@imdoor:ilgt.lvimdoor i got my project to build using pkgsStatic. i had to switch it from GHC 8.10.7 to 9.2.3, because of some (it seems) Template Haskell issue which was giving me a "attempting to use module [..] which is not loaded" error similar to this issue https://github.com/NixOS/nixpkgs/issues/124284, but there were no other problems (other than ones caused by the GHC upgrade) 20:44:03
@imdoor:ilgt.lvimdoorbtw, thanks for all the work put into static build support for Haskell. it's great being able to do this so easily20:53:58
4 Aug 2022
@ajf___:matrix.orgajf___ joined the room.17:10:22
26 Aug 2022
@kadokusei10:matrix.orgkadokusei10 joined the room.01:33:39
31 Aug 2022
@kadokusei10:matrix.orgkadokusei10 Anyone knows of a nix binary cache that has musl-ghc from pkgs-static or static-haskell-nix? Hopefully for a nixpkgs revision from the last 6 months? The static-haskell-nix repo's nixpkgs (which I assume influences what gets cached) is a revision from July 2021 02:23:44
@cdepillabout:matrix.orgcdepillabout
In reply to @kadokusei10:matrix.org
Anyone knows of a nix binary cache that has musl-ghc from pkgs-static or static-haskell-nix? Hopefully for a nixpkgs revision from the last 6 months? The static-haskell-nix repo's nixpkgs (which I assume influences what gets cached) is a revision from July 2021
I'm not sure what musl-ghc or pkgs-static are, but the haskell-updates jobset on the NixOS Hydra builds a few statically-linked libraries, so you should be able to get a GHC that is setup for static linking from there:
https://github.com/NixOS/nixpkgs/blob/30942c90cbdf884dc6df63fbec859ac812e7d9d1/pkgs/top-level/release-haskell.nix#L468-L481
05:26:11
@cdepillabout:matrix.orgcdepillaboutAlthough that might be different from the GHCs you'd be building if you used static-haskell-nix.05:26:34
@kadokusei10:matrix.orgkadokusei10
In reply to @cdepillabout:matrix.org
I'm not sure what musl-ghc or pkgs-static are, but the haskell-updates jobset on the NixOS Hydra builds a few statically-linked libraries, so you should be able to get a GHC that is setup for static linking from there:
https://github.com/NixOS/nixpkgs/blob/30942c90cbdf884dc6df63fbec859ac812e7d9d1/pkgs/top-level/release-haskell.nix#L468-L481

Ah, my bad. musl-ghc is just a name I used to refer to a GHC built with musl.
pkgs-static was a typo, I meant pkgsStatic the top-level attribute in the nixpkgs attribute set.

Thanks for the hydra link that sounds like a promising point, I will take a look at it!

09:48:29
@kadokusei10:matrix.orgkadokusei10
In reply to @cdepillabout:matrix.org
I'm not sure what musl-ghc or pkgs-static are, but the haskell-updates jobset on the NixOS Hydra builds a few statically-linked libraries, so you should be able to get a GHC that is setup for static linking from there:
https://github.com/NixOS/nixpkgs/blob/30942c90cbdf884dc6df63fbec859ac812e7d9d1/pkgs/top-level/release-haskell.nix#L468-L481
*

Ah, my bad. musl-ghc is just a name I used to refer to a GHC built with musl.
pkgs-static was a typo, I meant pkgsStatic the top-level attribute in the nixpkgs attribute set.

Thanks for the point about the jobset and hydra that sounds like a promising point, I will take a look at it!

09:49:16
@cdepillabout:matrix.orgcdepillabout
In reply to @kadokusei10:matrix.org

Ah, my bad. musl-ghc is just a name I used to refer to a GHC built with musl.
pkgs-static was a typo, I meant pkgsStatic the top-level attribute in the nixpkgs attribute set.

Thanks for the point about the jobset and hydra that sounds like a promising point, I will take a look at it!

Most of the commits where the haskell-updates branch in Nixpkgs is merged into master should likely work for you, so that might be a good place to start looking.
11:10:15
@kadokusei10:matrix.orgkadokusei10
In reply to @cdepillabout:matrix.org
Most of the commits where the haskell-updates branch in Nixpkgs is merged into master should likely work for you, so that might be a good place to start looking.
Thanks, it seems to have worked! I do have a choice between a branch that was merged into master and one that was merged into nixpkgs-unstable right? Either of these has ghcMusl cached but nixpkgs-unstable might be a tad bit older with overall more packages (in general) cached.
12:17:43
@cdepillabout:matrix.orgcdepillabout
In reply to @kadokusei10:matrix.org
Thanks, it seems to have worked! I do have a choice between a branch that was merged into master and one that was merged into nixpkgs-unstable right? Either of these has ghcMusl cached but nixpkgs-unstable might be a tad bit older with overall more packages (in general) cached.
I'm not super knowledgeable with the intricacies of the Nixpkgs Hydra, but I am definitely sure that there are a few Haskell packages built in pkgsStatic for the haskell-updates jobset. So that means as long as you use one of the fully-working commits from the haskell-updates break, you are very likely to be able to pull the statically-linking ghcs from the cache.
12:41:31
@cdepillabout:matrix.orgcdepillabout But if you use master or nixpkgs-unstable, you may get unlucky and not be able to get a statically-linking ghc from the cache. I think it just depends on what has happened on master since haskell-updates was merged in. I don't think the jobset for nixpkgs-unstable builds the statically-linking ghcs. 12:43:00
@kadokusei10:matrix.orgkadokusei10 Indeed it is as you say.
I meant getting the haskell-updates merge commit from nixpkgs-unstable rather than master but then the jobset for nixpkgs-unstable does not run on every master commit so I might get unlucky on that case as well
12:45:14
@kadokusei10:matrix.orgkadokusei10 * Indeed it is as you say.
I meant getting the haskell-updates merge commit from nixpkgs-unstable rather than master but then the jobset for nixpkgs-unstable does not run on every master commit so I might get unlucky on that case as well (if I understand correctly, which I probably do not :) )
12:45:46
@kadokusei10:matrix.orgkadokusei10 Is there any reason to prefer pkgsStatic or pkgsMusl for Haskell builds? Looking at haskell-release.nix it looks like pkgsStatic gets more packages run for caching 12:47:29
@kadokusei10:matrix.orgkadokusei10 * Is there any reason to prefer pkgsStatic or pkgsMusl for Haskell builds? Looking at haskell-release.nix it looks like pkgsStatic gets more packages run for caching
EDIT: Got an answer to this one. with pkgsStatic I do not get a cache-hit for ghc-musl so I will only use pkgsMusl
12:52:02
@cdepillabout:matrix.orgcdepillabout
In reply to @kadokusei10:matrix.org
Is there any reason to prefer pkgsStatic or pkgsMusl for Haskell builds? Looking at haskell-release.nix it looks like pkgsStatic gets more packages run for caching
EDIT: Got an answer to this one. with pkgsStatic I do not get a cache-hit for ghc-musl so I will only use pkgsMusl
With the Nixpkgs stuff, packages built with pkgsStatic really are statically linked against musl. So for instance pkgsStatic.stack gives you a fully statically-linked stack binary.
14:48:30
@cdepillabout:matrix.orgcdepillabout With the Nixpkgs stuff, pkgsMusl is for executables that are dynamically linked against musl. So, for instance, pkgsMusl.stack is a stack binary that is dynamically-linked against musl. 14:49:43
@cdepillabout:matrix.orgcdepillabout Although if you're talking about static-haskell-nix, it is a little bit different. I think internally static-haskell-nix normally uses pkgsMusl, but has a bunch of overrides so that all libraries produce both .a files for static linking, and .so files for dynamic-linking. So if you were using static-haskell-nix, then you'd be using pkgsMusl, but you could likely either statically-link or dynamically-link depending on what flags you pass to ld when compiling. 14:51:52

Show newer messages


Back to Room ListRoom Version: 6