Skip to content

Commit

Permalink
More sensible names in tools.nix
Browse files Browse the repository at this point in the history
  • Loading branch information
kolloch committed Feb 12, 2020
1 parent 620d83c commit a76b8d3
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 16 deletions.
5 changes: 3 additions & 2 deletions tests.nix
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ let
};
};
tools = pkgs.callPackage ./tools.nix {};
toolsAllowDeprecated = pkgs.callPackage ./tools.nix { strictDeprecation = false; };
buildTest =
{ name
, src
Expand Down Expand Up @@ -38,7 +39,7 @@ let
if builtins.isNull pregeneratedBuild
then
let
autoGeneratedCargoNix = tools.generate {
autoGeneratedCargoNix = tools.generatedCargoNix {
name = "buildTest_test_${name}";
inherit src cargoToml additionalCargoNixArgs;
};
Expand Down Expand Up @@ -366,7 +367,7 @@ in
bin_with_deprecated_alias =
let
bin_build = (
tools.generated {
toolsAllowDeprecated.generated {
name = "bin_with_deprecated_alias";
src = ./sample_projects/bin;
}
Expand Down
41 changes: 27 additions & 14 deletions tools.nix
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,28 @@
# avoid breaking the API and/or mention breakages in the CHANGELOG.
#

{ pkgs ? import ./nixpkgs.nix { config = {}; }, lib ? pkgs.lib }:
{ pkgs ? import ./nixpkgs.nix { config = {}; }
, lib ? pkgs.lib
, strictDeprecation ? true
}:

let
cargo_nix = pkgs.callPackage ./crate2nix/Cargo.nix {};
crate2nix = cargo_nix.rootCrate.build;
cargoNix = pkgs.callPackage ./crate2nix/Cargo.nix { inherit strictDeprecation; };
crate2nix = cargoNix.rootCrate.build;

in
rec {

/*
Returns the whole top-level function generated by crate2nix which is typically
called with `pkgs.callPackage`.
/* Returns the whole top-level function generated by crate2nix (`Cargo.nix`)
which is typically called with `pkgs.callPackage`.
name: will be part of the derivation name
src: the source that is needed to build the crate, usually the crate/workspace root directory
cargoToml: Path to the Cargo.toml file relative to src, "Cargo.toml" by default.
*/
generate =
name: will be part of the derivation name
src: the source that is needed to build the crate, usually the
crate/workspace root directory
cargoToml: Path to the Cargo.toml file relative to src, "Cargo.toml" by
default.
*/
generatedCargoNix =
{ name
, src
, cargoToml ? "Cargo.toml"
Expand Down Expand Up @@ -85,13 +89,22 @@ rec {

};

# Returns a derivation for a rust binary package.
# Applies the default arguments from pkgs to the generated `Cargo.nix` file.
#
# name: will be part of the derivation name
# src: the source that is needed to build the crate, usually the crate/workspace root directory
# cargoToml: Path to the Cargo.toml file relative to src, "Cargo.toml" by default.
generated = { cargoToml ? "Cargo.toml", ... } @ args:
pkgs.callPackage (generate args) {};
appliedCargoNix = { cargoToml ? "Cargo.toml", ... } @ args:
pkgs.callPackage (generatedCargoNix args) {};

generate =
cargoNix.internal.deprecationWarning
"crate2nix/tools.nix: generate deprecated since 0.7. Use generatedCargoNix instead."
generatedCargoNix;
generated =
cargoNix.internal.deprecationWarning
"crate2nix/tools.nix: generated deprecated since 0.7. Use appliedCargoNix in instead."
appliedCargoNix;

internal = rec {
# Unpack sources and add a .cargo-checksum.json file to make cargo happy.
Expand Down

0 comments on commit a76b8d3

Please sign in to comment.