Skip to content

Commit e467c4b

Browse files
author
Marcin Mazurek
authored
Merge pull request #3008 from input-output-hk/chore/ddw-1083-flakes
[DDW-1083] Build Daedalus with Nix flakes
2 parents 62d6332 + 139ac3c commit e467c4b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+2041
-2841
lines changed

.buildkite/pipeline.yml

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,42 @@
11
env:
2+
23
ARTIFACT_BUCKET: s3://ci-output-sink
4+
35
steps:
46

7+
# XXX: `</dev/null turns off any interactive questions from Nix (e.g. accept-flake-config)
8+
59
- input: ':recycle: Trigger ‘x86_64-darwin’'
610
key: 'trigger-x86_64-darwin'
711

812
- input: ':recycle: Trigger ‘aarch64-darwin’'
913
key: 'trigger-aarch64-darwin'
1014

1115
- label: 'daedalus-x86_64-darwin'
12-
command: 'scripts/with-nix-unstable.sh scripts/build-installer-unix.sh --build-id $BUILDKITE_BUILD_NUMBER'
16+
command: 'nix </dev/null run --no-accept-flake-config -L .#packages.x86_64-darwin.buildkitePipeline'
1317
depends_on: 'trigger-x86_64-darwin'
1418
agents:
1519
queue: lace
1620
system: x86_64-darwin
1721

1822
- label: 'daedalus-aarch64-darwin'
19-
command: 'scripts/with-nix-unstable.sh scripts/build-installer-unix.sh --build-id $BUILDKITE_BUILD_NUMBER'
23+
command: 'nix </dev/null run --no-accept-flake-config -L .#packages.aarch64-darwin.buildkitePipeline'
2024
depends_on: 'trigger-aarch64-darwin'
25+
env:
26+
# XXX: avoid Böhm GC segfaults in Nix on aarch64-darwin:
27+
GC_DONT_GC: 1
2128
agents:
2229
queue: lace
2330
system: aarch64-darwin
2431

25-
- label: 'daedalus-x86_64-linux-nix'
26-
command: 'scripts/with-nix-unstable.sh scripts/build-installer-nix.sh $BUILDKITE_BUILD_NUMBER'
32+
- label: 'daedalus-x86_64-linux'
33+
command: 'nix </dev/null run --no-accept-flake-config -L .#packages.x86_64-linux.buildkitePipeline'
2734
agents:
2835
queue: lace
2936
system: x86_64-linux
3037

31-
- label: 'daedalus-x86_64-windows-nix'
32-
command: 'scripts/with-nix-unstable.sh scripts/build-cross-windows.sh $BUILDKITE_BUILD_NUMBER'
38+
- label: 'daedalus-x86_64-windows'
39+
command: 'nix </dev/null run --no-accept-flake-config -L .#packages.x86_64-windows.buildkitePipeline'
3340
agents:
3441
queue: lace
3542
system: x86_64-linux
36-
37-
# TODO: Re-enable once script is fixed
38-
# - label: 'release.nix'
39-
# command: 'ci/check-hydra.sh'
40-
# agents:
41-
# system: x86_64-linux

.eslintrc

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,12 @@
9696
"plugins": ["@typescript-eslint", "import", "promise", "react", "jest"],
9797
"globals": {
9898
"API": true,
99-
"API_VERSION": true,
99+
"CARDANO_WALLET_VERSION": true,
100+
"CARDANO_NODE_VERSION": true,
100101
"NETWORK": true,
101-
"BUILD_NUMBER": true,
102+
"BUILD_REV": true,
103+
"BUILD_REV_SHORT": true,
104+
"BUILD_COUNTER": true,
102105
"Process": true // TODO: remove after fix
103106
},
104107
"settings": {

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
### Chores
1010

11+
- Switched Daedalus to be built with Nix flakes ([PR 3008](https://github.com/input-output-hk/daedalus/pull/3008))
1112
- Update `cardano-wallet` to `v2023-04-14` ([PR 3104](https://github.com/input-output-hk/daedalus/pull/3104))
1213
- Prepared an official `aarch64-darwin` build ([PR 3116](https://github.com/input-output-hk/daedalus/pull/3116))
1314
- Added regeneration of dev TLS certificates for cardano-wallet on each nix-shell entry ([PR 3117](https://github.com/input-output-hk/daedalus/pull/3117))

ConfigMutator.hs

Lines changed: 0 additions & 47 deletions
This file was deleted.

README.md

Lines changed: 56 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -18,50 +18,33 @@ Daedalus - Cryptocurrency Wallet
1818

1919
#### Nix
2020

21-
[Nix](https://nixos.org/nix/) is needed to run Daedalus in `nix-shell`.
21+
[Nix](https://nixos.org/nix/) is needed to run Daedalus in `nix develop` shell.
2222

23-
1. Install nix: `curl -L https://nixos.org/nix/install | sh` (use `sh <(curl -L https://nixos.org/nix/install) --darwin-use-unencrypted-nix-store-volume` on macOS 10.15 and higher)
23+
1. Install nix: `sh <(curl -L https://nixos.org/nix/install)`
2424
2. Employ the signed IOHK binary cache:
2525
```bash
2626
$ sudo mkdir -p /etc/nix
2727
$ sudo vi /etc/nix/nix.conf # ..or any other editor, if you prefer
2828
```
29-
and then add the following lines:
29+
and then add the following 4 settings are set to:
3030
```
31-
build-users-group = nixbld
32-
33-
max-jobs = auto
34-
cores = 0
35-
sandbox = false
36-
37-
require-sigs = true
38-
trusted-users = root
39-
allowed-users = *
40-
4131
substituters = https://cache.iog.io https://cache.nixos.org/
42-
trusted-substituters =
32+
4333
trusted-public-keys = hydra.iohk.io:f/Ea+s+dFdN+3Y/G+FDgSq+a5NEWhJGzdjvKNGv0/EQ= cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY=
44-
45-
# Only if using mac
46-
extra-sandbox-paths = /System/Library/Frameworks /System/Library/PrivateFrameworks /usr/lib
4734
4835
experimental-features = nix-command flakes
4936
50-
# If you are running on Linux x86/64
51-
system = x86_64-linux
52-
53-
# If you are running on a Mac with Intel chip
54-
system = x86_64-darwin
55-
56-
# If you are running on a Mac with M1 chip
57-
system = aarch64-darwin
37+
# If you are running on a Mac with Apple Silicon chip, but want to also build for Intel:
38+
extra-platforms = x86_64-darwin aarch64-darwin
5839
```
5940

60-
3. Run `nix-shell` with correct list of arguments or by using existing `package.json` scripts to load a shell with all the correct versions of all the required dependencies for development.
41+
3. Run `nix develop` with a correct argument or by using existing `package.json` scripts to load a shell with all the correct versions of all the required dependencies for development, e.g.:
42+
* `nix develop -L .#mainnet`
43+
* … which is equivalent to `yarn nix:mainnet`
6144

6245
**Notes:**
6346

64-
If you get SSL error when running `nix-shell` (SSL peer certificate or SSH remote key was not OK) try the next steps:
47+
If you get SSL error when running `nix develop` (SSL peer certificate or SSH remote key was not OK) try the next steps:
6548
1. Reinstall nix
6649
```bash
6750
$ nix-env -e *
@@ -74,7 +57,7 @@ If you get SSL error when running `nix-shell` (SSL peer certificate or SSH remot
7457
##### Selfnode
7558

7659
1. Run `yarn nix:selfnode` from `daedalus`.
77-
2. Run `yarn dev` from the subsequent `nix-shell` (use `KEEP_LOCAL_CLUSTER_RUNNING` environment variable to keep the local cluster running after Daedalus exits: `KEEP_LOCAL_CLUSTER_RUNNING=true yarn dev`)
60+
2. Run `yarn dev` from the subsequent `nix develop` shell (use `KEEP_LOCAL_CLUSTER_RUNNING` environment variable to keep the local cluster running after Daedalus exits: `KEEP_LOCAL_CLUSTER_RUNNING=true yarn dev`)
7861
3. Once Daedalus has started and has gotten past the loading screen run the following commands from a new terminal window if you wish to import funded wallets:
7962
- Byron wallets: `yarn byron:wallet:importer`
8063
- Shelley wallets: `yarn shelley:wallet:importer`
@@ -103,23 +86,23 @@ List of all funded wallet recovery phrases can be found here: https://github.com
10386
##### Mainnet
10487

10588
1. Run `yarn nix:mainnet` from `daedalus`.
106-
2. Run `yarn dev` from the subsequent `nix-shell`
89+
2. Run `yarn dev` from the subsequent shell
10790

10891
##### Flight
10992

11093
1. Run `yarn nix:flight` from `daedalus`.
111-
2. Run `yarn dev` from the subsequent `nix-shell`
94+
2. Run `yarn dev` from the subsequent shell
11295

11396
##### Testnet
11497

11598
1. Run `yarn nix:testnet` from `daedalus`.
116-
2. Run `yarn dev` from the subsequent `nix-shell`
99+
2. Run `yarn dev` from the subsequent shell
117100

118101
##### Native token metadata server
119102

120103
Daedalus, by default, uses the following metadata server for all networks except for the mainnet: `https://metadata.cardano-testnet.iohkdev.io/`.
121104

122-
It's also possible to use a mock server locally by running the following command in `nix-shell` prior to starting Daedalus:
105+
It's also possible to use a mock server locally by running the following command in `nix develop` prior to starting Daedalus:
123106

124107
```
125108
$ mock-token-metadata-server --port 65432 ./utils/cardano/native-tokens/registry.json
@@ -167,18 +150,13 @@ Most of the commands need `nix` and will run only on Linux or macOS.
167150

168151
#### Updating upstream dependencies (cardano-wallet, cardano-node)
169152

170-
`Niv` is used to manage the version of upstream dependencies. The versions of these dependencies can be seen in `nix/sources.json`.
171-
172-
Dependencies are updated with the follow nix commands:
173-
- Update cardano-wallet to the latest master: `nix-shell -A devops --arg nivOnly true --run "niv update cardano-wallet"`
174-
- Update cardano-wallet to a specific revision: `nix-shell -A devops --arg nivOnly true --run "niv update cardano-wallet -a rev=91db88f9195de49d4fb4299c68fc3f6de09856ab"`
175-
- Update cardano-node to a specific tag: `nix-shell -A devops --arg nivOnly true --run "niv update cardano-node -b tags/1.20.0"`
153+
Nix flake is used to manage the version of upstream dependencies. The versions of these dependencies can be seen in `flake.nix`.
176154

177-
#### Notes
155+
Dependencies are updated in the `inputs` section of `flake.nix` followed with e.g.:
178156

179-
`nix-shell` also provides a script for updating `yarn.lock` file:
180-
181-
nix-shell -A fixYarnLock
157+
```
158+
nix flake lock --update-input cardano-wallet-unpatched
159+
```
182160

183161
### Cardano Wallet Api documentation
184162

@@ -246,62 +224,62 @@ So you have to exit any development instances before running tests!
246224

247225
## Packaging
248226

249-
```bash
250-
$ yarn run package
251-
```
227+
It is possible to build, and run just the Daedalus package, that would be bundled inside an installer, avoiding building of the installer.
252228

253-
To package apps for all platforms:
229+
### Linux
254230

255-
```bash
256-
$ yarn run package:all
257-
```
231+
Build:
258232

259-
To package apps with options:
233+
nix build -L .#package.mainnet
260234

261-
```bash
262-
$ yarn run package -- --[option]
263-
```
235+
Run:
236+
237+
nix run -L .#package.mainnet
238+
239+
### macOS (Intel, and Apple Silicon)
264240

265-
### Options
241+
Build:
266242

267-
- --name, -n: Application name (default: Electron)
268-
- --version, -v: Electron version (default: latest version)
269-
- --asar, -a: [asar](https://github.com/atom/asar) support (default: false)
270-
- --icon, -i: Application icon
271-
- --all: pack for all platforms
243+
nix build -L .#package.mainnet
272244

273-
Use `electron-packager` to pack your app with `--all` options for macOS, Linux and Windows platform. After build, you will find them in `release` folder. Otherwise, you will only find one for your OS.
245+
Run:
274246

275-
## Automated builds
247+
nix run -L .#package.mainnet
276248

277-
### CI/dev build scripts
249+
If you want to run an Intel build from an Apple Silicon machine:
278250

279-
Platform-specific build scripts facilitate building Daedalus the way it is built by the IOHK CI:
251+
nix run -L .#packages.x86_64-darwin.package.mainnet
280252

281-
#### Linux/macOS
253+
## Installers
282254

283-
This script requires [Nix](https://nixos.org/nix/), (optionally) configured with the [IOHK binary cache][cache].
255+
Platform-specific build commands facilitate building Daedalus installers the way it is built by the IOHK CI:
284256

285-
scripts/build-installer-unix.sh [OPTIONS..]
257+
These commands require [Nix](https://nixos.org/nix/), optionally configured with the IOHK binary cache (recommended, see above).
258+
259+
### Linux/macOS
286260

287-
The result can be found at `installers/csl-daedalus/daedalus-*.pkg`.
261+
Run this from a Linux machine:
262+
263+
nix build -L .#installer.mainnet
264+
265+
The result can be found at `result/daedalus-*.bin`.
266+
267+
### Windows
288268

289-
[cache]: https://github.com/input-output-hk/cardano-sl/blob/3dbe220ae108fa707b55c47e689ed794edf5f4d4/docs/how-to/build-cardano-sl-and-daedalus-from-source-code.md#nix-build-mode-recommended
269+
Run this from a Linux machine (cross-building):
290270

291-
#### Windows
271+
nix build -L .#packages.x86_64-windows.installer.mainnet
292272

293-
This batch file requires [Node.js](https://nodejs.org/en/download/) and
294-
[7zip](https://www.7-zip.org/download.html).
273+
The result will can be found at `result/daedalus-*.exe`.
295274

296-
scripts/build-installer-win64.bat
275+
### macOS (Intel, and Apple Silicon)
297276

298-
The result will can be found at `.\daedalus-*.exe`.
277+
Run this from a macOS machine:
299278

300-
#### Pure Nix installer build
279+
nix build -L .#installer.mainnet
301280

302-
This will use nix to build a Linux installer. Using the [IOHK binary
303-
cache][cache] will speed things up.
281+
If you want to build an Intel version from an Apple Silicon machine:
304282

305-
nix build -f ./release.nix mainnet.installer
283+
nix build -L .#packages.x86_64-darwin.installer.mainnet
306284

307-
The result can be found at `./result/daedalus-*.bin`.
285+
The result can be found at `result/daedalus-*.pkg`.

ci/check-hydra.sh

Lines changed: 0 additions & 30 deletions
This file was deleted.

0 commit comments

Comments
 (0)