Skip to content

Commit

Permalink
chore: Auto wire crates with binaries
Browse files Browse the repository at this point in the history
  • Loading branch information
srid committed Jul 13, 2024
1 parent 5559fd8 commit 0d8b7c4
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions nix/modules/crate.nix
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,27 @@
type = lib.types.attrsOf lib.types.raw;
default = builtins.fromTOML (builtins.readFile ("${config.path}/Cargo.toml"));
};
hasBinaries = lib.mkOption {
type = lib.types.bool;
readOnly = true;
description = ''
Whether the crate has binaries or not.
See <https://doc.rust-lang.org/cargo/reference/cargo-targets.html#binaries>
'';
default =
lib.pathIsRegularFile "${config.path}/src/main.rs" ||
lib.pathIsDirectory "${config.path}/src/bin" ||
lib.hasAttr "bin" config.cargoToml;
};
autoWire = lib.mkOption {
type = lib.types.bool;
default = false;
default = config.hasBinaries;
defaultText = "true if the crate has binaries, false otherwise";
description = ''
Autowire the packages and checks for this crate on to the flake output.
Generally, not all workspace creates need to be wired, only the ones
that the user actually uses need to be.
By default, crates with binaries will have their packages and checks wired.
'';
};
crane = {
Expand Down

0 comments on commit 0d8b7c4

Please sign in to comment.