GaloisInc / HaLVM

The Haskell Lightweight Virtual Machine (HaLVM): GHC running on Xen
BSD 3-Clause "New" or "Revised" License
1.05k stars 88 forks source link

Nixify HaLVM #86

Closed dmjio closed 7 years ago

dmjio commented 7 years ago

@acw 👋 :)

The nix package manager allows someome to drop into an arbitrary shell w/ prebuilt haskell deps. (optionally profiled) w/ a GHC. It would be nice to add halvm-ghc to this list.

nix-repl> pkgs.haskell.compiler.
pkgs.haskell.compiler.ghc6102Binary  pkgs.haskell.compiler.ghc7103        pkgs.haskell.compiler.ghc784         pkgs.haskell.compiler.ghcjsHEAD
pkgs.haskell.compiler.ghc6104        pkgs.haskell.compiler.ghc722         pkgs.haskell.compiler.ghc801         pkgs.haskell.compiler.jhc
pkgs.haskell.compiler.ghc6123        pkgs.haskell.compiler.ghc742         pkgs.haskell.compiler.ghc802         pkgs.haskell.compiler.uhc
pkgs.haskell.compiler.ghc704         pkgs.haskell.compiler.ghc742Binary   pkgs.haskell.compiler.ghcHEAD        
pkgs.haskell.compiler.ghc704Binary   pkgs.haskell.compiler.ghc763         pkgs.haskell.compiler.ghcNokinds     
pkgs.haskell.compiler.ghc7102        pkgs.haskell.compiler.ghc783         pkgs.haskell.compiler.ghcjs    

So we could just do:

$ nix-shell -p "haskell.packages.ghcHaLVM (pkgs: with pkgs; [ BoundedChan ])"

Modifying this code would be a good starting point. https://github.com/NixOS/nixpkgs/blob/master/pkgs/development/compilers/ghc/head.nix

I'd like to start working on this, for ease of dev. w/ HaLVM.

izgzhen commented 7 years ago

Cool. How well NixOS supports Xen?

dmjio commented 7 years ago

@izgzhen It's supported afaict, https://github.com/NixOS/nixos/blob/master/modules/virtualisation/xen-dom0.nix https://nixos.org/wiki/NixOS_and_Xen

But this addition to nixpkgs would be moreso related to using the nix package manager, not necessarily NixOS, and the goal would be to get a working halvm-ghc and HaLVM environment setup fast, with any deps. you need. nix (package manager) just let's you sandbox your entire system, including language deps. system deps. If you use nix on NixOS you can declaratively specify systemd units and reify your configuration with sudo nixos-rebuild switch.

The nix package manager can run on any OS (best support for linux / darwin). So users should be able to write haskell code on any OS that ghc runs on and cross-compile to Xen using a nix-expression that references halvm-ghc w/ HaLVM.

On the GHCJS project, distribution of the compiler has been a major impediment to adoption. Some people put it on nixpkgs, and it's very simple to get a working environment setup, the only problem is the learning curve with nix. But knowledge of the entire lang. / eco-system isn't necessary if you want a working compiler fast.

Getting ghcjs from scratch

$ curl https://nixos.org/nix/install | sh
# copy . /home/<user>/.nix-profile/etc/profile.d/nix.sh   into your .bashrc
$ nix-shell -p "haskell.packages.ghcjs (pkgs: with pkgs; [ ghcjs-base, aeson ])"
# pulls prebuilt ghcjs from the hydra cache into your /nix/store and symlinks it into the shell below
[nix-shell:~]$  ghcsi --info
# ... etc

Lastly, it seems there is experimental support for generic ghc cross compilers: https://github.com/NixOS/nixpkgs/blob/master/pkgs/top-level/haskell-packages.nix#L135

acw commented 7 years ago

I'm on board. Anything you need on the HaLVM side?

Ericson2314 commented 7 years ago

@dmjio I'm quite interested in helping with this; in fact my motivation for https://github.com/NixOS/nixpkgs/pull/13131/files was in part hoping someone open just this issue!

dmjio commented 7 years ago

https://github.com/NixOS/nixpkgs/pull/23097 cc: @acw @izgzhen @Ericson2314 @elliottt

dmjio commented 7 years ago

HaLVM-2.4.0 is on nixpkgs/master, closing.