Skip to content

Add bubblewrap support for running nix2gpu without a container runtime#12

Merged
baileylu121 merged 13 commits intomainfrom
baileylu/bubblewrap
Mar 5, 2026
Merged

Add bubblewrap support for running nix2gpu without a container runtime#12
baileylu121 merged 13 commits intomainfrom
baileylu/bubblewrap

Conversation

@baileylu121
Copy link
Copy Markdown
Collaborator

@baileylu121 baileylu121 commented Jan 29, 2026

Add bubblewrap support for running nix2gpu without a container runtime

This PR updates the flake dependencies and switches from the baileylu/minimize-flake branch to the baileylu/bubblewrap branch of nimi.

Allow creation of the template

Adds a templates module and renames the basic template to default, making it available via nix flake init -t github:weyl-ai/nix2gpu.

Fix typo

Fixes a missing colon in the getting-started.md documentation.

Bind to nimi's bubblewrap with equivalency to the container config

Adds bubblewrap configuration to match container behavior, allowing nix2gpu containers to run in bubblewrap sandboxes. This includes:

  • Setting up filesystem binds for copyToRoot packages
  • Configuring GPU device access
  • Ensuring proper environment variables
  • Updating the startup script to handle bubblewrap environments

Optimize the calling to only evaluate the nimi module once

Refactors the container creation to evaluate the nimi module once and reuse the configuration for both container image and bubblewrap.

Properly bind gpu drivers

Adds comprehensive GPU device bindings for NVIDIA devices and configures the proper procfs access needed for GPU drivers to function in bubblewrap.


Note

Medium Risk
Adds a new execution path (bubblewrap sandbox) and updates startup/SSH/GPU binding logic, which may change runtime behavior and host integration. Dependency bumps (notably nimi) can also shift behavior outside this repo.

Overview
Adds bubblewrap mode by wiring Nimi’s mkBwrapWithConfig into container builds and exposing it as a runInBubblewrap passthru output, alongside a refactor to evaluate the Nimi module once and reuse the resulting config.

Updates nix2gpu modules to translate existing container settings into bubblewrap equivalents: copyToRoot is now also turned into read-only bind mounts (excluding tmpfs dirs), env vars/user/working dir are passed through to bubblewrap, and CUDA enables host GPU library/device binds plus host /proc usage for NVIDIA driver visibility.

Extends the startup script to better support bubblewrap (tmpfs-backed /etc, copy-in of /etc from copyToRootEnv, SSH key generation and port rewrite to 2222 in bubblewrap mode, and tightened directory permissions), adds a new NixOS test that boots and validates bubblewrap execution, and updates docs (new bubblewrap.md, nav links, typo fix) plus flake/template and dependency updates (switch nimi input to upstream and refresh flake.lock).

Written by Cursor Bugbot for commit 41bd76d. This will update automatically on new commits. Configure here.

Copy link
Copy Markdown
Collaborator Author

This stack of pull requests is managed by Graphite. Learn more about stacking.

@baileylu121 baileylu121 changed the title nix flake update + switch nimi feature branch Add bubblewrap support for running containers without Docker Jan 29, 2026
@github-actions
Copy link
Copy Markdown

github-actions bot commented Jan 29, 2026

PR Preview Action v1.8.1
Preview removed because the pull request was closed.
2026-03-05 15:38 UTC

@baileylu121 baileylu121 changed the title Add bubblewrap support for running containers without Docker Add bubblewrap support for running nix2gpu without a container runtime Jan 29, 2026
@baileylu121 baileylu121 marked this pull request as ready for review January 29, 2026 19:17
@baileylu121 baileylu121 requested a review from b7r6 January 29, 2026 19:17
@baileylu121 baileylu121 merged commit 1db39df into main Mar 5, 2026
2 of 3 checks passed
Copy link
Copy Markdown

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Bugbot Autofix prepared a fix for the issue found in the latest run.

  • ✅ Fixed: Bubblewrap environment skips uppercase variable name assertion
    • Bubblewrap now forces evaluation of the same validated env mapping used for container env strings via deepSeq so lowercase variable names trigger the uppercase assertion in both paths.

Create PR

Or push these changes by commenting:

@cursor push c803cb3b85
Preview (c803cb3b85)
diff --git a/nix2gpu/env.nix b/nix2gpu/env.nix
--- a/nix2gpu/env.nix
+++ b/nix2gpu/env.nix
@@ -84,6 +84,6 @@
         totalEnv = config.env // config.extraEnv;
       in
       lib.mapAttrsToList translateToGoEnvString totalEnv;
-    bubblewrap.environment = config.env // config.extraEnv;
+    bubblewrap.environment = builtins.deepSeq (lib.mapAttrsToList translateToGoEnvString totalEnv) totalEnv;
   };
 }
This Bugbot Autofix run was free. To enable autofix for future PRs, go to the Cursor dashboard.

totalEnv = config.env // config.extraEnv;
in
lib.mapAttrsToList translateToGoEnvString totalEnv;
bubblewrap.environment = config.env // config.extraEnv;
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Bubblewrap environment skips uppercase variable name assertion

Low Severity

The bubblewrap.environment is set to config.env // config.extraEnv directly, bypassing the translateToGoEnvString assertion that validates all environment variable names are uppercase. The container path checks this via lib.assertMsg (lib.toUpper var == var), but the bubblewrap path does not. Due to Nix laziness, building only the bubblewrap target would never trigger the validation, allowing lowercase env vars to slip through undetected.

Fix in Cursor Fix in Web

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.

1 participant