Skip to content

Commit 7ef6519

Browse files
committed
deployment shell: factor into a reusable component
1 parent 0b4d447 commit 7ef6519

File tree

3 files changed

+68
-38
lines changed

3 files changed

+68
-38
lines changed

nix/default.nix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ let
110110
inherit overlays;
111111
modules = self.importWithPkgs ../modules;
112112
roles = self.importWithPkgs ../roles;
113+
deployment-shell = import ./deployment-shell.nix { pkgs = self; };
113114
};
114115
sourcePaths = (super.sourcePaths or {}) // sourcePaths;
115116
};

nix/deployment-shell.nix

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
##
2+
## This allows us to build cardano-ops-like shells with deployment capability.
3+
##
4+
{ pkgs }:
5+
6+
let
7+
inherit (pkgs) globals lib;
8+
nivOverrides = pkgs.writeShellScriptBin "niv-overrides" ''
9+
niv --sources-file ${toString globals.sourcesJsonOverride} $@
10+
'';
11+
in
12+
{
13+
nativeBuildInputs =
14+
with pkgs;
15+
[
16+
awscli2
17+
bashInteractive
18+
cardano-cli
19+
dnsutils
20+
niv
21+
locli.components.exes.locli
22+
nivOverrides
23+
nix
24+
nix-diff
25+
nixops
26+
pandoc
27+
perl
28+
pstree
29+
telnet
30+
cardano-ping
31+
git
32+
direnv
33+
nix-direnv
34+
lorri
35+
relayUpdateTimer
36+
] ++ (lib.optionals stdenv.hostPlatform.isLinux ([
37+
# Those fail to compile under macOS:
38+
node-update
39+
# script NOT for use on mainnet:
40+
] ++ lib.optional (globals.environmentName != "mainnet") kes-rotation));
41+
42+
passthru =
43+
{
44+
gen-graylog-creds = lib.iohk-ops-lib.scripts.gen-graylog-creds { staticPath = ./static; };
45+
};
46+
47+
extraMkShellAttributes =
48+
{
49+
NIX_PATH = "nixpkgs=${pkgs.path}";
50+
NIXOPS_DEPLOYMENT = "${globals.deploymentName}";
51+
}
52+
// globals.environmentVariables;
53+
54+
cardanoOpsMkShellDefault =
55+
with pkgs;
56+
57+
## Note: we're using the non-rec, verbose, pkgs-relative references on purpose:
58+
## this serves as a reference on how to define a derived shell.
59+
mkShell
60+
({
61+
inherit (cardano-ops.deployment-shell) nativeBuildInputs passthru;
62+
}
63+
// cardano-ops.deployment-shell.extraMkShellAttributes);
64+
}

shell.nix

Lines changed: 3 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -10,43 +10,8 @@
1010
inherit config;
1111
}
1212
}:
13-
with pkgs; with lib;
14-
let
15-
nivOverrides = writeShellScriptBin "niv-overrides" ''
16-
niv --sources-file ${toString globals.sourcesJsonOverride} $@
17-
'';
1813

19-
in mkShell (rec {
20-
nativeBuildInputs = [
21-
awscli2
22-
bashInteractive
23-
cardano-cli
24-
dnsutils
25-
niv
26-
locli
27-
nivOverrides
28-
nix
29-
nix-diff
30-
nixops
31-
pandoc
32-
perl
33-
pstree
34-
telnet
35-
cardano-ping
36-
git
37-
direnv
38-
nix-direnv
39-
lorri
40-
relayUpdateTimer
41-
] ++ (lib.optionals pkgs.stdenv.hostPlatform.isLinux ([
42-
# Those fail to compile under macOS:
43-
node-update
44-
# script NOT for use on mainnet:
45-
] ++ lib.optional (globals.environmentName != "mainnet") kes-rotation));
14+
## See the definition of `cardanoOpsMkShellDefault` for a reference implementation
15+
## of a cardano-ops-like shell with deployment capability.
16+
pkgs.cardano-ops.deployment-shell.cardanoOpsMkShellDefault
4617

47-
NIX_PATH = "nixpkgs=${path}";
48-
NIXOPS_DEPLOYMENT = "${globals.deploymentName}";
49-
passthru = {
50-
gen-graylog-creds = iohk-ops-lib.scripts.gen-graylog-creds { staticPath = ./static; };
51-
};
52-
} // globals.environmentVariables)

0 commit comments

Comments
 (0)