refactor(nix): simplify package declaration
This commit is contained in:
44
flake.nix
44
flake.nix
@@ -41,36 +41,22 @@
|
|||||||
};
|
};
|
||||||
in {
|
in {
|
||||||
formatter = alejandra.defaultPackage.${system};
|
formatter = alejandra.defaultPackage.${system};
|
||||||
packages =
|
packages = let
|
||||||
(import ./nix/package.nix {inherit pkgs rustPlatform;})
|
nativeRustVersion = pkgs.rust-bin.stable.latest.default;
|
||||||
// {
|
nativeRustPlatform = pkgs.makeRustPlatform {
|
||||||
windows = let
|
cargo = nativeRustVersion;
|
||||||
mingwPkgs = pkgs.pkgsCross.mingwW64;
|
rustc = nativeRustVersion;
|
||||||
rustWindows = pkgs.rust-bin.stable.latest.default.override {
|
|
||||||
targets = ["x86_64-pc-windows-gnu"];
|
|
||||||
};
|
|
||||||
rustPlatformWindows = mingwPkgs.makeRustPlatform {
|
|
||||||
cargo = rustWindows;
|
|
||||||
rustc = rustWindows;
|
|
||||||
};
|
|
||||||
cargoToml = builtins.fromTOML (builtins.readFile ./Cargo.toml);
|
|
||||||
in
|
|
||||||
rustPlatformWindows.buildRustPackage {
|
|
||||||
pname = cargoToml.package.name;
|
|
||||||
version = cargoToml.package.version;
|
|
||||||
src = pkgs.lib.cleanSource ./.;
|
|
||||||
cargoLock.lockFile = ./Cargo.lock;
|
|
||||||
nativeBuildInputs = [pkgs.upx];
|
|
||||||
doCheck = false;
|
|
||||||
meta = {
|
|
||||||
description = "Conventional commits for Jujutsu";
|
|
||||||
homepage = "https://labs.phundrak.com/phundrak/jj-cz";
|
|
||||||
};
|
|
||||||
postBuild = ''
|
|
||||||
${pkgs.upx}/bin/upx target/*/release/jj-cz.exe
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
mingwPkgs = pkgs.pkgsCross.mingwW64;
|
||||||
|
windowsRustVersion = pkgs.rust-bin.stable.latest.default.override {
|
||||||
|
targets = ["x86_64-pc-windows-gnu"];
|
||||||
|
};
|
||||||
|
windowsRustPlatform = mingwPkgs.makeRustPlatform {
|
||||||
|
cargo = windowsRustVersion;
|
||||||
|
rustc = windowsRustVersion;
|
||||||
|
};
|
||||||
|
in
|
||||||
|
import ./nix/package.nix {inherit pkgs nativeRustPlatform windowsRustPlatform;};
|
||||||
devShell = import ./nix/shell.nix {
|
devShell = import ./nix/shell.nix {
|
||||||
inherit inputs pkgs rustVersion;
|
inherit inputs pkgs rustVersion;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,26 +1,36 @@
|
|||||||
{
|
{
|
||||||
pkgs,
|
pkgs,
|
||||||
rustPlatform,
|
nativeRustPlatform,
|
||||||
|
windowsRustPlatform,
|
||||||
...
|
...
|
||||||
}: let
|
}: let
|
||||||
cargoToml = fromTOML (builtins.readFile ../Cargo.toml);
|
cargoToml = fromTOML (builtins.readFile ../Cargo.toml);
|
||||||
name = cargoToml.package.name;
|
name = cargoToml.package.name;
|
||||||
version = cargoToml.package.version;
|
version = cargoToml.package.version;
|
||||||
rustBuild = rustPlatform.buildRustPackage {
|
buildArgs = {
|
||||||
pname = name;
|
pname = name;
|
||||||
inherit version;
|
inherit version;
|
||||||
src = pkgs.lib.cleanSource ../.;
|
src = pkgs.lib.cleanSource ../.;
|
||||||
cargoLock.lockFile = ../Cargo.lock;
|
cargoLock.lockFile = ../Cargo.lock;
|
||||||
nativeBuildInputs = [pkgs.upx];
|
|
||||||
useNextest = true;
|
useNextest = true;
|
||||||
meta = {
|
meta = {
|
||||||
description = "Conventional commits for Jujutsu";
|
inherit (cargoToml.package) description homepage;
|
||||||
homepage = "https://labs.phundrak.com/phundrak/jj-cz";
|
|
||||||
};
|
};
|
||||||
postBuild = ''
|
postBuild = ''
|
||||||
${pkgs.upx}/bin/upx target/*/release/${name}
|
${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 {
|
in {
|
||||||
default = rustBuild;
|
default = nativeBuild;
|
||||||
|
windows = windowsBuild;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user