nix: add installable package
This commit is contained in:
+97
@@ -0,0 +1,97 @@
|
||||
{
|
||||
lib,
|
||||
stdenv,
|
||||
rustPlatform,
|
||||
pkg-config,
|
||||
openssl,
|
||||
darwin,
|
||||
}:
|
||||
|
||||
let
|
||||
srcRoot = ./.;
|
||||
srcRootString = toString srcRoot;
|
||||
sourceFilter =
|
||||
path: type:
|
||||
let
|
||||
pathString = toString path;
|
||||
relPath = lib.removePrefix "${srcRootString}/" pathString;
|
||||
baseName = baseNameOf pathString;
|
||||
in
|
||||
!(
|
||||
baseName == ".git"
|
||||
|| baseName == "target"
|
||||
|| baseName == "result"
|
||||
|| lib.hasPrefix ".insomnia" relPath
|
||||
|| lib.hasPrefix "work-items" relPath
|
||||
);
|
||||
in
|
||||
rustPlatform.buildRustPackage rec {
|
||||
pname = "insomnia";
|
||||
version = "0.1.0";
|
||||
|
||||
src = lib.cleanSourceWith {
|
||||
src = srcRoot;
|
||||
filter = sourceFilter;
|
||||
};
|
||||
|
||||
cargoLock.lockFile = ./Cargo.lock;
|
||||
|
||||
strictDeps = true;
|
||||
|
||||
nativeBuildInputs = [ pkg-config ];
|
||||
|
||||
buildInputs = [
|
||||
openssl
|
||||
]
|
||||
++ lib.optionals stdenv.hostPlatform.isDarwin (
|
||||
with darwin.apple_sdk.frameworks;
|
||||
[
|
||||
CoreFoundation
|
||||
Security
|
||||
SystemConfiguration
|
||||
]
|
||||
);
|
||||
|
||||
cargoBuildFlags = [
|
||||
"-p"
|
||||
"pod"
|
||||
"-p"
|
||||
"tui"
|
||||
];
|
||||
|
||||
# The package check is a credential-free install smoke check below. Running the
|
||||
# workspace test suite is intentionally left to cargo-based CI because this
|
||||
# derivation is scoped to packaging the user-facing binaries.
|
||||
doCheck = false;
|
||||
|
||||
postInstall = ''
|
||||
install -Dm644 docs/nix.md "$out/share/doc/insomnia/nix.md"
|
||||
mkdir -p "$out/share/insomnia"
|
||||
cp -R resources "$out/share/insomnia/resources"
|
||||
'';
|
||||
|
||||
doInstallCheck = true;
|
||||
installCheckPhase = ''
|
||||
runHook preInstallCheck
|
||||
|
||||
"$out/bin/pod" --help >/dev/null
|
||||
test -x "$out/bin/tui"
|
||||
if "$out/bin/tui" --session not-a-uuid 2>tui.err; then
|
||||
echo "tui unexpectedly accepted an invalid --session value" >&2
|
||||
exit 1
|
||||
fi
|
||||
grep -q "invalid --session UUID" tui.err
|
||||
|
||||
test -d "$out/share/insomnia/resources/prompts"
|
||||
test -f "$out/share/doc/insomnia/nix.md"
|
||||
|
||||
runHook postInstallCheck
|
||||
'';
|
||||
|
||||
meta = {
|
||||
description = "Agentic coding Pod runtime and terminal UI";
|
||||
license = lib.licenses.mit;
|
||||
mainProgram = "tui";
|
||||
platforms = lib.platforms.unix;
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user