Skip to content

Commit

Permalink
Passthru NixOS system & OpenGL Driver
Browse files Browse the repository at this point in the history
Signed-off-by: Tristan Ross <[email protected]>
  • Loading branch information
RossComputerGuy committed Jun 20, 2024
1 parent 912afa5 commit 9a791fe
Showing 1 changed file with 23 additions and 2 deletions.
25 changes: 23 additions & 2 deletions crates/krun-guest/src/mount.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
use std::fs::File;
use std::fs::{File, create_dir_all};
use std::env::var_os;
use std::os::fd::AsFd;

use anyhow::{Context, Result};
use rustix::fs::CWD;
use rustix::mount::{mount2, move_mount, open_tree, MountFlags, MoveMountFlags, OpenTreeFlags};
use rustix::mount::{mount2, move_mount, mount_recursive_bind, open_tree, MountFlags, MoveMountFlags, OpenTreeFlags};

pub fn mount_filesystems() -> Result<()> {
mount2(
Expand Down Expand Up @@ -40,6 +41,26 @@ pub fn mount_filesystems() -> Result<()> {
.context("Failed to move_mount `/etc/resolv.conf`")?;
}

let opengl_driver = var_os("OPENGL_DRIVER");
if let Some(dir) = opengl_driver {
create_dir_all("/run/opengl-driver")?;
mount_recursive_bind(
dir,
"/run/opengl-driver",
)
.context("Failed to mount `/run/opengl-driver`")?;
}

let nixos_curr_sys = var_os("NIXOS_CURRENT_SYSTEM");
if let Some(dir) = nixos_curr_sys {
create_dir_all("/run/current-system")?;
mount_recursive_bind(
dir,
"/run/current-system",
)
.context("Failed to mount `/run/current-system`")?;
}

mount2(
Some("binfmt_misc"),
"/proc/sys/fs/binfmt_misc",
Expand Down

0 comments on commit 9a791fe

Please sign in to comment.