diff --git a/CHANGELOG.md b/CHANGELOG.md index 8cc85f0..a088666 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,17 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## Fixed +- c/c++: Use more appropriate versions of clangd and clang-format when + cross-compiling since the target platform does not actually + matter. +- c/c++: Use a debugger for the shell that comes from buildPackages + to get the correct hostPlatform when cross-compiling. +- c/c++: Enabling doxygen required the `name` attribute. Now, + pname is enough as well. +- c/c++: Use a more appropriate variant of `fd`, since it + does not depend on the target platform when cross-compiling. + ## [5.1.0] - 2024-12-12 ### Added diff --git a/c/make-derivation.nix b/c/make-derivation.nix index a0a00b9..b6d9656 100644 --- a/c/make-derivation.nix +++ b/c/make-derivation.nix @@ -4,8 +4,8 @@ platformOverrides: , pkgs , lib , buildPackages +, pkgsBuildBuild , substitute -, writeShellScriptBin , components , targetName , doxygenOutputDir ? "doc" @@ -29,7 +29,7 @@ let replacements = [ "--subst-var-by" "name" - attrs.name + attrs.name or attrs.pname "--subst-var-by" "version" attrs.version @@ -40,7 +40,7 @@ let }; - wrappedDoxygen = outputDir: doxyfiles: writeShellScriptBin "doxygen" '' + wrappedDoxygen = outputDir: doxyfiles: pkgsBuildBuild.writeShellScriptBin "doxygen" '' set -euo pipefail doxyfiles=(${builtins.concatStringsSep " " doxyfiles}) : ''${componentDir=$PWD} @@ -48,7 +48,7 @@ let doxyfiles+=("$componentDir/Doxyfile") fi if [[ $@ =~ "--print-generated-config" ]]; then - ${buildPackages.bat}/bin/bat "''${doxyfiles[@]}" + ${pkgsBuildBuild.bat}/bin/bat "''${doxyfiles[@]}" exit 0 fi @@ -57,9 +57,9 @@ let cp --no-preserve=mode "${mathjax}" "${outputDir}"/html/mathjax/MathJax.js if [ $# -eq 0 ]; then - ${buildPackages.doxygen}/bin/doxygen <(cat "''${doxyfiles[@]}") + ${pkgsBuildBuild.doxygen}/bin/doxygen <(cat "''${doxyfiles[@]}") else - ${buildPackages.doxygen}/bin/doxygen "$@" + ${pkgsBuildBuild.doxygen}/bin/doxygen "$@" fi ''; @@ -85,7 +85,7 @@ let outputs = [ "out" ] ++ lib.optionals (attrs.enableDoxygen or enableDoxygen) [ "doc" "man" ]; } // attrs // { nativeBuildInputs = [ - buildPackages.clang-tools + pkgsBuildBuild.clang-tools buildPackages.valgrind ] ++ attrs.nativeBuildInputs or [ ] @@ -98,15 +98,18 @@ let ] ); - shellInputs = [ - pkgs.${attrs.debugger or "gdb"} - ] ++ attrs.shellInputs or [ ]; + shellInputs = [ buildPackages.${attrs.debugger or "gdb"} ] + ++ attrs.shellInputs or [ ]; lintPhase = attrs.lintPhase or '' runHook preLint if [ -z "''${dontCheckClangFormat:-}" ]; then echo "🏟 Checking format in C/C++ files..." - ${buildPackages.fd}/bin/fd --ignore-file=.gitignore --glob '*.{h,hpp,hh,cpp,cxx,cc,c}' --exec-batch clang-format -Werror -n --style=LLVM + ${pkgsBuildBuild.fd}/bin/fd \ + --ignore-file=.gitignore \ + --glob '*.{h,hpp,hh,cpp,cxx,cc,c}' \ + --exec-batch clang-format -Werror -n --style=LLVM \; \ + "${sourceRoot:-.}" rc=$? if [ $rc -eq 0 ]; then @@ -129,7 +132,10 @@ let script = '' runHook preFormat echo "🏟️ Formatting C++ files..." - ${buildPackages.fd}/bin/fd --glob '*.{h,hpp,hh,cpp,cxx,cc,c}' --exec-batch clang-format --style=LLVM -i "$@" + ${pkgsBuildBuild.fd}/bin/fd \ + --glob '*.{h,hpp,hh,cpp,cxx,cc,c}' \ + --exec-batch clang-format --style=LLVM -i "$@" \; \ + "${componentDir:-.}" runHook postFormat ''; description = "Format source code in the component.";