refactor(nix): simplify package declaration
This commit is contained in:
@@ -1,26 +1,36 @@
|
||||
{
|
||||
pkgs,
|
||||
rustPlatform,
|
||||
nativeRustPlatform,
|
||||
windowsRustPlatform,
|
||||
...
|
||||
}: let
|
||||
cargoToml = fromTOML (builtins.readFile ../Cargo.toml);
|
||||
name = cargoToml.package.name;
|
||||
version = cargoToml.package.version;
|
||||
rustBuild = rustPlatform.buildRustPackage {
|
||||
buildArgs = {
|
||||
pname = name;
|
||||
inherit version;
|
||||
src = pkgs.lib.cleanSource ../.;
|
||||
cargoLock.lockFile = ../Cargo.lock;
|
||||
nativeBuildInputs = [pkgs.upx];
|
||||
useNextest = true;
|
||||
meta = {
|
||||
description = "Conventional commits for Jujutsu";
|
||||
homepage = "https://labs.phundrak.com/phundrak/jj-cz";
|
||||
inherit (cargoToml.package) description homepage;
|
||||
};
|
||||
postBuild = ''
|
||||
${pkgs.upx}/bin/upx target/*/release/${name}
|
||||
'';
|
||||
};
|
||||
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";
|
||||
};
|
||||
in {
|
||||
default = rustBuild;
|
||||
default = nativeBuild;
|
||||
windows = windowsBuild;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user