-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: --nvidia flag for enter + export and status commands
- Loading branch information
1 parent
25401c4
commit ec55c26
Showing
5 changed files
with
126 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
polkit.addRule(function(action, subject) { | ||
if ( | ||
( | ||
action.id == "org.freedesktop.machine1.shell" || | ||
action.id == "org.freedesktop.machine1.manage-machines" || | ||
action.id == "org.freedesktop.machine1.manage-images" || | ||
action.id == "org.freedesktop.machine1.login" || | ||
( | ||
action.id == "org.freedesktop.systemd1.manage-units" && | ||
RegExp('systemd-nspawn@[A-Za-z0-9_-]+.service').test(action.lookup("unit")) === true | ||
) | ||
) | ||
&& subject.isInGroup("wheel") | ||
) { | ||
return polkit.Result.YES; | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,32 @@ | ||
use logger.nu * | ||
use meta.nu NAME | ||
|
||
# Export programs from a machine by writing scripts and desktop files for exported apps | ||
export def "main export" [] {} | ||
export def "main export" [] { | ||
$"Usage: ($NAME) export <command>" | ||
} | ||
|
||
export def "main export bin" [ | ||
# Generate a script that will run a binary in a machine through nuspawn enter | ||
export def "main export binary" [ | ||
--extra-flags: string # Flags for the exported binary | ||
machine: string | ||
--export-path: path = "~/.local/bin" # Path where the binary will be exported to | ||
--nuspawn-args: string # Arguments that will be passed to nuspawn | ||
--nuspawn-prefix: string # Any prefix that will run before the nuspawn caller runs (e.g.: bwrap nuspawn) | ||
--prefix: string # Any prefix that will run before the command gets ran (e.g.: gamescope steam) | ||
--nuspawn-binary: string = "nuspawn" # Path to the nuspawn script (must be executable) (defaults to $PATH) | ||
machine: string # Machine that the program will be executed on | ||
binary: string # Binary that will be exported to the host | ||
] { | ||
let script = " | ||
#!/bin/sh | ||
nuspawn enter ($machine) -- | ||
" | ||
mkdir $export_path | ||
let exported_binary_path = $"($export_path)/($binary | path basename)" | ||
$"#!/bin/sh | ||
($nuspawn_prefix) ($nuspawn_binary) enter ($nuspawn_args) ($machine) /bin/sh -c \"($prefix) ($binary) ($extra_flags)\" | ||
" | save -f $exported_binary_path | ||
run-external "chmod" "+x" $exported_binary_path | ||
logger success $"Succesfully exported binary to ($exported_binary_path)" | ||
} | ||
|
||
# Export desktop files and data from a program in a machine | ||
export def "main export app" [] { | ||
logger error "To be implemented" | ||
} | ||
export def "main export app" [] {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,3 +12,4 @@ export use rename.nu * | |
export use setup.nu * | ||
export use start.nu * | ||
export use oci.nu * | ||
export use status.nu * |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
use logger.nu * | ||
|
||
# Get status for all the machines or just a specific one | ||
export def "main status" [ | ||
machine?: string | ||
] { | ||
if $machine != null { | ||
let data = (machinectl status $machine --output json | complete | get stdout | from json) | ||
if ($data | length) == 0 { | ||
logger warning $"Machine ($machine) is not running" | ||
return | ||
} | ||
return | ||
} | ||
|
||
let data = (machinectl list --output json | from json) | ||
if ($data | length) == 0 { | ||
logger warning "No machine is currently running" | ||
return | ||
} | ||
$data | ||
} |