nix-community / crate2nix

rebuild only changed crates in CI with crate2nix and nix
https://nix-community.github.io/crate2nix/
Apache License 2.0
354 stars 83 forks source link

Curry generated default nix to separate callPacked from custom bits #248

Open Ericson2314 opened 2 years ago

Ericson2314 commented 2 years ago

I think what I should have done here is that this is actually a function returning a function.

The first parameter attrs would just be the ones fillable by callPackage. And then a second parameter with the actual parameters. It is just hard to do that in backwards compatible manner...

{ nixpkgs ? {{config.nixpkgs_path | safe}}
, pkgs ? import nixpkgs { config = {}; }
, lib ? pkgs.lib
, stdenv ? pkgs.stdenv
}:
{
  buildRustCrateForPkgs ? pkgs: pkgs.buildRustCrate
  # This is used as the `crateOverrides` argument for `buildRustCrate`.
, defaultCrateOverrides ? pkgs.defaultCrateOverrides
  # The features to enable for the root_crate or the workspace_members.
, rootFeatures ? [ "default" ]
  # If true, throw errors instead of issueing deprecation warnings.
, strictDeprecation ? false
  # Used for conditional compilation based on CPU feature detection.
, targetFeatures ? []
  # Whether to perform release builds: longer compile times, faster binaries.
, release ? true
  # Additional crate2nix configuration if it exists.
, crateConfig
  ? if builtins.pathExists ./crate-config.nix
    then pkgs.callPackage ./crate-config.nix {}
    else {}
}:

_Originally posted by @kolloch in https://github.com/kolloch/crate2nix/pull/200#discussion_r726514081_