Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nix improvements #96

Merged
merged 6 commits into from
Aug 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .envrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/bash

if ! has nix_direnv_version || ! nix_direnv_version 2.2.1; then
source_url "https://raw.githubusercontent.com/nix-community/nix-direnv/2.2.1/direnvrc" "sha256-zelF0vLbEl5uaqrfIzbgNzJWGmLzCmYAkInj/LNxvKs="
fi

watch_file rust-toolchain.toml
use flake
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ target
*~
*.pyc
result
.direnv
26 changes: 17 additions & 9 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -20,26 +20,37 @@
flake-utils.lib.eachDefaultSystem
(system:
let
overlays = [ (import rust-overlay) ];
overlays = [
(import rust-overlay)
(import ./rocksdb-overlay.nix)
];
pkgs = import nixpkgs {
inherit system overlays;
};
rustToolchain = pkgs.pkgsBuildHost.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml;

craneLib = (crane.mkLib pkgs).overrideToolchain rustToolchain;

src = craneLib.cleanCargoSource ./.;
src = craneLib.cleanCargoSource ./.;

nativeBuildInputs = with pkgs; [ rustToolchain clang ]; # required only at build time
buildInputs = with pkgs; [ ]; # also required at runtime

commonArgs = {
inherit src buildInputs nativeBuildInputs;
envVars = {
LIBCLANG_PATH = "${pkgs.libclang.lib}/lib";
ELEMENTSD_SKIP_DOWNLOAD = true;
BITCOIND_SKIP_DOWNLOAD = true;
ELECTRUMD_SKIP_DOWNLOAD = true;

# link rocksdb dynamically
ROCKSDB_INCLUDE_DIR = "${pkgs.rocksdb}/include";
ROCKSDB_LIB_DIR = "${pkgs.rocksdb}/lib";
};

commonArgs = {
inherit src buildInputs nativeBuildInputs;
} // envVars;

cargoArtifacts = craneLib.buildDepsOnly commonArgs;
bin = craneLib.buildPackage (commonArgs // {
inherit cargoArtifacts;
Expand All @@ -55,7 +66,6 @@
doCheck = false;
});


in
with pkgs;
{
Expand All @@ -76,11 +86,9 @@
program = "${bin}/bin/electrs";
};


devShells.default = mkShell {
devShells.default = mkShell (envVars // {
inputsFrom = [ bin ];
LIBCLANG_PATH = "${pkgs.libclang.lib}/lib"; # for rocksdb
};
});
}
);
}
13 changes: 13 additions & 0 deletions rocksdb-overlay.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
final: prev: {

rocksdb = prev.rocksdb.overrideAttrs (oldAttrs: rec {
version = "8.1.1";

src = final.fetchFromGitHub {
owner = "facebook";
repo = oldAttrs.pname;
rev = "v${version}";
hash = "sha256-79hRtc5QSWLLyjRGCmuYZSoIc9IcIsnl8UCinz2sVw4=";
};
});
}
8 changes: 8 additions & 0 deletions rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,10 @@
[toolchain]
channel = "1.75.0"
components = [
"cargo",
"clippy",
"rust-src",
"rust-std",
"rustc",
"rustfmt"
]
2 changes: 1 addition & 1 deletion tests/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ impl TestRunner {
}

// Setup node
let node = NodeD::with_conf(noded::downloaded_exe_path().unwrap(), &node_conf).unwrap();
let node = NodeD::with_conf(noded::exe_path().unwrap(), &node_conf).unwrap();

#[cfg(not(feature = "liquid"))]
let (node_client, params) = (&node.client, &node.params);
Expand Down
3 changes: 1 addition & 2 deletions tests/electrum.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@ fn test_electrum() -> Result<()> {
let server_arg = format!("{}:t", electrum_addr.to_string());
electrum_wallet_conf.args = vec!["-v", "--server", &server_arg];
electrum_wallet_conf.view_stdout = true;
let electrum_wallet =
ElectrumD::with_conf(electrumd::downloaded_exe_path()?, &electrum_wallet_conf)?;
let electrum_wallet = ElectrumD::with_conf(electrumd::exe_path()?, &electrum_wallet_conf)?;

let notify_wallet = || {
electrum_server.notify();
Expand Down
Loading