Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rebuild helper script does not work with the switch arg #335

Open
Ramblurr opened this issue Feb 17, 2025 · 5 comments
Open

rebuild helper script does not work with the switch arg #335

Ramblurr opened this issue Feb 17, 2025 · 5 comments

Comments

@Ramblurr
Copy link

According to the docs, this should work:

nix run .#nixosConfigurations.my-microvm.config.microvm.deploy.rebuild [email protected] [email protected] switch

But when I run this I always get:

$ nix run .#nixosConfigurations.my-microvm.config.microvm.deploy.rebuild root@host root@target switch
Usage: /nix/store/kxrflcsnx1zayqaa389mn9zbfn9c3bby-microvm-rebuild/bin/microvm-rebuild root@<host> root@<target> [--use-remote-sudo] switch

Looking at the code, this makes sense, the conditional wrapping the "Usage" print will always trigger when "switch" is passed.

rebuild = with config.microvm.deploy; pkgs.writeShellScriptBin "microvm-rebuild" ''
set -eou pipefail
HOST="$1"
shift
TARGET="$1"
shift
OPTS="$@"
if [ $# -gt 0 ]; then
if [ "$1" == "--use-remote-sudo" ]; then
OPTS="$1"
shift
fi
fi
if [[ -z "$HOST" || -z "$TARGET" || $# -gt 0 ]]; then
echo "Usage: $0 root@<host> root@<target> [--use-remote-sudo] switch"
exit 1
fi
${lib.getExe installOnHost} "$HOST" $OPTS
${if canSwitchViaSsh
then ''${lib.getExe sshSwitch} "$TARGET" $OPTS''
else ''ssh "$HOST" -- systemctl restart "microvm@${hostName}.service"''
}
'';
};
}

Handling the "switch" isn't implemented AFAICT.

@astro
Copy link
Owner

astro commented Feb 17, 2025

Yeah, the arguments handling needs to be revised. IIRC that was the main reason I haven't tagged a stable version in a long time.

@Ramblurr
Copy link
Author

Which commands do you want it to support besides switch?

@astro
Copy link
Owner

astro commented Feb 17, 2025

build, and --use-remote-sudo but independent of its position

@Ramblurr
Copy link
Author

Ramblurr commented Feb 18, 2025

I read in another comment that there are plans to rewrite some scripts in python. Does that include this one? I could submit a PR either in bash or python.

@astro
Copy link
Owner

astro commented Feb 18, 2025

bash

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants