Skip to content

Commit

Permalink
make target mandatory input
Browse files Browse the repository at this point in the history
  • Loading branch information
soywod committed Nov 24, 2024
1 parent 3852b5a commit 44d94be
Show file tree
Hide file tree
Showing 5 changed files with 72 additions and 50 deletions.
17 changes: 12 additions & 5 deletions .github/workflows/pre-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,31 @@ jobs:
matrix:
include:
- target: aarch64-apple-darwin
artifact: macos.aarch64
os: macos-14
- target: aarch64-unknown-linux-musl
artifact: linux.aarch64
os: ubuntu-latest
- target: armv6l-unknown-linux-musleabihf
artifact: linux.armv6l
os: ubuntu-latest
- target: armv7l-unknown-linux-musleabihf
artifact: linux.armv7l
os: ubuntu-latest
- target: i686-unknown-linux-musl
artifact: linux.i686
os: ubuntu-latest
- target: i686-w64-mingw32
artifact: windows.i686
os: ubuntu-latest
# FIXME
# - target: i686-w64-mingw32
# os: ubuntu-latest
- target: x86_64-apple-darwin
artifact: macos.x86_64
os: macos-13
- target: x86_64-unknown-linux-musl
artifact: linux.x86_64
os: ubuntu-latest
- target: x86_64-w64-mingw32
artifact: windows.x86_64
os: ubuntu-latest
steps:
- name: Checkout code
Expand All @@ -37,7 +45,6 @@ jobs:
with:
nix_path: nixpkgs=channel:nixos-24.05
enable_kvm: true
# extra_nix_config: "experimental-features = nix-command flakes"
- name: Cache Nix store
uses: cachix/cachix-action@v15
with:
Expand All @@ -50,7 +57,7 @@ jobs:
- name: Upload release artifacts
uses: actions/upload-artifact@v4
with:
name: "himalaya.${{ matrix.target }}"
name: "himalaya.${{ matrix.artifact }}"
path: |
result/bin/himalaya*
result/bin/share
30 changes: 0 additions & 30 deletions cross-systems.nix

This file was deleted.

21 changes: 14 additions & 7 deletions default.nix
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
{ target ? null, defaultFeatures ? true, features ? "" }:
{ target
, defaultFeatures ? true
, features ? ""
}:

let
pkgs = import <nixpkgs> (
if isNull target then { } else {
crossSystem = { isStatic = true; config = target; };
}
);
systems = import ./systems.nix;
inherit (systems.${target}) rustTarget isStatic;

pkgs = import <nixpkgs> {
crossSystem = {
inherit isStatic;
config = target;
};
};

inherit (pkgs) lib hostPlatform;

Expand All @@ -15,7 +22,7 @@ let

rustToolchain = mkToolchain.fromTarget {
inherit lib;
targetSystem = hostPlatform.config;
targetSystem = rustTarget;
};

rustPlatform = pkgs.makeRustPlatform {
Expand Down
8 changes: 0 additions & 8 deletions package.nix
Original file line number Diff line number Diff line change
Expand Up @@ -28,19 +28,11 @@ rustPlatform.buildRustPackage rec {

cargoHash = "sha256-YS8IamapvmdrOPptQh2Ef9Yold0IK1XIeGs0kDIQ5b8=";

# TARGET_CC = "${stdenv.cc}/bin/${stdenv.cc.targetPrefix}cc";
# CARGO_BUILD_RUSTFLAGS = [
# "-Clinker=${TARGET_CC}"
# "-Clink-args=-static -latomic"
# "-Ctarget-feature=+crt-static"
# ];

# unit tests only
doCheck = false;
cargoTestFlags = [ "--lib" ];

nativeBuildInputs = [ ]
++ lib.optional hostPlatform.isDarwin [ darwin.libiconv ]
++ lib.optional (installManPages || installShellCompletions) installShellFiles;

buildInputs = [ ]
Expand Down
46 changes: 46 additions & 0 deletions systems.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
{
aarch64-apple-darwin = {
rustTarget = "aarch64-apple-darwin";
isStatic = false;
};

aarch64-unknown-linux-musl = {
rustTarget = "aarch64-unknown-linux-musl";
isStatic = true;
};

armv6l-unknown-linux-musleabihf = {
rustTarget = "arm-unknown-linux-musleabihf";
isStatic = true;
};

armv7l-unknown-linux-musleabihf = {
rustTarget = "armv7-unknown-linux-musleabihf";
isStatic = true;
};

i686-unknown-linux-musl = {
rustTarget = "i686-unknown-linux-musl";
isStatic = true;
};

i686-w64-mingw32 = {
rustTarget = "i686-pc-windows-gnu";
isStatic = false;
};

x86_64-apple-darwin = {
rustTarget = "x86_64-apple-darwin";
isStatic = false;
};

x86_64-unknown-linux-musl = {
rustTarget = "x86_64-unknown-linux-musl";
isStatic = true;
};

x86_64-w64-mingw32 = {
rustTarget = "x86_64-pc-windows-gnu";
isStatic = false;
};
}

0 comments on commit 44d94be

Please sign in to comment.