forked from IntersectMBO/cardano-node
-
Notifications
You must be signed in to change notification settings - Fork 0
/
flake.nix
101 lines (91 loc) · 3.12 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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
{
description = "Cardano Node";
inputs = {
haskell-nix.url = "github:input-output-hk/haskell.nix";
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
utils.url = "github:numtide/flake-utils";
};
outputs = { self, nixpkgs, utils, haskell-nix, ... }:
(utils.lib.eachSystem [ "x86_64-linux" "x86_64-darwin" ] (system:
let
legacyPackages = import ./nix {
inherit sources system nixpkgs iohkNix;
haskellNix = haskell-nix.legacyPackages.${system};
gitrev = self.rev or "dirty";
};
lib = nixpkgs.lib;
sources = import ./nix/sources.nix { pkgs = legacyPackages; };
iohkNix = import sources.iohk-nix { inherit system; };
environments = iohkNix.cardanoLib.environments;
environmentName = "testnet";
eachEnv = lib.flip lib.pipe [
(lib.forEach (builtins.attrNames environments))
lib.listToAttrs
];
config = env:
{ pkgs, ... }: {
services.cardano-node = rec {
stateDir = "/persist";
socketPath = "/alloc/node.socket";
enable = true;
package = pkgs.cardano-node;
environment = env;
cardanoNodePkgs = pkgs;
hostAddr = "0.0.0.0";
port = 3001;
};
};
evaluated = env:
lib.nixosSystem {
inherit system;
pkgs = legacyPackages;
modules = [ ./nix/nixos/cardano-node-service.nix (config env) ];
};
packages = let
deps = with legacyPackages; [
coreutils
findutils
gnugrep
gnused
postgresql
strace
lsof
dnsutils
bashInteractive
iproute
curl
netcat
bat
tree
];
vanilla = eachEnv (env:
lib.nameValuePair "cardano-node-${env}"
(legacyPackages.writeShellScriptBin "cardano-node-entrypoint" ''
${(evaluated env).config.services.cardano-node.script}
''));
debug = eachEnv (env:
let
entrypoint =
legacyPackages.writeShellScriptBin "cardano-node-entrypoint" ''
${(evaluated env).config.services.cardano-node.script}
'';
closure = legacyPackages.symlinkJoin {
name = "cardano-node-entrypoint";
paths = [ entrypoint ] ++ deps;
};
in lib.nameValuePair "cardano-node-${env}-debug" closure);
in debug // vanilla;
in {
inherit iohkNix environments evaluated legacyPackages packages;
apps = eachEnv (env:
lib.nameValuePair "cardano-node-${env}" (utils.lib.mkApp {
drv = packages."cardano-node-${env}";
exePath = "/bin/cardano-node-entrypoint";
}));
})) // {
overlay = import ./overlay.nix self;
nixosModules = {
cardano-node = { imports = [ ./nix/nixos/cardano-node-service.nix ]; };
};
};
}