Skip to content

Commit 138c894

Browse files
cleverca22disassembler
authored andcommitted
[DEVOPS-732] refactor release.nix (input-output-hk#3041)
1 parent 9b9b213 commit 138c894

6 files changed

+51
-26
lines changed

default.nix

+10-6
Original file line numberDiff line numberDiff line change
@@ -130,15 +130,19 @@ let
130130
}) { inherit pkgs; };
131131
inherit (pkgs) purescript;
132132
connectScripts = {
133-
mainnetWallet = connect {};
134-
mainnetExplorer = connect { executable = "explorer"; };
135-
stagingWallet = connect { environment = "mainnet-staging"; };
133+
mainnet = {
134+
wallet = connect {};
135+
explorer = connect { executable = "explorer"; };
136+
};
137+
staging = {
138+
wallet = connect { environment = "mainnet-staging"; };
139+
explorer = connect { executable = "explorer"; environment = "mainnet-staging"; };
140+
};
136141
demoWallet = connect { environment = "demo"; };
137-
stagingExplorer = connect { executable = "explorer"; environment = "mainnet-staging"; };
138142
};
139143
dockerImages = {
140-
mainnetWallet = mkDocker { environment = "mainnet"; };
141-
stagingWallet = mkDocker { environment = "mainnet-staging"; };
144+
mainnet.wallet = mkDocker { environment = "mainnet"; };
145+
staging.wallet = mkDocker { environment = "mainnet-staging"; };
142146
};
143147

144148
daedalus-bridge = let

docs/exchange-onboarding.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -160,9 +160,9 @@ By default the wallet's local state goes in
160160
`./state-wallet-mainnet`.
161161

162162
Build the wallet and generate the shell script to connect to
163-
mainnet (use `connectScripts.stagingWallet` for testnet)
163+
mainnet (use `connectScripts.staging.wallet` for testnet)
164164

165-
nix-build -A connectScripts.mainnetWallet -o "./launch_$(date -I)_$(git rev-parse --short HEAD)"
165+
nix-build -A connectScripts.mainnet.wallet -o "./launch_$(date -I)_$(git rev-parse --short HEAD)"
166166

167167
After the build finishes the generated connection script is
168168
available as a symlink called `./launch_2018-01-30_0d4f79eea`, or
@@ -172,9 +172,9 @@ similar. Run that symlink as a script to start the wallet.
172172

173173
Follow the above instructions for customization and dependencies. To build a docker
174174
container and import the image run
175-
(use `connectScripts.stagingWallet` for testnet):
175+
(use `connectScripts.staging.wallet` for testnet):
176176

177-
docker load < $(nix-build --no-out-link -A dockerImages.mainnetWallet)
177+
docker load < $(nix-build --no-out-link -A dockerImages.mainnet.wallet)
178178

179179
This will create an image `cardano-container-mainnet:latest`
180180
(or `cardano-container-staging:latest` for testnet)

docs/how-to/connect-to-cluster.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22

33
1. Make sure you’ve follow [the instructions to build from source using Nix](build-cardano-sl-and-daedalus-from-source-code.md)
44
2. Make sure you’re on latest `master` branch
5-
3. To build a script that will contain everything needed to connect to mainnet: `$ nix-build -A connectScripts.mainnetWallet -o connect-to-mainnet`
5+
3. To build a script that will contain everything needed to connect to mainnet: `$ nix-build -A connectScripts.mainnet.wallet -o connect-to-mainnet`
66
4. Alternatively you can connect to different environments and different executables by building the scripts:
7-
- Explorer node with mainnet: `$ nix-build -A connectScripts.mainnetExplorer -o connect-explorer-to-mainnet
8-
- Wallet to staging: `$ nix-build -A connectScripts.stagingWallet -o connect-to-staging`
9-
- Explorer to staging: `$ nix-build -A connectScripts.stagingExplorer -o connect-explorer-to-staging`
7+
- Explorer node with mainnet: `$ nix-build -A connectScripts.mainnet.explorer -o connect-explorer-to-mainnet
8+
- Wallet to staging: `$ nix-build -A connectScripts.staging.wallet -o connect-to-staging`
9+
- Explorer to staging: `$ nix-build -A connectScripts.staging.explorer -o connect-explorer-to-staging`
1010
3. A runtime state folder will be automatically created relative to your current
1111
working directory, but you can override it using `$ export CARDANO_STATE_DIR=~/wallet-state`
1212
4. Run the script: `$ ./connect-to-mainnet`

docs/tls-authentication.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ usurp either the server or the clients identities**.
4343

4444
> **NOTE** If you build the application using Nix
4545
>
46-
> e.g. `$ nix-build -A connectScripts.stagingWallet -o connect-to-staging`
46+
> e.g. `$ nix-build -A connectScripts.staging.wallet -o connect-to-staging`
4747
>
4848
> There's nothing to do, certificates will be generated upon launching the cluster
4949
> if they're missing, using the default configuration.

nixos-tests/wallet-api.nix

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import (pkgs.path + "/nixos/tests/make-test.nix") ({ pkgs, ... }: {
2222
wantedBy = [ "multi-user.target" ];
2323
after = [ "network.target" ];
2424
serviceConfig = {
25-
ExecStart = cardano_sl.connectScripts.stagingWallet;
25+
ExecStart = cardano_sl.connectScripts.staging.wallet;
2626
Type = "notify";
2727
NotifyAccess = "all";
2828
TimeoutStartSec = 600;
@@ -33,7 +33,7 @@ import (pkgs.path + "/nixos/tests/make-test.nix") ({ pkgs, ... }: {
3333
wantedBy = [ "multi-user.target" ];
3434
after = [ "network.target" ];
3535
serviceConfig = {
36-
ExecStart = cardano_sl.connectScripts.stagingWallet.override ( { walletListen = "127.0.0.1:8091"; ekgListen = "127.0.0.1:8001"; stateDir = "cardano-state-staging-custom-port"; } );
36+
ExecStart = cardano_sl.connectScripts.staging.wallet.override ( { walletListen = "127.0.0.1:8091"; ekgListen = "127.0.0.1:8001"; stateDir = "cardano-state-staging-custom-port"; } );
3737
Type = "notify";
3838
NotifyAccess = "all";
3939
TimeoutStartSec = 600;

release.nix

+30-9
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,16 @@ with (import (fixedNixpkgs + "/pkgs/top-level/release-lib.nix") {
1818
let
1919
iohkPkgs = import ./. { gitrev = cardano.rev; };
2020
pkgs = import fixedNixpkgs { config = {}; };
21-
stagingWalletdockerImage = pkgs.runCommand "${iohkPkgs.dockerImages.stagingWallet.name}-hydra" {} ''
21+
wrapDockerImage = cluster: let
22+
images = {
23+
mainnet = iohkPkgs.dockerImages.mainnet.wallet;
24+
staging = iohkPkgs.dockerImages.staging.wallet;
25+
};
26+
image = images."${cluster}";
27+
in pkgs.runCommand "${image.name}-hydra" {} ''
2228
mkdir -pv $out/nix-support/
2329
cat <<EOF > $out/nix-support/hydra-build-products
24-
file dockerimage ${iohkPkgs.dockerImages.stagingWallet}
30+
file dockerimage ${image}
2531
EOF
2632
'';
2733
platforms = {
@@ -35,21 +41,36 @@ let
3541
cardano-report-server-static = [ "x86_64-linux" ];
3642
stack2nix = supportedSystems;
3743
purescript = supportedSystems;
38-
connectScripts.mainnetWallet = [ "x86_64-linux" "x86_64-darwin" ];
39-
connectScripts.mainnetExplorer = [ "x86_64-linux" "x86_64-darwin" ];
40-
connectScripts.stagingWallet = [ "x86_64-linux" "x86_64-darwin" ];
41-
connectScripts.stagingExplorer = [ "x86_64-linux" "x86_64-darwin" ];
4244
daedalus-bridge = supportedSystems;
4345
};
46+
platforms' = {
47+
connectScripts.mainnet.wallet = [ "x86_64-linux" "x86_64-darwin" ];
48+
connectScripts.mainnet.explorer = [ "x86_64-linux" "x86_64-darwin" ];
49+
connectScripts.staging.wallet = [ "x86_64-linux" "x86_64-darwin" ];
50+
connectScripts.staging.explorer = [ "x86_64-linux" "x86_64-darwin" ];
51+
};
52+
mapped = mapTestOn platforms;
53+
mapped' = mapTestOn platforms';
54+
makeConnectScripts = cluster: let
55+
in {
56+
inherit (mapped'.connectScripts."${cluster}") wallet explorer;
57+
};
4458
nixosTests = import ./nixos-tests;
4559
shellcheckTests = iohkPkgs.shellcheckTests;
4660
swaggerSchemaValidation = iohkPkgs.swaggerSchemaValidation;
4761
walletIntegrationTests = iohkPkgs.buildWalletIntegrationTests;
48-
in (mapTestOn platforms) // {
49-
inherit stagingWalletdockerImage walletIntegrationTests swaggerSchemaValidation shellcheckTests;
62+
makeRelease = cluster: {
63+
name = cluster;
64+
value = {
65+
dockerImage = wrapDockerImage cluster;
66+
connectScripts = makeConnectScripts cluster;
67+
};
68+
};
69+
in mapped // {
70+
inherit walletIntegrationTests swaggerSchemaValidation shellcheckTests;
5071
nixpkgs = let
5172
wrapped = pkgs.runCommand "nixpkgs" {} ''
5273
ln -sv ${fixedNixpkgs} $out
5374
'';
5475
in if 0 <= builtins.compareVersions builtins.nixVersion "1.12" then wrapped else fixedNixpkgs;
55-
}
76+
} // (builtins.listToAttrs (map makeRelease [ "mainnet" "staging" ]))

0 commit comments

Comments
 (0)