use git.nu use download.nu def url_crystal [] { let $ssha = sshagent_loaded if $ssha { return "git@github.com:freeflowuniverse/crystallib.git" } else { return "https://github.com/freeflowuniverse/crystallib" } } export def clone_crystal [ --reset=false , --pull=false ] string { let $url = url_crystal let $r = git git_clone crystallib $url return $r } 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" let $destpath = $"($env.BASE)/bin/hero" let $url = url_hero print $url download download_do $destpath $"($url)" --minsize 4 chmod +x $destpath }