Replace Bash qvm scripts with Go CLI implementation
This commit is contained in:
parent
ffb456707f
commit
2a6a333721
27 changed files with 2551 additions and 1702 deletions
89
flake.nix
89
flake.nix
|
|
@ -53,67 +53,42 @@
|
|||
let
|
||||
pkgs = import nixpkgs { inherit system; };
|
||||
|
||||
qvm = pkgs.stdenv.mkDerivation {
|
||||
qvm = pkgs.buildGoModule {
|
||||
pname = "qvm";
|
||||
version = "0.1.0";
|
||||
|
||||
# NOTE: In a flake, only git-tracked files are included by default.
|
||||
# The Go source files must be committed to git for this build to work.
|
||||
# For development, use: go build ./cmd/qvm
|
||||
src = ./.;
|
||||
|
||||
vendorHash = "sha256-d6Z32nPDawwFqhKfVw/QwHUuDuMuTdQdHApmxcXzFng=";
|
||||
|
||||
subPackages = [ "cmd/qvm" ];
|
||||
|
||||
nativeBuildInputs = with pkgs; [
|
||||
makeWrapper
|
||||
installShellFiles
|
||||
];
|
||||
|
||||
buildInputs = with pkgs; [
|
||||
bash
|
||||
];
|
||||
|
||||
installPhase = ''
|
||||
runHook preInstall
|
||||
|
||||
# Create output directories
|
||||
mkdir -p $out/bin
|
||||
mkdir -p $out/lib/qvm
|
||||
mkdir -p $out/share/qvm
|
||||
|
||||
# Install library files
|
||||
install -Dm755 lib/common.sh $out/lib/qvm/common.sh
|
||||
|
||||
postInstall = ''
|
||||
# Install default VM flake template
|
||||
if [ -d "flake/default-vm" ]; then
|
||||
cp -r flake/default-vm $out/share/qvm/default-vm
|
||||
if [ -d "$src/flake/default-vm" ]; then
|
||||
mkdir -p $out/share/qvm
|
||||
cp -r $src/flake/default-vm $out/share/qvm/default-vm
|
||||
fi
|
||||
|
||||
# Install all scripts from bin/
|
||||
for script in bin/*; do
|
||||
if [ -f "$script" ]; then
|
||||
install -Dm755 "$script" "$out/bin/$(basename "$script")"
|
||||
fi
|
||||
done
|
||||
|
||||
# Wrap all scripts with PATH containing required dependencies
|
||||
for script in $out/bin/*; do
|
||||
wrapProgram "$script" \
|
||||
--prefix PATH : ${
|
||||
pkgs.lib.makeBinPath [
|
||||
pkgs.qemu
|
||||
pkgs.openssh
|
||||
pkgs.jq
|
||||
pkgs.coreutils
|
||||
pkgs.gnused
|
||||
pkgs.gnugrep
|
||||
pkgs.nix
|
||||
pkgs.netcat-gnu
|
||||
pkgs.bc
|
||||
pkgs.procps
|
||||
pkgs.sshpass
|
||||
]
|
||||
} \
|
||||
--set QVM_LIB_DIR "$out/lib/qvm" \
|
||||
--set QVM_BIN_DIR "$out/bin"
|
||||
done
|
||||
|
||||
runHook postInstall
|
||||
# Wrap binary with PATH containing required dependencies
|
||||
wrapProgram $out/bin/qvm \
|
||||
--prefix PATH : ${
|
||||
pkgs.lib.makeBinPath [
|
||||
pkgs.qemu
|
||||
pkgs.openssh
|
||||
pkgs.jq
|
||||
pkgs.nix
|
||||
pkgs.netcat-gnu
|
||||
pkgs.sshpass
|
||||
]
|
||||
}
|
||||
'';
|
||||
|
||||
meta = with pkgs.lib; {
|
||||
|
|
@ -150,24 +125,20 @@
|
|||
qemu
|
||||
openssh
|
||||
jq
|
||||
coreutils
|
||||
gnused
|
||||
gnugrep
|
||||
nix
|
||||
netcat-gnu
|
||||
bc
|
||||
procps
|
||||
sshpass
|
||||
|
||||
# Development tools
|
||||
shellcheck
|
||||
shfmt
|
||||
go
|
||||
gopls
|
||||
gotools
|
||||
];
|
||||
|
||||
shellHook = ''
|
||||
export QVM_LIB_DIR="$(pwd)/lib"
|
||||
echo "QVM development environment"
|
||||
echo "Library directory: $QVM_LIB_DIR"
|
||||
echo "QVM development environment (Go)"
|
||||
echo "Build: go build ./cmd/qvm"
|
||||
echo "Run: ./qvm status"
|
||||
'';
|
||||
};
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue