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: refactor and add runImageInLinuxVM; apptainer.passthru.tests.exec-image-in-linux-vm: init #268199

Draft
wants to merge 9 commits into
base: master
Choose a base branch
from

Conversation

ShamrockLee
Copy link
Contributor

@ShamrockLee ShamrockLee commented Nov 18, 2023

Description of changes

  • Refactor singularity-tools:
    • Replace mkLayer with pkgs.writeClosure. This prevents unnecessary copy of the closures just to get the reference list. (done in trivial-builders: replace writeReferencesToFile with writeClosure #178717)
    • Drop storeDir from the override interface.
    • Use directory name .singularity.d in sandbox for both apptainer and singularity
    • Split the buildImage into multiple reusable build helpers.
      • Add passthru.buildscriptPackage to each of the image derivation, which can be executed to build the image outside of Nix Store. This saves the space and CPU time needed to spawn a VM, allocate a virtual disk file, and copy the result image out from the store.
      • Make each image build helper run preImageBuild and postImageBuild hooks to provide a uniform overriding interface.
      • Split the privileged, VM-spawning build process into buildImageInLinuxVM. Add argument supportImageRuning to opt in image running support during build.
  • Add runImageInLinuxVM which wraps around buildImageInLinuxVM.
  • Add apptainer.passthru.tests.exec-image-in-linux-vm to automate the binary functionality tests. If applied, we can test the image building and running functionality of Apptainer simply by running the Nix CI, and version bumping PRs made by r-ryantm can be merged directly when all the tests is passed.
    It's currently impossible for singularity (Sylabs SingularityCE) to run images in Nix sandbox, since it (still) requires a loop device to mount the image, which is not available in the Nix sandbox.

Depends on #178717.

Initial effort for #224636.

Cc: @jbedo @SomeoneSerge @GaetanLepage

 _______________
< Hello, world! >
 ---------------
        \   ^__^
         \  (oo)\_______
            (__)\       )\/\
                ||----w |
                ||     ||

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/)
  • 23.11 Release Notes (or backporting 23.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.

@ShamrockLee
Copy link
Contributor Author

Result of nixpkgs-review run on x86_64-linux 1

@ShamrockLee ShamrockLee marked this pull request as ready for review November 18, 2023 01:01
@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 Nov 18, 2023
@ShamrockLee ShamrockLee force-pushed the singularity-tools-reusability branch 2 times, most recently from 9042633 to 12d7c03 Compare November 19, 2023 20:55
@ShamrockLee ShamrockLee changed the title singularity-tools: refactor and add runImageInLinuxVM; apptainer, singularity: add passthru.tests.exec-image-in-linux-vm singularity-tools: refactor and add runImageInLinuxVM; apptainer.passthru.tests.exec-image-in-linux-vm: init Nov 19, 2023
@ShamrockLee
Copy link
Contributor Author

@ofborg build apptainer.passthru.tests singularity.passthru.tests

@ShamrockLee ShamrockLee marked this pull request as draft November 29, 2023 19:54
@ofborg ofborg bot added 10.rebuild-linux: 1-10 and removed 10.rebuild-linux: 0 This PR does not cause any packages to rebuild on Linux labels Dec 4, 2023
@wegank wegank added the 2.status: merge conflict This PR has merge conflicts with the target branch label Mar 20, 2024
@ShamrockLee ShamrockLee force-pushed the singularity-tools-reusability branch from c5159c1 to 38e5850 Compare April 23, 2024 13:42
@ofborg ofborg bot added 10.rebuild-linux: 0 This PR does not cause any packages to rebuild on Linux and removed 2.status: merge conflict This PR has merge conflicts with the target branch 10.rebuild-linux: 1-10 labels Apr 23, 2024
@wegank wegank added the 2.status: merge conflict This PR has merge conflicts with the target branch label May 3, 2024
ShamrockLee and others added 9 commits August 3, 2024 05:22
Name the directory inside SIF (the SquashFS image) ".singularity.d"
instead of ".${projectName}.d" for compatibility across Apptainer and
Singularity.
Split the build steps used by buildImage into

*   buildSandboxFromContents
*   buildImageFromSandbox
*   buildImageInLinuxVM

Attach buildScriptBin package to the passthru of each of the returned
package (except for those returned by *InLinuxVM), making it possible to
build images outside the Nix Store by simply executing the
buildScriptBin package.

Make this toolset extensible.

Add argument supportImageRunning for buildImageInLinuxVM.

Add runImageInLinuxVM.
@ShamrockLee ShamrockLee force-pushed the singularity-tools-reusability branch from 38e5850 to 96bda30 Compare August 4, 2024 06:03
@ofborg ofborg bot removed the 2.status: merge conflict This PR has merge conflicts with the target branch label Aug 4, 2024
@wegank wegank added the 2.status: merge conflict This PR has merge conflicts with the target branch label Sep 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
2.status: merge conflict This PR has merge conflicts with the target branch 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.

2 participants