2020-12-26 11:53:05 +01:00
|
|
|
{ lib, fetchurl, fetchFromGitHub, fetchpatch, callPackage
|
2004-03-31 12:19:01 +02:00
|
|
|
, storeDir ? "/nix/store"
|
|
|
|
, stateDir ? "/nix/var"
|
2017-05-03 15:04:52 +02:00
|
|
|
, confDir ? "/etc"
|
2020-01-04 22:35:53 +01:00
|
|
|
, boehmgc
|
2021-01-22 15:50:16 +01:00
|
|
|
, Security
|
2004-03-31 12:19:01 +02:00
|
|
|
}:
|
2004-02-16 17:54:01 +01:00
|
|
|
|
2015-07-30 12:01:40 +02:00
|
|
|
let
|
2010-08-17 17:21:42 +02:00
|
|
|
|
2019-03-10 18:30:54 +01:00
|
|
|
common =
|
2020-12-26 11:50:49 +01:00
|
|
|
{ lib, stdenv, perl, curl, bzip2, sqlite, openssl ? null, xz
|
2021-03-22 23:49:22 +01:00
|
|
|
, bash, coreutils, util-linuxMinimal, gzip, gnutar
|
2019-04-21 21:00:46 +02:00
|
|
|
, pkg-config, boehmgc, libsodium, brotli, boost, editline, nlohmann_json
|
2020-10-21 12:52:48 +02:00
|
|
|
, autoreconfHook, autoconf-archive, bison, flex
|
2021-03-02 00:10:19 +01:00
|
|
|
, jq, libarchive, libcpuid
|
2020-10-21 12:52:48 +02:00
|
|
|
, lowdown, mdbook
|
2020-05-12 14:44:11 +02:00
|
|
|
# Used by tests
|
2021-03-14 19:03:18 +01:00
|
|
|
, gtest
|
2019-03-10 18:30:54 +01:00
|
|
|
, busybox-sandbox-shell
|
|
|
|
, storeDir
|
|
|
|
, stateDir
|
|
|
|
, confDir
|
2021-02-25 17:21:13 +01:00
|
|
|
, withLibseccomp ? lib.meta.availableOn stdenv.hostPlatform libseccomp, libseccomp
|
2021-03-05 03:22:23 +01:00
|
|
|
, withAWS ? !enableStatic && (stdenv.isLinux || stdenv.isDarwin), aws-sdk-cpp
|
2020-12-20 07:11:26 +01:00
|
|
|
, enableStatic ? stdenv.hostPlatform.isStatic
|
2021-06-05 10:56:28 +02:00
|
|
|
, enableDocumentation ? lib.versionOlder version "2.4pre" ||
|
|
|
|
stdenv.hostPlatform == stdenv.buildPlatform
|
2021-04-13 13:10:56 +02:00
|
|
|
, pname, version, suffix ? "", src
|
2020-12-26 11:53:05 +01:00
|
|
|
, patches ? [ ]
|
2019-03-10 18:30:54 +01:00
|
|
|
}:
|
|
|
|
let
|
|
|
|
sh = busybox-sandbox-shell;
|
|
|
|
nix = stdenv.mkDerivation rec {
|
2021-04-13 13:10:56 +02:00
|
|
|
inherit pname version src patches;
|
2018-09-25 14:46:36 +02:00
|
|
|
|
2020-11-02 22:02:59 +01:00
|
|
|
is24 = lib.versionAtLeast version "2.4pre";
|
2021-12-11 03:19:17 +01:00
|
|
|
is25 = lib.versionAtLeast version "2.5pre";
|
2018-09-25 14:46:36 +02:00
|
|
|
|
2020-02-11 16:33:18 +01:00
|
|
|
VERSION_SUFFIX = suffix;
|
2018-09-25 14:46:36 +02:00
|
|
|
|
2021-06-05 10:56:28 +02:00
|
|
|
outputs =
|
|
|
|
[ "out" "dev" ]
|
|
|
|
++ lib.optionals enableDocumentation [ "man" "doc" ];
|
2018-09-25 14:46:36 +02:00
|
|
|
|
2021-05-23 20:45:20 +02:00
|
|
|
hardeningEnable = [ "pie" ];
|
|
|
|
|
2018-09-25 14:46:36 +02:00
|
|
|
nativeBuildInputs =
|
2021-01-17 10:17:16 +01:00
|
|
|
[ pkg-config ]
|
2021-04-02 10:51:12 +02:00
|
|
|
++ lib.optionals stdenv.isLinux [ util-linuxMinimal ]
|
2021-06-05 10:56:28 +02:00
|
|
|
++ lib.optionals (is24 && enableDocumentation) [
|
|
|
|
(lib.getBin lowdown) mdbook
|
|
|
|
]
|
2020-11-02 22:02:59 +01:00
|
|
|
++ lib.optionals is24
|
2020-10-21 12:52:48 +02:00
|
|
|
[ autoreconfHook
|
|
|
|
autoconf-archive
|
|
|
|
bison flex
|
|
|
|
jq
|
|
|
|
];
|
2018-09-25 14:46:36 +02:00
|
|
|
|
2020-04-03 23:04:04 +02:00
|
|
|
buildInputs =
|
2021-11-11 11:45:26 +01:00
|
|
|
[ curl libsodium openssl sqlite xz bzip2
|
2020-04-03 23:04:04 +02:00
|
|
|
brotli boost editline
|
|
|
|
]
|
2021-01-22 15:50:16 +01:00
|
|
|
++ lib.optionals stdenv.isDarwin [ Security ]
|
2021-03-14 19:03:18 +01:00
|
|
|
++ lib.optionals is24 [ libarchive gtest lowdown ]
|
2021-03-12 13:22:37 +01:00
|
|
|
++ lib.optional (is24 && stdenv.isx86_64) libcpuid
|
2018-09-25 14:46:36 +02:00
|
|
|
++ lib.optional withLibseccomp libseccomp
|
2020-04-03 23:04:04 +02:00
|
|
|
++ lib.optional withAWS
|
2018-09-25 14:46:36 +02:00
|
|
|
((aws-sdk-cpp.override {
|
|
|
|
apis = ["s3" "transfer"];
|
|
|
|
customMemoryManagement = false;
|
|
|
|
}).overrideDerivation (args: {
|
2020-12-26 11:50:49 +01:00
|
|
|
patches = args.patches or [] ++ [
|
|
|
|
./aws-sdk-cpp-TransferManager-ContentEncoding.patch
|
|
|
|
];
|
2018-09-25 14:46:36 +02:00
|
|
|
}));
|
|
|
|
|
|
|
|
propagatedBuildInputs = [ boehmgc ];
|
|
|
|
|
2021-11-03 22:39:53 +01:00
|
|
|
NIX_LDFLAGS = lib.optionals (!is24) [
|
2019-09-29 16:32:56 +02:00
|
|
|
# https://github.com/NixOS/nix/commit/3e85c57a6cbf46d5f0fe8a89b368a43abd26daba
|
2021-11-03 22:39:53 +01:00
|
|
|
(lib.optionalString enableStatic "-lssl -lbrotlicommon -lssh2 -lz -lnghttp2 -lcrypto")
|
2019-09-29 16:32:56 +02:00
|
|
|
# https://github.com/NixOS/nix/commits/74b4737d8f0e1922ef5314a158271acf81cd79f8
|
2021-11-03 22:39:53 +01:00
|
|
|
(lib.optionalString (stdenv.hostPlatform.system == "armv5tel-linux" || stdenv.hostPlatform.system == "armv6l-linux") "-latomic")
|
|
|
|
];
|
2018-09-25 14:46:36 +02:00
|
|
|
|
|
|
|
preConfigure =
|
|
|
|
# Copy libboost_context so we don't get all of Boost in our closure.
|
|
|
|
# https://github.com/NixOS/nixpkgs/issues/45462
|
2019-09-29 16:32:56 +02:00
|
|
|
lib.optionalString (!enableStatic) ''
|
2020-03-02 13:07:42 +01: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-04 15:32:02 +02: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.
|
2020-12-31 19:48:42 +01:00
|
|
|
lib.optionalString (
|
2021-06-04 15:32:02 +02:00
|
|
|
stdenv.buildPlatform != stdenv.hostPlatform && !is24
|
2020-12-31 19:48:42 +01:00
|
|
|
) ''
|
2020-03-02 13:04:31 +01: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
|
|
|
|
'';
|
2018-09-25 14:46:36 +02:00
|
|
|
|
|
|
|
configureFlags =
|
|
|
|
[ "--with-store-dir=${storeDir}"
|
|
|
|
"--localstatedir=${stateDir}"
|
|
|
|
"--sysconfdir=${confDir}"
|
|
|
|
"--enable-gc"
|
|
|
|
]
|
2021-06-05 10:56:28 +02:00
|
|
|
++ lib.optional (!enableDocumentation) "--disable-doc-gen"
|
2021-06-01 19:15:55 +02:00
|
|
|
++ lib.optionals (!is24) [
|
|
|
|
# option was removed in 2.4
|
|
|
|
"--disable-init-state"
|
|
|
|
]
|
2020-04-03 23:04:04 +02:00
|
|
|
++ lib.optionals stdenv.isLinux [
|
2018-09-25 14:46:36 +02:00
|
|
|
"--with-sandbox-shell=${sh}/bin/busybox"
|
|
|
|
]
|
|
|
|
++ lib.optional (
|
|
|
|
stdenv.hostPlatform != stdenv.buildPlatform && stdenv.hostPlatform ? nix && stdenv.hostPlatform.nix ? system
|
2021-01-24 10:19:10 +01:00
|
|
|
) "--with-system=${stdenv.hostPlatform.nix.system}"
|
2018-09-25 14:46:36 +02:00
|
|
|
# RISC-V support in progress https://github.com/seccomp/libseccomp/pull/50
|
|
|
|
++ lib.optional (!withLibseccomp) "--disable-seccomp-sandboxing";
|
|
|
|
|
2020-07-06 07:46:10 +02:00
|
|
|
makeFlags = [ "profiledir=$(out)/etc/profile.d" ]
|
|
|
|
++ lib.optional (stdenv.hostPlatform != stdenv.buildPlatform) "PRECOMPILE_HEADERS=0";
|
2018-09-25 14:46:36 +02:00
|
|
|
|
2019-10-27 14:03:25 +01:00
|
|
|
installFlags = [ "sysconfdir=$(out)/etc" ];
|
2018-09-25 14:46:36 +02:00
|
|
|
|
|
|
|
doInstallCheck = true; # not cross
|
|
|
|
|
|
|
|
# socket path becomes too long otherwise
|
2021-03-24 20:43:59 +01:00
|
|
|
preInstallCheck = lib.optionalString stdenv.isDarwin ''
|
2018-09-25 14:46:36 +02:00
|
|
|
export TMPDIR=$NIX_BUILD_TOP
|
2021-12-11 03:19:17 +01:00
|
|
|
''
|
|
|
|
# See https://github.com/NixOS/nix/issues/5687
|
|
|
|
+ lib.optionalString (is25 && stdenv.isDarwin) ''
|
|
|
|
echo "exit 99" > tests/gc-non-blocking.sh
|
2018-08-22 13:21:05 +02:00
|
|
|
'';
|
|
|
|
|
2021-11-03 22:58:55 +01:00
|
|
|
separateDebugInfo = stdenv.isLinux && (is24 -> !enableStatic);
|
2018-09-25 14:46:36 +02:00
|
|
|
|
|
|
|
enableParallelBuilding = true;
|
|
|
|
|
2021-11-09 20:26:11 +01:00
|
|
|
meta = with lib; {
|
2018-09-25 14:46:36 +02:00
|
|
|
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.
|
|
|
|
'';
|
2020-04-01 03:11:51 +02:00
|
|
|
homepage = "https://nixos.org/";
|
2021-11-09 20:26:11 +01:00
|
|
|
license = licenses.lgpl2Plus;
|
|
|
|
maintainers = with maintainers; [ eelco lovesegfault ];
|
|
|
|
platforms = platforms.unix;
|
|
|
|
outputsToInstall = [ "out" ] ++ optional enableDocumentation "man";
|
2018-09-25 14:46:36 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
passthru = {
|
2019-04-21 21:00:46 +02:00
|
|
|
perl-bindings = perl.pkgs.toPerlModule (stdenv.mkDerivation {
|
2019-08-13 23:52:01 +02:00
|
|
|
pname = "nix-perl";
|
|
|
|
inherit version;
|
2018-09-25 14:46:36 +02:00
|
|
|
|
|
|
|
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-01-17 10:17:16 +01:00
|
|
|
[ perl pkg-config curl nix libsodium boost autoreconfHook autoconf-archive nlohmann_json ];
|
2018-09-25 14:46:36 +02:00
|
|
|
|
|
|
|
configureFlags =
|
2019-04-21 21:00:46 +02:00
|
|
|
[ "--with-dbi=${perl.pkgs.DBI}/${perl.libPrefix}"
|
|
|
|
"--with-dbd-sqlite=${perl.pkgs.DBDSQLite}/${perl.libPrefix}"
|
2018-09-25 14:46:36 +02:00
|
|
|
];
|
|
|
|
|
|
|
|
preConfigure = "export NIX_STATE_DIR=$TMPDIR";
|
|
|
|
|
|
|
|
preBuild = "unset NIX_INDENT_MAKE";
|
2019-04-21 21:00:46 +02:00
|
|
|
});
|
2021-07-18 00:00:00 +02:00
|
|
|
inherit boehmgc;
|
2018-09-25 14:46:36 +02:00
|
|
|
};
|
2015-07-30 12:01:40 +02:00
|
|
|
};
|
2018-09-25 14:46:36 +02:00
|
|
|
in nix;
|
2009-11-06 00:47:53 +01:00
|
|
|
|
2021-07-18 00:00:00 +02: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-26 09:01:11 +02:00
|
|
|
url = "https://github.com/hercules-ci/nix/raw/5c58d84a76d96f269e3ff1e72c9c9ba5f68576af/boehmgc-coroutine-sp-fallback.diff";
|
2021-07-18 00:00:00 +02:00
|
|
|
sha256 = "sha256-JvnWVTlkltmQUs/0qApv/LPZ690UX1/2hEP+LYRwKbI=";
|
|
|
|
})
|
|
|
|
];
|
|
|
|
});
|
|
|
|
|
2021-11-11 11:45:26 +01:00
|
|
|
# master: https://github.com/NixOS/nix/pull/5536
|
|
|
|
# 2.4: https://github.com/NixOS/nix/pull/5537
|
|
|
|
installNlohmannJsonPatch = fetchpatch {
|
|
|
|
url = "https://github.com/NixOS/nix/pull/5536.diff";
|
|
|
|
sha256 = "sha256-SPnam4xNIjbMgnq6IP1AaM1V62X0yZNo4DEVmI8sHOo=";
|
|
|
|
};
|
|
|
|
|
2015-07-30 12:01:40 +02:00
|
|
|
in rec {
|
|
|
|
|
2018-02-22 16:40:02 +01:00
|
|
|
nix = nixStable;
|
2016-02-12 16:10:18 +01:00
|
|
|
|
2021-11-02 07:54:48 +01:00
|
|
|
nixStable = nix_2_4;
|
2021-11-02 07:54:06 +01:00
|
|
|
|
|
|
|
nix_2_3 = callPackage common (rec {
|
2021-04-13 13:10:56 +02:00
|
|
|
pname = "nix";
|
2021-09-07 05:36:53 +02:00
|
|
|
version = "2.3.16";
|
2018-02-22 16:40:02 +01:00
|
|
|
src = fetchurl {
|
2021-04-13 13:10:56 +02:00
|
|
|
url = "https://nixos.org/releases/nix/${pname}-${version}/${pname}-${version}.tar.xz";
|
2021-09-07 05:36:53 +02:00
|
|
|
sha256 = "sha256-fuaBtp8FtSVJLSAsO+3Nne4ZYLuBj2JpD2xEk7fCqrw=";
|
2016-02-12 16:10:18 +01:00
|
|
|
};
|
2019-03-10 18:30:54 +01:00
|
|
|
|
2021-07-07 22:49:18 +02:00
|
|
|
boehmgc = boehmgc_nix;
|
|
|
|
|
|
|
|
inherit storeDir stateDir confDir;
|
2019-04-30 03:30:56 +02:00
|
|
|
});
|
2016-02-12 16:10:18 +01:00
|
|
|
|
2021-10-08 00:23:50 +02:00
|
|
|
nix_2_4 = callPackage common (rec {
|
|
|
|
pname = "nix";
|
2021-11-02 07:53:02 +01:00
|
|
|
version = "2.4";
|
2021-10-08 00:23:50 +02:00
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "NixOS";
|
|
|
|
repo = "nix";
|
|
|
|
rev = version;
|
2021-11-02 07:53:02 +01:00
|
|
|
sha256 = "sha256-op48CCDgLHK0qV1Batz4Ln5FqBiRjlE6qHTiZgt3b6k=";
|
2021-10-08 00:23:50 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
boehmgc = boehmgc_nixUnstable;
|
|
|
|
|
2021-11-11 11:45:26 +01:00
|
|
|
patches = [ installNlohmannJsonPatch ];
|
|
|
|
|
2021-10-08 00:23:50 +02:00
|
|
|
inherit storeDir stateDir confDir;
|
|
|
|
});
|
|
|
|
|
2019-03-10 18:30:54 +01:00
|
|
|
nixUnstable = lib.lowPrio (callPackage common rec {
|
2021-04-13 13:10:56 +02:00
|
|
|
pname = "nix";
|
2021-10-07 23:01:38 +02:00
|
|
|
version = "2.5${suffix}";
|
2021-12-06 18:06:37 +01:00
|
|
|
suffix = "pre20211206_${lib.substring 0 7 src.rev}";
|
2020-04-03 23:29:31 +02:00
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "NixOS";
|
|
|
|
repo = "nix";
|
2021-12-06 18:06:37 +01:00
|
|
|
rev = "d1aaa7ef71713b6693ad3ddf8704ce62bab82095";
|
|
|
|
sha256 = "sha256-zdMODMLdJ0smEEzNMOoIzBxt9QWVzgMvr+pwxkhtD4g=";
|
2016-02-12 16:10:18 +01:00
|
|
|
};
|
2019-03-10 18:30:54 +01:00
|
|
|
|
2021-07-07 22:49:18 +02:00
|
|
|
boehmgc = boehmgc_nixUnstable;
|
|
|
|
|
2021-11-11 11:45:26 +01:00
|
|
|
patches = [ installNlohmannJsonPatch ];
|
|
|
|
|
2021-07-07 22:49:18 +02:00
|
|
|
inherit storeDir stateDir confDir;
|
2021-05-13 06:25:01 +02:00
|
|
|
|
2018-09-25 14:46:36 +02:00
|
|
|
});
|
2015-07-30 12:01:40 +02:00
|
|
|
|
2004-02-16 16:40:55 +01:00
|
|
|
}
|