2024-01-13 10:50:06 +00:00
|
|
|
use git.nu
|
|
|
|
use download.nu
|
2024-01-13 11:42:27 +00:00
|
|
|
use runonce.nu
|
2024-01-13 10:50:06 +00:00
|
|
|
|
|
|
|
def sshagent_loaded [ ] bool {
|
|
|
|
return ( (ssh-add -l | lines -s | length) > 0 )
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
def url_crystal [] {
|
|
|
|
let $ssha = sshagent_loaded
|
|
|
|
if $ssha {
|
|
|
|
return "git@github.com:freeflowuniverse/crystallib.git"
|
|
|
|
} else {
|
|
|
|
return "https://github.com/freeflowuniverse/crystallib"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-01-13 13:51:29 +00:00
|
|
|
def url_webcomponents [] {
|
|
|
|
let $ssha = sshagent_loaded
|
|
|
|
if $ssha {
|
|
|
|
return "git@github.com:freeflowuniverse/webcomponents.git"
|
|
|
|
} else {
|
|
|
|
return "https://github.com/freeflowuniverse/webcomponents"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-01-13 11:42:27 +00:00
|
|
|
export def install_crystal [ --reset=false , --pull=false ] string {
|
|
|
|
let $vpath = install_v
|
2024-01-13 10:50:06 +00:00
|
|
|
let $url = url_crystal
|
2024-01-13 13:51:29 +00:00
|
|
|
let $crlibpath = git git_clone crystallib $url --reset=$reset --pull=$pull
|
|
|
|
let $weburl = url_webcomponents
|
|
|
|
let $webpath = git git_clone webcomponents $weburl --reset=$reset --pull=$pull
|
|
|
|
let $vmodpath = $"($env.BASE)/.vmodules"
|
|
|
|
mkdir $"($vmodpath)/freeflowuniverse"
|
|
|
|
rm -f $"($vmodpath)/freeflowuniverse/crystallib"
|
|
|
|
rm -f $"($vmodpath)/freeflowuniverse/webcomponents"
|
|
|
|
ln -s $"($crlibpath)/crystallib" $"($vmodpath)/freeflowuniverse/crystallib"
|
|
|
|
ln -s $"($webpath)/webcomponents" $"($vmodpath)/freeflowuniverse/webcomponents"
|
|
|
|
return $crlibpath
|
2024-01-13 10:50:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
export def clone_nuscripts [ --reset=false , --pull=false ] string {
|
|
|
|
let $ssha = sshagent_loaded
|
|
|
|
let $dest = $"($env.BASE)/nuscripts"
|
|
|
|
let $dest_org = $"($env.BASE)/nushell"
|
|
|
|
if $ssha {
|
2024-01-13 13:51:29 +00:00
|
|
|
let $r = git git_clone nuscripts "git@git.ourworld.tf:despiegk/nuscripts.git" --reset=$reset --pull=$pull
|
2024-01-13 10:50:06 +00:00
|
|
|
rm -f $dest
|
|
|
|
ln -s $r $dest
|
|
|
|
return $r
|
|
|
|
} else {
|
|
|
|
error make { msg: "load ssh-agent" }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-01-13 11:42:27 +00:00
|
|
|
export def install_v [ --reset=false , --pull=false ] string {
|
2024-01-13 13:51:29 +00:00
|
|
|
let $vpath = git git_clone v "https://github.com/vlang/v"
|
2024-01-13 11:42:27 +00:00
|
|
|
runonce run 'install_v' {
|
2024-01-13 13:51:29 +00:00
|
|
|
cd $vpath
|
2024-01-13 11:42:27 +00:00
|
|
|
print "will compile V, can take a long while."
|
|
|
|
^make
|
|
|
|
} --reset $reset
|
2024-01-13 13:51:29 +00:00
|
|
|
rm -f $"($env.BASE)/bin/v"
|
|
|
|
ln -s $"($vpath)/v" $"($env.BASE)/bin/v"
|
|
|
|
return $vpath
|
2024-01-13 11:42:27 +00:00
|
|
|
}
|
2024-01-13 10:50:06 +00:00
|
|
|
|
|
|
|
def url_mycelium [] string {
|
|
|
|
let $os = $nu.os-info.name
|
|
|
|
let $arch = $nu.os-info.arch
|
|
|
|
if $os == "macos" {
|
|
|
|
if $arch == "aarch64" {
|
|
|
|
return "https://github.com/threefoldtech/mycelium/releases/download/v0.2.3/mycelium-aarch64-apple-darwin.tar.gz"
|
|
|
|
} else if $arch == "x86_64" {
|
|
|
|
return "https://github.com/threefoldtech/mycelium/releases/download/v0.2.3/mycelium-x86_64-apple-darwin.tar.gz"
|
|
|
|
}
|
|
|
|
} else if $os == "linux" {
|
|
|
|
if $arch == "aarch64" {
|
|
|
|
return "https://github.com/threefoldtech/mycelium/releases/download/v0.2.3/mycelium-aarch64-unknown-linux-musl.tar.gz"
|
|
|
|
} else if $arch == "x86_64" {
|
|
|
|
return "https://github.com/threefoldtech/mycelium/releases/download/v0.2.3/mycelium-x86_64-unknown-linux-musl.tar.gz"
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
error make { msg: "only support darwin & linux" }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export def install_mycelium [] {
|
|
|
|
let $name = "mycelium"
|
|
|
|
let tmppath = $"/tmp/($name)"
|
|
|
|
let $bin_dir = $"($env.BASE)/bin"
|
|
|
|
mkdir $bin_dir
|
|
|
|
let $url = url_mycelium
|
|
|
|
print $url
|
|
|
|
download download_expand $tmppath $"($url)" --minsize 2
|
|
|
|
mv -f $"($tmppath)/($name)" $"($bin_dir)/($name)"
|
|
|
|
chmod +x $"($bin_dir)/($name)"
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
def url_hero [] string {
|
|
|
|
let $os = $nu.os-info.name
|
|
|
|
let $arch = $nu.os-info.arch
|
|
|
|
if $os == "macos" {
|
|
|
|
if $arch == "aarch64" {
|
|
|
|
return "https://f003.backblazeb2.com/file/threefold/macos-arm64/hero"
|
|
|
|
} else if $arch == "x86_64" {
|
|
|
|
return "https://f003.backblazeb2.com/file/threefold/macos-i64/hero"
|
|
|
|
}
|
|
|
|
} else if $os == "linux" {
|
|
|
|
if $arch == "aarch64" {
|
|
|
|
error make { msg: "find url for hero on linux arm" }
|
|
|
|
} else if $arch == "x86_64" {
|
|
|
|
return "https://f003.backblazeb2.com/file/threefold/linux-i64/hero"
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
error make { msg: "only support darwin & linux" }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export def install_hero [] {
|
|
|
|
let $name = "hero"
|
2024-01-13 13:51:29 +00:00
|
|
|
runonce run $'install_($name)' {
|
|
|
|
let $destpath = $"($env.BASE)/bin/hero"
|
|
|
|
let $url = url_hero
|
|
|
|
print $url
|
|
|
|
download download_do $destpath $"($url)" --minsize 4
|
|
|
|
chmod +x $destpath
|
|
|
|
}
|
2024-01-13 10:50:06 +00:00
|
|
|
}
|