Skip to content

Commit

Permalink
Fix macOS build
Browse files Browse the repository at this point in the history
  • Loading branch information
lucperkins committed Jun 17, 2024
1 parent fb0742c commit 1addb31
Show file tree
Hide file tree
Showing 2 changed files with 80 additions and 79 deletions.
101 changes: 47 additions & 54 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

58 changes: 33 additions & 25 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
url = "https://flakehub.com/f/ipetkov/crane/0.14.1.tar.gz";
inputs.nixpkgs.follows = "nixpkgs";
};
rust-overlay = {
url = "github:oxalica/rust-overlay";
fenix = {
url = "https://flakehub.com/f/nix-community/fenix/0.1.1885.tar.gz";
inputs.nixpkgs.follows = "nixpkgs";
};
};
Expand All @@ -24,42 +24,50 @@
inherit system;
pkgs = import inputs.nixpkgs {
inherit system;
overlays = [
inputs.self.overlays.default
inputs.rust-overlay.overlays.default
];
overlays = [ inputs.self.overlays.default ];
};
lib = pkgs.lib;
});
in
{
overlays.default = final: prev: {
overlays.default = final: prev: rec {
system = final.stdenv.hostPlatform.system;

rustToolchain = with inputs.fenix.packages.${system};
combine ([
stable.clippy
stable.rustc
stable.cargo
stable.rustfmt
stable.rust-src
] ++ final.lib.optionals (system == "x86_64-linux") [
targets.x86_64-unknown-linux-musl.stable.rust-std
] ++ final.lib.optionals (system == "aarch64-linux") [
targets.aarch64-unknown-linux-musl.stable.rust-std
]);

craneLib = (inputs.crane.mkLib final).overrideToolchain rustToolchain;

flakehub-push = inputs.self.packages.${final.stdenv.system}.flakehub-push;
};

packages = forAllSystems ({ system, pkgs, lib, ... }:
let
craneLib = (inputs.crane.mkLib pkgs).overrideToolchain rustToolchain;
rustToolchain = pkgs.rust-bin.stable.latest.default.override {
targets = [ "x86_64-unknown-linux-musl" ];
};
in
rec {
default = flakehub-push;
packages = forAllSystems ({ system, pkgs, ... }: rec {
default = flakehub-push;

flakehub-push = craneLib.buildPackage {
flakehub-push = pkgs.craneLib.buildPackage
{
pname = "flakehub-push";
version = "0.1.0";
src = craneLib.path ./.;
src = pkgs.craneLib.path ./.;

CARGO_BUILD_TARGET = "x86_64-unknown-linux-musl";
CARGO_BUILD_RUSTFLAGS = "-C target-feature=+crt-static";

buildInputs = lib.optionals (pkgs.stdenv.isDarwin) (with pkgs; [
buildInputs = pkgs.lib.optionals (pkgs.stdenv.isDarwin) (with pkgs; [
libiconv
darwin.apple_sdk.frameworks.SystemConfiguration
]);
};
});
} // pkgs.lib.optionalAttrs pkgs.stdenv.isLinux {
CARGO_BUILD_TARGET = "x86_64-unknown-linux-musl";
CARGO_BUILD_RUSTFLAGS = "-C target-feature=+crt-static";
};
});

devShells = forAllSystems ({ system, pkgs, ... }: {
default = pkgs.mkShell {
Expand Down

0 comments on commit 1addb31

Please sign in to comment.