Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

singularity-tools: miscellaneous fixes (2nd round) #333843

Merged
merged 8 commits into from
Aug 15, 2024

Conversation

ShamrockLee
Copy link
Contributor

@ShamrockLee ShamrockLee commented Aug 11, 2024

Description of changes

When rebasing #268199, I found some more minor issues. Here's what I do in this round of fixes:

  • Include bashInteractive and runScriptFile into closureInfo and the resulting container image.
  • Make singularity-tools extensible instead of using rec. This will be useful for singularity-tools: refactor and add runImageInLinuxVM; apptainer.passthru.tests.exec-image-in-linux-vm: init #268199.
  • Tidy up the VM disk image mounting code. Place the disk image outside "$out" instead of removing it.
  • String-interpolate contents before copying (instead of toString) to ensure that path objects get appropriately included in the resulting image.
  • Don't preserve ownership when copying store contents so that such copying won't require root privileges.
  • Miscellaneous shell linting.

Thank you, @SomeoneSerge, for being so patient in reviewing everything.

Things done

  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandboxing enabled in nix.conf? (See Nix manual)
    • sandbox = relaxed
    • sandbox = true
  • Tested, as applicable:
  • Tested compilation of all packages that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage
  • Tested basic functionality of all binary files (usually in ./result/bin/)
  • 24.11 Release Notes (or backporting 23.11 and 24.05 Release notes)
    • (Package updates) Added a release notes entry if the change is major or breaking
    • (Module updates) Added a release notes entry if the change is significant
    • (Module addition) Added a release notes entry if adding a new NixOS module
  • Fits CONTRIBUTING.md.

Add a 👍 reaction to pull requests you find important.

@ShamrockLee ShamrockLee marked this pull request as draft August 11, 2024 05:16
@ShamrockLee
Copy link
Contributor Author

ShamrockLee commented Aug 11, 2024

I found some issues inside this PR and will hold it back until they are resolved.

@ShamrockLee
Copy link
Contributor Author

Problem solved. It's now ready for review.

@ShamrockLee ShamrockLee marked this pull request as ready for review August 11, 2024 05:29
@ofborg ofborg bot added 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin 10.rebuild-linux: 0 This PR does not cause any packages to rebuild on Linux labels Aug 11, 2024
cp -ar $f ./$f
done
while IFS= read -r f; do
cp -r "$f" "./$f"
Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder why -a is not necessary. I'm seeing that if I do

$ touch a
$ chmod +x a
$ cp a b
$ stat b

...bs still has the +x bit, but I don't know why

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm seeing that if I do

$ touch a
$ chmod +x a
$ cp a b
$ stat b

...bs still has the +x bit, but I don't know why

For cp, -a (--archive) implies --preserve all, which means preserving all attributes, including mode, ownership, timestamps, links (hard links), context (SELinux or SMACK security context), xattr. cp preserves the file mode by default but not the file ownership.

It requires root privileges to create a file owned by root:root, which is why it requires root privileges to cp -ra from a store object.

I wonder why -a is not necessary.

The initial purpose of preserving ownership might be to please Nix when using Nix inside the container. However, the container Nix store is inherently broken from Nix's perspective, as it doesn't include the database.

Cc: @jbedo, the original author of singularity-tools.

Copy link
Contributor

Choose a reason for hiding this comment

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

It requires root privileges to create a file owned by root:root

It doesn't? In particular, this works:

with import <nixpkgs> { };

runCommand "abc" { } ''
  cp -ar ${hello}/ $out/
''

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It requires root privileges to create a file owned by root:root

It doesn't? In particular, this works:

with import <nixpkgs> { };

runCommand "abc" { } ''
  cp -ar ${hello}/ $out/
''

Oops! I remember that it wasn't when I first worked on it.

for c in ${lib.escapeShellArgs contents} ; do
for f in "$c"/bin/* ; do
if [ ! -e "bin/$(basename "$f")" ] ; then
ln -s "$f" bin/
Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I agree with using PATH instead of /bin symlinking. I used it in the definition-based build provided by #224636. Here is our previous discussion on this topic: https://github.com/NixOS/nixpkgs/pull/224636/files#r1160279847

May not be in scope for the PR

I'm unsure if people (we) have reached a consensus about this change, so I didn't include it in this PR.

String-interpolation converts path objects inside `contents` into store
paths to ensure they are properly included in the result image.

See tests.trivial-builders.references for the necessity of
string-interpolation.

Quote each string-interpolated content member to accomodates spaces
inside.
@ShamrockLee
Copy link
Contributor Author

I don't see why the "Check pkgs/by-name pkgs-by-name-check" CI check fails. This pull request has nothing to do with pkgs/by-name, and the test doesn't show which part has failed as it used to.

image

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't see why the "Check pkgs/by-name pkgs-by-name-check" CI check fails.

Not sure, I restarted the job and it seems fine

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

Huh, I thought that was a day ago

Copy link
Contributor

Choose a reason for hiding this comment

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

https://www.githubstatus.com/incidents/mrpx4trfk45z they had another one in this area

@SomeoneSerge SomeoneSerge merged commit 10ce447 into NixOS:master Aug 15, 2024
21 checks passed
@ShamrockLee ShamrockLee deleted the singularity-tools-fixes2 branch August 15, 2024 18:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin 10.rebuild-linux: 0 This PR does not cause any packages to rebuild on Linux
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants