build: default crossSystem to musl64 on linux if enableStatic

This commit is contained in:
Brendan Hay 2020-10-30 13:02:27 +01:00
parent 58094c265c
commit 3e31aae7b9
No known key found for this signature in database
GPG Key ID: 80E915C54A7C457D
2 changed files with 35 additions and 32 deletions

50
ci.nix
View File

@ -48,31 +48,21 @@ let
extension = "pill";
};
systems = lib.filterAttrs (_: v: builtins.elem v.system supportedSystems) {
linux = {
system = "x86_64-linux";
crossSystem = lib.systems.examples.musl64;
systems = lib.filterAttrs (_: v: builtins.elem v supportedSystems) {
linux = "x86_64-linux";
darwin = "x86_64-darwin";
};
darwin = {
system = "x86_64-darwin";
crossSystem = null;
};
};
in localLib.dimension "system" systems (systemName:
{ system, crossSystem }:
in localLib.dimension "system" systems (systemName: system:
let
# Shared libraries/executables for the build (current) system.
localPackages = import ./default.nix {
dynamicPackages = import ./default.nix {
inherit system;
enableStatic = false;
};
# Static libraries/executables for the host (cross) system.
staticPackages = import ./default.nix {
inherit system crossSystem;
inherit system;
enableStatic = true;
};
@ -82,23 +72,23 @@ in localLib.dimension "system" systems (systemName:
haskell-nix.haskellLib.selectProjectPackages staticPackages.hs;
# The top-level set of attributes to build on ci.
finalPackages = localPackages // rec {
finalPackages = dynamicPackages // rec {
# Replace some top-level attributes with their static variant.
inherit (staticPackages) urbit tarball;
# Expose the nix-shell derivation as a sanity check.
shell = import ./shell.nix;
# Replace the top-level urbit attribute with the static variant.
urbit = staticPackages.urbit;
# Replace the top-level tarball attribute with the static variant.
tarball = staticPackages.tarball;
# Replace the localPackages.hs attribute with the individual components
# Replace the .hs attribute with the individual collections of components
# displayed as top-level attributes:
#
# <system>.hs.library.[...]
# <system>.hs.checks.[...]
# <system>.hs.tests.[...]
# <system>.hs.bencharmks.[...]
# <system>.hs.benchmarks.[...]
# ...
#
# Note that .checks are the actual _execution_ of the tests.
hs = localLib.collectHaskellComponents haskellPackages;
# Push the tarball to the remote google storage bucket.
@ -111,12 +101,12 @@ in localLib.dimension "system" systems (systemName:
# Replace top-level pill attributes with push to google storage variants.
} // lib.optionalAttrs (system == "x86_64-linux") {
ivory = pushPill "ivory" localPackages.ivory;
brass = pushPill "brass" localPackages.brass;
solid = pushPill "solid" localPackages.solid;
ivory = pushPill "ivory" dynamicPackages.ivory;
brass = pushPill "brass" dynamicPackages.brass;
solid = pushPill "solid" dynamicPackages.solid;
ivory-ropsten = pushPill "ivory-ropsten" localPackages.ivory-ropsten;
brass-ropsten = pushPill "brass-ropsten" localPackages.brass-ropsten;
ivory-ropsten = pushPill "ivory-ropsten" dynamicPackages.ivory-ropsten;
brass-ropsten = pushPill "brass-ropsten" dynamicPackages.brass-ropsten;
};
# Filter derivations that have meta.platform missing the current system,

View File

@ -8,6 +8,11 @@
$ nix-build -A urbit --arg enableSatic true
Note that on linux the previous command is equivalent to:
$ nix-build -A urbit --argstr crossSystem x86_64-unknown-linux-musl \
--arg enableSatic true
Static urbit-king binary:
$ nix-build -A hs.urbit-king.components.exes.urbit-king --arg enableStatic true
@ -47,12 +52,20 @@
, crossOverlays ? [ ]
# Whether to use pkgs.pkgsStatic.* to obtain statically linked package
# dependencies - ie. when building fully-static libraries or executables.
, enableStatic ? crossSystem != null }:
, enableStatic ? false }:
let
pkgs = import ./nix/default.nix {
inherit system crossSystem sources config overlays crossOverlays;
inherit system sources config overlays crossOverlays;
crossSystem =
# If we're running on linux and crossSystem is unspecified but static
# builds are requested - set the crossSystem to musl64.
if system == "x86_64-linux" && crossSystem == null && enableStatic then
"x86_64-unknown-linux-musl"
else
crossSystem;
};
# Local library import from derivation functions such as fetchGitHubLFS, etc.