Skip to content

Instantly share code, notes, and snippets.

@athas
Created June 12, 2020 20:50
Show Gist options
  • Save athas/9f2fb45ae7b2d8b9b8f6e621fa5793f0 to your computer and use it in GitHub Desktop.
Save athas/9f2fb45ae7b2d8b9b8f6e621fa5793f0 to your computer and use it in GitHub Desktop.
# This default.nix builds a tarball containing a statically linked
# Futhark binary and some manpages. Likely to only work on linux.
#
# Just run 'nix-build' and fish the tarball out of 'result/'.
let
# Fetch the latest haskell.nix and import its default.nix
haskellNix = import (builtins.fetchTarball https://github.com/input-output-hk/haskell.nix/archive/master.tar.gz) {};
# haskell.nix provides access to the nixpkgs pins which are used by our CI, hence
# you will be more likely to get cache hits when using these.
# But you can also just use your own, e.g. '<nixpkgs>'
nixpkgsSrc = haskellNix.sources.nixpkgs-2003;
# haskell.nix provides some arguments to be passed to nixpkgs, including some patches
# and also the haskell.nix functionality itself as an overlay.
nixpkgsArgs = haskellNix.nixpkgsArgs;
in
{ pkgs ? import nixpkgsSrc nixpkgsArgs,
haskellCompiler ? "ghc883",
suffix ? "nightly",
commit ? "" }:
let futharkProject =
pkgs.haskell-nix.cabalProject {
# 'cleanGit' cleans a source directory based on the files known by git
src = pkgs.haskell-nix.haskellLib.cleanGit { name = "futhark"; src = ./.; };
compiler-nix-name = haskellCompiler;
};
futhark =
futharkProject.components.exes.futhark;
in pkgs.stdenv.mkDerivation rec {
name = "futhark-" + suffix;
version = futhark.version;
src = tools/release;
buildInputs = [ futhark ];
buildPhase = ''
cp -r skeleton futhark-${suffix}
cp -r ${futhark}/bin futhark-${suffix}/bin
mkdir -p futhark-${suffix}/share
cp -r ${futhark}/share/man futhark-${suffix}/share/
chmod +w -R futhark-${suffix}
cp ${futhark}/share/futhark/LICENSE futhark-${suffix}/
[ "${commit}" ] && echo "${commit}" > futhark-${suffix}/commit-id
tar -Jcf futhark-${suffix}.tar.xz futhark-${suffix}
'';
installPhase = ''
mkdir -p $out
cp futhark-${suffix}.tar.xz $out/futhark-${suffix}.tar.xz
'';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment