aboutsummaryrefslogtreecommitdiff
path: root/src/libstore/globals.cc
AgeCommit message (Collapse)Author
2024-03-19libutil: remove exception handling workingness checkeldritch horrors
within lix itself this problem is caught by the test suite. outside of lix itself three cases can be had: either the problem is fully inside lix libs, fully inside user code, or it exists at the boundary. the first is caught by the test suite, the second isn't caught at all, and the third is something lix should not be responsible for. Change-Id: I95aa35d8cb6f0ef5816a2941c467bc0c15916063
2024-03-17Delete hasPrefix and hasSuffix from the codebaseJade Lovelace
These now have equivalents in the standard lib in C++20. This change was performed with a custom clang-tidy check which I will submit later. Executed like so: ninja -C build && run-clang-tidy -checks='-*,nix-*' -load=build/libnix-clang-tidy.so -p .. -fix ../tests | tee -a clang-tidy-result Change-Id: I62679e315ff9e7ce72a40b91b79c3e9fc01b27e9
2024-03-15Allow dlopen of plugins to failJade Lovelace
It happens with some frequency that plugins that might be unimportant to the evaluation at hand mismatch with the nix version, leading to spurious load failures. Let's make these non fatal. Change-Id: Iba10e951d171725ccf1a121bcd9be1e1d6ad69eb
2024-03-04Merge pull request #9233 from bouk/bouk/apply-config-innereldritch horrors
config: add included files into parsedContents before applying (cherry picked from commit 82359eba6b692691ef08a71196ef25a61bc4d3d3) Change-Id: Idde3177010fec7b8bafe6088c3c23d5caf491845
2023-11-16libstore: Add apple-virt to system features when availableRobert Hensing
I'm sure that we'll adjust the implementation over time, but this at least discerns between an apple silicon bare metal machine and a tart VM. (cherry picked from commit 9277eb276bf0a942e88fcf499f6a6b9c262be853)
2023-06-18Split `OptionalPathSetting` from `PathSetting`John Ericson
Rather than doing `allowEmpty` as boolean, have separate types and use `std::optional`. This makes it harder to forget the possibility of an empty path. The `build-hook` setting was categorized as a `PathSetting`, but actually it was split into arguments. No good! Now, it is `Setting<Strings>` which actually reflects what it means and how it is used. Because of the subtyping, we now also have support for `Setting<std::optional<String>>` in general. I imagine this can be used to clean up many more settings also.
2023-06-15Fix build hook error for libstore library usersRobert Hensing
A library shouldn't require changes to the caller's argument handling, especially if it doesn't have to, and indeed we don't have to. This changes the lookup order to prioritize the hardcoded path to nix if it exists. The static executable still finds itself through /proc and the like.
2023-05-26create pathAccessible, use it to infer default dirsYorick van Pelt
2023-05-26Call getDefaultSSLCertFile() only when none is specifiedYorick van Pelt
This does pathExists on various paths, which crashes on EPERM in the macOS sandbox.
2023-04-17Fix some issues with experimental config settingsJohn Ericson
Issues: 1. Features gated on disabled experimental settings should warn and be ignored, not silently succeed. 2. Experimental settings in the same config "batch" (file or env var) as the enabling of the experimental feature should work. 3. For (2), the order should not matter. These are analogous to the issues @roberth caught with my changes for arg handling, but they are instead for config handling. Co-authored-by: Robert Hensing <roberth@users.noreply.github.com>
2023-04-07libstore: Remove lockCPU dead codeRobert Hensing
Left over from 9747ea84b, https://github.com/NixOS/nix/pull/5821
2023-04-07Move initLibUtil() from initNix to initLibStoreRobert Hensing
libutil is a dependency of libstore, so it should always be initialized as such. libutil is also a dependency of libmain. Being explicit about this dependency might be good, but not worth the slight code complexity until the library structure gets more advanced. Part of an effort to make it easier to initialize the right things, by moving code into the appropriate libraries.
2023-04-07Move macOS TMPDIR hack from initNix to initLibStoreRobert Hensing
This code is bad. We shouldn't unset variables in programs whose children may need them. Fixing one issue at a time, so postponing. See https://github.com/NixOS/nix/issues/7731 Part of an effort to make it easier to initialize the right things, by moving code into the appropriate libraries.
2023-04-07Move preloadNSS() from initNix to initLibStoreRobert Hensing
It is required for the sandbox, which is a libstore responsibility; not just libmain. Part of an effort to make it easier to initialize the right things, by moving code into the appropriate libraries.
2023-04-07Move sodium_init() to initLibStore()Robert Hensing
Part of an effort to make it easier to initialize the right things, by moving code into the appropriate libraries.
2023-04-07Move loadConfFile() to initLibStoreRobert Hensing
Part of an effort to make it easier to initialize the right things, by moving code into the appropriate libraries. Using libstore without loading the config file is risky, as sqlite may then be misconfigured. See https://github.com/cachix/cachix/issues/475
2023-03-27Merge pull request #8062 from edolstra/ssl-cert-fileEelco Dolstra
Add a setting for configuring the SSL certificates file
2023-03-20Move enabled experimental feature to libutil structJohn Ericson
This is needed in subsequent commits to allow the settings and CLI args infrastructure itself to read this setting.
2023-03-17Add a setting for configuring the SSL certificates fileEelco Dolstra
This provides a platform-independent way to configure the SSL certificates file in the Nix daemon. Previously we provided instructions for overriding the environment variable in launchd, but that obviously doesn't work with systemd. Now we can just tell users to add ssl-cert-file = /etc/ssl/my-certificate-bundle.crt to their nix.conf.
2023-03-01Treat empty env var paths as unsetFélix Baylac Jacqué
We make sure the env var paths are actually set (ie. not "") before sending them to the canonicalization function. If we forget to do so, the user will end up facing a puzzled failed assertion internal error. We issue a non-failing warning as a stop-gap measure. We could want to revisit this to issue a detailed failing error message in the future.
2023-02-01Merge pull request #7203 from graham33/feature/cpp20Eelco Dolstra
Proposal: Use C++20
2022-12-24libstore: Make sure that initNix has been calledRobert Hensing
Prevent bugs like https://github.com/cachix/cachix/pull/477
2022-11-08Split auto UID allocation from cgroupsEelco Dolstra
Cgroups are now only used for derivations that require the uid-range range feature. This allows auto UID allocation even on systems that don't have cgroups (like macOS). Also, make things work on modern systems that use cgroups v2 (where there is a single hierarchy and no "systemd" controller).
2022-10-22Fix C++20 warningsGraham Bennett
2022-10-14Remove useless debug statementsEelco Dolstra
We haven't parsed the '-v' command line flags yet when this code executes, so we can't actually get debug output here.
2022-10-14Use /usr/bin/trueEelco Dolstra
2022-10-13Improve Rosetta detectionEelco Dolstra
Turns out that one of those *.plist files can exist even if Rosetta is not installed. So let's just try to run an x86_64-darwin binary directly.
2022-07-19libstore/globals.cc: Move cgroup detection to libutilAlex Wied
2022-07-19libstore/globals.cc: Automatically set cores based on cgroup CPU limitAlex Wied
By default, Nix sets the "cores" setting to the number of CPUs which are physically present on the machine. If cgroups are used to limit the CPU and memory consumption of a large Nix build, the OOM killer may be invoked. For example, consider a GitLab CI pipeline which builds a large software package. The GitLab runner spawns a container whose CPU is limited to 4 cores and whose memory is limited to 16 GiB. If the underlying machine has 64 cores, Nix will invoke the build with -j64. In many cases, that level of parallelism will invoke the OOM killer and the build will completely fail. This change sets the default value of "cores" to be ceil(cpu_quota / cpu_period), with a fallback to std::thread::hardware_concurrency() if cgroups v2 is not detected.
2022-06-23Remove NIX_LIBEXEC_DIREelco Dolstra
2022-06-23Fix build-remote in nix-staticEelco Dolstra
'build-remote' is now executed via /proc/self/exe so it always works.
2022-02-25Remove std::string alias (for real this time)Eelco Dolstra
Also use std::string_view in a few more places.
2021-11-23"recursive-nix" system feature only with experimental featureJohn Ericson
2021-10-26Make experimental-features a proper typeregnat
Rather than having them plain strings scattered through the whole codebase, create an enum containing all the known experimental features. This means that - Nix can now `warn` when an unkwown experimental feature is passed (making it much nicer to spot typos and spot deprecated features) - It’s now easy to remove a feature altogether (once the feature isn’t experimental anymore or is dropped) by just removing the field for the enum and letting the compiler point us to all the now invalid usages of it.
2021-10-15Add another path where a Rosetta 2 configuration file is possibly locatedyvt
2021-09-14Advise using --extra-experimental-features instead of --experimental-featuresEelco Dolstra
Fixes #3737.
2021-03-26Fix some typosEelco Dolstra
Fixes #4671.
2021-02-25Don't crash when copying realisations to a non-ca remoteregnat
Rather throw a proper exception, and catch&log it on the client side
2021-02-24Initialize plugins after handling initial command line flagsShea Levy
This is technically a breaking change, since attempting to set plugin files after the first non-flag argument will now throw an error. This is acceptable given the relative lack of stability in a plugin interface and the need to tie the knot somewhere once plugins can actually define new subcommands.
2021-02-24Bail if plugin-files is set after plugins have been loaded.Shea Levy
We know the flag will be ignored but the user wants it to take effect.
2021-02-22Add x86_64 compute levels as additional system typesDaniël de Kok
When performing distributed builds of machine learning packages, it would be nice if builders without the required SIMD instructions can be excluded as build nodes. Since x86_64 has accumulated a large number of different instruction set extensions, listing all possible extensions would be unwieldy. AMD, Intel, Red Hat, and SUSE have recently defined four different microarchitecture levels that are now part of the x86-64 psABI supplement and will be used in glibc 2.33: https://gitlab.com/x86-psABIs/x86-64-ABI https://lwn.net/Articles/844831/ This change uses libcpuid to detect CPU features and then uses them to add the supported x86_64 levels to the additional system types. For example on a Ryzen 3700X: $ ~/aps/bin/nix -vv --version | grep "Additional system" Additional system types: i686-linux, x86_64-v1-linux, x86_64-v2-linux, x86_64-v3-linux
2021-01-08string2Int(): Return std::optionalEelco Dolstra
2020-12-04Use com.apple.oahd.plist for rosetta 2 detectionMatthew Bauer
2020-12-03Add extraPlatforms for Rosetta 2 macOSMatthew Bauer
macOS systems with ARM64 can utilize a translation layer at /Library/Apple/usr/libexec/oah to run x86_64 binaries. This change makes Nix recognize that and it to "extra-platforms". Note that there are two cases here since Nix could be built for either x86_64 or aarch64. In either case, we can switch to the other architecture. Unfortunately there is not a good way to prevent aarch64 binaries from being run in x86_64 contexts or vice versa - programs can always execute programs for the other architecture.
2020-10-29Generalize extra-* settingsEelco Dolstra
This removes the extra-substituters and extra-sandbox-paths settings and instead makes every array setting extensible by setting "extra-<name> = <value>" in the configuration file or passing "--<name> <value>" on the command line.
2020-10-21Add NIX_CONFIG env var for applying nix.conf overridesChristian Kampka
2020-10-06Remove static variable name clashesEelco Dolstra
This was useful for an experiment with building Nix as a single compilation unit. It's not very useful otherwise but also doesn't hurt...
2020-09-22Merge pull request #4038 from maljub01/masterEelco Dolstra
Add a nix.conf option for allowing a symlinked store
2020-09-21Serialize SandboxMode enum to string for JSONCole Helbling
Rather than showing an integer as the default, instead show the boolean referenced in the description. The nix.conf.5 manpage used to show "default: 0", which is unnecessarily opaque and confusing (doesn't 0 mean false, even though the default is true?); now it properly shows that the default is true.
2020-09-21abstractsettingtojson.hh -> abstract-setting-to-json.hhEelco Dolstra