nix mintd pkg (#486)

This commit is contained in:
thesimplekid
2024-12-05 10:01:32 +00:00
committed by GitHub
parent d4975c7170
commit a0dca228b9
5 changed files with 5552 additions and 7 deletions

2
.gitignore vendored
View File

@@ -1,5 +1,4 @@
**/target
/Cargo.lock
.direnv
.vscode/
.idea/
@@ -7,3 +6,4 @@
*.sqlite*
config.toml
.pre-commit-config.yaml
result

5406
Cargo.lock generated Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -8,8 +8,7 @@ resolver = "2"
license = "MIT"
homepage = "https://github.com/cashubtc/cdk"
repository = "https://github.com/cashubtc/cdk.git"
rust-version = "1.63.0" # MSRV
version = "0.3.0"
version = "0.5.0"
[workspace.metadata]
authors = ["CDK Developers"]
@@ -24,3 +23,6 @@ keywords = ["bitcoin", "e-cash", "cashu"]
inherits = "dev"
incremental = false
lto = "off"
[workspace.metadata.crane]
name = "cdk-workspace"

44
flake.lock generated
View File

@@ -1,5 +1,41 @@
{
"nodes": {
"crane": {
"locked": {
"lastModified": 1733016477,
"narHash": "sha256-Hh0khbqBeCtiNS0SJgqdWrQDem9WlPEc2KF5pAY+st0=",
"owner": "ipetkov",
"repo": "crane",
"rev": "76d64e779e2fbaf172110038492343a8c4e29b55",
"type": "github"
},
"original": {
"owner": "ipetkov",
"repo": "crane",
"type": "github"
}
},
"fenix": {
"inputs": {
"nixpkgs": [
"nixpkgs"
],
"rust-analyzer-src": []
},
"locked": {
"lastModified": 1732689334,
"narHash": "sha256-yKI1KiZ0+bvDvfPTQ1ZT3oP/nIu3jPYm4dnbRd6hYg4=",
"owner": "nix-community",
"repo": "fenix",
"rev": "a8a983027ca02b363dfc82fbe3f7d9548a8d3dce",
"type": "github"
},
"original": {
"owner": "nix-community",
"repo": "fenix",
"type": "github"
}
},
"flake-compat": {
"flake": false,
"locked": {
@@ -57,11 +93,11 @@
},
"nixpkgs": {
"locked": {
"lastModified": 1731386116,
"narHash": "sha256-lKA770aUmjPHdTaJWnP3yQ9OI1TigenUqVC3wweqZuI=",
"lastModified": 1733016324,
"narHash": "sha256-8qwPSE2g1othR1u4uP86NXxm6i7E9nHPyJX3m3lx7Q4=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "689fed12a013f56d4c4d3f612489634267d86529",
"rev": "7e1ca67996afd8233d9033edd26e442836cc2ad6",
"type": "github"
},
"original": {
@@ -126,6 +162,8 @@
},
"root": {
"inputs": {
"crane": "crane",
"fenix": "fenix",
"flake-utils": "flake-utils",
"nixpkgs": "nixpkgs",
"pre-commit-hooks": "pre-commit-hooks",

101
flake.nix
View File

@@ -11,12 +11,23 @@
};
};
fenix = {
url = "github:nix-community/fenix";
inputs.nixpkgs.follows = "nixpkgs";
inputs.rust-analyzer-src.follows = "";
};
flake-utils.url = "github:numtide/flake-utils";
crane = {
url = "github:ipetkov/crane";
inputs.nixpkgs.follows = "nixpkgs";
};
pre-commit-hooks.url = "github:cachix/pre-commit-hooks.nix";
};
outputs = { self, nixpkgs, rust-overlay, flake-utils, pre-commit-hooks, ... }:
outputs = { self, nixpkgs, rust-overlay, flake-utils, pre-commit-hooks, crane, fenix, ... }:
flake-utils.lib.eachDefaultSystem (system:
let
overlays = [ (import rust-overlay) ];
@@ -35,6 +46,7 @@
};
# Toolchains
# latest stable
stable_toolchain = pkgs.rust-bin.stable."1.82.0".default.override {
@@ -82,6 +94,77 @@
WASMInputs = with pkgs; [
];
craneLib = crane.mkLib pkgs;
src = craneLib.cleanCargoSource ./.;
# Common arguments can be set here to avoid repeating them later
commonArgs = {
inherit src;
strictDeps = true;
buildInputs = [
# Add additional build inputs here
pkgs.protobuf
pkgs.pkg-config
] ++ lib.optionals pkgs.stdenv.isDarwin [
# Additional darwin specific inputs can be set here
pkgs.libiconv
];
# Additional environment variables can be set directly
# MY_CUSTOM_VAR = "some value";
PROTOC = "${pkgs.protobuf}/bin/protoc";
PROTOC_INCLUDE = "${pkgs.protobuf}/include";
};
craneLibLLvmTools = craneLib.overrideToolchain
(fenix.packages.${system}.complete.withComponents [
"cargo"
"llvm-tools"
"rustc"
]);
cargoArtifacts = craneLib.buildDepsOnly commonArgs;
individualCrateArgs = commonArgs // {
inherit cargoArtifacts;
inherit (craneLib.crateNameFromCargoToml { inherit src; }) version;
# NB: we disable tests since we'll run them all via cargo-nextest
doCheck = false;
};
fileSetForCrate = crate: lib.fileset.toSource {
root = ./.;
fileset = lib.fileset.unions [
./Cargo.toml
./Cargo.lock
(craneLib.fileset.commonCargoSources ./crates/cdk)
(craneLib.fileset.commonCargoSources ./crates/cdk-axum)
(craneLib.fileset.commonCargoSources ./crates/cdk-cln)
(craneLib.fileset.commonCargoSources ./crates/cdk-lnd)
(craneLib.fileset.commonCargoSources ./crates/cdk-fake-wallet)
(craneLib.fileset.commonCargoSources ./crates/cdk-lnbits)
(craneLib.fileset.commonCargoSources ./crates/cdk-strike)
(craneLib.fileset.commonCargoSources ./crates/cdk-phoenixd)
(craneLib.fileset.commonCargoSources ./crates/cdk-redb)
(craneLib.fileset.commonCargoSources ./crates/cdk-sqlite)
./crates/cdk-sqlite/src/mint/migrations
./crates/cdk-sqlite/src/wallet/migrations
(craneLib.fileset.commonCargoSources crate)
];
};
cdk-mintd = craneLib.buildPackage (individualCrateArgs // {
pname = "cdk-mintd";
name = "cdk-mintd-${individualCrateArgs.version}";
cargoExtraArgs = "-p cdk-mintd";
src = fileSetForCrate ./crates/cdk-mintd;
});
nativeBuildInputs = with pkgs; [
#Add additional build inputs here
] ++ lib.optionals isDarwin [
@@ -123,6 +206,22 @@
};
};
packages = {
inherit cdk-mintd;
default = cdk-mintd;
} // lib.optionalAttrs (!pkgs.stdenv.isDarwin) {
my-workspace-llvm-coverage = craneLibLLvmTools.cargoLlvmCov (commonArgs // {
inherit cargoArtifacts;
});
};
apps = {
cdk-mintd = flake-utils.lib.mkApp {
drv = cdk-mintd;
};
};
devShells =
let
# pre-commit-checks