2021-01-09 10:05:03 +00:00
|
|
|
{ lib, fetchurl, fetchFromGitHub, fetchpatch, callPackage
|
2020-04-24 23:36:52 +00:00
|
|
|
, storeDir ? "/nix/store"
|
|
|
|
, stateDir ? "/nix/var"
|
|
|
|
, confDir ? "/etc"
|
|
|
|
, boehmgc
|
2021-02-05 17:12:51 +00:00
|
|
|
, Security
|
2020-04-24 23:36:52 +00:00
|
|
|
}:
|
|
|
|
|
|
|
|
let
|
|
|
|
|
|
|
|
common =
|
2021-01-09 10:05:03 +00:00
|
|
|
{ lib, stdenv, perl, curl, bzip2, sqlite, openssl ? null, xz
|
2021-03-20 04:20:00 +00:00
|
|
|
, bash, coreutils, util-linuxMinimal, gzip, gnutar
|
2021-04-12 18:23:04 +00:00
|
|
|
, pkg-config, boehmgc, libsodium, brotli, boost, editline, nlohmann_json
|
2020-10-27 00:29:36 +00:00
|
|
|
, autoreconfHook, autoconf-archive, bison, flex
|
2021-03-12 07:09:13 +00:00
|
|
|
, jq, libarchive, libcpuid
|
2020-10-27 00:29:36 +00:00
|
|
|
, lowdown, mdbook
|
2020-05-15 21:57:56 +00:00
|
|
|
# Used by tests
|
2021-04-05 15:23:46 +00:00
|
|
|
, gtest
|
2020-04-24 23:36:52 +00:00
|
|
|
, busybox-sandbox-shell
|
|
|
|
, storeDir
|
|
|
|
, stateDir
|
|
|
|
, confDir
|
2021-05-20 23:08:51 +00:00
|
|
|
, withLibseccomp ? lib.meta.availableOn stdenv.hostPlatform libseccomp, libseccomp
|
2021-03-09 03:18:52 +00:00
|
|
|
, withAWS ? !enableStatic && (stdenv.isLinux || stdenv.isDarwin), aws-sdk-cpp
|
2021-01-05 17:05:55 +00:00
|
|
|
, enableStatic ? stdenv.hostPlatform.isStatic
|
2021-06-28 23:13:55 +00:00
|
|
|
, enableDocumentation ? lib.versionOlder version "2.4pre" ||
|
|
|
|
stdenv.hostPlatform == stdenv.buildPlatform
|
2021-04-13 19:44:15 +00:00
|
|
|
, pname, version, suffix ? "", src
|
2021-01-09 10:05:03 +00:00
|
|
|
, patches ? [ ]
|
2020-04-24 23:36:52 +00:00
|
|
|
}:
|
|
|
|
let
|
|
|
|
sh = busybox-sandbox-shell;
|
|
|
|
nix = stdenv.mkDerivation rec {
|
2021-04-13 19:44:15 +00:00
|
|
|
inherit pname version src patches;
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2020-11-03 02:18:15 +00:00
|
|
|
is24 = lib.versionAtLeast version "2.4pre";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
VERSION_SUFFIX = suffix;
|
|
|
|
|
2021-06-28 23:13:55 +00:00
|
|
|
outputs =
|
|
|
|
[ "out" "dev" ]
|
|
|
|
++ lib.optionals enableDocumentation [ "man" "doc" ];
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2021-08-05 21:33:18 +00:00
|
|
|
hardeningEnable = [ "pie" ];
|
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
nativeBuildInputs =
|
2021-02-05 17:12:51 +00:00
|
|
|
[ pkg-config ]
|
2021-04-05 15:23:46 +00:00
|
|
|
++ lib.optionals stdenv.isLinux [ util-linuxMinimal ]
|
2021-06-28 23:13:55 +00:00
|
|
|
++ lib.optionals (is24 && enableDocumentation) [
|
|
|
|
(lib.getBin lowdown) mdbook
|
|
|
|
]
|
2020-11-03 02:18:15 +00:00
|
|
|
++ lib.optionals is24
|
2020-10-27 00:29:36 +00:00
|
|
|
[ autoreconfHook
|
|
|
|
autoconf-archive
|
|
|
|
bison flex
|
|
|
|
jq
|
|
|
|
];
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
buildInputs =
|
2021-06-06 07:54:09 +00:00
|
|
|
[ curl libsodium openssl sqlite xz bzip2 nlohmann_json
|
2020-04-24 23:36:52 +00:00
|
|
|
brotli boost editline
|
|
|
|
]
|
2021-02-05 17:12:51 +00:00
|
|
|
++ lib.optionals stdenv.isDarwin [ Security ]
|
2021-04-05 15:23:46 +00:00
|
|
|
++ lib.optionals is24 [ libarchive gtest lowdown ]
|
2021-03-15 08:37:03 +00:00
|
|
|
++ lib.optional (is24 && stdenv.isx86_64) libcpuid
|
2020-04-24 23:36:52 +00:00
|
|
|
++ lib.optional withLibseccomp libseccomp
|
|
|
|
++ lib.optional withAWS
|
|
|
|
((aws-sdk-cpp.override {
|
|
|
|
apis = ["s3" "transfer"];
|
|
|
|
customMemoryManagement = false;
|
|
|
|
}).overrideDerivation (args: {
|
2021-01-09 10:05:03 +00:00
|
|
|
patches = args.patches or [] ++ [
|
|
|
|
./aws-sdk-cpp-TransferManager-ContentEncoding.patch
|
|
|
|
];
|
2020-04-24 23:36:52 +00:00
|
|
|
}));
|
|
|
|
|
|
|
|
propagatedBuildInputs = [ boehmgc ];
|
|
|
|
|
|
|
|
# Seems to be required when using std::atomic with 64-bit types
|
2020-06-18 07:06:33 +00:00
|
|
|
NIX_LDFLAGS =
|
|
|
|
# need to list libraries individually until
|
|
|
|
# https://github.com/NixOS/nix/commit/3e85c57a6cbf46d5f0fe8a89b368a43abd26daba
|
|
|
|
# is in a release
|
|
|
|
lib.optionalString enableStatic "-lssl -lbrotlicommon -lssh2 -lz -lnghttp2 -lcrypto"
|
|
|
|
|
|
|
|
# need to detect it here until
|
|
|
|
# https://github.com/NixOS/nix/commits/74b4737d8f0e1922ef5314a158271acf81cd79f8
|
|
|
|
# is in a release
|
|
|
|
+ lib.optionalString (stdenv.hostPlatform.system == "armv5tel-linux" || stdenv.hostPlatform.system == "armv6l-linux") "-latomic";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
preConfigure =
|
|
|
|
# Copy libboost_context so we don't get all of Boost in our closure.
|
|
|
|
# https://github.com/NixOS/nixpkgs/issues/45462
|
2020-06-18 07:06:33 +00:00
|
|
|
lib.optionalString (!enableStatic) ''
|
2020-04-24 23:36:52 +00:00
|
|
|
mkdir -p $out/lib
|
|
|
|
cp -pd ${boost}/lib/{libboost_context*,libboost_thread*,libboost_system*} $out/lib
|
|
|
|
rm -f $out/lib/*.a
|
|
|
|
${lib.optionalString stdenv.isLinux ''
|
|
|
|
chmod u+w $out/lib/*.so.*
|
|
|
|
patchelf --set-rpath $out/lib:${stdenv.cc.cc.lib}/lib $out/lib/libboost_thread.so.*
|
|
|
|
''}
|
|
|
|
'' +
|
2021-06-28 23:13:55 +00:00
|
|
|
# On all versions before c9f51e87057652db0013289a95deffba495b35e7, which
|
|
|
|
# removes config.nix entirely and is not present in 2.3.x, we need to
|
|
|
|
# patch around an issue where the Nix configure step pulls in the build
|
|
|
|
# system's bash and other utilities when cross-compiling.
|
2021-01-05 17:05:55 +00:00
|
|
|
lib.optionalString (
|
2021-06-28 23:13:55 +00:00
|
|
|
stdenv.buildPlatform != stdenv.hostPlatform && !is24
|
2021-01-05 17:05:55 +00:00
|
|
|
) ''
|
2020-04-24 23:36:52 +00:00
|
|
|
mkdir tmp/
|
|
|
|
substitute corepkgs/config.nix.in tmp/config.nix.in \
|
|
|
|
--subst-var-by bash ${bash}/bin/bash \
|
|
|
|
--subst-var-by coreutils ${coreutils}/bin \
|
|
|
|
--subst-var-by bzip2 ${bzip2}/bin/bzip2 \
|
|
|
|
--subst-var-by gzip ${gzip}/bin/gzip \
|
|
|
|
--subst-var-by xz ${xz}/bin/xz \
|
|
|
|
--subst-var-by tar ${gnutar}/bin/tar \
|
|
|
|
--subst-var-by tr ${coreutils}/bin/tr
|
|
|
|
mv tmp/config.nix.in corepkgs/config.nix.in
|
|
|
|
'';
|
|
|
|
|
|
|
|
configureFlags =
|
|
|
|
[ "--with-store-dir=${storeDir}"
|
|
|
|
"--localstatedir=${stateDir}"
|
|
|
|
"--sysconfdir=${confDir}"
|
|
|
|
"--enable-gc"
|
|
|
|
]
|
2021-06-28 23:13:55 +00:00
|
|
|
++ lib.optional (!enableDocumentation) "--disable-doc-gen"
|
2021-06-04 09:07:49 +00:00
|
|
|
++ lib.optionals (!is24) [
|
|
|
|
# option was removed in 2.4
|
|
|
|
"--disable-init-state"
|
|
|
|
]
|
2020-04-24 23:36:52 +00:00
|
|
|
++ lib.optionals stdenv.isLinux [
|
|
|
|
"--with-sandbox-shell=${sh}/bin/busybox"
|
|
|
|
]
|
|
|
|
++ lib.optional (
|
|
|
|
stdenv.hostPlatform != stdenv.buildPlatform && stdenv.hostPlatform ? nix && stdenv.hostPlatform.nix ? system
|
2021-02-05 17:12:51 +00:00
|
|
|
) "--with-system=${stdenv.hostPlatform.nix.system}"
|
2020-04-24 23:36:52 +00:00
|
|
|
# RISC-V support in progress https://github.com/seccomp/libseccomp/pull/50
|
|
|
|
++ lib.optional (!withLibseccomp) "--disable-seccomp-sandboxing";
|
|
|
|
|
2020-07-18 16:06:22 +00:00
|
|
|
makeFlags = [ "profiledir=$(out)/etc/profile.d" ]
|
|
|
|
++ lib.optional (stdenv.hostPlatform != stdenv.buildPlatform) "PRECOMPILE_HEADERS=0";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
installFlags = [ "sysconfdir=$(out)/etc" ];
|
|
|
|
|
|
|
|
doInstallCheck = true; # not cross
|
|
|
|
|
|
|
|
# socket path becomes too long otherwise
|
2021-03-20 04:20:00 +00:00
|
|
|
preInstallCheck = lib.optionalString stdenv.isDarwin ''
|
2020-04-24 23:36:52 +00:00
|
|
|
export TMPDIR=$NIX_BUILD_TOP
|
|
|
|
'';
|
|
|
|
|
|
|
|
separateDebugInfo = stdenv.isLinux;
|
|
|
|
|
|
|
|
enableParallelBuilding = true;
|
|
|
|
|
|
|
|
meta = {
|
|
|
|
description = "Powerful package manager that makes package management reliable and reproducible";
|
|
|
|
longDescription = ''
|
|
|
|
Nix is a powerful package manager for Linux and other Unix systems that
|
|
|
|
makes package management reliable and reproducible. It provides atomic
|
|
|
|
upgrades and rollbacks, side-by-side installation of multiple versions of
|
|
|
|
a package, multi-user package management and easy setup of build
|
|
|
|
environments.
|
|
|
|
'';
|
|
|
|
homepage = "https://nixos.org/";
|
2021-01-15 22:18:51 +00:00
|
|
|
license = lib.licenses.lgpl2Plus;
|
|
|
|
maintainers = [ lib.maintainers.eelco ];
|
|
|
|
platforms = lib.platforms.unix;
|
2021-06-28 23:13:55 +00:00
|
|
|
outputsToInstall = [ "out" ] ++ lib.optional enableDocumentation "man";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
passthru = {
|
2021-04-12 18:23:04 +00:00
|
|
|
perl-bindings = perl.pkgs.toPerlModule (stdenv.mkDerivation {
|
2020-04-24 23:36:52 +00:00
|
|
|
pname = "nix-perl";
|
|
|
|
inherit version;
|
|
|
|
|
|
|
|
inherit src;
|
|
|
|
|
|
|
|
postUnpack = "sourceRoot=$sourceRoot/perl";
|
|
|
|
|
|
|
|
# This is not cross-compile safe, don't have time to fix right now
|
|
|
|
# but noting for future travellers.
|
|
|
|
nativeBuildInputs =
|
2021-02-05 17:12:51 +00:00
|
|
|
[ perl pkg-config curl nix libsodium boost autoreconfHook autoconf-archive nlohmann_json ];
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
configureFlags =
|
2021-04-12 18:23:04 +00:00
|
|
|
[ "--with-dbi=${perl.pkgs.DBI}/${perl.libPrefix}"
|
|
|
|
"--with-dbd-sqlite=${perl.pkgs.DBDSQLite}/${perl.libPrefix}"
|
2020-04-24 23:36:52 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
preConfigure = "export NIX_STATE_DIR=$TMPDIR";
|
|
|
|
|
|
|
|
preBuild = "unset NIX_INDENT_MAKE";
|
2021-04-12 18:23:04 +00:00
|
|
|
});
|
2021-07-21 07:28:18 +00:00
|
|
|
inherit boehmgc;
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
in nix;
|
|
|
|
|
2021-07-21 07:28:18 +00:00
|
|
|
boehmgc_nix = boehmgc.override {
|
|
|
|
enableLargeConfig = true;
|
|
|
|
};
|
|
|
|
|
|
|
|
boehmgc_nixUnstable = boehmgc_nix.overrideAttrs (drv: {
|
|
|
|
patches = (drv.patches or []) ++ [
|
|
|
|
# Part of the GC solution in https://github.com/NixOS/nix/pull/4944
|
|
|
|
(fetchpatch {
|
2021-10-28 06:52:43 +00:00
|
|
|
url = "https://github.com/hercules-ci/nix/raw/5c58d84a76d96f269e3ff1e72c9c9ba5f68576af/boehmgc-coroutine-sp-fallback.diff";
|
2021-07-21 07:28:18 +00:00
|
|
|
sha256 = "sha256-JvnWVTlkltmQUs/0qApv/LPZ690UX1/2hEP+LYRwKbI=";
|
|
|
|
})
|
|
|
|
];
|
|
|
|
});
|
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
in rec {
|
|
|
|
|
|
|
|
nix = nixStable;
|
|
|
|
|
|
|
|
nixStable = callPackage common (rec {
|
2021-04-13 19:44:15 +00:00
|
|
|
pname = "nix";
|
2021-10-08 15:17:17 +00:00
|
|
|
version = "2.3.16";
|
2020-04-24 23:36:52 +00:00
|
|
|
src = fetchurl {
|
2021-04-13 19:44:15 +00:00
|
|
|
url = "https://nixos.org/releases/nix/${pname}-${version}/${pname}-${version}.tar.xz";
|
2021-10-08 15:17:17 +00:00
|
|
|
sha256 = "sha256-fuaBtp8FtSVJLSAsO+3Nne4ZYLuBj2JpD2xEk7fCqrw=";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
2021-07-21 07:28:18 +00:00
|
|
|
boehmgc = boehmgc_nix;
|
|
|
|
|
|
|
|
inherit storeDir stateDir confDir;
|
2020-04-24 23:36:52 +00:00
|
|
|
});
|
|
|
|
|
2021-10-08 15:17:17 +00:00
|
|
|
nix_2_4 = callPackage common (rec {
|
|
|
|
pname = "nix";
|
|
|
|
version = "2.4pre-rc1";
|
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "NixOS";
|
|
|
|
repo = "nix";
|
|
|
|
rev = version;
|
|
|
|
sha256 = "sha256-KOb8etMm5LksvT2l+CkvqzMO1bgmo9tJmyaNh0LvaR8=";
|
|
|
|
};
|
|
|
|
|
|
|
|
boehmgc = boehmgc_nixUnstable;
|
|
|
|
|
|
|
|
inherit storeDir stateDir confDir;
|
|
|
|
});
|
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
nixUnstable = lib.lowPrio (callPackage common rec {
|
2021-04-13 19:44:15 +00:00
|
|
|
pname = "nix";
|
2021-10-08 15:17:17 +00:00
|
|
|
version = "2.5${suffix}";
|
|
|
|
suffix = "pre20211007_${lib.substring 0 7 src.rev}";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "NixOS";
|
|
|
|
repo = "nix";
|
2021-10-08 15:17:17 +00:00
|
|
|
rev = "844dd901a7debe8b03ec93a7f717b6c4038dc572";
|
|
|
|
sha256 = "sha256-fe1B4lXkS6/UfpO0rJHwLC06zhOPrdSh4s9PmQ1JgPo=";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
2021-07-21 07:28:18 +00:00
|
|
|
boehmgc = boehmgc_nixUnstable;
|
|
|
|
|
|
|
|
inherit storeDir stateDir confDir;
|
2021-05-20 23:08:51 +00:00
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
}
|