aboutsummaryrefslogtreecommitdiff
path: root/tests
AgeCommit message (Collapse)Author
2024-05-03Rename `nix show-config` to `nix config show`Théophane Hufschmitt
Part of #7672 My main motivation is to be able to use `nix.checkConfig`[1]. This doesn't work with Lix currently since the module uses `nix show-config` if the Nix version is <2.20pre and `nix config show` otherwise. I think this is the only instance where nixpkgs checks for which Nix commands exist that affects us now, so I figured we could just perform the rename here as well[2] and still provide the current version number[3]. I don't have a strong opinion on whether to deprecate `nix show-config`, the warning is added there automatically. (cherry picked from commit f300e11b056dea414d7d77bbc6e5a7dc5d9ddd41) [1] https://nixos.org/manual/nixos/stable/options.html#opt-nix.checkConfig [2] I should add that I don't use the "official" ways of installing Lix because using the flake directly and callPackaging it seemed to fit better into my workflow: I already have a little mess to make sure Hydra from the flake uses the correct pkgs.nix and I didn't want to complicate it further while keeping a single package-set I can build in CI. Don't get me wrong, I think such a module for a quick-start is very important, just giving context on why I bother in the first place :) [3] When we go public, I think it's worth considering to add support in nixpkgs itself for Lix. Change-Id: I47b4239b05cbeda3c370d2fa56ea768b768768ac
2024-05-03libutil: make rewriteStrings soundeldritch horrors
this is used in CA rewriting, replacement of placeholders in derivations, generating scripts for devShells, and some more places. in all of these transitive replacements are unsound, and overlapping replacements would be as well. there even is a test that transitive replacements do not happen (in the CA RewriteSink suite), but none for overlapping replacements. a minimally surprising binary rewriter surely would not do any of these replacements, the only reason we have not seen this break yet is probably that rewriteStrings is only called for store paths and things that look like store paths (and those should never overlap nor admit such transitive replacements) Change-Id: I6fc29f939d5061d9f56c752624a823ece8437c07
2024-05-02Merge changes from topic "profile-v3" into mainQyriad
* changes: nix3-profile: remove check "name" attr in manifests Add profile migration test nix3-profile: make element names stable getNameFromURL(): Support uppercase characters in attribute names nix3-profile: remove indices nix3-profile: allow using human-readable names to select packages implement parsing human-readable names from URLs
2024-05-02Add profile migration testEelco Dolstra
(cherry picked from commit 72560f7bbef2ab3c02b8ca040fe084328bdd5fbe) Upstream-PR: https://github.com/NixOS/nix/pull/9656 Change-Id: I405e5848e2627a76940220fb6aebadfb8f094afb
2024-05-02nix3-profile: make element names stableQyriad
Based off of commit 6268a45b650f563bae2360e0540920a2959bdd40 Upstream-PR: https://github.com/NixOS/nix/pull/9656 Co-authored-by: Eelco Dolstra <edolstra@gmail.com> Change-Id: I0fcf069a8537c61ad6fc4eee1f3c193a708ea1c4
2024-05-02getNameFromURL(): Support uppercase characters in attribute namesEelco Dolstra
In particular, this makes it handle 'legacyPackages' correctly. (cherry picked from commit 936a3642264ac159f3f9093710be3465b70e0e89) Upstream-PR: https://github.com/NixOS/nix/pull/9657 Change-Id: Icc4efe02f7f8e90a2970589f72fd3d3cd4418d95
2024-05-02nix3-profile: remove indicesQyriad
Based off of commit 3187bc9ac3dd193b9329ef68c73ac3cca794ed78 Upstream-PR: https://github.com/NixOS/nix/pull/9656 Co-authored-by: Eelco Dolstra <edolstra@gmail.com> Change-Id: I8ac4a33314cd1cf9de95404c20f58e883460acc7
2024-05-02nix3-profile: allow using human-readable names to select packagesQyriad
These names are parsed from the URL provided for that package Based off of commit 257b768436a0e8ab7887f9b790c5b92a7fe51ef5 Upstream-PR: https://github.com/NixOS/nix/pull/8678 Co-authored-by: Felix Uhl <felix.uhl@outlook.com> Change-Id: I76d5f9cfb11d3d2915b3dd1db21d7bb49e91f4fb
2024-05-02Disallow store path names that are . or .. (plus opt. -)Robert Hensing
As discussed in the maintainer meeting on 2024-01-29. Mainly this is to avoid a situation where the name is parsed and treated as a file name, mostly to protect users. .-* and ..-* are also considered invalid because they might strip on that separator to remove versions. Doesn't really work, but that's what we decided, and I won't argue with it, because .-* probably doesn't seem to have a real world application anyway. We do still permit a 1-character name that's just "-", which still poses a similar risk in such a situation. We can't start disallowing trailing -, because a non-zero number of users will need it and we've seen how annoying and painful such a change is. What matters most is preventing a situation where . or .. can be injected, and to just get this done. (cherry picked from commit f1b4663805a9dbcb1ace64ec110092d17c9155e0) Change-Id: I900a8509933cee662f888c3c76fa8986b0058839
2024-05-02test: Generate distinct hashesRobert Hensing
Gen::just is the constant generator. Don't just return that! (cherry picked from commit 8406da28773f050e00a006e4812e3ecbf919a2a9) Change-Id: Ibfd0bd40f90942077a4720086ce0cd3bfabef79d
2024-05-02test: Generate distinct path namesRobert Hensing
Gen: :just is the constant generator. Don't just return that! (cherry picked from commit 69bbd5852af9b2f0b794162bd1debcdf64fc6648) Change-Id: Id6e58141f5a42a1f67bd11d48c87b32a3ebd0500
2024-05-02parseStorePath: Support leading periodRobert Hensing
(cherry picked from commit b13e6a76b4f289c6db69ffaa7bd35b7e44f2a391) Change-Id: Ie14be437d87d17248f80e1f009aa2a4311ddede6
2024-05-02Revert "StorePath: reject names starting with '.'"Robert Hensing
This reverts commit 24bda0c7b381e1a017023c6f7cb9661fae8560bd. (cherry picked from commit 9ddd0f2af8fd95e1380027a70d0aa650ea2fd5e4) Change-Id: Ideb547e2a8ac911cf39d58d3e0c1553867bdd776
2024-04-30implement parsing human-readable names from URLsQyriad
Based off of commit 257b768436a0e8ab7887f9b790c5b92a7fe51ef5 Upstream-PR: https://github.com/NixOS/nix/pull/8678 Co-authored-by: Felix Uhl <felix.uhl@outlook.com> Change-Id: Idcb7f6191ca3310ef9dc854197f7798260c3f71d
2024-04-29add VM test for nix upgrade-nixQyriad
This commit adds a new NixOS VM test, which tests that `nix upgrade-nix` works on both kinds of profiles (manifest.nix and manifest.json). Done as a separate commit from 831d18a13, since it relies on the --store-path argument from 026c90e5f as well. Change-Id: I5fc94b751d252862cb6cffb541a4c072faad9f3b
2024-04-26Merge "ssh-ng: Set log-fd for ssh to `4` by default" into mainMaximilian Bosch
2024-04-26ssh-ng: Set log-fd for ssh to `4` by defaultMaximilian Bosch
That's expected by `build-remote` and makes sure that errors are correctly forwarded to the user. For instance, let's say that the host-key of `example.org` is unknown and nix-build ../nixpkgs -A hello -j0 --builders 'ssh-ng://example.org' is issued, then you get the following output: cannot build on 'ssh-ng://example.org?&': error: failed to start SSH connection to 'example.org' Failed to find a machine for remote build! derivation: yh46gakxq3kchrbihwxvpn5bmadcw90b-hello-2.12.1.drv required (system, features): (x86_64-linux, []) 2 available machines: [...] The relevant information (`Host key verification failed`) ends up in the daemon's log, but that's not very obvious considering that the daemon isn't very chatty normally. This can be fixed - the same way as its done for legacy-ssh - by passing fd 4 to the SSH wrapper. Now you'd get the following error: cannot build on 'ssh-ng://example.org': error: failed to start SSH connection to 'example.org': Host key verification failed. Failed to find a machine for remote build! [...] ...and now it's clear what's wrong. Please note that this is won't end up in the derivation's log. For previous discussion about this change see https://github.com/NixOS/nix/pull/7659. Change-Id: I5790856dbf58e53ea3e63238b015ea06c347cf92
2024-04-25gc: Find roots using libproc on DarwinArtemis Tosini
Previously, the garbage collector found runtime roots on Darwin by shelling out to `lsof -n -w -F n` then parsing the result. However, this requires an lsof binary and can be extremely slow. The official Apple lsof returns in a reasonable amount of time, about 250ms in my tests, but the lsof packaged in nixpkgs is quite slow, taking about 40 seconds to run the command. Using libproc directly is about the same speed as Apple lsof, and allows us to reënable several tests that were disabled on Darwin. Change-Id: Ifa0adda7984e13c15535693baba835aae79a3577
2024-04-22tests: add error messages to the asserts in tarball flakes testQyriad
In hopes of avoiding opaque error messages like the one in https://buildbot.lix.systems/#/builders/49/builds/1054/steps/1/logs/stdio Traceback (most recent call last): File "/nix/store/wj6wh89jhd2492r781qsr09r9wydfs6m-nixos-test-driver-1.1/bin/.nixos-test-driver-wrapped", line 9, in <module> sys.exit(main()) ^^^^^^ File "/nix/store/wj6wh89jhd2492r781qsr09r9wydfs6m-nixos-test-driver-1.1/lib/python3.11/site-packages/test_driver/__init__.py", line 126, in main driver.run_tests() File "/nix/store/wj6wh89jhd2492r781qsr09r9wydfs6m-nixos-test-driver-1.1/lib/python3.11/site-packages/test_driver/driver.py", line 159, in run_tests self.test_script() File "/nix/store/wj6wh89jhd2492r781qsr09r9wydfs6m-nixos-test-driver-1.1/lib/python3.11/site-packages/test_driver/driver.py", line 151, in test_script exec(self.tests, symbols, None) File "<string>", line 13, in <module> AssertionError Change-Id: Idd2212a1c3714ce58c7c3a9f34c2ca4313eb6d55
2024-04-21remove extraneous cache entry from github fetcherPuck Meerburg
This isn't necessary, as it's already covered by the tarball fetcher's cache. Change-Id: I85e35f5a61594f27b8f30d82145f92c5d6559e1f
2024-04-18tests: unhaunt the flakes nixos testseldritch horrors
these should really wait for networks to come up, otherwise they can fail. fixes #235 Change-Id: I08989e8bdb0de280df74660ac43983de5c34fa9d
2024-04-16Merge "libstore/build: set NO_NEW_PRIVS for the sandbox" into mainIlya K
2024-04-15abort with a descriptive message on bad HintFmt usageQyriad
Change-Id: Ic2f05572042343a8160fd971394372f5f2706fc4
2024-04-15libstore/build: set NO_NEW_PRIVS for the sandboxK900
Change-Id: I711f64e2b68495ed9c85c1a4bd5025405805e43a
2024-04-13libstore/build: just copy the magic /etc files into the sandboxK900
Saves us a bunch of thinking about how to handle symlinks, and prevents the DNS config from changing on the fly under the build, which may or may not be a good thing? Change-Id: I071e6ae7e220884690b788d94f480866f428db71
2024-04-11Merge pull request #10456 from NixOS/fixpermdeniedbindThéophane Hufschmitt
Fix adding symlink to the sandbox paths (cherry-picked from commit da1e977bf48cff2a635034c85e7c13878e38efc2) Change-Id: I221c85a38180800ec6552d2e86a88df48398fad8
2024-04-09Print top-level errors normally in `nix repl`Rebecca Turner
Previously, errors while printing values in `nix repl` would be printed in `«error: ...»` brackets rather than displayed normally: ``` nix-repl> legacyPackages.aarch64-darwin.pythonPackages.APScheduler «error: Package ‘python-2.7.18.7’ in /nix/store/6s0m1qc31zw3l3kq0q4wd5cp3lqpkq0q-source/pkgs/development/interpreters/python/cpython/2.7/default.nix:335 is marked as insecure, refusing to evaluate.» ``` Now, errors will be displayed normally if they're emitted at the top-level of an expression: ``` nix-repl> legacyPackages.aarch64-darwin.pythonPackages.APScheduler error: … in the condition of the assert statement at /nix/store/6s0m1qc31zw3l3kq0q4wd5cp3lqpkq0q-source/lib/customisation.nix:268:17: 267| in commonAttrs // { 268| drvPath = assert condition; drv.drvPath; | ^ 269| outPath = assert condition; drv.outPath; … in the left operand of the OR (||) operator at /nix/store/6s0m1qc31zw3l3kq0q4wd5cp3lqpkq0q-source/pkgs/development/interpreters/python/passthrufun.nix:28:45: 27| if lib.isDerivation value then 28| lib.extendDerivation (valid value || throw "${name} should use `buildPythonPackage` or `toPythonModule` if it is to be part of the Python packages set.") {} value | ^ 29| else (stack trace truncated; use '--show-trace' to show the full trace) error: Package ‘python-2.7.18.7’ in /nix/store/6s0m1qc31zw3l3kq0q4wd5cp3lqpkq0q-source/pkgs/development/interpreters/python/cpython/2.7/default.nix:335 is marked as insecure, refusing to evaluate. ``` Errors emitted in nested structures (like e.g. when printing `nixpkgs`) will still be printed in brackets. Change-Id: I25aeddf08c017582718cb9772a677bf51b9fc2ad
2024-04-09Merge "Add `repl-overlays`" into mainrebecca “wiggles” turner
2024-04-08Add `repl-overlays`Rebecca Turner
Adds a `repl-overlays` option, which specifies files that can overlay and modify the top-level bindings in `nix repl`. For example, with the following contents in `~/.config/nix/repl.nix`: info: final: prev: let optionalAttrs = predicate: attrs: if predicate then attrs else {}; in optionalAttrs (prev ? legacyPackages && prev.legacyPackages ? ${info.currentSystem}) { pkgs = prev.legacyPackages.${info.currentSystem}; } We can run `nix repl` and use `pkgs` to refer to `legacyPackages.${currentSystem}`: $ nix repl --repl-overlays ~/.config/nix/repl.nix nixpkgs Lix 2.90.0 Type :? for help. Loading installable 'flake:nixpkgs#'... Added 5 variables. Loading 'repl-overlays'... Added 6 variables. nix-repl> pkgs.bash «derivation /nix/store/g08b5vkwwh0j8ic9rkmd8mpj878rk62z-bash-5.2p26.drv» Change-Id: Ic12e0f2f210b2f46e920c33088dfe1083f42391a
2024-04-08"but doctor, I AM the untrusted store": nix doctor had wrong trustednessJade Lovelace
This probably snuck in in a refactor using truthiness or so. The trustedness flag was having the optional fullness checked, rather than the actual contained trust level. Also adds some tests. ``` m1@6876551b-255d-4cb0-af02-8a4f17b27e2e ~ % nix store ping warning: 'nix store ping' is a deprecated alias for 'nix store info' Store URL: daemon Version: 2.20.4 Trusted: 0 m1@6876551b-255d-4cb0-af02-8a4f17b27e2e ~ % nix doctor warning: 'doctor' is a deprecated alias for 'config check' [PASS] PATH contains only one nix version. [PASS] All profiles are gcroots. [PASS] Client protocol matches store protocol. [INFO] You are trusted by store uri: daemon ``` Fixes: https://git.lix.systems/lix-project/lix/issues/232 Change-Id: I21576e2a0a755036edf8814133345987617ba3d0
2024-04-08Merge "Don't run libstore unit tests in project root" into mainrebecca “wiggles” turner
2024-04-08Don't run libstore unit tests in project rootRebecca Turner
This keeps the libstore unit tests from writing `libstore-unit-tests.xml` to the project root. Change-Id: I0d9909aabf9f3574cc1e72a5ae81daefba9a394b
2024-04-08Fix REPL test parser nitsRebecca Turner
Follow-up to https://gerrit.lix.systems/c/lix/+/546 Change-Id: Ie603f01e5520329bf879e061cea9e3fba45213fd
2024-04-08Merge "Rename some parse failure tests to `parse-fail-*`" into mainrebecca “wiggles” turner
2024-04-08Merge "Add `PathsSetting`" into mainrebecca “wiggles” turner
2024-04-07Merge pull request #10208 from 9999years/print-strings-directlyRobert Hensing
`:print` strings directly in `nix repl` (cherry picked from commit 3539172fd2f7cee639ce46423c58beca4231f2db) Change-Id: I1972f3bf3b56312851f38288509d371d37f21677 Upstream-PR: https://github.com/NixOS/nix/pull/10208
2024-04-07Add `PathsSetting`Rebecca Turner
Change-Id: I1165f6ef033a5f757ca3716d3f8008ba36b01fd0
2024-04-06Merge "Rewrite REPL test parser" into mainrebecca “wiggles” turner
2024-04-06Merge "meson: add missing tests: ca, dyn-drv, plugins, libstoreconsumer" ↵Qyriad
into main
2024-04-05Merge changes I1fa30114,I3ca208b6,Ide4c6e00,I74c46b9f,I05fa6a9d, ... into maineldritch horrors
* changes: Revert "libutil: drop Pool resources on exceptional free" Revert "libutil: remove Pool::Handle::bad" Revert "libstore: remove one Resource::good flag" Revert "libstore: using throwing finally in withFramedSink" Revert "libutil: allow graceful dropping of Pool::Handle" Revert "libutil: drop Fs{Source,Sink}::good" libutil: guard Finally against invalid exception throws
2024-04-05Merge "meson: run repl characterization test" into mainQyriad
2024-04-05Rewrite REPL test parserRebecca Turner
- Use a recursive descent parser so that it's easy to extend. - Add `@args` to enable customizing command-line arguments - Add `@should-start` to enable `nix repl` tests that error before entering the REPL - Make sure to read all stdout output before comparing. This catches some extra output we were tossing out before! Change-Id: I5522555df4c313024ab15cd10f9f04e7293bda3a
2024-04-05Revert "libutil: drop Pool resources on exceptional free"eldritch horrors
This reverts commit de2884b82b376d10de5c400d8e73bc7d98f195d2. Change-Id: I1fa301149d7c2ed3d266a40c15b2d010e12e44e6
2024-04-04meson: add missing tests: ca, dyn-drv, plugins, libstoreconsumerQyriad
Change-Id: I6a74ebaf93697cb99aadd6b51538c2766b0a808a
2024-04-04Rename some parse failure tests to `parse-fail-*`Rebecca Turner
These were mistakenly labeled `eval-fail-*`. Note that the `lang.sh` runner passes `parse-fail-*` tests on stdin, so filenames are removed from error messages. Change-Id: I7f3a0d78b6cfa87af29aaa1b7af19d5a57fd4ade
2024-04-03meson: run repl characterization testQyriad
This was mistakenly left out of 69c3363f2. Fixes #205. Change-Id: Ib9a2088c9eee3a192623bee107ba32221d048640
2024-04-03Make `repl_characterization.cc` constants `string_view`sRebecca Turner
Change-Id: I96455ee365799ae87d9ab433cf102c691616a45e
2024-04-03Add `EscapeStringOptions` and `escapeString` testsRebecca Turner
Change-Id: I86ead2f969c9e03c9edfa51bbc92ee06393fd7d6
2024-03-31Merge pull request #9920 from 9999years/forbid-nested-debuggersThéophane Hufschmitt
Forbid nested debuggers (cherry picked from commit e164b39ee90fd655dbb7f479fdd4fbe38cc883bd) Change-Id: Iff62f40fd251116516a63e2d3f9fb5b21480b16d
2024-03-31Merge changes Ib62d3d68,Ic3e7affe into mainjade
* changes: Make things that can throw not noexcept anymore Fix various clang-tidy lints