7 src ? fetchFromGitHub {
16 maintainers ? lib.teams.lix.members,
18 assert (hash == null) -> (src != null);
26 busybox-sandbox-shell,
60 lix-doc ? callPackage ./doc {
62 version = "${version}${suffix}";
63 cargoHash = docCargoHash;
64 cargoLock = docCargoLock;
67 enableDocumentation ? stdenv.hostPlatform == stdenv.buildPlatform,
68 enableStatic ? stdenv.hostPlatform.isStatic,
69 withAWS ? !enableStatic && (stdenv.hostPlatform.isLinux || stdenv.hostPlatform.isDarwin),
71 # RISC-V support in progress https://github.com/seccomp/libseccomp/pull/50
72 withLibseccomp ? lib.meta.availableOn stdenv.hostPlatform libseccomp,
79 assert lib.assertMsg (docCargoHash != null || docCargoLock != null)
80 "Either `lix-doc`'s cargoHash using `docCargoHash` or `lix-doc`'s `cargoLock.lockFile` using `docCargoLock` must be set!";
82 isLegacyParser = lib.versionOlder version "2.91";
87 version = "${version}${suffix}";
88 VERSION_SUFFIX = suffix;
97 ++ lib.optionals enableDocumentation [
121 ++ lib.optionals isLegacyParser [ bison ]
122 ++ lib.optionals enableDocumentation [
123 (lib.getBin lowdown-unsandboxed)
128 ++ lib.optionals stdenv.hostPlatform.isLinux [ util-linuxMinimal ];
148 ++ lib.optionals (!isLegacyParser) [ pegtl ]
149 ++ lib.optionals stdenv.hostPlatform.isDarwin [ Security ]
150 ++ lib.optionals (stdenv.hostPlatform.isx86_64) [ libcpuid ]
151 ++ lib.optionals withLibseccomp [ libseccomp ]
152 ++ lib.optionals withAWS [ aws-sdk-cpp ];
154 propagatedBuildInputs = [
160 patchShebangs --build tests doc/manual
164 # Copy libboost_context so we don't get all of Boost in our closure.
165 # https://github.com/NixOS/nixpkgs/issues/45462
166 lib.optionalString (!enableStatic) ''
168 cp -pd ${boost}/lib/{libboost_context*,libboost_thread*,libboost_system*} $out/lib
170 ${lib.optionalString stdenv.hostPlatform.isLinux ''
171 chmod u+w $out/lib/*.so.*
172 patchelf --set-rpath $out/lib:${stdenv.cc.cc.lib}/lib $out/lib/libboost_thread.so.*
174 ${lib.optionalString stdenv.hostPlatform.isDarwin ''
175 for LIB in $out/lib/*.dylib; do
177 install_name_tool -id $LIB $LIB
178 install_name_tool -delete_rpath ${boost}/lib/ $LIB || true
180 install_name_tool -change ${boost}/lib/libboost_system.dylib $out/lib/libboost_system.dylib $out/lib/libboost_thread.dylib
184 # -O3 seems to anger a gcc bug and provide no performance benefit.
185 # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114360
186 # We use -O2 upstream https://gerrit.lix.systems/c/lix/+/554
187 mesonBuildType = "debugoptimized";
191 # Enable LTO, since it improves eval performance a fair amount
192 # LTO is disabled on static due to strange linking errors
193 (lib.mesonBool "b_lto" (!stdenv.hostPlatform.isStatic))
194 (lib.mesonEnable "gc" true)
195 (lib.mesonBool "enable-tests" true)
196 (lib.mesonBool "enable-docs" enableDocumentation)
197 (lib.mesonEnable "internal-api-docs" enableDocumentation)
198 (lib.mesonBool "enable-embedded-sandbox-shell" (stdenv.hostPlatform.isLinux && stdenv.hostPlatform.isStatic))
199 (lib.mesonEnable "seccomp-sandboxing" withLibseccomp)
201 (lib.mesonOption "store-dir" storeDir)
202 (lib.mesonOption "state-dir" stateDir)
203 (lib.mesonOption "sysconfdir" confDir)
205 ++ lib.optionals stdenv.hostPlatform.isLinux [
206 (lib.mesonOption "sandbox-shell" "${busybox-sandbox-shell}/bin/busybox")
209 ninjaFlags = [ "-v" ];
212 lib.optionalString enableDocumentation ''
213 mkdir -p $doc/nix-support
214 echo "doc manual $doc/share/doc/nix/manual" >> $doc/nix-support/hydra-build-products
216 mkdir -p $devdoc/nix-support
217 echo "devdoc internal-api $devdoc/share/doc/nix/internal-api" >> $devdoc/nix-support/hydra-build-products
219 + lib.optionalString stdenv.hostPlatform.isStatic ''
220 mkdir -p $out/nix-support
221 echo "file binary-dist $out/bin/nix" >> $out/nix-support/hydra-build-products
223 + lib.optionalString stdenv.hostPlatform.isDarwin ''
224 for lib in liblixutil.dylib liblixexpr.dylib; do
226 -change "${lib.getLib boost}/lib/libboost_context.dylib" \
227 "$out/lib/libboost_context.dylib" \
232 # This needs to run after _multioutDocs moves the docs to $doc
233 postFixup = lib.optionalString enableDocumentation ''
234 mkdir -p $devdoc/share/doc/nix
235 mv $doc/share/doc/nix/internal-api $devdoc/share/doc/nix
248 doInstallCheck = true;
249 mesonInstallCheckFlags = [
250 "--suite=installcheck"
254 preInstallCheck = lib.optionalString stdenv.hostPlatform.isDarwin ''
255 # socket path becomes too long otherwise
256 export TMPDIR=$NIX_BUILD_TOP
257 # Prevent crashes in libcurl due to invoking Objective-C `+initialize` methods after `fork`.
258 # See http://sealiesoftware.com/blog/archive/2017/6/5/Objective-C_and_fork_in_macOS_1013.html.
259 export OBJC_DISABLE_INITIALIZE_FORK_SAFETY=YES
262 installCheckPhase = ''
263 runHook preInstallCheck
264 flagsArray=($mesonInstallCheckFlags "''${mesonInstallCheckFlagsArray[@]}")
265 meson test --no-rebuild "''${flagsArray[@]}"
266 runHook postInstallCheck
270 # strictoverflow is disabled because we trap on signed overflow instead
273 # fortify breaks the build with lto and musl for some reason
274 ++ lib.optional stdenv.hostPlatform.isMusl "fortify";
276 # hardeningEnable = lib.optionals (!stdenv.hostPlatform.isDarwin) [ "pie" ];
277 separateDebugInfo = stdenv.hostPlatform.isLinux && !enableStatic;
278 enableParallelBuilding = true;
280 # Used by (1) test which has dynamic port assignment.
281 __darwinAllowLocalNetworking = true;
284 inherit aws-sdk-cpp boehmgc;
286 misc = nixosTests.nix-misc.lix;
290 # point 'nix edit' and ofborg at the file that defines the attribute,
291 # not this common file.
292 pos = builtins.unsafeGetAttrPos "version" args;
294 description = "Powerful package manager that makes package management reliable and reproducible";
296 Lix (a fork of Nix) is a powerful package manager for Linux and other Unix systems that
297 makes package management reliable and reproducible. It provides atomic
298 upgrades and rollbacks, side-by-side installation of multiple versions of
299 a package, multi-user package management and easy setup of build
302 homepage = "https://lix.systems";
303 license = lib.licenses.lgpl21Plus;
305 platforms = lib.platforms.unix;
306 outputsToInstall = [ "out" ] ++ lib.optional enableDocumentation "man";