#!/usr/bin/env nu def main [] { main run } def "main build" [] { let config = get-config build $config } def "main push" [] { let config = get-config push $config } def "main run" [] { let config = get-config run $config } def get-config [] { if ('./deploy.config.toml.secret' | path exists) { return (sops decrypt deploy.config.toml.secret | from toml) } else { return (open deploy.config.toml) } } def build [config] { nix build $".#($config | get target_platform)" } def push [config] { build $config ssh ($config | get target_machine) "mkdir -p bin && rm -f bin/snooze-pal" scp result/bin/snooze-pal ($config | get target_machine):bin/snooze-pal } def run [config] { push $config ssh ($config | get target_machine) "chmod +rwx bin/snooze-pal && bin/snooze-pal" }