Skip to content
This repository has been archived by the owner on Jun 4, 2024. It is now read-only.

2.0.0 #3

Merged
merged 119 commits into from
Mar 5, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
119 commits
Select commit Hold shift + click to select a range
d7e07a0
just in time buffer copy screen display working with display glitches…
Dec 28, 2018
c4527fa
fix glitch in buffer copying version
Dec 28, 2018
45df418
only have one dynamic buffer for prompts rather than copying all curr…
Dec 28, 2018
f6231b9
use symbolic constants to make clear intention in magic number bagl v…
Dec 31, 2018
8a5c02e
first attempt at callbacks
Jan 3, 2019
f93f2b4
believe this fixes the crashes in previous patch
Jan 3, 2019
4e513b4
use callback system to display some (but not all) prompts
Jan 3, 2019
9d9f62d
first compiling full conversion
Jan 3, 2019
f6c8203
clean up return types
Jan 3, 2019
f1dd50c
code cleanup
Jan 3, 2019
7e6114f
fix random app quitting after prompt
Jan 4, 2019
c2a3040
actually fix bug
Jan 4, 2019
e054bae
clean up elliot comments
Jan 4, 2019
5ec9189
comments and use of macros
Dec 13, 2018
64fd945
Merge branch 'develop' into memory_savings
3noch Jan 11, 2019
6bbd328
Merge pull request #36 from obsidiansystems/memory_savings
3noch Jan 15, 2019
9005915
Update README for firmware 1.5.5 and Ledger Live
3noch Jan 17, 2019
f307116
Merge pull request #42 from obsidiansystems/fix-readme
3noch Jan 17, 2019
9216b97
Merge pull request #40 from LedgerHQ/master
3noch Jan 17, 2019
6acbe12
Merge remote-tracking branch 'origin/master' into develop
3noch Jan 17, 2019
7d4ca75
Update README for build instructions
3noch Jan 18, 2019
9cc1f03
Add nix build support
3noch Jan 18, 2019
50a04d6
Make VERSION_TAG and COMMIT nix-friendly
3noch Jan 18, 2019
0b9bdc5
Add helper script for nix builds
3noch Jan 18, 2019
0bf7839
Report binary size in nix build
3noch Jan 18, 2019
9fc300b
Add ledgerblue shell for nix
3noch Jan 18, 2019
b28d62f
Add install script for nix
3noch Jan 18, 2019
780449a
Remove old ledger-blue-shell.nix
3noch Jan 18, 2019
dcbe91d
Move most globals to globals.c
3noch Jan 15, 2019
70ab792
WIP: Use single struct for globals
3noch Jan 15, 2019
12135ea
Move some globals back
3noch Jan 15, 2019
7609e3b
Fix baking app
3noch Jan 15, 2019
f7ce71e
Pull in some lingering globals
3noch Jan 15, 2019
fc10614
Function-local statics moved to globals
3noch Jan 16, 2019
2e025a5
Fix comment
3noch Jan 16, 2019
7c18c48
Make size of privateKeyData clearer
3noch Jan 16, 2019
117d81b
Use memset instead of os_memset for consistency
3noch Jan 16, 2019
d03887b
Use union for APDU globals
3noch Jan 17, 2019
803ad20
Move blake2b hash_state to globals
3noch Jan 17, 2019
81db7ac
Merge pull request #41 from obsidiansystems/eac-init-globals
3noch Jan 22, 2019
9b4a458
Fix reference to incorrect file for building ledger apps on NixOS
tomsmalley Jan 31, 2019
c0c640b
Merge pull request #45 from tomsmalley/patch-1
3noch Feb 1, 2019
51962c2
Merge branch 'master' into develop
3noch Feb 1, 2019
e9b9442
Add nix/env.sh and show what app is being built in Makefile
3noch Feb 1, 2019
29c012e
Add watch script
3noch Feb 1, 2019
0474685
Improve install scripts
3noch Feb 1, 2019
8f9eb5d
Automatically detect NVRAM data size during install
3noch Feb 1, 2019
bd7f8b2
Clean up test/apdu.sh
3noch Feb 1, 2019
2a650cb
Change copy_string for reasons
3noch Feb 1, 2019
ebe6592
Clean up headers
3noch Feb 1, 2019
c7a3bb5
Centralize APDU instruction table
3noch Feb 1, 2019
1091eb2
Move throw_stack_size to globals.h
3noch Feb 1, 2019
160d6f3
Add some helpful debug macros
3noch Feb 1, 2019
5f3d29d
Refactor to use bip32_path struct
3noch Feb 1, 2019
7da20af
Clean up headers
3noch Feb 1, 2019
ac036ba
Add setup APDU
3noch Feb 1, 2019
544523e
Use G for globals in apdu_pubkey.c
3noch Feb 1, 2019
516c2a2
Use G for globals in apdu_baking.c
3noch Feb 1, 2019
665a3f2
Factor out provide_pubkey
3noch Feb 1, 2019
e1f875b
Use safer abstraction for pubkey generation
3noch Feb 1, 2019
f11b103
Add new APDU for querying both HWMs and chain ID
3noch Feb 1, 2019
ee3639e
Fix HWM updates on baking idle screens
3noch Feb 1, 2019
971970e
Use G for globals in ui.c
3noch Feb 1, 2019
6e90ed4
Show chain ID with alias on baking idle screens
3noch Feb 1, 2019
a1051eb
Move baking idle screen globals to better place
3noch Feb 1, 2019
4a40251
Show chain ID aliases in setup prompts
3noch Feb 1, 2019
9d53371
Add clarifications to some string size constants
3noch Feb 1, 2019
cc7e789
Update baking idle screens any time NVRAM changes
3noch Feb 1, 2019
69d8d3c
Merge pull request #46 from obsidiansystems/eac-test-hwm-rebase
3noch Feb 1, 2019
193abf7
Pin nixpkgs and add docs for Nix scripts
3noch Feb 4, 2019
9f3fd34
Merge pull request #47 from obsidiansystems/eac-improve-nix-docs
3noch Feb 5, 2019
a0eded0
Use pinned nixpkgs in nix/install.sh
3noch Feb 5, 2019
a2595b8
Bump version to 2.0.0
3noch Feb 7, 2019
10ec886
Convert comment to clearer code for parsed_operations
3noch Feb 6, 2019
9d3587c
Use G for globals in apdu_sign.c
3noch Feb 6, 2019
e54c343
Clarify member of parsed_contract
3noch Feb 6, 2019
63b1c3a
Make pubkey_to_pkh_string safer with nulls
3noch Feb 6, 2019
0366493
Unify curve and bip32_path in NVRAM
3noch Feb 6, 2019
7f24452
Unify bip32_path and curve in apdu_sign.c
3noch Feb 6, 2019
d89bd7c
Inline setup globals struct
3noch Feb 6, 2019
b53bc82
Unify curve and bip32_path in apdu_setup
3noch Feb 6, 2019
0e02ee2
Unify curve and bip32_path in apdu_pubkey
3noch Feb 6, 2019
1fa87a3
Move SET_STATIC_UI_VALUE to a place it can be shared
3noch Feb 6, 2019
56caf97
Break authorize-to-bake via register-as-delegate
3noch Feb 6, 2019
5fad981
Merge pull request #48 from obsidiansystems/eac-break-self-delegate
3noch Feb 7, 2019
442224e
Fix broken link
alexfmpe Feb 8, 2019
acd70d6
Merge pull request #49 from obsidiansystems/alexfmpe-patch-1
3noch Feb 8, 2019
a6fe2e3
Throw security error in baking app when trying to sign unauthorized s…
3noch Feb 11, 2019
c7c118c
Merge pull request #50 from obsidiansystems/eac-better-error-baking-app
3noch Feb 11, 2019
94a3b8b
Merge remote-tracking branch 'origin/master' into develop
3noch Feb 14, 2019
ff1de11
Fix typo
alexfmpe Feb 19, 2019
b6977cb
Add deauthorize APDU instruction to baking app
3noch Feb 20, 2019
a1eea3f
Factor out common APDU code and normalize
3noch Feb 20, 2019
e7b6dde
Don't use exceptions to return success
3noch Feb 20, 2019
e794b52
Merge pull request #51 from obsidiansystems/eac-deauthorize
3noch Feb 20, 2019
4850c29
Add APDU to return both curve and path of authorized baking key
3noch Feb 21, 2019
e6f61a6
Merge pull request #52 from obsidiansystems/eac-curve-and-path
3noch Feb 25, 2019
d782c57
Include note on importing fundraiser account
mikereinhart Feb 28, 2019
989acbe
Update daemon instructions in readme
mikereinhart Feb 28, 2019
785827a
Merge pull request #55 from mikereinhart/patch-7
3noch Feb 28, 2019
c222ec7
Merge pull request #54 from mikereinhart/patch-6
3noch Feb 28, 2019
29a2aa2
Updates to voting section and intro
mikereinhart Feb 28, 2019
35c927b
Merge pull request #56 from mikereinhart/patch-8
3noch Feb 28, 2019
e6a2108
Use new installer based on app tars with manifest
3noch Feb 25, 2019
4a6d5b7
Update basic manual installation instructions
3noch Feb 25, 2019
3654344
Merge pull request #53 from obsidiansystems/eac-install-manifest
3noch Feb 28, 2019
273c087
Fix crash due to null operations parsing output
3noch Mar 1, 2019
8cef8f8
Don't let it happen again: Define type-safe true/false
3noch Mar 1, 2019
7c6f6e3
Merge pull request #57 from obsidiansystems/eac-fix-crash
3noch Mar 1, 2019
58d5704
updated sections to reference Ledger Live Manager
mikereinhart Mar 1, 2019
93c01a7
fixed broken link to tezos documentation
mikereinhart Mar 1, 2019
1b8a4cf
Merge pull request #59 from mikereinhart/patch-10
3noch Mar 1, 2019
74be68e
Merge pull request #58 from mikereinhart/patch-9
3noch Mar 1, 2019
74da3e6
Add dirty flag to Git commit; update release instructions
3noch Mar 1, 2019
da5f0fe
Update Readme for new Tezos Baking commands
mikereinhart Mar 4, 2019
85ab57e
Merge pull request #61 from mikereinhart/patch-11
3noch Mar 4, 2019
dbfd854
Improve HWM for endorsements
3noch Mar 4, 2019
7d57ca6
Merge remote-tracking branch 'origin/master' into develop
3noch Mar 4, 2019
73a22a2
Merge pull request #60 from obsidiansystems/develop
3noch Mar 4, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
bin
debug
dep
/dep
obj
src/u2f_crypto_data.h
src/glyphs.h
Expand Down
21 changes: 21 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Contributing

## Hacking with [Nix](https://nixos.org/nix/)

The `nix/` folder contains helper scripts for working with the ledger via Nix.

### Developing
Use `nix/env.sh` to enter a shell where you can run `make` and it will just work. You can also pass a command instead, e.g. `nix/env.sh make clean`.

For development, use `nix/watch.sh make APP=<tezos_baking|tezos_wallet>` to incrementally build on every change. Be sure to `nix/env.sh make clean` if you start watching a different `APP`.

### Building
To do a full Nix build run `nix/build.sh`. You can pass `nix-build` arguments to this to build specific attributes, e.g. `nix/build.sh -A wallet`.

### Installing
`nix/install.sh` will install both the wallet and baking apps. Use `nix/install.sh baking` to install just the baking app or `nix/install.sh wallet` to install just the wallet.


### Releasing

`nix/build -A release.all`
27 changes: 21 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -30,23 +30,38 @@ else ifeq ($(APP),tezos_wallet)
APPNAME = "Tezos Wallet"
endif
APP_LOAD_PARAMS=--appFlags 0 --curve ed25519 --curve secp256k1 --curve prime256r1 --path "44'/1729'" $(COMMON_LOAD_PARAMS)
VERSION_TAG=$(shell git describe --tags | cut -f1 -d-)
APPVERSION_M=1
APPVERSION_N=5
VERSION_TAG ?= $(shell git describe --tags 2>/dev/null | cut -f1 -d-)
APPVERSION_M=2
APPVERSION_N=0
APPVERSION_P=0
APPVERSION=$(APPVERSION_M).$(APPVERSION_N).$(APPVERSION_P)

ifneq (v$(APPVERSION), $(VERSION_TAG))
# Only warn about version tags if specified/inferred
ifeq ($(VERSION_TAG),)
$(warning VERSION_TAG not checked)
else
ifneq (v$(APPVERSION), $(VERSION_TAG))
$(warning "Version-Tag Mismatch: v$(APPVERSION) version and $(VERSION_TAG) tag")
endif
endif

COMMIT := $(shell git describe --abbrev=8 --always)
COMMIT ?= $(shell git describe --tags --abbrev=8 --always --long --dirty 2>/dev/null)
ifeq ($(COMMIT),)
$(error COMMIT not specified and could not be determined with git)
endif

ICONNAME=icon.gif

################
# Default rule #
################
all: default
all: show-app default


.PHONY: show-app
show-app:
@echo ">>>>> Building $(APP) at commit $(COMMIT)"


############
# Platform #
Expand Down
256 changes: 98 additions & 158 deletions README.md

Large diffs are not rendered by default.

82 changes: 82 additions & 0 deletions default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
{ pkgs ? import nix/nixpkgs.nix {}, commit, ... }:
let

fetchThunk = p:
if builtins.pathExists (p + /git.json)
then pkgs.fetchgit { inherit (builtins.fromJSON (builtins.readFile (p + /git.json))) url rev sha256; }
else if builtins.pathExists (p + /github.json)
then pkgs.fetchFromGitHub { inherit (builtins.fromJSON (builtins.readFile (p + /github.json))) owner repo rev sha256; }
else p;

fhs = pkgs.callPackage nix/fhs.nix {};
bolosEnv = pkgs.callPackage nix/bolos-env.nix {};
bolosSdk = fetchThunk nix/dep/nanos-secure-sdk;
src = pkgs.lib.sources.sourceFilesBySuffices (pkgs.lib.sources.cleanSource ./.) [".c" ".h" ".gif" "Makefile"];

app = bakingApp: pkgs.runCommand "ledger-app-tezos-${if bakingApp then "baking" else "wallet"}" {} ''
set -Eeuo pipefail

cp -a '${src}'/* .
chmod -R u+w .

'${fhs}/bin/enter-fhs' <<EOF
set -Eeuxo pipefail
export BOLOS_SDK='${bolosSdk}'
export BOLOS_ENV='${bolosEnv}'
export APP='${if bakingApp then "tezos_baking" else "tezos_wallet"}'
export COMMIT='${commit}'
make clean
make all
EOF

mkdir -p "$out"
cp -R bin "$out"
cp -R debug "$out"

echo
echo ">>>> Application size: <<<<"
'${pkgs.binutils-unwrapped}/bin/size' "$out/bin/app.elf"
'';

mkRelease = short_name: name: appDir: pkgs.runCommand "${short_name}-release-dir" {} ''
mkdir -p "$out"

cp '${appDir + /bin/app.hex}' "$out/app.hex"

cat > "$out/app.manifest" <<EOF
name='${name}'
nvram_size=$(grep _nvram_data_size '${appDir + /debug/app.map}' | tr -s ' ' | cut -f2 -d' ')
target_id=0x31100004
version=$(echo '${commit}' | cut -f1 -d- | cut -f2 -dv)
EOF

cp '${dist/icon.hex}' "$out/icon.hex"
'';

walletApp = app false;
bakingApp = app true;
in {
wallet = walletApp;
baking = bakingApp;

release = rec {
wallet = mkRelease "wallet" "Tezos Wallet" walletApp;
baking = mkRelease "baking" "Tezos Baking" bakingApp;
all = pkgs.runCommand "release.tar.gz" {} ''
cp -r '${wallet}' wallet
cp -r '${baking}' baking
cp '${./release-installer.sh}' install.sh
chmod +x install.sh
tar czf "$out" install.sh wallet baking
'';
};

# Script that places you in the environment to run `make`, etc.
env-shell = pkgs.writeScriptBin "env-shell" ''
#!${pkgs.stdenv.shell}
export BOLOS_SDK='${bolosSdk}'
export BOLOS_ENV='${bolosEnv}'
export COMMIT='${commit}'
exec '${fhs}/bin/enter-fhs'
'';
}
18 changes: 9 additions & 9 deletions install.sh
Original file line number Diff line number Diff line change
@@ -1,37 +1,37 @@
#!/bin/sh
set -eux
#!/usr/bin/env bash
set -Eeuo pipefail

rootdir="$(cd "$(dirname "$0")"/; pwd)"
root="$(git rev-parse --show-toplevel)"

app_name=Tezos
if [ "${1:-}X" != X ]; then
app_name="$1"
fi

app_file=$rootdir/bin/app.hex
app_dir="$root"
if [ "${2:-}X" != X ]; then
app_file="$2"
app_dir="$2"
fi

if [ "${3:-}X" = X ]; then
version="$(git -C "$rootdir" describe --tags | cut -f1 -d- | cut -f2 -dv)"
version="$(git -C "$root" describe --tags | cut -f1 -d- | cut -f2 -dv)"
else
version="$3"
fi

set -x
python -m ledgerblue.loadApp \
--appFlags 0x00 \
--dataSize 0x80 \
--dataSize "$(grep _nvram_data_size "$app_dir/debug/app.map" | tr -s ' ' | cut -f2 -d' ')" \
--tlv \
--curve ed25519 \
--curve secp256k1 \
--curve prime256r1 \
--targetId "${TARGET_ID:-0x31100004}" \
--delete \
--path 44"'"/1729"'" \
--fileName "$app_file" \
--fileName "$app_dir/bin/app.hex" \
--appName "$app_name" \
--appVersion "$version" \
--icon "$(cat "$rootdir/dist/icon.hex")" \
--icon "$(cat "$root/dist/icon.hex")" \
--targetVersion ""
25 changes: 25 additions & 0 deletions nix/bolos-env.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{ pkgs, ... }:
let
requireCurl = { url, sha256 }: pkgs.lib.overrideDerivation
(pkgs.requireFile { inherit url sha256; })
(attrs: {
builder = pkgs.writeScript "get-the-thing" ''
#!${pkgs.stdenv.shell}
'${pkgs.curl}/bin/curl' --cacert '${pkgs.cacert}/etc/ssl/certs/ca-bundle.crt' --url '${url}' -o "$out"
'';
});
clang = requireCurl {
url = http://releases.llvm.org/4.0.0/clang+llvm-4.0.0-x86_64-linux-gnu-ubuntu-16.10.tar.xz;
sha256 = "0j0kc73xvm2dl84f7gd2kh6a8nxlr7alk91846m0im77mvm631rv";
};
gcc = requireCurl {
url = https://launchpadlibrarian.net/251687888/gcc-arm-none-eabi-5_3-2016q1-20160330-linux.tar.bz2;
sha256 = "08x2sv2mhx3l3adw8kgcvmrs10qav99al410wpl18w19yfq50y11";
};
in pkgs.runCommand "bolos-env" {} ''
mkdir -p "$out"
mkdir "$out/clang-arm-fropi"
tar xavf '${clang}' --strip-components=1 -C "$out/clang-arm-fropi"
mkdir "$out/gcc-arm-none-eabi-5_3-2016q1"
tar xavf '${gcc}' --strip-components=1 -C "$out/gcc-arm-none-eabi-5_3-2016q1"
''
8 changes: 8 additions & 0 deletions nix/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/usr/bin/env bash
set -Eeuo pipefail

# Override package set by passing --arg pkgs

commit=$(git describe --tags --abbrev=8 --always --long --dirty 2>/dev/null)
echo >&2 "Git commit: $commit"
exec nix-build --no-out-link --argstr commit "$commit" "$@"
7 changes: 7 additions & 0 deletions nix/dep/nanos-secure-sdk/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# DO NOT HAND-EDIT THIS FILE
import ((import <nixpkgs> {}).fetchFromGitHub (
let json = builtins.fromJSON (builtins.readFile ./github.json);
in { inherit (json) owner repo rev sha256;
private = json.private or false;
}
))
7 changes: 7 additions & 0 deletions nix/dep/nanos-secure-sdk/github.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"owner": "LedgerHQ",
"repo": "nanos-secure-sdk",
"branch": "master",
"rev": "f9e1c7b8904df2eee0ae7e603f552b876c169334",
"sha256": "1wzra32zkqw521a5cmvqsblpkbkfzgx2pbngqpymcgf8db20p50i"
}
15 changes: 15 additions & 0 deletions nix/env.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/usr/bin/env bash

commit=$(git describe --tags --abbrev=8 --always --long --dirty 2>/dev/null)
echo >&2 "Git commit: $commit"
shell_dir="$(nix-build -A env-shell --no-out-link --argstr commit "$commit" "${NIX_BUILD_ARGS:-}")"
shell="$shell_dir/bin/env-shell"

if [ $# -eq 0 ]; then
echo >&2 "Entering via $shell"
exec "$shell"
else
exec "$shell" <<EOF
$@
EOF
fi
21 changes: 21 additions & 0 deletions nix/fhs.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{ pkgs, ... }:
let
libtinfo5 = pkgs.runCommand "libtinfo5" {} ''
mkdir -p "$out/lib"
ln -s '${pkgs.ncurses5}/lib/libncursesw.so.5' "$out/lib/libtinfo.so.5"
'';
in pkgs.buildFHSUserEnv {
name = "enter-fhs";

# TODO: Reduce this set to the minimal set
targetPkgs = pkgs: with pkgs; [
alsaLib atk cairo cups dbus expat file fontconfig freetype gdb git glib
libnotify libxml2 libxslt
netcat nspr nss strace udev watch wget which xorg.libX11
xorg.libXScrnSaver xorg.libXcomposite xorg.libXcursor xorg.libXdamage
xorg.libXext xorg.libXfixes xorg.libXi xorg.libXrandr xorg.libXrender
xorg.libXtst xorg.libxcb xorg.xcbutilkeysyms zlib zsh
gnumake libtinfo5 glibc_multi.dev (python2.withPackages (ps: [ps.pillow]))
];
runScript = "bash"; # "$SHELL";
}
24 changes: 24 additions & 0 deletions nix/install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/usr/bin/env bash
set -Eeuo pipefail

root="$(git rev-parse --show-toplevel)"

install() {
local release_file
release_file=$("$root/nix/build.sh" -A "release.$1")
bash "$root/release-installer.sh" "$release_file"
}

export root
export -f install

nix-shell "$root/nix/ledgerblue.nix" -A shell --run "$(cat <<EOF
set -Eeuo pipefail
if [ $# -eq 0 ]; then
install wallet
install baking
else
install "${1:-}"
fi
EOF
)"
7 changes: 7 additions & 0 deletions nix/ledgerblue.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{ pkgs ? import ../nix/nixpkgs.nix {}, ... }:
rec {
withLedgerblue = (pkgs.python36.withPackages (ps: with ps; [
ecpy hidapi pycrypto python-u2flib-host requests ledgerblue pillow pkgs.hidapi protobuf
]));
shell = withLedgerblue.env;
}
10 changes: 10 additions & 0 deletions nix/nixpkgs.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# To bump:
# 1. Select channel from: http://howoldis.herokuapp.com/
# 2. Copy the URL to a `nixexprs.tar.xz` file. It should include hashes (i.e. not be a redirect).
# 3. Run `nix-prefetch-url --unpack <url>` to get the SHA256 hash of the contents.*
# 4. Update the URL and SHA256 values below.

import (builtins.fetchTarball {
url = "https://releases.nixos.org/nixpkgs/nixpkgs-19.03pre167327.11cf7d6e1ff/nixexprs.tar.xz";
sha256 = "0y0fs0j6pb9p9hzv1zagcavvpv50z2anqnbri6kq5iy1j4yqaric";
})
23 changes: 23 additions & 0 deletions nix/watch.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/usr/bin/env bash

set -uo pipefail

root="$(git rev-parse --show-toplevel)"

fail() { unset ___empty; : "${___empty:?$1}"; }

[ -z "${1:-}" ] && fail "No command given; try running $0 make"

watchdirs=("$root/default.nix" "$root/nix" "$root/Makefile" "$root/src")

inotifywait="$(nix-build '<nixpkgs>' -A inotify-tools --no-out-link)/bin/inotifywait"
while true; do
"$root/nix/env.sh" <<EOF
$@
EOF
if ! "$inotifywait" -qre close_write "${watchdirs[@]}"; then
fail "inotifywait failed"
fi
echo "----------------------"
echo
done
Loading