Skip to content

Conversation

@cole-h
Copy link
Contributor

@cole-h cole-h commented Jan 29, 2026

--no-preserve=mode causes cp to attempt to clear out the xattrs,
which involves calling the fsetxattr syscall to set the
"system.posix_acl_access" xattr.

A previous attempt used --no-preserve-mode + --preserve=xattr to
prevent needing to change any xattrs at all, but this doesn't work when
cp is built without xattr support. So instead we just create the effect
of --no-preserve=mode without using that flag: making $out writeable,
recursively.

Without this, builds can fail when using macOS's Virtualization.framework
to share the store into a Linux VM, because its implementation of virtiofs
doesn't seem to support xattrs.

Specifically, this fixes building crane derivations with the Native
Linux Builder.

Motivation

Checklist

  • added tests to verify new behavior
  • added an example template or updated an existing one
  • updated docs/API.md (or general documentation) with changes
  • updated CHANGELOG.md

@cole-h cole-h force-pushed the mkDummySrc-preserve-xattrs branch from b34171d to e426c14 Compare January 29, 2026 19:27
`--no-preserve=mode` causes `cp` to attempt to clear out the xattrs,
which involves calling the fsetxattr syscall to set the
"system.posix_acl_access" xattr.

A previous attempt used `--no-preserve-mode` + `--preserve=xattr` to
prevent needing to change any xattrs at all, but this doesn't work when
`cp` is built without xattr support. So instead we just create the effect
of `--no-preserve=mode` without using that flag: making `$out` writeable,
recursively.

Without this, builds can fail when using macOS's Virtualization.framework
to share the store into a Linux VM, because its implementation of virtiofs
doesn't seem to support xattrs.

Specifically, this fixes building crane derivations with the Native
Linux Builder.
@cole-h cole-h force-pushed the mkDummySrc-preserve-xattrs branch from e426c14 to 71d917b Compare January 29, 2026 19:28
@cole-h cole-h changed the title mkDummySrc: preserve xattrs mkDummySrc: preserve mode and then make writeable separately Jan 29, 2026
mkdir -p $out
cp --recursive --no-preserve=mode,ownership ${cleanSrc}/. -t $out
cp --recursive --no-preserve=ownership ${cleanSrc}/. -t $out
chmod +w -R $out
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The exact effect of +w seems to be umask-dependent. Is that OK? Should it use more explicit way of setting the permissions?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking at the generic stdenv setup (what runCommand eventually delegates to) it doesn't seem like umask is set (to something different than its default) so I don't imagine it would affect things here?

Either way if we get this wrong builds will fail if we try to clobber the files. Once the derivation finishes the write permissions will get stripped from the store path

Copy link
Owner

@ipetkov ipetkov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the contribution! Pushed a comment to note that the chmod is "load bearing" here

@ipetkov ipetkov enabled auto-merge (squash) January 30, 2026 01:33
@ipetkov ipetkov merged commit b2f45c3 into ipetkov:master Jan 30, 2026
18 checks passed
@cole-h cole-h deleted the mkDummySrc-preserve-xattrs branch January 30, 2026 01:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants