All Projects → input-output-hk → Nix Hs Hello Windows

input-output-hk / Nix Hs Hello Windows

Licence: other
Cross compiling Hello World (haskell) to Windows using nix.

Labels

Projects that are alternatives of or similar to Nix Hs Hello Windows

Nixlisp
Stars: ✭ 33 (-40%)
Mutual labels:  nix
Rust Nightly Nix
A Nix expression for nightly Rust versions
Stars: ✭ 43 (-21.82%)
Mutual labels:  nix
Backerei
Automated reward payment & account management for Tezos bakers.
Stars: ✭ 51 (-7.27%)
Mutual labels:  nix
Nixdroid
building aosp roms (e.g. LineageOS) with nix. because why not?
Stars: ✭ 34 (-38.18%)
Mutual labels:  nix
Nix Rehash
Nix development utils that will blow up your mind
Stars: ✭ 41 (-25.45%)
Mutual labels:  nix
Nixery
Container registry which transparently builds images using the Nix package manager
Stars: ✭ 1,023 (+1760%)
Mutual labels:  nix
Nixos Config
NixOS configurations for server and desktop systems, including user specific config. with Home Manager
Stars: ✭ 30 (-45.45%)
Mutual labels:  nix
Neutron
🌠 Purely functional Apache Pulsar client for Scala built on top of Fs2
Stars: ✭ 53 (-3.64%)
Mutual labels:  nix
Dotfiles
💻 Public repo for my personal dotfiles
Stars: ✭ 43 (-21.82%)
Mutual labels:  nix
Nix Dotfiles
My personal nix and nixos configuration
Stars: ✭ 48 (-12.73%)
Mutual labels:  nix
Nix Query Tree Viewer
GTK viewer for the output of `nix-store --query --tree`
Stars: ✭ 36 (-34.55%)
Mutual labels:  nix
Flake Compat
Stars: ✭ 41 (-25.45%)
Mutual labels:  nix
Rust Overlay
Pure and reproducible nix overlay for binary distributed rust toolchains
Stars: ✭ 46 (-16.36%)
Mutual labels:  nix
Nix Flakes Installer
A temporary place to host Nix Flakes releases, until the NixOS project publishes official releases.
Stars: ✭ 34 (-38.18%)
Mutual labels:  nix
Idempotent Desktop
🛸 NixOS, Xmonad, Neovim
Stars: ✭ 51 (-7.27%)
Mutual labels:  nix
Nix Examples
Showcase of Nix usage for various technologies
Stars: ✭ 31 (-43.64%)
Mutual labels:  nix
Base16 Zathura
base16 colors for zathura
Stars: ✭ 44 (-20%)
Mutual labels:  nix
Snabblab Nixos
NixOS configuration for the Snabb Lab
Stars: ✭ 53 (-3.64%)
Mutual labels:  nix
Microgram
ABANDONED
Stars: ✭ 52 (-5.45%)
Mutual labels:  nix
Workshops
Stars: ✭ 47 (-14.55%)
Mutual labels:  nix
  • Hello Windows

    This repository contains the necessary nix-expressions and a nixpkgs submodule that should allow us to cross compile a small haskell application into a working windows executable.

    [[file:hs-hello.png]]

** Building To build the cross compiled hs-hello.exe with nix, all we need is

#+BEGIN_SRC bash $ nix-build -A hello-world --cores 0 #+END_SRC

This will build the necessary dependencies, and finally build the hs-hello.exe, which we can find in result/bin/hs-hello.exe.

** config.nix We will need a customized GHC. Due to the introduction of the buildPackages for the cross compilation capabilities in nixpkgs this turns out to be a bit more complicated than we like. The core issue here is that the stage logic and the packageOverrides do not play well together. Specifically changes made via packageOverrides do not show up in the buildPackages.

** hello-world.nix This is our usual haskell package expression. Just note the additional

#+BEGIN_SRC nix enableSharedExecutables = false; setupHaskellDepends = [ Cabal_HEAD ]; #+END_SRC

as we don't have dynamic libraries with our cross compiler (yet). And need to link against a custom Cabal library.

** default.nix In the default.nix we'll pull everything together. Set the crossSystem to mingwW64 and the packageOverlays via config.

In addition we setup a custom Cabal library, which we want to link against; the one that ships with GHC has some defects when cross compiling to windows.

We use callPackage on the buildPackages to ensure that the Cabal library is built for the build machine. For the hello-world package (hello-world.nix) we use pkgs which will result in the package to be built for the host machine.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].