Skip to content

Commit

Permalink
Fix Nix devtools build (#377)
Browse files Browse the repository at this point in the history
  • Loading branch information
tirr-c authored Oct 31, 2024
1 parent 2fbd5f4 commit 108e955
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 21 deletions.
32 changes: 20 additions & 12 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -114,10 +114,12 @@

naerskBuildPackageNative =
extraArgs:
buildPackage {
naersk = naerskForNative;
}
// extraArgs;
buildPackage (
{
naersk = naerskForNative;
}
// extraArgs
);

naerskBuildPackageCross =
{
Expand All @@ -131,14 +133,16 @@
inherit (pkgsCross) hostPlatform stdenv;
isMinGW = pkgsCross.stdenv.cc.isGNU or false && hostPlatform.isWindows;
in
buildPackage {
pkgs = pkgsCross;
naersk = naerskFor target;
stdenv = if isMinGW then wrapMingwStdenv stdenv else stdenv;
crossTarget = target;
inherit static;
}
// args;
buildPackage (
{
pkgs = pkgsCross;
naersk = naerskFor target;
stdenv = if isMinGW then wrapMingwStdenv stdenv else stdenv;
crossTarget = target;
inherit static;
}
// args
);

crossPackages = mapListToAttrs (
spec@{ target, ... }:
Expand All @@ -154,6 +158,10 @@
native-devtools = naerskBuildPackageNative {
enableDevtools = true;
};
native-ffmpeg = naerskBuildPackageNative {
enableDevtools = true;
enableFfmpeg = true;
};
} // crossPackages;
defaultPackage = packages.native;

Expand Down
36 changes: 27 additions & 9 deletions nix/build.nix
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ let
inherit (builtins)
concatStringsSep
replaceStrings
isNull
;

jxlOxideCliToml = builtins.fromTOML (builtins.readFile ../crates/jxl-oxide-cli/Cargo.toml);
Expand All @@ -38,7 +37,11 @@ let
++ lib.optional enableFfmpeg "__ffmpeg";
featureListStr = concatStringsSep "," featureList;
in
[ "-p" "jxl-oxide-cli" "--no-default-features" ]
[
"-p"
"jxl-oxide-cli"
"--no-default-features"
]
++ lib.optionals (featureList != [ ]) [
"--features"
featureListStr
Expand All @@ -50,11 +53,14 @@ let
let
featureList =
[ "conformance" ] # conformance tests only
++ lib.optional enableMimalloc "mimalloc"
++ lib.optional enableRayon "rayon";
++ lib.optional enableMimalloc "mimalloc" ++ lib.optional enableRayon "rayon";
featureListStr = concatStringsSep "," featureList;
in
[ "-p" "jxl-oxide-tests" "--no-default-features" ]
[
"-p"
"jxl-oxide-tests"
"--no-default-features"
]
++ lib.optionals (featureList != [ ]) [
"--features"
featureListStr
Expand All @@ -67,7 +73,21 @@ let
strictDeps = true;

cargoBuildOptions = args: args ++ cargoBuildArgs;
buildInputs = lib.optionals stdenv.isDarwin [ darwin.apple_sdk.frameworks.SystemConfiguration ];
buildInputs =
lib.optionals enableFfmpeg (
with pkgs;
[
ffmpeg_7-headless
rustPlatform.bindgenHook
]
)
++ lib.optionals stdenv.isDarwin [ darwin.apple_sdk.frameworks.SystemConfiguration ];
nativeBuildInputs = lib.optionals enableFfmpeg (
with pkgs;
[
pkg-config
]
);

doCheck = true;
cargoTestOptions = args: args ++ cargoTestArgs;
Expand All @@ -86,9 +106,7 @@ let
in
naersk.buildPackage (
commonBuildArgs
// {
}
// lib.optionalAttrs (!isNull crossTarget) rec {
// lib.optionalAttrs (crossTarget != null) rec {
depsBuildBuild = [
stdenv.cc
] ++ lib.optional isMinGW windows.pthreads;
Expand Down

0 comments on commit 108e955

Please sign in to comment.