Skip to content

Commit

Permalink
Merge pull request #54 from obsidiansystems/release-utils
Browse files Browse the repository at this point in the history
Release utils
  • Loading branch information
alexfmpe authored Mar 16, 2021
2 parents 218805b + ac3d746 commit 98818ef
Show file tree
Hide file tree
Showing 8 changed files with 52 additions and 16 deletions.
21 changes: 6 additions & 15 deletions default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,9 @@
, runTest ? true
}:
let
# TODO: Replace this with hackGet for added safety checking once hackGet is separated from reflex-platform
fetchThunk = p:
if builtins.pathExists (p + /thunk.nix)
then (import (p + /thunk.nix))
else fetchThunkBackup p;

fetchThunkBackup = 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;
nix-thunk = import ./nix/dep/nix-thunk { inherit pkgs; };
sources = nix-thunk.mapSubdirectories nix-thunk.thunkSource ./nix/dep;
gitignoreSource = (import sources."gitignore.nix" {}).gitignoreSource;

usbtool = import ./nix/usbtool.nix { inherit pkgs; };

Expand All @@ -34,7 +25,7 @@ let
{
s = rec {
name = "s";
sdk = patchSDKBinBash "nanos-secure-sdk" (fetchThunk ./nix/dep/nanos-secure-sdk);
sdk = patchSDKBinBash "nanos-secure-sdk" (sources.nanos-secure-sdk);
env = pkgs.callPackage ./nix/bolos-env.nix { clangVersion = 4; };
target = "TARGET_NANOS";
targetId = "0x31100004";
Expand All @@ -47,7 +38,7 @@ let
};
x = rec {
name = "x";
sdk = patchSDKBinBash "ledger-nanox-sdk" (fetchThunk ./nix/dep/ledger-nanox-sdk);
sdk = patchSDKBinBash "ledger-nanox-sdk" (sources.ledger-nanox-sdk);
env = pkgs.callPackage ./nix/bolos-env.nix { clangVersion = 7; };
target = "TARGET_NANOX";
targetId = "0x33000004";
Expand All @@ -60,7 +51,7 @@ let
};
};

src = pkgs.nix-gitignore.gitignoreSource [] ./.;
src = gitignoreSource ./.;
# src = foo: ./.;
# src = let glyphsFilter = (p: _: let p' = baseNameOf p; in p' != "glyphs.c" && p' != "glyphs.h");
# in (pkgs.lib.sources.sourceFilesBySuffices
Expand Down
2 changes: 2 additions & 0 deletions nix/dep/gitignore.nix/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# DO NOT HAND-EDIT THIS FILE
import (import ./thunk.nix)
7 changes: 7 additions & 0 deletions nix/dep/gitignore.nix/github.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"owner": "hercules-ci",
"repo": "gitignore.nix",
"private": false,
"rev": "211907489e9f198594c0eb0ca9256a1949c9d412",
"sha256": "06j7wpvj54khw0z10fjyi31kpafkr6hi1k0di13k1xp8kywvfyx8"
}
9 changes: 9 additions & 0 deletions nix/dep/gitignore.nix/thunk.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# DO NOT HAND-EDIT THIS FILE
let fetch = { private ? false, fetchSubmodules ? false, owner, repo, rev, sha256, ... }:
if !fetchSubmodules && !private then builtins.fetchTarball {
url = "https://github.com/${owner}/${repo}/archive/${rev}.tar.gz"; inherit sha256;
} else (import <nixpkgs> {}).fetchFromGitHub {
inherit owner repo rev sha256 fetchSubmodules private;
};
json = builtins.fromJSON (builtins.readFile ./github.json);
in fetch json
2 changes: 2 additions & 0 deletions nix/dep/nix-thunk/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# DO NOT HAND-EDIT THIS FILE
import (import ./thunk.nix)
7 changes: 7 additions & 0 deletions nix/dep/nix-thunk/github.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"owner": "obsidiansystems",
"repo": "nix-thunk",
"private": false,
"rev": "bab7329163fce579eaa9cfba67a4851ab806b76f",
"sha256": "0wn96xn6prjzcsh4n8p1n40wi8la53ym5h2frlqbfzas7isxwygg"
}
9 changes: 9 additions & 0 deletions nix/dep/nix-thunk/thunk.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# DO NOT HAND-EDIT THIS FILE
let fetch = { private ? false, fetchSubmodules ? false, owner, repo, rev, sha256, ... }:
if !fetchSubmodules && !private then builtins.fetchTarball {
url = "https://github.com/${owner}/${repo}/archive/${rev}.tar.gz"; inherit sha256;
} else (import <nixpkgs> {}).fetchFromGitHub {
inherit owner repo rev sha256 fetchSubmodules private;
};
json = builtins.fromJSON (builtins.readFile ./github.json);
in fetch json
11 changes: 10 additions & 1 deletion release.nix
Original file line number Diff line number Diff line change
@@ -1,10 +1,19 @@
{ runTest ? true, gitDescribe ? "TEST-dirty" }:
let
ledger-app = import ./. { inherit runTest gitDescribe; };
in {
in rec {
analysis-nanos = ledger-app.clangAnalysis.s.wallet;
release-nanos = ledger-app.nano.s.release.all;
release-nanox = ledger-app.nano.x.release.all;
debug-build = (import ./. { debug = true; inherit runTest gitDescribe; }).nano.s.release.all;
usbtool = import ./nix/usbtool.nix {};
hashes = ledger-app.pkgs.writeScript "hashes" ''
PATH=${ledger-app.pkgs.coreutils}:$PATH
MD5=$(md5sum -b ${release-nanos} | awk '{print $1;}')
SHA256=$(sha256sum -b ${release-nanos} | awk '{print $1;}')
SHA512=$(sha512sum -b ${release-nanos} | awk '{print $1;}')
echo "MD5 | $MD5"
echo "SHA256 | $SHA256"
echo "SHA512 | $SHA512"
'';
}

0 comments on commit 98818ef

Please sign in to comment.