Set up Cargo and Nix project

This commit is contained in:
2026-06-16 01:46:49 +09:00
parent 4e82f47f90
commit 34855f3b7b
9 changed files with 194 additions and 0 deletions
+54
View File
@@ -0,0 +1,54 @@
{
lib,
rustPlatform,
}:
let
srcRoot = ./.;
srcRootString = toString srcRoot;
sourceFilter =
path: type:
let
pathString = toString path;
relPath = lib.removePrefix "${srcRootString}/" pathString;
baseName = baseNameOf pathString;
isExcludedTree = dir: relPath == dir || lib.hasPrefix "${dir}/" relPath;
in
!(
baseName == ".git"
|| baseName == "target"
|| baseName == "result"
|| isExcludedTree ".yoi"
|| isExcludedTree ".worktree"
);
in
rustPlatform.buildRustPackage {
pname = "decodal";
version = "0.1.0";
src = lib.cleanSourceWith {
src = srcRoot;
filter = sourceFilter;
};
cargoLock.lockFile = ./Cargo.lock;
strictDeps = true;
doInstallCheck = true;
installCheckPhase = ''
runHook preInstallCheck
test -x "$out/bin/decodal"
"$out/bin/decodal" >/dev/null
runHook postInstallCheck
'';
meta = {
description = "Deferred Constraint Data Language";
license = lib.licenses.mit;
mainProgram = "decodal";
platforms = lib.platforms.unix;
};
}