Skip to content

Commit

Permalink
fix(crate2nix): reimplement overrideAttrs properly
Browse files Browse the repository at this point in the history
  • Loading branch information
yusdacra committed Aug 3, 2021
1 parent a208403 commit b8110cd
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions build.nix
Original file line number Diff line number Diff line change
Expand Up @@ -164,17 +164,22 @@ else if lib.isCrate2Nix buildPlatform then
[ "--no-default-features" "--features" (lib.concatStringsSep " " config.rootFeatures) ];
} // (builtins.removeAttrs config [ "runTests" ])
);
package = pkg.override { inherit (config) runTests; };
mkJoin = package: pkgs.symlinkJoin {
inherit (common) meta;
name = "${pkgName}-${cargoPkg.version}";
paths = [ package ];
};
mkJoinWithOv = package: (mkJoin package) // {
overrideAttrsTop = (mkJoin package).overrideAttrs;
};
in
# This is a workaround so that crate2nix doesnt get built until we actually build
# otherwise nix will try to build it even if you only run `nix flake show`
# https://github.com/NixOS/nix/issues/4265
# TODO: probably provide a way to override the inner derivation?
pkgs.symlinkJoin {
inherit (common) meta;
name = "${pkgName}-${cargoPkg.version}";
paths = [
(pkg.override { inherit (config) runTests; })
];
(mkJoinWithOv package) // {
overrideAttrs = f: mkJoinWithOv (package.overrideAttrs f);
override = attrs: mkJoinWithOv (package.override attrs);
};
}
else if lib.isBuildRustPackage buildPlatform then
Expand Down

0 comments on commit b8110cd

Please sign in to comment.