qvm/flake.nix

129 lines
3.4 KiB
Nix

{
description = "QVM - Quick development VMs for AI-assisted workflows";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";
};
outputs = { self, nixpkgs, flake-utils }:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = import nixpkgs { inherit system; };
qvm = pkgs.stdenv.mkDerivation {
pname = "qvm";
version = "0.1.0";
src = ./.;
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
# Install default VM flake template
if [ -d "flake/default-vm" ]; then
cp -r 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"
done
runHook postInstall
'';
meta = with pkgs.lib; {
description = "Quick development VMs for AI-assisted workflows";
homepage = "https://github.com/josh/qvm";
license = licenses.mit;
maintainers = [];
platforms = platforms.linux;
mainProgram = "qvm";
};
};
in {
packages = {
inherit qvm;
default = qvm;
};
apps = {
qvm = {
type = "app";
program = "${qvm}/bin/qvm";
};
default = {
type = "app";
program = "${qvm}/bin/qvm";
};
};
devShells.default = pkgs.mkShell {
buildInputs = with pkgs; [
# Runtime dependencies for development
qemu
openssh
jq
coreutils
gnused
gnugrep
nix
netcat-gnu
bc
procps
sshpass
# Development tools
shellcheck
shfmt
];
shellHook = ''
export QVM_LIB_DIR="$(pwd)/lib"
echo "QVM development environment"
echo "Library directory: $QVM_LIB_DIR"
'';
};
}
);
}