-
Notifications
You must be signed in to change notification settings - Fork 3
/
build.nu
31 lines (27 loc) · 1.71 KB
/
build.nu
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
use std log
let messages = {
"enforce-daemon" : $"Found (ansi blue)($env.XDG_CURRENT_DESKTOP?)(ansi reset) from env\(`(ansi blue)XDG_CURRENT_DESKTOP(ansi reset)`\) activating `(ansi red)enforce-daemon(ansi reset)` mode,
this will cause the copy action to (ansi yellow)use daemon mode(ansi reset) without the (ansi green)`--daemon` \(`-d`\)(ansi reset) flag
and cause `--daemon` flag to have inverted functionality (ansi red)\(now using -d will disable daemon mode\)(ansi reset)",
"use-wayland" : $"Found (ansi blue)wayland(ansi reset) in env\(`(ansi blue)XDG_SESSION_TYPE(ansi reset)`\): activating `(ansi green)use-wayland(ansi reset)` feature"
}
def main [package_file: path = nupm.nuon] {
let repo_root = (ls -f $package_file | first | get name | path dirname)
let install_root = $env.NUPM_HOME | path join "plugins"
let name = open ($repo_root | path join "Cargo.toml") | get package.name
let features = []
| if ($nu.os-info.name == "linux") { $in | append enforce-daemon } else { $in }
| if ($nu.os-info.name == "linux" and ($env.XDG_SESSION_TYPE? == "wayland")) {$in | append use-wayland } else { $in }
for feature in $features {
let message = $messages | get $feature
if $message != null {
log info $message
}
}
let cmd = $"cargo install --path ($repo_root) --root ($install_root) --features=($features | str join ",")"
log info $"building plugin using: (ansi blue)($cmd)(ansi reset)"
nu -c $cmd
let ext: string = if ($nu.os-info.name == 'windows') { '.exe' } else { '' }
plugin add $"($install_root | path join "bin" $name)($ext)"
log info "do not forget to restart Nushell for the plugin to be fully available!"
}