buildRustPackage: add example package

This commit is contained in:
DavHau 2023-10-17 18:58:28 +01:00 committed by mergify[bot]
parent 1caf997f69
commit 72e4fd904d
3 changed files with 44 additions and 0 deletions

View File

@ -0,0 +1,29 @@
{
lib,
config,
dream2nix,
...
}: {
imports = [
dream2nix.modules.dream2nix.rust-cargo-lock
dream2nix.modules.dream2nix.buildRustPackage
];
deps = {nixpkgs, ...}: {
inherit (nixpkgs) fetchFromGitHub;
};
name = lib.mkForce "ripgrep";
version = lib.mkForce "13.0.0";
# options defined on top-level will be applied to the main derivation (the derivation that is exposed)
mkDerivation = {
# define the source root that contains the package we want to build.
src = config.deps.fetchFromGitHub {
owner = "BurntSushi";
repo = "ripgrep";
rev = config.version;
sha256 = "sha256-udEh+Re2PeO3DnX4fQThsaT1Y3MBHFfrX5Q5EN2XrF0=";
};
};
}

View File

@ -146,6 +146,7 @@
in {
imports = [
dream2nix.modules.dream2nix.mkDerivation
./interface.nix
];
package-func.func = config.deps.rustPlatform.buildRustPackage;
@ -158,12 +159,14 @@ in {
deps = {nixpkgs, ...}: {
inherit
(nixpkgs)
cargo
fetchurl
jq
moreutils
python3Packages
runCommandLocal
rustPlatform
writeText
;
inherit
(nixpkgs.writers)

View File

@ -0,0 +1,12 @@
{lib, ...}: {
options.deps = {
cargo = lib.mkOption {
type = lib.types.package;
description = "The cargo package to use";
};
writeText = lib.mkOption {
type = lib.types.raw;
description = "The function to use to write text to a file";
};
};
}