2021-08-26 03:30:35 +03:00
|
|
|
|
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 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
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
# 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
|
2021-12-08 11:53:31 +03:00
|
|
|
# dependencies - ie. when building fully-static libraries or executables.
|
2022-05-26 04:52:09 +03:00
|
|
|
, enableStatic ? false
|
|
|
|
# release channel (when static)
|
|
|
|
, verePace ? "" }:
|
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
|
2022-06-05 11:12:12 +03:00
|
|
|
if system == "aarch64-linux" && crossSystem == null && enableStatic then
|
|
|
|
"aarch64-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
|
2021-12-08 11:53:31 +03:00
|
|
|
# inputs like python etc.
|
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
|
|
|
ca-bundle = callPackage ./nix/pkgs/ca-bundle { };
|
|
|
|
|
|
|
|
ent = callPackage ./nix/pkgs/ent { };
|
|
|
|
|
2021-08-03 23:46:40 +03:00
|
|
|
libaes_siv = callPackage ./nix/pkgs/libaes_siv { inherit (pkgsNative) cmake; };
|
2020-10-27 15:55:49 +03:00
|
|
|
|
|
|
|
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 { };
|
|
|
|
|
2021-09-26 22:26:48 +03:00
|
|
|
marsSources = callPackage ./nix/pkgs/marsSources { };
|
|
|
|
|
2021-08-06 17:47:49 +03:00
|
|
|
urcrypt = callPackage ./nix/pkgs/urcrypt { inherit enableStatic; };
|
2021-08-20 03:03:19 +03:00
|
|
|
|
2021-01-09 19:04:45 +03:00
|
|
|
docker-image = callPackage ./nix/pkgs/docker-image { };
|
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.
|
2021-12-08 18:08:37 +03:00
|
|
|
inherit (pkgsStatic) libsigsegv lmdb;
|
2020-10-27 15:55:49 +03:00
|
|
|
|
2020-11-06 11:47:11 +03:00
|
|
|
urbit-tests = libLocal.testFakeShip {
|
2020-11-21 02:21:50 +03:00
|
|
|
inherit arvo;
|
2020-10-27 15:55:49 +03:00
|
|
|
|
|
|
|
pill = solid.lfs;
|
|
|
|
};
|
|
|
|
|
2022-10-26 06:01:32 +03:00
|
|
|
ivory-goerli = ivory.override { arvo = arvo.goerli; };
|
|
|
|
brass-goerli = brass.override { arvo = arvo.goerli; };
|
2020-10-27 15:55:49 +03:00
|
|
|
|
2020-10-28 12:48:44 +03:00
|
|
|
# Create a .tgz of the primary binaries.
|
|
|
|
tarball = let
|
|
|
|
name = "urbit-v${urbit.version}-${urbit.system}";
|
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";
|
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)
|