2020-10-27 15:55:49 +03:00
|
|
|
/* Examples
|
|
|
|
|
|
|
|
Shared urbit and urbit-worker binaries:
|
|
|
|
|
|
|
|
$ nix-build -A urbit
|
|
|
|
|
|
|
|
Static urbit and urbit-worker binaries:
|
|
|
|
|
2020-11-06 11:47:11 +03:00
|
|
|
$ nix-build -A urbit --arg enableStatic true
|
2020-10-27 15:55:49 +03:00
|
|
|
|
2020-10-30 15:02:27 +03:00
|
|
|
Note that on linux the previous command is equivalent to:
|
|
|
|
|
|
|
|
$ nix-build -A urbit --argstr crossSystem x86_64-unknown-linux-musl \
|
2020-12-14 20:07:42 +03:00
|
|
|
--arg enableStatic true
|
2020-10-30 15:02:27 +03:00
|
|
|
|
2020-10-27 15:55:49 +03:00
|
|
|
Static urbit-king binary:
|
|
|
|
|
|
|
|
$ nix-build -A hs.urbit-king.components.exes.urbit-king --arg enableStatic true
|
|
|
|
|
|
|
|
Static release tarball:
|
|
|
|
|
|
|
|
$ nix-build -A tarball --arg enableStatic true
|
|
|
|
|
|
|
|
Build a pill:
|
|
|
|
|
|
|
|
$ nix-build -A ivory.build
|
|
|
|
$ nix-build -A brass.build
|
|
|
|
$ nix-build -A solid.build
|
|
|
|
|
2020-11-11 10:48:53 +03:00
|
|
|
Run the king-haskell checks (.tests are _build_ the test code, .checks _runs_):
|
2020-10-29 18:20:41 +03:00
|
|
|
|
|
|
|
$ nix-build -A hs.urbit-king.checks.urbit-king-tests
|
|
|
|
|
2020-10-27 15:55:49 +03:00
|
|
|
Build a specific Haskell package from ./pkg/hs:
|
|
|
|
|
|
|
|
$ nix-build -A hs.urbit-noun.components.library
|
|
|
|
$ nix-build -A hs.urbit-atom.components.benchmarks.urbit-atom-bench
|
|
|
|
$ nix-build -A hs.urbit-atom.components.tests.urbit-atom-tests
|
|
|
|
*/
|
|
|
|
|
|
|
|
# The build system where packages will be _built_.
|
|
|
|
{ system ? builtins.currentSystem
|
|
|
|
# The host system where packages will _run_.
|
|
|
|
, crossSystem ? null
|
|
|
|
# Additional sources.json overrides.
|
|
|
|
, sources ? { }
|
|
|
|
# Additional nixpkgs.config overrides.
|
|
|
|
, config ? { }
|
|
|
|
# Additional nixpkgs.overlays.
|
|
|
|
, overlays ? [ ]
|
|
|
|
# Overlays to apply to the last package set in cross compilation.
|
|
|
|
, crossOverlays ? [ ]
|
|
|
|
# Whether to use pkgs.pkgsStatic.* to obtain statically linked package
|
|
|
|
# dependencies - ie. when building fully-static libraries or executables.
|
2020-10-30 15:02:27 +03:00
|
|
|
, enableStatic ? false }:
|
2020-10-27 15:55:49 +03:00
|
|
|
|
2018-11-09 00:11:43 +03:00
|
|
|
let
|
|
|
|
|
2020-11-06 11:47:11 +03:00
|
|
|
pkgsNative = import ./nix/default.nix { inherit system; };
|
|
|
|
|
|
|
|
pkgsCross = import ./nix/default.nix {
|
2020-10-30 15:02:27 +03:00
|
|
|
inherit system sources config overlays crossOverlays;
|
|
|
|
|
2020-11-06 11:47:11 +03:00
|
|
|
# If we're running on linux and crossSystem is unspecified but
|
|
|
|
# enableStatic = true - set the crossSystem to musl64.
|
2020-10-30 15:02:27 +03:00
|
|
|
crossSystem =
|
|
|
|
if system == "x86_64-linux" && crossSystem == null && enableStatic then
|
|
|
|
"x86_64-unknown-linux-musl"
|
|
|
|
else
|
|
|
|
crossSystem;
|
2020-10-27 15:55:49 +03:00
|
|
|
};
|
|
|
|
|
2020-11-06 11:47:11 +03:00
|
|
|
# Use nixpkgs' top-level/static overlay if enableStatic = true.
|
|
|
|
pkgsStatic = if enableStatic then pkgsCross.pkgsStatic else pkgsCross;
|
2020-10-27 15:55:49 +03:00
|
|
|
|
|
|
|
# Enrich the global package set with our local functions and packages.
|
2020-11-06 11:47:11 +03:00
|
|
|
# Cross vs static build dependencies can be selectively overridden for
|
|
|
|
# inputs like python and haskell-nix
|
2020-10-27 15:55:49 +03:00
|
|
|
callPackage =
|
2020-11-06 11:47:11 +03:00
|
|
|
pkgsNative.lib.callPackageWith (pkgsStatic // libLocal // pkgsLocal);
|
|
|
|
|
|
|
|
# Local library import-from-derivation functions such as fetchGitHubLFS, etc.
|
|
|
|
libLocal = pkgsNative.callPackage ./nix/lib { };
|
2020-10-27 15:55:49 +03:00
|
|
|
|
|
|
|
# Local vendored packages defined in ./pkg.
|
|
|
|
# For non-vendored nixpkgs specific package overrides, see ./nix/overlays.
|
2020-11-06 11:47:11 +03:00
|
|
|
pkgsLocal = {
|
2020-10-27 15:55:49 +03:00
|
|
|
argon2u = callPackage ./nix/pkgs/argon2u { };
|
|
|
|
|
|
|
|
ca-bundle = callPackage ./nix/pkgs/ca-bundle { };
|
|
|
|
|
|
|
|
ed25519 = callPackage ./nix/pkgs/ed25519 { };
|
|
|
|
|
|
|
|
ent = callPackage ./nix/pkgs/ent { };
|
|
|
|
|
|
|
|
ge-additions = callPackage ./nix/pkgs/ge-additions { };
|
|
|
|
|
|
|
|
libaes_siv = callPackage ./nix/pkgs/libaes_siv { };
|
|
|
|
|
|
|
|
libscrypt = callPackage ./nix/pkgs/libscrypt { };
|
|
|
|
|
|
|
|
murmur3 = callPackage ./nix/pkgs/murmur3 { };
|
|
|
|
|
|
|
|
softfloat3 = callPackage ./nix/pkgs/softfloat3 { };
|
|
|
|
|
2020-11-06 11:47:11 +03:00
|
|
|
herb = callPackage ./nix/pkgs/herb { inherit (pkgsCross) python; };
|
2020-10-27 15:55:49 +03:00
|
|
|
|
|
|
|
arvo = callPackage ./nix/pkgs/arvo { };
|
|
|
|
|
|
|
|
ivory = callPackage ./nix/pkgs/pill/ivory.nix { };
|
|
|
|
|
|
|
|
brass = callPackage ./nix/pkgs/pill/brass.nix { };
|
|
|
|
|
|
|
|
solid = callPackage ./nix/pkgs/pill/solid.nix { };
|
|
|
|
|
|
|
|
urbit = callPackage ./nix/pkgs/urbit { inherit enableStatic; };
|
|
|
|
|
2021-01-09 19:04:45 +03:00
|
|
|
docker-image = callPackage ./nix/pkgs/docker-image { };
|
|
|
|
|
2020-10-27 15:55:49 +03:00
|
|
|
hs = callPackage ./nix/pkgs/hs {
|
2020-10-28 20:19:53 +03:00
|
|
|
inherit enableStatic;
|
2020-11-06 11:47:11 +03:00
|
|
|
inherit (pkgsCross) haskell-nix;
|
2020-10-27 15:55:49 +03:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
# Additional top-level packages and attributes exposed for convenience.
|
2020-11-06 11:47:11 +03:00
|
|
|
pkgsExtra = with pkgsLocal; rec {
|
2020-11-11 10:48:53 +03:00
|
|
|
# Expose packages with local customisations (like patches) for dev access.
|
2020-11-06 11:47:11 +03:00
|
|
|
inherit (pkgsCross) libsigsegv;
|
2020-10-27 15:55:49 +03:00
|
|
|
|
2020-11-11 10:48:53 +03:00
|
|
|
# Collect haskell check (aka "run the tests") attributes so we can run every
|
|
|
|
# test for our local haskell packages, similar to the urbit-tests attribute.
|
|
|
|
hs-checks = (pkgsNative.recurseIntoAttrs
|
|
|
|
(libLocal.collectHaskellComponents pkgsLocal.hs)).checks;
|
|
|
|
|
2020-10-27 15:55:49 +03:00
|
|
|
urbit-debug = urbit.override { enableDebug = true; };
|
2020-11-06 11:47:11 +03:00
|
|
|
urbit-tests = libLocal.testFakeShip {
|
2020-11-04 13:12:49 +03:00
|
|
|
inherit herb;
|
2020-11-21 02:21:50 +03:00
|
|
|
inherit arvo;
|
2020-10-27 15:55:49 +03:00
|
|
|
|
2020-11-04 13:12:49 +03:00
|
|
|
urbit = urbit-debug;
|
2020-10-27 15:55:49 +03:00
|
|
|
pill = solid.lfs;
|
|
|
|
};
|
|
|
|
|
|
|
|
ivory-ropsten = ivory.override { arvo = arvo.ropsten; };
|
|
|
|
brass-ropsten = brass.override { arvo = arvo.ropsten; };
|
|
|
|
|
2020-10-28 12:48:44 +03:00
|
|
|
# Create a .tgz of the primary binaries.
|
|
|
|
tarball = let
|
|
|
|
name = "urbit-v${urbit.version}-${urbit.system}";
|
|
|
|
urbit-king = hs.urbit-king.components.exes.urbit-king;
|
2020-11-06 11:47:11 +03:00
|
|
|
in libLocal.makeReleaseTarball {
|
2020-10-28 12:48:44 +03:00
|
|
|
inherit name;
|
|
|
|
|
2020-10-27 15:55:49 +03:00
|
|
|
contents = {
|
2020-10-28 12:48:44 +03:00
|
|
|
"${name}/urbit" = "${urbit}/bin/urbit";
|
|
|
|
"${name}/urbit-worker" = "${urbit}/bin/urbit-worker";
|
2020-12-08 13:10:26 +03:00
|
|
|
# temporarily removed for compatibility reasons
|
|
|
|
# "${name}/urbit-king" = "${urbit-king}/bin/urbit-king";
|
2020-10-27 15:55:49 +03:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2021-01-13 15:33:09 +03:00
|
|
|
inherit (pkgsNative) skopeo;
|
|
|
|
|
2020-10-27 15:55:49 +03:00
|
|
|
# A convenience function for constructing a shell.nix for any of the
|
2020-11-11 10:48:53 +03:00
|
|
|
# pkgsLocal derivations by automatically propagating any dependencies
|
|
|
|
# to the nix-shell.
|
2020-10-27 15:55:49 +03:00
|
|
|
#
|
|
|
|
# Example:
|
|
|
|
#
|
|
|
|
# let
|
|
|
|
# pkgs = import ./default.nix { };
|
|
|
|
# in pkgs.shellFor {
|
|
|
|
# packages = ps: [
|
|
|
|
# ps.urbit
|
|
|
|
# ps.herb
|
|
|
|
# ];
|
|
|
|
# }
|
|
|
|
#
|
|
|
|
shellFor = { name, packages, ... }@attrs:
|
2020-11-12 04:26:29 +03:00
|
|
|
pkgsNative.mkShell ({
|
2020-11-06 11:47:11 +03:00
|
|
|
inputsFrom = packages pkgsLocal;
|
2020-10-27 15:55:49 +03:00
|
|
|
} // builtins.removeAttrs attrs [ "packages" ]);
|
|
|
|
};
|
2018-11-09 00:11:43 +03:00
|
|
|
|
2020-10-27 15:55:49 +03:00
|
|
|
# Ensure that in the case of cross-compilation we're not statically linking
|
|
|
|
# against glibc. This is typically a sign that crossSystem is misconfigured.
|
|
|
|
checkPlatform =
|
2020-11-06 11:47:11 +03:00
|
|
|
if enableStatic && pkgsCross.stdenv.hostPlatform.libc == "glibc" then
|
2020-10-27 15:55:49 +03:00
|
|
|
builtins.trace "warning: statically linking against glibc."
|
|
|
|
else
|
2020-11-06 11:47:11 +03:00
|
|
|
pkgsNative.lib.id;
|
2018-11-09 00:11:43 +03:00
|
|
|
|
2020-11-06 11:47:11 +03:00
|
|
|
in checkPlatform (pkgsLocal // pkgsExtra)
|