mirror of
https://github.com/logos-storage/logos-storage-nim.git
synced 2026-01-27 01:33:17 +00:00
chore: update nix config (#1363)
This commit is contained in:
parent
60861d6af8
commit
e59e98ba92
32
flake.nix
32
flake.nix
@ -26,11 +26,12 @@
|
||||
};
|
||||
build = targets: buildTarget.override { inherit targets; };
|
||||
in rec {
|
||||
nim-codex = build ["all"];
|
||||
default = nim-codex;
|
||||
logos-storage-nim = build ["all"];
|
||||
libstorage = build ["libstorage"];
|
||||
default = logos-storage-nim;
|
||||
});
|
||||
|
||||
nixosModules.nim-codex = { config, lib, pkgs, ... }: import ./nix/service.nix {
|
||||
nixosModules.logos-storage-nim = { config, lib, pkgs, ... }: import ./nix/service.nix {
|
||||
inherit config lib pkgs self;
|
||||
circomCompatPkg = circom-compat.packages.${pkgs.system}.default;
|
||||
};
|
||||
@ -40,7 +41,8 @@
|
||||
in {
|
||||
default = pkgs.mkShell {
|
||||
inputsFrom = [
|
||||
packages.${system}.nim-codex
|
||||
packages.${system}.logos-storage-nim
|
||||
packages.${system}.libstorage
|
||||
circom-compat.packages.${system}.default
|
||||
];
|
||||
# Not using buildInputs to override fakeGit and fakeCargo.
|
||||
@ -51,24 +53,24 @@
|
||||
checks = forAllSystems (system: let
|
||||
pkgs = pkgsFor.${system};
|
||||
in {
|
||||
nim-codex-test = pkgs.nixosTest {
|
||||
name = "nim-codex-test";
|
||||
logos-storage-nim-test = pkgs.nixosTest {
|
||||
name = "logos-storage-nim-test";
|
||||
nodes = {
|
||||
server = { config, pkgs, ... }: {
|
||||
imports = [ self.nixosModules.nim-codex ];
|
||||
services.nim-codex.enable = true;
|
||||
services.nim-codex.settings = {
|
||||
data-dir = "/var/lib/nim-codex-test";
|
||||
imports = [ self.nixosModules.logos-storage-nim ];
|
||||
services.logos-storage-nim.enable = true;
|
||||
services.logos-storage-nim.settings = {
|
||||
data-dir = "/var/lib/logos-storage-nim-test";
|
||||
};
|
||||
systemd.services.nim-codex.serviceConfig.StateDirectory = "nim-codex-test";
|
||||
systemd.services.logos-storage-nim.serviceConfig.StateDirectory = "logos-storage-nim-test";
|
||||
};
|
||||
};
|
||||
testScript = ''
|
||||
print("Starting test: nim-codex-test")
|
||||
print("Starting test: logos-storage-nim-test")
|
||||
machine.start()
|
||||
machine.wait_for_unit("nim-codex.service")
|
||||
machine.succeed("test -d /var/lib/nim-codex-test")
|
||||
machine.wait_until_succeeds("journalctl -u nim-codex.service | grep 'Started Storage node'", 10)
|
||||
machine.wait_for_unit("logos-storage-nim.service")
|
||||
machine.succeed("test -d /var/lib/logos-storage-nim-test")
|
||||
machine.wait_until_succeeds("journalctl -u logos-storage-nim.service | grep 'Started Storage node'", 10)
|
||||
'';
|
||||
};
|
||||
});
|
||||
|
||||
@ -22,6 +22,12 @@ It can be also done without even cloning the repo:
|
||||
nix build 'git+https://github.com/logos-storage/logos-storage-nim?submodules=1#'
|
||||
```
|
||||
|
||||
To build the C bindings you can use:
|
||||
|
||||
```sh
|
||||
nix build ".?submodules=1#libstorage"
|
||||
```
|
||||
|
||||
## Running
|
||||
|
||||
```sh
|
||||
|
||||
@ -6,7 +6,7 @@ let
|
||||
in pkgs.fetchFromGitHub {
|
||||
owner = "nim-lang";
|
||||
repo = "checksums";
|
||||
rev = tools.findKeyValue "^ +ChecksumsStableCommit = \"([a-f0-9]+)\"$" sourceFile;
|
||||
rev = tools.findKeyValue "^ +ChecksumsStableCommit = \"([a-f0-9]+)\".*$" sourceFile;
|
||||
# WARNING: Requires manual updates when Nim compiler version changes.
|
||||
hash = "sha256-Bm5iJoT2kAvcTexiLMFBa9oU5gf7d4rWjo3OiN7obWQ=";
|
||||
hash = "sha256-JZhWqn4SrAgNw/HLzBK0rrj3WzvJ3Tv1nuDMn83KoYY=";
|
||||
}
|
||||
|
||||
@ -83,8 +83,14 @@ in pkgs.gcc13Stdenv.mkDerivation rec {
|
||||
'';
|
||||
|
||||
installPhase = ''
|
||||
mkdir -p $out/bin
|
||||
cp build/storage $out/bin/
|
||||
if [ -f build/storage ]; then
|
||||
mkdir -p $out/bin
|
||||
cp build/storage $out/bin/
|
||||
else
|
||||
mkdir -p $out/lib $out/include
|
||||
cp build/libstorage* $out/lib/
|
||||
cp library/libstorage.h $out/include/
|
||||
fi
|
||||
'';
|
||||
|
||||
meta = with pkgs.lib; {
|
||||
@ -93,4 +99,4 @@ in pkgs.gcc13Stdenv.mkDerivation rec {
|
||||
license = licenses.mit;
|
||||
platforms = stableSystems;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@ -9,5 +9,5 @@ in pkgs.fetchFromGitHub {
|
||||
fetchSubmodules = true;
|
||||
rev = tools.findKeyValue "^ +NimbleStableCommit = \"([a-f0-9]+)\".+" sourceFile;
|
||||
# WARNING: Requires manual updates when Nim compiler version changes.
|
||||
hash = "sha256-Rz48sGUKZEAp+UySla+MlsOfsERekuGKw69Tm11fDz8=";
|
||||
hash = "sha256-wgzFhModFkwB8st8F5vSkua7dITGGC2cjoDvgkRVZMs=";
|
||||
}
|
||||
|
||||
@ -9,7 +9,12 @@ in {
|
||||
let
|
||||
linesFrom = file: splitString "\n" (fileContents file);
|
||||
matching = regex: lines: map (line: match regex line) lines;
|
||||
extractMatch = matches: last (flatten (remove null matches));
|
||||
extractMatch = matches:
|
||||
let xs = flatten (remove null matches);
|
||||
in if xs == [] then
|
||||
throw "findKeyValue: no match for regex '${regex}' in ${toString sourceFile}"
|
||||
else
|
||||
last xs;
|
||||
in
|
||||
extractMatch (matching regex (linesFrom sourceFile));
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user