Commit Graph
33 Commits
Author SHA1 Message Date
Lily Ballard 20fed838a6 libcmd: replace @docroot@ when rendering markdown
Also replace links to `.md` files with the equivalent `.html` files.

Change-Id: Id0000000f267872d021985daf2d833a93ec06e66
2025-06-18 00:42:36 -07:00
Lily Ballard 97f1c5cfa1 Fix markdown link edge cases
Lowdown doesn't quite conform to CommonMark in parsing shortcut links
that are followed by a parenthesized expression, which looks like
`[link text] (unrelated text)`. CommonMark says the space there is
significant and ensures the `[link text]` is parsed as a shortcut link,
but Lowdown parses this like `[link text](unrelated text)`.

This fixes the output of `nix help`. The other case of a near-link was
in the `nix-env --install` docs, which don't get parsed by Lowdown, but
it turns out the link reference definition was missing. The generated
manpage stripped the brackets but the HTML manual page rendered the
broken link with brackets.

Change-Id: I6a6a69641fd2dbf9930bcd875ed21ea80fba909a
2025-06-15 19:04:00 -07:00
Lily BallardandLix Systems Gerrit 8fa0363b91 Merge "libutil: read window size from stdout if stderr fails" into main 2025-05-18 21:09:16 +00:00
Lily Ballard 8630cedbca libutil: read window size from stdout if stderr fails
This fixes the output of `nix help 2>/dev/null` so it stops wrapping at
60 columns.

Change-Id: Id0000000842b5befd73afbd6aff2825bdeae46af
2025-05-17 12:19:06 -07:00
Lily BallardandLix Systems Gerrit b7ce00fc55 Merge "libutil: move filterANSIEscapes tests" into main 2025-05-15 01:42:34 +00:00
Lily BallardandLix Systems Gerrit 5ed5efe6fc Merge "libcmd: use correct stream for ANSI testing for markdown" into main 2025-05-14 02:15:18 +00:00
Lily Ballard bc5d7ad458 libutil: move filterANSIEscapes tests
This moves the original test suite for `filterANSIEscapes` into the same
file as the newer tests. There is some overlap between the old and new
tests but that doesn't hurt anything so I kept them as-is.

Change-Id: Id00000009919024a5f206ec9a7bc0022541ff612
2025-05-13 19:04:52 -07:00
Lily BallardandLix Systems Gerrit 6237c50161 Merge "libutil: handle OSC escapes in filterANSIEscapes()" into main 2025-05-14 02:02:08 +00:00
Lily Ballard 207b5d81bf libutil: handle OSC escapes in filterANSIEscapes()
This teaches `filterANSIEscapes()` how to find the end of an OSC
sequence. It also keeps OSC 8 (hyperlinks) when not instructed to filter
out all escapes, just as it keeps colors.

This also relaxes the parsing of CSI escapes to find the end of the
sequence for invalid sequences, and handles better escapes that don't
start CSI or OSC.

This fixes the repl output for `:doc builtins.fetchGit`.

Fixes: https://git.lix.systems/lix-project/lix/issues/160
Change-Id: Id0000000f2a6956c042c883a4545edf347fa1799
2025-05-13 18:59:08 -07:00
Lily Ballard 530532ca8a libcmd: use correct stream for ANSI testing for markdown
Rendering markdown tests if ANSI is supported in order to tell lowdown
to disable ANSI escapes. Unfortunately it was testing stderr and yet
nearly all rendered markdown output was printed to stdout.

Change-Id: Id0000000f0e667d235239c095330d355a9b7714a
2025-05-11 17:55:44 -07:00
Lily Ballard e4b48ca3f0 version.json: 2.93.0 -> 2.94.0-dev
Change-Id: Id00000000f2c82a2c5cedd4e962521a34436d45d
2025-05-11 16:51:25 -07:00
Lily Ballardandjade 7f98021c93 daemon: test group membership better on macOS
macOS uses opendirectory for users and groups, which supports nested
groups and groups with synthesized membership. This means that asking
for a group's users isn't sufficient to test for group membership.

With this change, groups like `@localaccounts` or `@_developer` will
work in `trusted-users` and `allowed-users`.

Fixes https://github.com/NixOS/nix/issues/5885

Change-Id: I3b0783ce7cec303de5aba32c8e5ac0f976112c72
2025-02-28 04:45:02 +00:00
Lily BallardandGerrit Code Review df336747e6 Merge "libstore: use BEGIN IMMEDIATE SQLite transactions" into main 2025-02-19 04:51:39 +00:00
Lily Ballard 98ccb179f9 libstore: use BEGIN IMMEDIATE SQLite transactions
Upgrading a read transaction to a write transaction will immediately
fail if another connection/process started a write transaction in the
meantime. For transactions that we expect to perform a write after a
read, starting with `BEGIN IMMEDIATE` gives us a write transaction
immediately instead of beginning with a read transaction and upgrading
it.

Change-Id: I82b8a3843382940a4fa4ffe45f30b365b690ff86
2025-02-17 19:07:59 -08:00
Lily BallardandGerrit Code Review 0069c59eda Merge "libstore: use monotonic clock for SQLITE_BUSY warnings" into main 2025-02-18 02:44:28 +00:00
Lily Ballard ed03c3985d libstore: use monotonic clock for SQLITE_BUSY warnings
Using time_t meant a warning could be printed arbitrarily soon depending
on when the second rolled over relative to when the SQLite transaction
was attempted.

Change-Id: I93401aea65f90e37cd450a293c4dd4d64fba7628
2025-02-16 22:48:45 -08:00
Lily BallardandGerrit Code Review 3b10c19006 Merge "libstore: make SQLite busy back-off logic portable" into main 2025-02-06 04:45:30 +00:00
Lily BallardandGerrit Code Review af1f27cac1 Merge "daemon: get peer pid, gid for socket connection on darwin" into main 2025-02-04 04:50:49 +00:00
Lily Ballard 3eea7866f6 daemon: get peer pid, gid for socket connection on darwin
Fixes: https://git.lix.systems/lix-project/lix/issues/640
Change-Id: I2c4dc0e2642379e3f16fc39909dd4da8695d7239
2025-02-02 22:27:13 -08:00
Lily Ballard a258f78736 libstore: make SQLite busy back-off logic portable
Use C++ standard library not Unix functions for sleeping and randomness.

Also change the PRNG seed from `clock()` to `std::random_device` because
there's no good reason not to and this avoids two threads seeding their
PRNG the same.

Upstream-PR: https://github.com/NixOS/nix/pull/10399
Change-Id: I8424e7406366ea8e825d3e93dbb261ce60e3a37f
2025-01-31 21:27:48 -08:00
Lily BallardandGerrit Code Review d0e0969810 Merge "feat: Add temp-dir setting" into main 2024-11-09 08:44:58 +00:00
Lily Ballard 3c8096e5cb feat: Add temp-dir setting
This adds a new temp-dir setting for controlling the temporary directory
without having to change the TMPDIR env var. This can be used to e.g.
use a path on a case-sensitive store on macOS for temporary files
without changing the TMPDIR var used by interactive shells or commands
invoked with `nix run`.

This also stops unsetting `TMPDIR` on darwin when the env var value
starts with `/var/folders/`, preferring instead to just do the check
when reading `TMPDIR`. This way the inherited `TMPDIR` env var is
preserved for child processes (such as interactive shells).

As a side effect this changes the behavior of `nix-build -o ''` to act
like `nix-build --no-out-link` instead of failing with an error caused
by trying to create a symlink at the cwd.

Fixes: https://git.lix.systems/lix-project/lix/issues/253
Fixes: https://git.lix.systems/lix-project/lix/issues/112
Change-Id: I9ee826323f2deca62854715a77ca7a373a948a29
2024-11-06 18:11:47 -08:00
Lily BallardandGerrit Code Review 72cce7be3f Merge "libstore: replace random() calls with atomic counter" into main 2024-11-07 00:15:23 +00:00
Lily BallardandGerrit Code Review b1a0e3c002 Merge "libstore: remove unnecessary lstats in optimisePath" into main 2024-11-03 05:15:40 +00:00
Lily BallardandGerrit Code Review 834450e237 Merge changes Ibb849b68,I501397c8 into main
* changes:
  libstore: ignore broken symlinks in ssl-cert-file default
  change-authors: add lilyball
2024-11-01 03:51:21 +00:00
Lily Ballard 69957a971e libstore: replace random() calls with atomic counter
random() is not thread-safe, it relies on global state, and calling it
from worker threads can result in multiple threads producing the same
value. It also doesn't guarantee unique values even in single-threaded
use.

Use an atomic counter for the use-case of generating temporary paths,
and switch to a thread-local RNG for the one remaining call.

This will probably fix https://github.com/NixOS/nix/issues/7273 though
I'm not willing to risk corrupting my store to find out.

Change-Id: I4c4c4c9796613573ffefd29cc8efe3d07839facc
2024-10-30 19:54:43 -07:00
Lily Ballard 684f93e783 libstore: ignore broken symlinks in ssl-cert-file default
Also tweak `pathAccessible` to ignore other relevant errors too. It was
documented as ignoring permission errors but it was only ignoring
`EPERM`, which comes from the darwin sandbox, and not ignoring `EACCESS`
which is the real permission error. I figured it also makes sense to
ignore `ELOOP`.

Fixes: https://git.lix.systems/lix-project/lix/issues/560
Change-Id: Ibb849b68d07386eb80afb52b57f7d12b3a48a202
2024-10-30 19:50:38 -07:00
Lily Ballard 11950a0a79 change-authors: add lilyball
Change-Id: I501397c8e3a215a2ccb6074100e2508bae98d1a9
2024-10-30 19:50:38 -07:00
Lily Ballard a042bbde56 libstore: remove unnecessary lstats in optimisePath
We were calling `lstat()` twice on the link path, and a third time if it
existed. We only need to call it once.

Change-Id: Ifadc2f24681648d0ec7e4bad5c6d2dcb2e560e7b
2024-10-27 20:03:29 -07:00
Lily BallardandGerrit Code Review 5ce1d8463a Merge "libstore: add missing #include on darwin" into main 2024-10-22 02:05:44 +00:00
Lily Ballard 4308ec1ae4 gitignore: ignore *.pyc files
Running our installcheck test suite creates these files.

Change-Id: I97ac8f1aa165a491c55dff6b48486db17b75443b
2024-10-20 22:08:35 -07:00
Lily Ballard 65551175e3 libstore: add missing #include on darwin
optimise-store.cc used std::regex on darwin, but forgot to include the
header. This probably compiled due to the precompiled headers file, but
it caused errors in the editor.

Change-Id: I23297c08cb66d44e4d4f303560f46e4adc7d5a43
2024-10-20 22:08:35 -07:00
Lily Ballard 068f4b147d libstore: fix sign comparison warnings in darwin platform
It's not clear to me if `proc_pidinfo()` or `proc_pidfdinfo()` can
actually return negative values, the syscall wrappers convert `-1` into
zero and the semantics suggest that negative values don't make sense,
but just to be safe we'll preserve the int type until we've checked that
it's a positive value.

Fixes: https://git.lix.systems/lix-project/lix/issues/548
Change-Id: If575aec6b1e27dba63091c7a0316c7b3788747cd
2024-10-20 13:13:11 -07:00