Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 Fix C platform overrides #20

Merged
merged 1 commit into from
Dec 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Fixed
- C does not expect `doc` and `man` output if doxygen is disabled.
- C platform override now lets the user override all attributes of the derivation, not
just the attributes sent in. For example, `lintPhase` was hardcoded in `mkDerivation`
for all C platforms.

## [2.0.0] - 2023-11-07

Expand Down
21 changes: 11 additions & 10 deletions c/make-derivation.nix
Original file line number Diff line number Diff line change
Expand Up @@ -77,13 +77,8 @@ let

fn = args:
let
attrs' = (attrsFn args);
platformAttrs = attrs' // (platformOverrides attrs');
attrs = platformAttrs // (overrideAttrs platformAttrs);

in
(base.mkDerivation
({
attrs = (attrsFn args);
mkDerivationArgs = ({
inherit stdenv;
doCheck = true;
strictDeps = true;
Expand Down Expand Up @@ -111,7 +106,7 @@ let
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=file
${buildPackages.fd}/bin/fd --ignore-file=.gitignore --glob '*.[h,hpp,hh,cpp,cxx,cc,c]' --exec-batch clang-format -Werror -n --style=LLVM
rc=$?

if [ $rc -eq 0 ]; then
Expand All @@ -134,7 +129,7 @@ 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=file -i "$@"
${buildPackages.fd}/bin/fd --glob '*.[h,hpp,hh,cpp,cxx,cc,c]' --exec-batch clang-format --style=LLVM -i "$@"
runHook postFormat
'';
description = "Format source code in the component.";
Expand Down Expand Up @@ -170,7 +165,13 @@ let
};
}
// attrs.shellCommands or { };
}));
});

platformAttrs = mkDerivationArgs // (platformOverrides mkDerivationArgs);
attrs' = platformAttrs // (overrideAttrs platformAttrs);

in
(base.mkDerivation attrs');

splicedComponents = base.mapComponentsRecursive
(_path: component:
Expand Down