mirror of
https://github.com/urbit/shrub.git
synced 2024-12-24 20:47:27 +03:00
52 lines
2.0 KiB
Nix
52 lines
2.0 KiB
Nix
# Run using:
|
|
#
|
|
# $(nix-build --no-link -A fullBuildScript)
|
|
{
|
|
stack2nix-output-path ? "custom-stack2nix-output.nix",
|
|
}:
|
|
let
|
|
cabalPackageName = "urbit-king";
|
|
compiler = "ghc865"; # matching stack.yaml
|
|
|
|
# Pin static-haskell-nix version.
|
|
static-haskell-nix =
|
|
if builtins.pathExists ../.in-static-haskell-nix
|
|
then toString ../. # for the case that we're in static-haskell-nix itself, so that CI always builds the latest version.
|
|
# Update this hash to use a different `static-haskell-nix` version:
|
|
else fetchTarball https://github.com/nh2/static-haskell-nix/archive/d1b20f35ec7d3761e59bd323bbe0cca23b3dfc82.tar.gz;
|
|
|
|
# Pin nixpkgs version
|
|
# By default to the one `static-haskell-nix` provides, but you may also give
|
|
# your own as long as it has the necessary patches, using e.g.
|
|
# pkgs = import (fetchTarball https://github.com/nh2/nixpkgs/archive/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa123.tar.gz) {};
|
|
pkgs = import "${static-haskell-nix}/nixpkgs.nix";
|
|
|
|
stack2nix-script = import "${static-haskell-nix}/static-stack2nix-builder/stack2nix-script.nix" {
|
|
inherit pkgs;
|
|
stack-project-dir = toString ./.; # where stack.yaml is
|
|
hackageSnapshot = "2020-01-20T00:00:00Z"; # pins e.g. extra-deps without hashes or revisions
|
|
};
|
|
|
|
static-stack2nix-builder = import "${static-haskell-nix}/static-stack2nix-builder/default.nix" {
|
|
normalPkgs = pkgs;
|
|
inherit cabalPackageName compiler stack2nix-output-path;
|
|
# disableOptimization = true; # for compile speed
|
|
};
|
|
|
|
# Full invocation, including pinning `nix` version itself.
|
|
fullBuildScript = pkgs.writeShellScript "stack2nix-and-build-script.sh" ''
|
|
set -eu -o pipefail
|
|
STACK2NIX_OUTPUT_PATH=$(${stack2nix-script})
|
|
export NIX_PATH=nixpkgs=${pkgs.path}
|
|
${pkgs.nix}/bin/nix-build --no-link -A static_package --argstr stack2nix-output-path "$STACK2NIX_OUTPUT_PATH" "$@"
|
|
'';
|
|
|
|
in
|
|
{
|
|
static_package = static-stack2nix-builder.static_package;
|
|
inherit fullBuildScript;
|
|
# For debugging:
|
|
inherit stack2nix-script;
|
|
inherit static-stack2nix-builder;
|
|
}
|