Files
jj-cz/nix/package.nix

37 lines
872 B
Nix
Raw Normal View History

2026-02-05 16:25:14 +01:00
{
2026-03-08 15:44:26 +01:00
pkgs,
nativeRustPlatform,
windowsRustPlatform,
2026-02-05 16:25:14 +01:00
...
}: let
cargoToml = fromTOML (builtins.readFile ../Cargo.toml);
name = cargoToml.package.name;
version = cargoToml.package.version;
buildArgs = {
2026-02-05 16:25:14 +01:00
pname = name;
inherit version;
2026-03-08 15:44:26 +01:00
src = pkgs.lib.cleanSource ../.;
2026-02-05 16:25:14 +01:00
cargoLock.lockFile = ../Cargo.lock;
2026-03-08 15:44:26 +01:00
useNextest = true;
meta = {
inherit (cargoToml.package) description homepage;
2026-03-08 15:44:26 +01:00
};
postBuild = ''
${pkgs.upx}/bin/upx target/*/release/${name}
'';
2026-02-05 16:25:14 +01:00
};
nativeBuild =
nativeRustPlatform.buildRustPackage buildArgs
// {
postBuild = "${pkgs.upx}/bin/upx target/*/release/${name}";
};
windowsBuild =
windowsRustPlatform.buildRustPackage buildArgs
// {
postBuild = "${pkgs.upx}/bin/upx target/*/release/${name}.exe";
};
2026-02-05 16:25:14 +01:00
in {
default = nativeBuild;
windows = windowsBuild;
2026-02-05 16:25:14 +01:00
}