-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add flake.nix * Add profile `opt` * Update .gitignore * Fix Windows binary not being built properly * Split `flake.nix` into files
- Loading branch information
Showing
7 changed files
with
449 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
/target | ||
/result |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
let | ||
inherit (builtins) fetchTarball fromJSON readFile; | ||
getFlake = | ||
name: with (fromJSON (readFile ./flake.lock)).nodes.${name}.locked; { | ||
inherit rev; | ||
outPath = fetchTarball { | ||
url = "https://github.com/${owner}/${repo}/archive/${rev}.tar.gz"; | ||
sha256 = narHash; | ||
}; | ||
}; | ||
in | ||
|
||
{ | ||
pkgs, | ||
lib ? pkgs.lib, | ||
windows ? pkgs.windows, | ||
hostPlatform ? pkgs.hostPlatform, | ||
stdenv ? pkgs.stdenv, | ||
naersk, | ||
|
||
crossTarget ? null, | ||
static ? false, | ||
enableMimalloc ? true, | ||
enableRayon ? true, | ||
enableFfmpeg ? false, | ||
enableDevtools ? enableFfmpeg, | ||
... | ||
}: | ||
|
||
let | ||
inherit (builtins) | ||
concatStringsSep | ||
replaceStrings | ||
isNull | ||
; | ||
|
||
jxlOxideCliToml = builtins.fromTOML (builtins.readFile ./crates/jxl-oxide-cli/Cargo.toml); | ||
|
||
toScreamingSnakeCase = s: replaceStrings [ "-" ] [ "_" ] (lib.strings.toUpper s); | ||
cargoEnvPrefix = "CARGO_TARGET_${toScreamingSnakeCase crossTarget}_"; | ||
|
||
commonBuildArgs = { | ||
inherit (jxlOxideCliToml.package) name version; | ||
pname = "jxl-oxide"; | ||
src = ./.; | ||
strictDeps = true; | ||
overrideMain = old: { | ||
preConfigure = '' | ||
cargo_build_options="$cargo_build_options -p jxl-oxide-cli" | ||
''; | ||
}; | ||
}; | ||
|
||
cargoBuildArgs = | ||
let | ||
featureList = | ||
[ ] | ||
++ lib.optional enableMimalloc "mimalloc" | ||
++ lib.optional enableRayon "rayon" | ||
++ lib.optional enableDevtools "__devtools" | ||
++ lib.optional enableFfmpeg "__ffmpeg"; | ||
featureListStr = concatStringsSep "," featureList; | ||
in | ||
[ "--no-default-features" ] | ||
++ lib.optionals (featureList != [ ]) [ | ||
"--features" | ||
featureListStr | ||
]; | ||
|
||
isMinGW = stdenv.cc.isGNU or false && hostPlatform.isWindows; | ||
in | ||
naersk.buildPackage ( | ||
commonBuildArgs | ||
// { | ||
cargoBuildOptions = args: args ++ cargoBuildArgs; | ||
} | ||
// lib.optionalAttrs (!isNull crossTarget) rec { | ||
depsBuildBuild = [ | ||
stdenv.cc | ||
] ++ lib.optional isMinGW windows.pthreads; | ||
|
||
CARGO_BUILD_TARGET = crossTarget; | ||
TARGET_CC = "${stdenv.cc}/bin/${stdenv.cc.targetPrefix}cc"; | ||
"${cargoEnvPrefix}LINKER" = TARGET_CC; | ||
} | ||
// lib.optionalAttrs static { | ||
"${cargoEnvPrefix}RUSTFLAGS" = "-C target-feature=+crt-static"; | ||
} | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
let | ||
inherit (builtins) fetchTarball fromJSON readFile; | ||
getFlake = | ||
name: with (fromJSON (readFile ./flake.lock)).nodes.${name}.locked; { | ||
inherit rev; | ||
outPath = fetchTarball { | ||
url = "https://github.com/${owner}/${repo}/archive/${rev}.tar.gz"; | ||
sha256 = narHash; | ||
}; | ||
}; | ||
|
||
pkgs = import <nixpkgs> { }; | ||
fenix = pkgs.callPackage (getFlake "fenix") { }; | ||
toolchain = fenix.stable.withComponents [ | ||
"cargo" | ||
"rustc" | ||
]; | ||
naersk = pkgs.callPackage (getFlake "naersk") { | ||
cargo = toolchain; | ||
rustc = toolchain; | ||
}; | ||
in | ||
|
||
pkgs.callPackage ./build.nix { | ||
inherit naersk; | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.