-
Notifications
You must be signed in to change notification settings - Fork 26
/
Copy pathflake.nix
76 lines (71 loc) · 2.59 KB
/
flake.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
{
description = "Nim Codex build flake";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-24.11";
circom-compat = {
url = "github:codex-storage/circom-compat-ffi";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs = { self, nixpkgs, circom-compat}:
let
stableSystems = [
"x86_64-linux" "aarch64-linux"
"x86_64-darwin" "aarch64-darwin"
];
forAllSystems = f: nixpkgs.lib.genAttrs stableSystems (system: f system);
pkgsFor = forAllSystems (system: import nixpkgs { inherit system; });
in rec {
packages = forAllSystems (system: let
circomCompatPkg = circom-compat.packages.${system}.default;
buildTarget = pkgsFor.${system}.callPackage ./nix/default.nix rec {
inherit stableSystems circomCompatPkg;
src = pkgsFor.${system}.lib.traceValFn (v: "self.submodules: ${toString v.submodules}") self;
};
build = targets: buildTarget.override { inherit targets; };
in rec {
nim-codex = build ["all"];
default = nim-codex;
});
nixosModules.nim-codex = { config, lib, pkgs, ... }: import ./nix/service.nix {
inherit config lib pkgs self;
circomCompatPkg = circom-compat.packages.${pkgs.system}.default;
};
devShells = forAllSystems (system: let
pkgs = pkgsFor.${system};
in {
default = pkgs.mkShell {
inputsFrom = [
packages.${system}.nim-codex
circom-compat.packages.${system}.default
];
# Not using buildInputs to override fakeGit and fakeCargo.
nativeBuildInputs = with pkgs; [ git cargo nodejs_18 ];
};
});
checks = forAllSystems (system: let
pkgs = pkgsFor.${system};
in {
nim-codex-test = pkgs.nixosTest {
name = "nim-codex-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";
};
systemd.services.nim-codex.serviceConfig.StateDirectory = "nim-codex-test";
};
};
testScript = ''
print("Starting test: nim-codex-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 codex node'", 10)
'';
};
});
};
}