Add nix flake

This commit is contained in:
Mike Heier 2023-08-11 23:50:50 -04:00
parent 5895ad906d
commit 9f53e855da
3 changed files with 463 additions and 354 deletions

710
Cargo.lock generated

File diff suppressed because it is too large Load Diff

60
flake.lock Normal file
View File

@ -0,0 +1,60 @@
{
"nodes": {
"flake-utils": {
"inputs": {
"systems": "systems"
},
"locked": {
"lastModified": 1689068808,
"narHash": "sha256-6ixXo3wt24N/melDWjq70UuHQLxGV8jZvooRanIHXw0=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "919d646de7be200f3bf08cb76ae1f09402b6f9b4",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1691807049,
"narHash": "sha256-LEvnZFLkyiJUBWfu8FGYhlW0iFXau99pt0d1rR5XGXQ=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "e35d8c2b1b0b3ae614b246f66ad0a914ceae4e72",
"type": "github"
},
"original": {
"owner": "nixos",
"repo": "nixpkgs",
"type": "github"
}
},
"root": {
"inputs": {
"flake-utils": "flake-utils",
"nixpkgs": "nixpkgs"
}
},
"systems": {
"locked": {
"lastModified": 1681028828,
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
"owner": "nix-systems",
"repo": "default",
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
"type": "github"
},
"original": {
"owner": "nix-systems",
"repo": "default",
"type": "github"
}
}
},
"root": "root",
"version": 7
}

47
flake.nix Normal file
View File

@ -0,0 +1,47 @@
{
inputs = {
nixpkgs.url = "github:nixos/nixpkgs";
flake-utils.url = "github:numtide/flake-utils";
};
outputs = { self, nixpkgs, flake-utils }:
let
productVersion = "0.4.1";
productName = "blockstream-electrs-${productVersion}";
in
flake-utils.lib.eachDefaultSystem (system:
with nixpkgs.legacyPackages.${system}; {
packages.${productName} = rustPlatform.buildRustPackage {
name = "${productName}";
version = "${productVersion}";
src = lib.cleanSource ./.;
cargoSha256 = "sha256-d84QNj9SIRUwtlsa9sdYKuYf0oCptdGm7pDs3eGTcBg=";
preConfigure = ''
export LIBCLANG_PATH="${llvmPackages.libclang.lib}/lib";
'';
nativeBuildInputs = [ cargo clang cmake ];
};
defaultPackage = self.packages.${system}.${productName};
devShell = mkShell {
inputsFrom = builtins.attrValues self.packages.${system};
shellHook = ''
export LIBCLANG_PATH="${llvmPackages.libclang.lib}/lib"
'';
# LIBCLANG_PATH="${llvmPackages.libclang.lib}/lib";
# I'm never quite sure which one to use, but in this case neither
# result in a proper dev shell
buildInputs = [ cargo ];
nativeBuildInputs = [ cargo clang ];
};
modules.${productName} = import [ ./module.nix ];
defaultModule = self.modules.${system}.${productName};
});
}