devshell: run multi-machine clan updates sequentially
Parallel updates interleave output and bury the YubiKey PIN prompts; a clan wrapper in the dev shell loops one machine at a time instead.
This commit is contained in:
@@ -59,13 +59,39 @@
|
|||||||
|
|
||||||
# Add the Clan cli tool to the dev shell.
|
# Add the Clan cli tool to the dev shell.
|
||||||
# Use "nix develop" to enter the dev shell.
|
# Use "nix develop" to enter the dev shell.
|
||||||
devShells = forAllSystems (system: {
|
devShells = forAllSystems (
|
||||||
|
system:
|
||||||
|
let
|
||||||
|
clanCli = clan-core.packages.${system}.clan-cli;
|
||||||
|
# `clan machines update a b c` normally runs machines in parallel,
|
||||||
|
# which interleaves their output and buries the YubiKey PIN prompts.
|
||||||
|
# This wrapper (first in PATH) runs them one at a time instead; any
|
||||||
|
# flags fall through to the real CLI untouched.
|
||||||
|
clanSequential = (pkgsFor system).writeShellScriptBin "clan" ''
|
||||||
|
if [ "$#" -gt 3 ] && [ "$1" = machines ] && [ "$2" = update ]; then
|
||||||
|
shift 2
|
||||||
|
for arg in "$@"; do
|
||||||
|
case "$arg" in
|
||||||
|
-*) exec ${clanCli}/bin/clan machines update "$@" ;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
for machine in "$@"; do
|
||||||
|
${clanCli}/bin/clan machines update "$machine" || exit
|
||||||
|
done
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
exec ${clanCli}/bin/clan "$@"
|
||||||
|
'';
|
||||||
|
in
|
||||||
|
{
|
||||||
default = (pkgsFor system).mkShell {
|
default = (pkgsFor system).mkShell {
|
||||||
packages = [
|
packages = [
|
||||||
clan-core.packages.${system}.clan-cli
|
clanSequential
|
||||||
|
clanCli
|
||||||
(treefmtFor system).config.build.wrapper
|
(treefmtFor system).config.build.wrapper
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
});
|
}
|
||||||
|
);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user