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

View File

@ -8,6 +8,11 @@
$ nix-build -A urbit --arg enableSatic true $ 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: Static urbit-king binary:
$ nix-build -A hs.urbit-king.components.exes.urbit-king --arg enableStatic true $ nix-build -A hs.urbit-king.components.exes.urbit-king --arg enableStatic true
@ -47,12 +52,20 @@
, crossOverlays ? [ ] , crossOverlays ? [ ]
# Whether to use pkgs.pkgsStatic.* to obtain statically linked package # Whether to use pkgs.pkgsStatic.* to obtain statically linked package
# dependencies - ie. when building fully-static libraries or executables. # dependencies - ie. when building fully-static libraries or executables.
, enableStatic ? crossSystem != null }: , enableStatic ? false }:
let let
pkgs = import ./nix/default.nix { 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. # Local library import from derivation functions such as fetchGitHubLFS, etc.