Fix windows build, add release target
This commit is contained in:
parent
c65a201222
commit
7e5aeb5f28
55
flake.nix
55
flake.nix
@ -38,7 +38,13 @@
|
||||
"x86_64-windows" = newBuildTarget {
|
||||
nixPkgsSystem = "x86_64-w64-mingw32";
|
||||
rustTarget = "x86_64-pc-windows-gnu";
|
||||
nativeBuildInputs = pkgsCross: [ pkgsCross.windows.pthreads ];
|
||||
nativeBuildInputs = pkgsCross: [
|
||||
pkgsCross.stdenv.cc
|
||||
pkgsCross.windows.pthreads
|
||||
];
|
||||
rustFlags = pkgsCross: [
|
||||
"-C" "link-arg=-L${pkgsCross.windows.pthreads}/lib"
|
||||
];
|
||||
};
|
||||
};
|
||||
|
||||
@ -62,12 +68,29 @@
|
||||
# "$system.cross-$system" for every system.
|
||||
#
|
||||
eachCrossSystem = supportedSystems: callback:
|
||||
eachSystem supportedSystems (buildSystem: builtins.foldl'
|
||||
eachSystem supportedSystems (buildSystem: let
|
||||
pkgs = mkPkgs buildSystem null;
|
||||
crosses = builtins.foldl'
|
||||
(inner: targetSystem: inner // {
|
||||
"cross-${targetSystem}" = callback buildSystem targetSystem;
|
||||
})
|
||||
{ default = callback buildSystem buildSystem; }
|
||||
supportedSystems
|
||||
supportedSystems;
|
||||
in
|
||||
crosses // (rec {
|
||||
default = callback buildSystem buildSystem;
|
||||
release = let
|
||||
bins = pkgs.symlinkJoin {
|
||||
name = "${default.name}-all-bins";
|
||||
paths = builtins.attrValues crosses;
|
||||
};
|
||||
in
|
||||
pkgs.runCommand "${default.name}-release" {} ''
|
||||
cp -rL "${bins}" "$out"
|
||||
chmod +w "$out"/bin
|
||||
(cd "$out"/bin && sha256sum * > sha256.txt)
|
||||
'';
|
||||
})
|
||||
);
|
||||
|
||||
mkPkgs = buildSystem: targetSystem: import nixpkgs ({
|
||||
@ -82,20 +105,9 @@
|
||||
}));
|
||||
|
||||
mkToolchain = buildSystem: targetSystem: let
|
||||
debug = v: builtins.trace v v;
|
||||
buildTarget = buildTargets.${targetSystem};
|
||||
rustTarget = buildTarget.rustTarget;
|
||||
#fenixPkgs = fenix.packages.${buildSystem};
|
||||
|
||||
# TODO prefer to use the nix flake fenix
|
||||
fenixPkgs = import ((mkPkgs buildSystem null).fetchFromGitHub {
|
||||
owner = "nix-community";
|
||||
repo = "fenix";
|
||||
rev = "81ab0b4f7ae9ebb57daa0edf119c4891806e4d3a";
|
||||
hash = "sha256-bZmI7ytPAYLpyFNgj5xirDkKuAniOkj1xHdv5aIJ5GM=";
|
||||
}) {
|
||||
system = buildSystem;
|
||||
};
|
||||
fenixPkgs = fenix.packages.${buildSystem};
|
||||
|
||||
# TODO I'd prefer to use the toolchain file
|
||||
# https://github.com/nix-community/fenix/issues/123
|
||||
@ -145,7 +157,7 @@
|
||||
|
||||
# https://github.com/rust-lang/cargo/issues/4133
|
||||
"-C" "linker=${TARGET_CC}"
|
||||
];
|
||||
] ++ (buildTarget.rustFlags pkgsCross);
|
||||
};
|
||||
|
||||
in {
|
||||
@ -165,6 +177,17 @@
|
||||
strictDeps = true;
|
||||
doCheck = false;
|
||||
release = true;
|
||||
postInstall = ''
|
||||
cd "$out"/bin
|
||||
for f in "$(ls)"; do
|
||||
if ext="$(echo "$f" | grep -oP '\.[a-z]+$')"; then
|
||||
base="$(echo "$f" | cut -d. -f1)"
|
||||
mv "$f" "$base-${targetSystem}$ext"
|
||||
else
|
||||
mv "$f" "$f-${targetSystem}"
|
||||
fi
|
||||
done
|
||||
'';
|
||||
} // (buildEnv buildSystem targetSystem))
|
||||
);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user