fix(build): statically linked binaries for linux (#55)
This commit is contained in:
parent
6d2bf5ac09
commit
59c99f4f5c
10
.github/workflows/release.yml
vendored
10
.github/workflows/release.yml
vendored
@ -31,7 +31,7 @@ jobs:
|
|||||||
- os: ubuntu-latest
|
- os: ubuntu-latest
|
||||||
os_target: linux
|
os_target: linux
|
||||||
binary_name: timr-tui
|
binary_name: timr-tui
|
||||||
arch: x86_64 # `x86_64` by default
|
arch: x86_64 # based on target 'x86_64-unknown-linux-musl' defined by `CARGO_BUILD_TARGET` in flake.nix
|
||||||
- os: ubuntu-latest
|
- os: ubuntu-latest
|
||||||
os_target: windows
|
os_target: windows
|
||||||
binary_name: timr-tui.exe
|
binary_name: timr-tui.exe
|
||||||
@ -49,8 +49,12 @@ jobs:
|
|||||||
if: matrix.os_target == 'windows'
|
if: matrix.os_target == 'windows'
|
||||||
run: nix build .#windows
|
run: nix build .#windows
|
||||||
|
|
||||||
- name: Build (linux/macos)
|
- name: Build (linux)
|
||||||
if: matrix.os_target != 'windows'
|
if: matrix.os_target == 'linux'
|
||||||
|
run: nix build .#linuxStatic
|
||||||
|
|
||||||
|
- name: Build (macos)
|
||||||
|
if: matrix.os_target == 'macos'
|
||||||
run: nix build
|
run: nix build
|
||||||
|
|
||||||
- name: Copy artifact
|
- name: Copy artifact
|
||||||
|
|||||||
2
Cargo.lock
generated
2
Cargo.lock
generated
@ -1191,7 +1191,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "timr-tui"
|
name = "timr-tui"
|
||||||
version = "1.0.0"
|
version = "1.1.0-alpha"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"clap",
|
"clap",
|
||||||
"color-eyre",
|
"color-eyre",
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "timr-tui"
|
name = "timr-tui"
|
||||||
version = "1.0.0"
|
version = "1.1.0-alpha"
|
||||||
description = "TUI to organize your time: Pomodoro, Countdown, Timer."
|
description = "TUI to organize your time: Pomodoro, Countdown, Timer."
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
rust-version = "1.84.0"
|
rust-version = "1.84.0"
|
||||||
|
|||||||
19
flake.nix
19
flake.nix
@ -23,6 +23,7 @@
|
|||||||
minimal.rustc
|
minimal.rustc
|
||||||
minimal.cargo
|
minimal.cargo
|
||||||
targets.x86_64-pc-windows-gnu.latest.rust-std
|
targets.x86_64-pc-windows-gnu.latest.rust-std
|
||||||
|
targets.x86_64-unknown-linux-musl.latest.rust-std
|
||||||
];
|
];
|
||||||
craneLib = (crane.mkLib pkgs).overrideToolchain toolchain;
|
craneLib = (crane.mkLib pkgs).overrideToolchain toolchain;
|
||||||
|
|
||||||
@ -32,19 +33,24 @@
|
|||||||
cargoArtifacts = craneLib.buildDepsOnly {
|
cargoArtifacts = craneLib.buildDepsOnly {
|
||||||
src = craneLib.cleanCargoSource ./.;
|
src = craneLib.cleanCargoSource ./.;
|
||||||
};
|
};
|
||||||
|
strictDeps = true;
|
||||||
doCheck = false; # skip tests during nix build
|
doCheck = false; # skip tests during nix build
|
||||||
};
|
};
|
||||||
|
|
||||||
# Native build
|
# Native build
|
||||||
timr = craneLib.buildPackage commonArgs;
|
timr = craneLib.buildPackage commonArgs;
|
||||||
|
|
||||||
|
# Linux build w/ statically linked binaries
|
||||||
|
staticLinuxBuild = craneLib.buildPackage (commonArgs
|
||||||
|
// {
|
||||||
|
CARGO_BUILD_TARGET = "x86_64-unknown-linux-musl";
|
||||||
|
CARGO_BUILD_RUSTFLAGS = "-C target-feature=+crt-static";
|
||||||
|
});
|
||||||
|
|
||||||
# Windows cross-compilation build
|
# Windows cross-compilation build
|
||||||
# @see https://crane.dev/examples/cross-windows.html
|
# @see https://crane.dev/examples/cross-windows.html
|
||||||
crossBuild = craneLib.buildPackage {
|
windowsBuild = craneLib.buildPackage {
|
||||||
src = craneLib.cleanCargoSource ./.;
|
inherit (commonArgs) src strictDeps doCheck;
|
||||||
|
|
||||||
strictDeps = true;
|
|
||||||
doCheck = false;
|
|
||||||
|
|
||||||
CARGO_BUILD_TARGET = "x86_64-pc-windows-gnu";
|
CARGO_BUILD_TARGET = "x86_64-pc-windows-gnu";
|
||||||
|
|
||||||
@ -65,7 +71,8 @@
|
|||||||
packages = {
|
packages = {
|
||||||
inherit timr;
|
inherit timr;
|
||||||
default = timr;
|
default = timr;
|
||||||
windows = crossBuild;
|
linuxStatic = staticLinuxBuild;
|
||||||
|
windows = windowsBuild;
|
||||||
};
|
};
|
||||||
|
|
||||||
# Development shell with all necessary tools
|
# Development shell with all necessary tools
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user