From 108e9551826576e1a9f41de7276fb6870b287ee6 Mon Sep 17 00:00:00 2001 From: Wonwoo Choi Date: Fri, 1 Nov 2024 00:25:37 +0900 Subject: [PATCH] Fix Nix devtools build (#377) --- flake.nix | 32 ++++++++++++++++++++------------ nix/build.nix | 36 +++++++++++++++++++++++++++--------- 2 files changed, 47 insertions(+), 21 deletions(-) diff --git a/flake.nix b/flake.nix index 3ab9ef43..0337f095 100644 --- a/flake.nix +++ b/flake.nix @@ -114,10 +114,12 @@ naerskBuildPackageNative = extraArgs: - buildPackage { - naersk = naerskForNative; - } - // extraArgs; + buildPackage ( + { + naersk = naerskForNative; + } + // extraArgs + ); naerskBuildPackageCross = { @@ -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, ... }: @@ -154,6 +158,10 @@ native-devtools = naerskBuildPackageNative { enableDevtools = true; }; + native-ffmpeg = naerskBuildPackageNative { + enableDevtools = true; + enableFfmpeg = true; + }; } // crossPackages; defaultPackage = packages.native; diff --git a/nix/build.nix b/nix/build.nix index 9ef415f5..c35b5f31 100644 --- a/nix/build.nix +++ b/nix/build.nix @@ -20,7 +20,6 @@ let inherit (builtins) concatStringsSep replaceStrings - isNull ; jxlOxideCliToml = builtins.fromTOML (builtins.readFile ../crates/jxl-oxide-cli/Cargo.toml); @@ -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 @@ -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 @@ -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; @@ -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;