Skip to content

Commit

Permalink
feat: add VMspawn support to enter
Browse files Browse the repository at this point in the history
  • Loading branch information
tulilirockz committed Jul 5, 2024
1 parent f0e4c70 commit 152e24b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 9 deletions.
18 changes: 9 additions & 9 deletions src/lib/enter.nu
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ export def --env "main enter" [
--set-xdg = true # Set XDG variables by default
--machinectl (-m) = false # Use machinectl for operations instead of machinectl
--boot # Force booting for machine when not using machinectl
--shadow = true # Copy your user hashed password from /etc/shadow and put it inside the machine
--no-bind # Use this if you are having issue with user binding
--user: string # User that will be binded to the machine
--hostname: string # Hostname
--hostname: string # Hostname that the machine will get
--type: string = "tar" # Type of the machine (change this if running into checking errors)
--vm (-v) # Treat machine as vm -> run with systemd-vmspawn
--share-ipc (-s) # Share IPC into the machine
machine: string # Name of the machine to be logged into
...args: string
] {
Expand All @@ -42,12 +42,11 @@ export def --env "main enter" [
}

if $vm {
(
systemd-vmspawn
(if $type == "raw" { "-i" } else { "-D" })
$"--machine=($MACHINE_STORAGE_PATH)"

)
(systemd-vmspawn
(if $type == "raw" { $"--image=($MACHINE_STORAGE_PATH)/($machine).raw" } else { $"--directory=($MACHINE_STORAGE_PATH)/($machine)" })
$"--machine=($machine)"
$machine
...($args))
return
}

Expand All @@ -57,7 +56,8 @@ export def --env "main enter" [
return
}

(privileged_run
(privileged_run
$"--setenv=SYSTEMD_NSPAWN_SHARE_NS_IPC=(if $share_ipc { "1" } else { "" })"
"systemd-nspawn"
"--quiet"
"--set-credential=firstboot.locale:C.UTF-8"
Expand Down
7 changes: 7 additions & 0 deletions src/lib/machine_manager.nu
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,13 @@ export extern systemd-run [
--quiet (-q)
...args: string
]
export extern systemd-vmspawn [
--image (-i)
--directory (-d)
--machine (-m)
machine: string
...args: string
]
export extern "machinectl pull-tar" [url: string, name?: string]
export extern "machinectl pull-raw" [url: string, name?: string]
export extern "machinectl remove" [machine: string]
Expand Down

0 comments on commit 152e24b

Please sign in to comment.