summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBenedikt Peetz <benedikt.peetz@b-peetz.de>2026-11-09 16:33:34 +0100
committerBenedikt Peetz <benedikt.peetz@b-peetz.de>2026-11-09 16:39:23 +0100
commite4ea0cd4cad0f54ab3bc311c3b35bc4bb61bf8d4 (patch)
tree74d90a5e2b20617951734eac291d8e90acbef9bb
parentpkgs/rollup: Support creating and applying patches at the same time (diff)
downloadnixos-config-e4ea0cd4cad0f54ab3bc311c3b35bc4bb61bf8d4.zip
pkgs/rollup: Check if the `--to` directory is actually writable
Otherwise we would create the patches, but fail to apply them. The issue is that we already moved the tag forward, so the user now needs to manually create the patches again (after exiting the sandbox).
-rw-r--r--pkgs/by-name/ro/rollup/src/main.rs25
1 files changed, 24 insertions, 1 deletions
diff --git a/pkgs/by-name/ro/rollup/src/main.rs b/pkgs/by-name/ro/rollup/src/main.rs
index 12cf7dd9..069ed59b 100644
--- a/pkgs/by-name/ro/rollup/src/main.rs
+++ b/pkgs/by-name/ro/rollup/src/main.rs
@@ -2,7 +2,7 @@ use std::{
env::current_dir,
fs,
io::Write,
- path::PathBuf,
+ path::{Path, PathBuf},
process::{Command, Stdio},
};
@@ -285,3 +285,26 @@ fn apply_patches(patch_files: Vec<PathBuf>, to: PathBuf, debug_parse: bool) -> R
Ok(())
}
+
+fn check_to(to: &Path) -> Result<()> {
+ let to = to.join(".git");
+
+ // NOTE: We cannot just try to stat() the path, because landlock might be in use and does not
+ // currently deny that (tracked in: https://github.com/landlock-lsm/linux/issues/52) <2026-11-09>
+ // So we instead try to list it.
+ let is_listable = {
+ let dir_entries = fs::read_dir(&to).with_context(|| {
+ format!(
+ "Failed check regarding `--to` directory (`{}`) readability. Are you in a sandbox?",
+ to.display()
+ )
+ })?;
+ dir_entries.count() > 0
+ };
+
+ if !is_listable {
+ bail!("To directory (`{}`) is not readable", to.display());
+ }
+
+ Ok(())
+}