Skip to content

Commit 883cbed

Browse files
author
Marcin Mazurek
authored
Merge pull request #3145 from input-output-hk/fix/ddw-1227-hydra-oom
[DDW-1227] Fix out-of-memory errors on ci.iog.io
2 parents ac43451 + 3effc28 commit 883cbed

File tree

16 files changed

+270
-273
lines changed

16 files changed

+270
-273
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
## vNext
44

5+
### Fixes
6+
7+
- Fixed out-of-memory errors on https://ci.iog.io ([PR 3145](https://github.com/input-output-hk/daedalus/pull/3145))
8+
59
## 5.3.0
610

711
### Features

flake.nix

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,8 @@
2525
import ./nix/packages.nix { inherit inputs buildSystem; }
2626
);
2727

28-
devShells = lib.genAttrs supportedSystems (
29-
system: let
30-
all = lib.genAttrs inputs.self.internal.installerClusters (
31-
cluster: import ./nix/internal/old-shell.nix { inherit inputs system cluster; }
32-
);
33-
in all // { default = all.mainnet; }
28+
devShells = lib.genAttrs supportedSystems (targetSystem:
29+
import ./nix/devshells.nix { inherit inputs targetSystem; }
3430
);
3531

3632
# Compatibility with older Nix:
@@ -39,9 +35,7 @@
3935

4036
hydraJobs = {
4137
installer = lib.genAttrs (supportedSystems ++ ["x86_64-windows"]) (
42-
targetSystem: lib.genAttrs inputs.self.internal.installerClusters (
43-
cluster: inputs.self.internal.${targetSystem}.${cluster}.unsignedInstaller
44-
)
38+
targetSystem: inputs.self.internal.${targetSystem}.unsignedInstaller
4539
);
4640
devshell = lib.genAttrs supportedSystems (system: inputs.self.devShells.${system}.default);
4741
required = inputs.nixpkgs.legacyPackages.x86_64-linux.releaseTools.aggregate {

nix/internal/old-shell.nix renamed to nix/devshells.nix

Lines changed: 40 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,38 @@
1-
{ system
2-
, inputs
3-
, cluster ? "selfnode"
1+
{ inputs
2+
, targetSystem
43
}:
54

65
let
7-
internal = inputs.self.internal.${system}.${cluster};
8-
pkgs = internal.newCommon.pkgs;
9-
10-
daedalusPkgs = import ./old-default.nix {
11-
inherit inputs cluster;
12-
target = system;
13-
devShell = true;
14-
};
15-
16-
regenerateDevCerts = let
17-
moddedConfig = pkgs.writeText "launcher-config.yaml" (builtins.toJSON (
18-
daedalusPkgs.launcherConfigs.launcherConfig
19-
// {
20-
daedalusBin = "true";
21-
}
22-
));
23-
in
24-
pkgs.writeShellScriptBin "regenerate-dev-certs" ''
25-
${daedalusPkgs.daedalus-bridge}/bin/cardano-launcher --config ${moddedConfig}
26-
'';
27-
28-
gcRoot = pkgs.runCommandLocal "gc-root" {
29-
inherit daedalusShell;
30-
cardanoWalletsHaskellNix = daedalusPkgs.walletFlake.outputs.legacyPackages.${system}.roots;
31-
daedalusInstallerInputs = with daedalusPkgs.daedalus-installer; buildInputs ++ nativeBuildInputs;
32-
# cardano-bridge inputs are GC’d, and rebuilt too often on Apple M1 CI:
33-
cardanoBridgeInputs = builtins.map (attr: if daedalusPkgs ? ${attr} && pkgs.lib.isDerivation daedalusPkgs.${attr} then daedalusPkgs.${attr} else null) (builtins.attrNames (builtins.functionArgs (import ./cardano-bridge.nix)));
34-
} "export >$out";
35-
36-
daedalusShell = pkgs.stdenv.mkDerivation (rec {
6+
internal = inputs.self.internal.${targetSystem};
7+
inherit (internal) common;
8+
inherit (common) pkgs;
9+
10+
devShells = pkgs.lib.genAttrs inputs.self.internal.installerClusters (cluster: let
11+
12+
launcherConfigs = common.mkLauncherConfigs {
13+
inherit cluster;
14+
devShell = true;
15+
};
16+
17+
regenerateDevCerts = let
18+
moddedConfig = pkgs.writeText "launcher-config.yaml" (builtins.toJSON (
19+
launcherConfigs.launcherConfig
20+
// {
21+
daedalusBin = "true";
22+
}
23+
));
24+
in
25+
pkgs.writeShellScriptBin "regenerate-dev-certs" ''
26+
${common.daedalus-bridge.${cluster}}/bin/cardano-launcher --config ${moddedConfig}
27+
'';
28+
29+
in pkgs.stdenv.mkDerivation (rec {
3730
buildInputs = [
38-
internal.newCommon.nodejs
39-
internal.newCommon.yarn
40-
daedalusPkgs.daedalus-bridge
41-
daedalusPkgs.daedalus-installer
42-
daedalusPkgs.mock-token-metadata-server
31+
internal.common.nodejs
32+
internal.common.yarn
33+
common.daedalus-bridge.${cluster}
34+
common.daedalus-installer
35+
common.mock-token-metadata-server
4336
regenerateDevCerts
4437
] ++ (with pkgs; [
4538
nix bash binutils coreutils curl gnutar
@@ -61,11 +54,11 @@ let
6154
name = "daedalus";
6255
buildCommand = "touch $out";
6356
LAUNCHER_CONFIG = DAEDALUS_CONFIG + "/launcher-config.yaml";
64-
CARDANO_NODE_VERSION = daedalusPkgs.cardanoNodeVersion;
65-
CARDANO_WALLET_VERSION = daedalusPkgs.cardanoWalletVersion;
57+
CARDANO_NODE_VERSION = common.cardanoNodeVersion;
58+
CARDANO_WALLET_VERSION = common.cardanoWalletVersion;
6659
DAEDALUS_CONFIG = pkgs.runCommand "daedalus-config" {} ''
6760
mkdir -pv $out
68-
cp ${pkgs.writeText "launcher-config.yaml" (builtins.toJSON daedalusPkgs.launcherConfigs.launcherConfig)} $out/launcher-config.yaml
61+
cp ${pkgs.writeText "launcher-config.yaml" (builtins.toJSON launcherConfigs.launcherConfig)} $out/launcher-config.yaml
6962
'';
7063
DAEDALUS_INSTALL_DIRECTORY = "./";
7164
DAEDALUS_DIR = DAEDALUS_INSTALL_DIRECTORY;
@@ -89,7 +82,7 @@ let
8982
source <(cardano-address --bash-completion-script cardano-address)
9083
[[ $(type -P cardano-wallet) ]] && source <(cardano-wallet --bash-completion-script cardano-wallet)
9184
92-
cp -f ${daedalusPkgs.launcherConfigs.installerConfig.iconPath.small} $DAEDALUS_INSTALL_DIRECTORY/icon.png
85+
cp -f ${launcherConfigs.installerConfig.iconPath.small} $DAEDALUS_INSTALL_DIRECTORY/icon.png
9386
9487
# These links will only occur to binaries that exist for the
9588
# specific build config
@@ -99,7 +92,7 @@ let
9992
10093
source <(cardano-node --bash-completion-script `type -p cardano-node`)
10194
102-
export NIX_CFLAGS_COMPILE="$NIX_CFLAGS_COMPILE -I${internal.newCommon.nodejs}/include/node -I${toString ../../.}/node_modules/node-addon-api"
95+
export NIX_CFLAGS_COMPILE="$NIX_CFLAGS_COMPILE -I${internal.common.nodejs}/include/node -I${toString ../../.}/node_modules/node-addon-api"
10396
yarn install
10497
10598
# Rebuild native modules for <https://www.electronjs.org/docs/latest/tutorial/using-native-node-modules>:
@@ -123,7 +116,7 @@ let
123116
124117
echo 'Resolving environment variables to absolute paths…'
125118
# XXX: they originally contain references to HOME or XDG_DATA_HOME in launcher-config.yaml:
126-
export CARDANO_WALLET_TLS_PATH="${daedalusPkgs.launcherConfigs.launcherConfig.tlsPath}"
119+
export CARDANO_WALLET_TLS_PATH="${launcherConfigs.launcherConfig.tlsPath}"
127120
128121
echo 'Re-generating dev certificates for ‘cardano-wallet’…'
129122
mkdir -p "$CARDANO_WALLET_TLS_PATH"
@@ -132,5 +125,6 @@ let
132125
echo
133126
echo 'Now, run ‘yarn dev’.'
134127
'';
135-
});
136-
in daedalusShell // { inherit gcRoot; }
128+
}));
129+
130+
in devShells // { default = devShells.mainnet; }

nix/internal.nix

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,7 @@ let
55
inherit (import ./internal/source-lib.nix { inherit inputs; }) installerClusters;
66
in
77

8-
(__mapAttrs (targetSystem: src: lib.genAttrs installerClusters (cluster: import src {
9-
inherit inputs targetSystem cluster;
10-
})) {
8+
(__mapAttrs (targetSystem: src: import src { inherit inputs targetSystem; }) {
119
x86_64-linux = ./internal/x86_64-linux.nix;
1210
x86_64-windows = ./internal/x86_64-windows.nix;
1311
x86_64-darwin = ./internal/any-darwin.nix;

nix/internal/any-darwin.nix

Lines changed: 35 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,30 @@
1-
{ inputs, targetSystem, cluster }:
1+
{ inputs, targetSystem }:
22

33
assert targetSystem == "x86_64-darwin" || targetSystem == "aarch64-darwin";
44

55
let
66

7-
newCommon = import ./new-common.nix { inherit inputs targetSystem cluster; };
7+
common = import ./common.nix { inherit inputs targetSystem; };
88

9-
inherit (newCommon) sourceLib oldCode pkgs;
9+
inherit (common) sourceLib pkgs;
1010
inherit (pkgs) lib;
1111

12-
inherit (oldCode)
12+
inherit (common)
1313
daedalus-bridge daedalus-installer launcherConfigs mock-token-metadata-server
1414
cardanoNodeVersion cardanoWalletVersion;
1515

16-
inherit (newCommon) originalPackageJson electronVersion electronChromedriverVersion commonSources;
16+
inherit (common) originalPackageJson electronVersion electronChromedriverVersion commonSources;
1717

1818
archSuffix = if pkgs.system == "aarch64-darwin" then "arm64" else "x64";
1919
packageVersion = originalPackageJson.version;
20-
installerName = "daedalus-${packageVersion}-${toString sourceLib.buildCounter}-${cluster}-${sourceLib.buildRevShort}-${pkgs.system}";
20+
installerName = cluster: "daedalus-${packageVersion}-${toString sourceLib.buildCounter}-${cluster}-${sourceLib.buildRevShort}-${pkgs.system}";
21+
22+
genClusters = lib.genAttrs sourceLib.installerClusters;
2123

2224
in rec {
2325

24-
inherit newCommon oldCode;
25-
inherit (newCommon) nodejs nodePackages yarn yarn2nix offlineCache srcLockfiles srcWithoutNix;
26+
inherit common;
27+
inherit (common) nodejs nodePackages yarn yarn2nix offlineCache srcLockfiles srcWithoutNix;
2628

2729
# The following is used in all `configurePhase`s:
2830
darwinSpecificCaches = let
@@ -65,7 +67,7 @@ in rec {
6567
apple_sdk.frameworks.CoreServices
6668
apple_sdk.frameworks.AppKit
6769
]);
68-
configurePhase = newCommon.setupCacheAndGypDirs + darwinSpecificCaches;
70+
configurePhase = common.setupCacheAndGypDirs + darwinSpecificCaches;
6971
buildPhase = ''
7072
# Do not look up in the registry, but in the offline cache:
7173
${yarn2nix.fixup_yarn_lock}/bin/fixup_yarn_lock yarn.lock
@@ -103,7 +105,7 @@ in rec {
103105

104106
darwin-launcher = pkgs.callPackage ./darwin-launcher.nix {};
105107

106-
package = let
108+
package = genClusters (cluster: let
107109
pname = "daedalus";
108110
in pkgs.stdenv.mkDerivation {
109111
name = pname;
@@ -115,7 +117,7 @@ in rec {
115117
apple_sdk.frameworks.AppKit
116118
libobjc
117119
]) ++ [
118-
daedalus-bridge
120+
daedalus-bridge.${cluster}
119121
darwin-launcher
120122
mock-token-metadata-server
121123
];
@@ -125,25 +127,25 @@ in rec {
125127
BUILD_COUNTER = sourceLib.buildCounter;
126128
CARDANO_WALLET_VERSION = cardanoWalletVersion;
127129
CARDANO_NODE_VERSION = cardanoNodeVersion;
128-
configurePhase = newCommon.setupCacheAndGypDirs + darwinSpecificCaches + ''
130+
configurePhase = common.setupCacheAndGypDirs + darwinSpecificCaches + ''
129131
# Grab all cached `node_modules` from above:
130132
cp -r ${node_modules}/. ./
131133
chmod -R +w .
132134
'';
133135
outputs = [ "out" "futureInstaller" ];
134136
buildPhase = ''
135137
patchShebangs .
136-
sed -r 's#.*patchElectronRebuild.*#${newCommon.patchElectronRebuild}/bin/*#' -i scripts/rebuild-native-modules.sh
138+
sed -r 's#.*patchElectronRebuild.*#${common.patchElectronRebuild}/bin/*#' -i scripts/rebuild-native-modules.sh
137139
138140
export DEVX_FIXME_DONT_YARN_INSTALL=1
139141
(
140142
cd installers/
141-
cp -r ${launcherConfigs.configFiles}/. ./.
143+
cp -r ${launcherConfigs.${cluster}.configFiles}/. ./.
142144
143145
# make-installer needs to see `bin/nix-store` to break all references to dylibs inside /nix/store:
144146
export PATH="${lib.makeBinPath [ pkgs.nixUnstable ]}:$PATH"
145147
146-
make-installer --cardano ${daedalus-bridge} \
148+
make-installer --cardano ${daedalus-bridge.${cluster}} \
147149
--build-rev-short ${sourceLib.buildRevShort} \
148150
--build-counter ${toString sourceLib.buildCounter} \
149151
--cluster ${cluster} \
@@ -153,7 +155,7 @@ in rec {
153155
'';
154156
installPhase = ''
155157
mkdir -p $out/Applications/
156-
cp -r release/darwin-${archSuffix}/${lib.escapeShellArg launcherConfigs.installerConfig.spacedName}-darwin-${archSuffix}/${lib.escapeShellArg launcherConfigs.installerConfig.spacedName}.app $out/Applications/
158+
cp -r release/darwin-${archSuffix}/${lib.escapeShellArg launcherConfigs.${cluster}.installerConfig.spacedName}-darwin-${archSuffix}/${lib.escapeShellArg launcherConfigs.${cluster}.installerConfig.spacedName}.app $out/Applications/
157159
158160
# XXX: remove redundant native modules, and point bindings.js to Contents/MacOS/*.node instead:
159161
echo 'Deleting all redundant ‘*.node’ files under to-be-distributed ‘node_modules/’:'
@@ -169,7 +171,7 @@ in rec {
169171
mkdir -p $out/bin/
170172
cat >$out/bin/${pname} << EOF
171173
#!/bin/sh
172-
exec $out/Applications/${lib.escapeShellArg launcherConfigs.installerConfig.spacedName}.app/Contents/MacOS/${lib.escapeShellArg launcherConfigs.installerConfig.spacedName}
174+
exec $out/Applications/${lib.escapeShellArg launcherConfigs.${cluster}.installerConfig.spacedName}.app/Contents/MacOS/${lib.escapeShellArg launcherConfigs.${cluster}.installerConfig.spacedName}
173175
EOF
174176
chmod +x $out/bin/${pname}
175177
@@ -181,13 +183,13 @@ in rec {
181183
${signAllBinaries} $out
182184
'';
183185
dontFixup = true; # TODO: just to shave some seconds, turn back on after everything works
184-
};
186+
});
185187

186-
unsignedInstaller = pkgs.stdenv.mkDerivation {
188+
unsignedInstaller = genClusters (cluster: pkgs.stdenv.mkDerivation {
187189
name = "daedalus-unsigned-darwin-installer";
188190
dontUnpack = true;
189191
buildPhase = ''
190-
${makeSignedInstaller}/bin/* | tee make-installer.log
192+
${makeSignedInstaller.${cluster}}/bin/* | tee make-installer.log
191193
'';
192194
installPhase = ''
193195
mkdir -p $out
@@ -197,9 +199,9 @@ in rec {
197199
mkdir -p $out/nix-support
198200
echo "file binary-dist \"$(echo $out/*.pkg)\"" >$out/nix-support/hydra-build-products
199201
'';
200-
};
202+
});
201203

202-
makeSignedInstaller = pkgs.writeShellScriptBin "make-signed-installer" (let
204+
makeSignedInstaller = genClusters (cluster: pkgs.writeShellScriptBin "make-signed-installer" (let
203205

204206
# FIXME: in the future this has to be done better, now let’s reuse the Buildkite legacy:
205207
credentials = "/var/lib/buildkite-agent/signing.sh";
@@ -230,8 +232,8 @@ in rec {
230232
eval $(${readConfigs})
231233
232234
workDir=$(mktemp -d)
233-
appName=${lib.escapeShellArg launcherConfigs.installerConfig.spacedName}.app
234-
appDir=${package}/Applications/"$appName"
235+
appName=${lib.escapeShellArg launcherConfigs.${cluster}.installerConfig.spacedName}.app
236+
appDir=${package.${cluster}}/Applications/"$appName"
235237
236238
echo "Info: workDir = $workDir"
237239
cd "$workDir"
@@ -242,20 +244,20 @@ in rec {
242244
243245
if ${shallSignPredicate} ; then
244246
echo "Signing code…"
245-
${package.futureInstaller}/codesign.sh "$codeSigningIdentity" "$codeSigningKeyChain" \
246-
"$appName" ${package.futureInstaller}/entitlements.xml
247+
${package.${cluster}.futureInstaller}/codesign.sh "$codeSigningIdentity" "$codeSigningKeyChain" \
248+
"$appName" ${package.${cluster}.futureInstaller}/entitlements.xml
247249
fi
248250
249251
echo "Making installer…"
250252
/usr/bin/pkgbuild \
251-
--identifier ${lib.escapeShellArg ("org." + launcherConfigs.installerConfig.macPackageName + ".pkg")} \
253+
--identifier ${lib.escapeShellArg ("org." + launcherConfigs.${cluster}.installerConfig.macPackageName + ".pkg")} \
252254
--component "$workDir/$appName" \
253255
--install-location /Applications \
254-
${lib.escapeShellArg (installerName + ".phase1.pkg")}
256+
${lib.escapeShellArg ((installerName cluster) + ".phase1.pkg")}
255257
rm -r "$workDir/$appName"
256258
/usr/bin/productbuild --product ${../../installers/data/plist} \
257259
--package *.phase1.pkg \
258-
${lib.escapeShellArg (installerName + ".phase2.pkg")}
260+
${lib.escapeShellArg ((installerName cluster) + ".phase2.pkg")}
259261
rm *.phase1.pkg
260262
261263
if ${shallSignPredicate} ; then
@@ -269,14 +271,14 @@ in rec {
269271
270272
productsign --sign "$signingIdentity" --keychain "$signingKeyChain" \
271273
*.phase2.pkg \
272-
${lib.escapeShellArg (installerName + ".pkg")}
274+
${lib.escapeShellArg ((installerName cluster) + ".pkg")}
273275
rm *.phase2.pkg
274276
else
275-
mv *.phase2.pkg ${lib.escapeShellArg (installerName + ".pkg")}
277+
mv *.phase2.pkg ${lib.escapeShellArg ((installerName cluster) + ".pkg")}
276278
fi
277279
278280
echo "Done, you can submit it for notarization now:"
279-
echo "$workDir"/${lib.escapeShellArg (installerName + ".pkg")}
281+
echo "$workDir"/${lib.escapeShellArg ((installerName cluster) + ".pkg")}
280282
'';
281283

282284
in ''
@@ -287,7 +289,7 @@ in rec {
287289
else
288290
exec ${packAndSign}
289291
fi
290-
'');
292+
''));
291293

292294
darwinSources = {
293295
electron = pkgs.fetchurl {

0 commit comments

Comments
 (0)