5 , src ? fetchFromGitHub { owner = "NixOS"; repo = "nix"; rev = version; inherit sha256; }
8 assert (sha256 == null) -> (src != null);
10 atLeast24 = lib.versionAtLeast version "2.4pre";
11 atLeast25 = lib.versionAtLeast version "2.5pre";
12 atLeast27 = lib.versionAtLeast version "2.7pre";
13 atLeast210 = lib.versionAtLeast version "2.10pre";
23 , busybox-sandbox-shell
49 , enableDocumentation ? !atLeast24 || stdenv.hostPlatform == stdenv.buildPlatform
50 , enableStatic ? stdenv.hostPlatform.isStatic
51 , withAWS ? !enableStatic && (stdenv.isLinux || stdenv.isDarwin), aws-sdk-cpp
52 , withLibseccomp ? lib.meta.availableOn stdenv.hostPlatform libseccomp, libseccomp
61 self = stdenv.mkDerivation {
64 version = "${version}${suffix}";
65 VERSION_SUFFIX = suffix;
71 ++ lib.optionals enableDocumentation [ "man" "doc" ];
73 hardeningEnable = lib.optionals (!stdenv.isDarwin) [ "pie" ];
77 ] ++ lib.optionals atLeast24 [
83 ] ++ lib.optionals (atLeast24 && enableDocumentation) [
86 ] ++ lib.optionals stdenv.isLinux [
100 ] ++ lib.optionals stdenv.isDarwin [
102 ] ++ lib.optionals atLeast24 [
106 ] ++ lib.optionals (atLeast24 && stdenv.isx86_64) [
108 ] ++ lib.optionals withLibseccomp [
110 ] ++ lib.optionals withAWS [
114 propagatedBuildInputs = [
116 ] ++ lib.optionals (atLeast27) [
120 NIX_LDFLAGS = lib.optionals (!atLeast24) [
121 # https://github.com/NixOS/nix/commit/3e85c57a6cbf46d5f0fe8a89b368a43abd26daba
122 (lib.optionalString enableStatic "-lssl -lbrotlicommon -lssh2 -lz -lnghttp2 -lcrypto")
123 # https://github.com/NixOS/nix/commits/74b4737d8f0e1922ef5314a158271acf81cd79f8
124 (lib.optionalString (stdenv.hostPlatform.system == "armv5tel-linux" || stdenv.hostPlatform.system == "armv6l-linux") "-latomic")
128 # Copy libboost_context so we don't get all of Boost in our closure.
129 # https://github.com/NixOS/nixpkgs/issues/45462
130 lib.optionalString (!enableStatic) ''
132 cp -pd ${boost}/lib/{libboost_context*,libboost_thread*,libboost_system*} $out/lib
134 ${lib.optionalString stdenv.isLinux ''
135 chmod u+w $out/lib/*.so.*
136 patchelf --set-rpath $out/lib:${stdenv.cc.cc.lib}/lib $out/lib/libboost_thread.so.*
139 # On all versions before c9f51e87057652db0013289a95deffba495b35e7, which
140 # removes config.nix entirely and is not present in 2.3.x, we need to
141 # patch around an issue where the Nix configure step pulls in the build
142 # system's bash and other utilities when cross-compiling.
143 lib.optionalString (stdenv.buildPlatform != stdenv.hostPlatform && !atLeast24) ''
145 substitute corepkgs/config.nix.in tmp/config.nix.in \
146 --subst-var-by bash ${bash}/bin/bash \
147 --subst-var-by coreutils ${coreutils}/bin \
148 --subst-var-by bzip2 ${bzip2}/bin/bzip2 \
149 --subst-var-by gzip ${gzip}/bin/gzip \
150 --subst-var-by xz ${xz}/bin/xz \
151 --subst-var-by tar ${gnutar}/bin/tar \
152 --subst-var-by tr ${coreutils}/bin/tr
153 mv tmp/config.nix.in corepkgs/config.nix.in
157 "--with-store-dir=${storeDir}"
158 "--localstatedir=${stateDir}"
159 "--sysconfdir=${confDir}"
161 ] ++ lib.optionals (!enableDocumentation) [
163 ] ++ lib.optionals (!atLeast24) [
164 # option was removed in 2.4
165 "--disable-init-state"
166 ] ++ lib.optionals stdenv.isLinux [
167 "--with-sandbox-shell=${busybox-sandbox-shell}/bin/busybox"
168 ] ++ lib.optionals (stdenv.hostPlatform != stdenv.buildPlatform && stdenv.hostPlatform ? nix && stdenv.hostPlatform.nix ? system) [
169 "--with-system=${stdenv.hostPlatform.nix.system}"
170 ] ++ lib.optionals (!withLibseccomp) [
171 # RISC-V support in progress https://github.com/seccomp/libseccomp/pull/50
172 "--disable-seccomp-sandboxing"
173 ] ++ lib.optionals (atLeast210 && stdenv.cc.isGNU && !enableStatic) [
178 "profiledir=$(out)/etc/profile.d"
179 ] ++ lib.optional (stdenv.hostPlatform != stdenv.buildPlatform) "PRECOMPILE_HEADERS=0"
180 ++ lib.optional (stdenv.hostPlatform.isDarwin) "PRECOMPILE_HEADERS=1";
182 installFlags = [ "sysconfdir=$(out)/etc" ];
184 doInstallCheck = true;
185 installCheckTarget = if atLeast210 then "installcheck" else null;
187 # socket path becomes too long otherwise
188 preInstallCheck = lib.optionalString stdenv.isDarwin ''
189 export TMPDIR=$NIX_BUILD_TOP
191 # See https://github.com/NixOS/nix/issues/5687
192 + lib.optionalString (atLeast25 && stdenv.isDarwin) ''
193 echo "exit 99" > tests/gc-non-blocking.sh
196 separateDebugInfo = stdenv.isLinux && (atLeast24 -> !enableStatic);
198 enableParallelBuilding = true;
201 inherit aws-sdk-cpp boehmgc;
203 perl-bindings = perl.pkgs.toPerlModule (callPackage ./nix-perl.nix { nix = self; inherit Security; });
206 nixi686 = pkgsi686Linux.nixVersions.${"nix_${lib.versions.major version}_${lib.versions.minor version}"};
211 description = "Powerful package manager that makes package management reliable and reproducible";
213 Nix is a powerful package manager for Linux and other Unix systems that
214 makes package management reliable and reproducible. It provides atomic
215 upgrades and rollbacks, side-by-side installation of multiple versions of
216 a package, multi-user package management and easy setup of build
219 homepage = "https://nixos.org/";
220 license = licenses.lgpl2Plus;
221 maintainers = with maintainers; [ eelco lovesegfault artturin ];
222 platforms = platforms.unix;
223 outputsToInstall = [ "out" ] ++ optional enableDocumentation "man";