-
Notifications
You must be signed in to change notification settings - Fork 93
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tools.nix: Also expose as perSystem attribute "tools" in flake
- Loading branch information
Showing
3 changed files
with
96 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
{ | ||
# provider perSystem | ||
transposition.tools = { }; | ||
|
||
perSystem = { config, pkgs, lib, ... }: { | ||
options.tools = lib.mkOption { | ||
description = '' | ||
Library functions to generate the `Cargo.nix` build | ||
file automatically. | ||
''; | ||
|
||
type = lib.types.submoduleWith { | ||
modules = [ | ||
{ | ||
options.generatedCargoNix = lib.mkOption { | ||
description = '' | ||
Returns a derivation containing the generated `Cargo.nix` file | ||
which can be 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. | ||
''; | ||
type = lib.types.functionTo lib.types.package; | ||
}; | ||
options.appliedCargoNix = lib.mkOption { | ||
description = '' | ||
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. | ||
''; | ||
type = lib.types.functionTo lib.types.attrs; | ||
}; | ||
} | ||
]; | ||
}; | ||
}; | ||
|
||
config.tools = | ||
let tools = pkgs.callPackage ../../tools.nix { }; | ||
in { | ||
inherit (tools) generatedCargoNix appliedCargoNix; | ||
}; | ||
|
||
config.checks = { | ||
toolsGeneratedCargoNix_crate2nix = | ||
let | ||
cargoNixBuilder = config.tools.generatedCargoNix { name = "crate2nix"; src = ../../crate2nix; }; | ||
cargoNix = pkgs.callPackage cargoNixBuilder { }; | ||
in | ||
cargoNix.rootCrate.build; | ||
|
||
toolsAppliedCargoNix_crate2nix = | ||
let cargoNix = config.tools.appliedCargoNix { name = "crate2nix"; src = ../../crate2nix; }; | ||
in cargoNix.rootCrate.build; | ||
}; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters