Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
at devShellTools-shell 285 lines 6.5 kB view raw
1{ 2 lib, 3 fetchFromGitHub, 4 version, 5 suffix ? "", 6 hash ? null, 7 src ? fetchFromGitHub { 8 owner = "NixOS"; 9 repo = "nix"; 10 rev = version; 11 inherit hash; 12 }, 13 patches ? [ ], 14 maintainers ? [ 15 lib.maintainers.lovesegfault 16 lib.maintainers.artturin 17 ], 18 teams ? [ lib.teams.nix ], 19 self_attribute_name, 20}@args: 21assert (hash == null) -> (src != null); 22{ 23 stdenv, 24 bison, 25 boehmgc, 26 boost, 27 brotli, 28 busybox-sandbox-shell, 29 bzip2, 30 callPackage, 31 cmake, 32 curl, 33 doxygen, 34 editline, 35 flex, 36 git, 37 gtest, 38 jq, 39 lib, 40 libarchive, 41 libblake3, 42 libcpuid, 43 libgit2, 44 libsodium, 45 lowdown, 46 lowdown-unsandboxed, 47 toml11, 48 man, 49 meson, 50 ninja, 51 mdbook, 52 mdbook-linkcheck, 53 nlohmann_json, 54 nixosTests, 55 openssl, 56 perl, 57 python3, 58 pkg-config, 59 rapidcheck, 60 rsync, 61 sqlite, 62 util-linuxMinimal, 63 xz, 64 enableDocumentation ? stdenv.buildPlatform.canExecute stdenv.hostPlatform, 65 enableStatic ? stdenv.hostPlatform.isStatic, 66 withAWS ? 67 lib.meta.availableOn stdenv.hostPlatform aws-c-common 68 && !enableStatic 69 && (stdenv.hostPlatform.isLinux || stdenv.hostPlatform.isDarwin), 70 aws-c-common, 71 aws-sdk-cpp, 72 withLibseccomp ? lib.meta.availableOn stdenv.hostPlatform libseccomp, 73 libseccomp, 74 75 confDir, 76 stateDir, 77 storeDir, 78 79 # passthru tests 80 pkgsi686Linux, 81 pkgsStatic, 82 runCommand, 83 pkgs, 84}: 85 86stdenv.mkDerivation (finalAttrs: { 87 pname = "nix"; 88 89 version = "${version}${suffix}"; 90 VERSION_SUFFIX = suffix; 91 92 inherit src patches; 93 94 outputs = [ 95 "out" 96 "dev" 97 ] 98 ++ lib.optionals enableDocumentation [ 99 "man" 100 "doc" 101 ]; 102 103 hardeningEnable = lib.optionals (!stdenv.hostPlatform.isDarwin) [ "pie" ]; 104 105 hardeningDisable = [ 106 "shadowstack" 107 ] 108 ++ lib.optional stdenv.hostPlatform.isMusl "fortify"; 109 110 nativeCheckInputs = [ 111 git 112 man 113 ]; 114 115 nativeBuildInputs = [ 116 bison 117 cmake 118 flex 119 jq 120 meson 121 ninja 122 pkg-config 123 rsync 124 ] 125 ++ lib.optionals enableDocumentation [ 126 (lib.getBin lowdown-unsandboxed) 127 mdbook 128 mdbook-linkcheck 129 ] 130 ++ lib.optionals stdenv.hostPlatform.isLinux [ 131 util-linuxMinimal 132 ] 133 ++ lib.optionals enableDocumentation [ 134 python3 135 doxygen 136 ]; 137 138 buildInputs = [ 139 boost 140 brotli 141 bzip2 142 curl 143 editline 144 libgit2 145 libsodium 146 lowdown 147 openssl 148 sqlite 149 toml11 150 xz 151 ] 152 ++ lib.optionals (lib.versionAtLeast version "2.26") [ 153 libblake3 154 ] 155 ++ lib.optionals stdenv.hostPlatform.isx86_64 [ 156 libcpuid 157 ] 158 ++ lib.optionals withLibseccomp [ 159 libseccomp 160 ] 161 ++ lib.optionals withAWS [ 162 aws-sdk-cpp 163 ]; 164 165 propagatedBuildInputs = [ 166 boehmgc 167 nlohmann_json 168 libarchive 169 ]; 170 171 checkInputs = [ 172 gtest 173 rapidcheck 174 ]; 175 176 postPatch = '' 177 patchShebangs --build tests 178 ''; 179 180 preConfigure = 181 # Copy libboost_context so we don't get all of Boost in our closure. 182 # https://github.com/NixOS/nixpkgs/issues/45462 183 lib.optionalString (!enableStatic) '' 184 mkdir -p $out/lib 185 cp -pd ${boost}/lib/{libboost_context*,libboost_thread*,libboost_system*} $out/lib 186 rm -f $out/lib/*.a 187 ${lib.optionalString stdenv.hostPlatform.isLinux '' 188 chmod u+w $out/lib/*.so.* 189 patchelf --set-rpath $out/lib:${lib.getLib stdenv.cc.cc}/lib $out/lib/libboost_thread.so.* 190 ''} 191 ''; 192 193 dontUseCmakeConfigure = true; 194 195 mesonFlags = [ 196 (lib.mesonBool "unit-tests" (stdenv.buildPlatform.canExecute stdenv.hostPlatform)) 197 (lib.mesonBool "bindings" false) 198 (lib.mesonOption "libstore:store-dir" storeDir) 199 (lib.mesonOption "libstore:localstatedir" stateDir) 200 (lib.mesonOption "libstore:sysconfdir" confDir) 201 (lib.mesonEnable "libutil:cpuid" stdenv.hostPlatform.isx86_64) 202 (lib.mesonEnable "libstore:seccomp-sandboxing" withLibseccomp) 203 (lib.mesonBool "libstore:embedded-sandbox-shell" ( 204 stdenv.hostPlatform.isLinux && stdenv.hostPlatform.isStatic 205 )) 206 (lib.mesonBool "doc-gen" enableDocumentation) 207 ] 208 ++ lib.optionals stdenv.hostPlatform.isLinux [ 209 (lib.mesonOption "libstore:sandbox-shell" "${busybox-sandbox-shell}/bin/busybox") 210 # RISC-V support in progress https://github.com/seccomp/libseccomp/pull/50 211 ] 212 ++ lib.optionals (stdenv.cc.isGNU && !enableStatic) [ 213 # TODO: do we still need this? 214 # "--enable-lto" 215 ]; 216 217 doCheck = true; 218 219 # socket path becomes too long otherwise 220 preInstallCheck = 221 lib.optionalString stdenv.hostPlatform.isDarwin '' 222 export TMPDIR=$NIX_BUILD_TOP 223 '' 224 # See https://github.com/NixOS/nix/issues/5687 225 + lib.optionalString (stdenv.hostPlatform.system == "aarch64-linux") '' 226 echo "exit 0" > tests/functional/flakes/show.sh 227 '' 228 + '' 229 # nixStatic otherwise does not find its man pages in tests. 230 export MANPATH=$man/share/man:$MANPATH 231 ''; 232 233 separateDebugInfo = stdenv.hostPlatform.isLinux && enableStatic; 234 235 passthru = { 236 inherit aws-sdk-cpp boehmgc; 237 238 # TODO: 239 perl-bindings = perl.pkgs.toPerlModule ( 240 callPackage ./nix-perl.nix { 241 nix = finalAttrs.finalPackage; 242 } 243 ); 244 245 tests = import ./tests.nix { 246 inherit 247 runCommand 248 version 249 src 250 lib 251 stdenv 252 pkgs 253 pkgsi686Linux 254 pkgsStatic 255 nixosTests 256 self_attribute_name 257 ; 258 nix = finalAttrs.finalPackage; 259 }; 260 }; 261 262 # point 'nix edit' and ofborg at the file that defines the attribute, 263 # not this common file. 264 pos = builtins.unsafeGetAttrPos "version" args; 265 meta = with lib; { 266 description = "Powerful package manager that makes package management reliable and reproducible"; 267 longDescription = '' 268 Nix is a powerful package manager for Linux and other Unix systems that 269 makes package management reliable and reproducible. It provides atomic 270 upgrades and rollbacks, side-by-side installation of multiple versions of 271 a package, multi-user package management and easy setup of build 272 environments. 273 ''; 274 homepage = "https://nixos.org/"; 275 license = licenses.lgpl21Plus; 276 inherit maintainers teams; 277 platforms = platforms.unix; 278 # Gets stuck in functional-tests in cross-trunk jobset and doesn't timeout 279 # https://hydra.nixos.org/build/298175022 280 # probably https://github.com/NixOS/nix/issues/13042 281 broken = stdenv.hostPlatform.system == "i686-linux" && stdenv.buildPlatform != stdenv.hostPlatform; 282 outputsToInstall = [ "out" ] ++ optional enableDocumentation "man"; 283 mainProgram = "nix"; 284 }; 285})