Skip to content

Clean up AutoRemoveJail, AutoDelete, and AutoUnmount#15079

Merged
Ericson2314 merged 1 commit intomasterfrom
auto-cleanup-cleanups
Jan 27, 2026
Merged

Clean up AutoRemoveJail, AutoDelete, and AutoUnmount#15079
Ericson2314 merged 1 commit intomasterfrom
auto-cleanup-cleanups

Conversation

@Ericson2314
Copy link
Member

Motivation

  • Extract destructor logic into named methods (deletePath(), unmount(), and remove()) that can be called explicitly. These ones will throw exceptions normally, unlike the destructor which must quash them to avoid double-exceptions.

  • Use std::filesystem::path in AutoUnmount (changed from Path)

  • Remove del field from AutoRemoveJail, using INVALID_JAIL sentinel value instead.

  • Add move assignment operators implemented via friend swap functions for all three RAII classes.

  • Remove old reset(...) methods that took parameters. These were a bit misleading --- do they cancel or immediately destroy? --- and doing it explicitly with cancel and then assignment is not hard.

Context

Needed for some sandboxing cleanups.


Add 👍 to pull requests you find important.

The Nix maintainer team uses a GitHub project board to schedule and track reviews.

@Ericson2314 Ericson2314 requested a review from edolstra as a code owner January 24, 2026 23:50
@github-actions github-actions bot added the fetching Networking with the outside (non-Nix) world, input locking label Jan 24, 2026
@Ericson2314 Ericson2314 force-pushed the auto-cleanup-cleanups branch 2 times, most recently from 0e6dce9 to ad5a1e1 Compare January 24, 2026 23:53
@Ericson2314 Ericson2314 force-pushed the auto-cleanup-cleanups branch from ad5a1e1 to e71b860 Compare January 26, 2026 19:11
@github-actions github-actions bot added new-cli Relating to the "nix" command store Issues and pull requests concerning the Nix store labels Jan 26, 2026
@Ericson2314 Ericson2314 force-pushed the auto-cleanup-cleanups branch 2 times, most recently from c7694a2 to 6f9c5a7 Compare January 26, 2026 22:04
@Ericson2314 Ericson2314 force-pushed the auto-cleanup-cleanups branch from 6f9c5a7 to f3668dc Compare January 26, 2026 22:10
@Ericson2314 Ericson2314 force-pushed the auto-cleanup-cleanups branch from f3668dc to 3a5c0fa Compare January 26, 2026 22:17
@Ericson2314 Ericson2314 force-pushed the auto-cleanup-cleanups branch from 985418e to acce905 Compare January 26, 2026 22:22
- Extract destructor logic into named methods (`deletePath()`,
  `unmount()`, and `remove()`) that can be called explicitly. These ones
  will throw exceptions normally, unlike the destructor which must quash
  them to avoid double-exceptions.

- Use `std::filesystem::path` in `AutoUnmount` (changed from `Path`)

- Remove `del` field from `AutoRemoveJail`, using `INVALID_JAIL`
  sentinel value instead.

- Add move assignment operators implemented via friend `swap` functions
  for all three RAII classes.

- Remove old `reset(...)` methods that took parameters. These were a bit
  misleading --- do they cancel or immediately destroy? --- and doing it
  explicitly with cancel and then assignment is not hard.

Co-authored-by: Sergei Zimmerman <sergei@zimmerman.foo>
@Ericson2314 Ericson2314 force-pushed the auto-cleanup-cleanups branch from 008a2e8 to 5dfd81c Compare January 26, 2026 22:27
@Ericson2314 Ericson2314 added this pull request to the merge queue Jan 26, 2026
Merged via the queue into master with commit bad1a00 Jan 27, 2026
18 checks passed
@Ericson2314 Ericson2314 deleted the auto-cleanup-cleanups branch January 27, 2026 00:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fetching Networking with the outside (non-Nix) world, input locking new-cli Relating to the "nix" command store Issues and pull requests concerning the Nix store

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants