-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathflake.nix
129 lines (114 loc) · 3.68 KB
/
flake.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
{
description = "Lexe public monorepo flake";
inputs = {
# NixOS/nixpkgs - nixos-stable branch for the current release
nixpkgs.url = "github:nixos/nixpkgs/release-24.11";
# nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
# library for building rust projects. supports basic incremental cargo
# artifact caching.
crane.url = "github:ipetkov/crane";
# Provides official pre-built rust toolchains.
#
# This flake is lighter weight than oxalica/rust-overlay since
# 1. it doesn't use an overlay (costly during nix eval)
# 2. it has a much smaller git repo (only tracks the latest stable/beta/nightly)
#
# TODO(phlip9): Use this until I can figure out how to get sgx cross build via nixpkgs.
fenix = {
url = "github:nix-community/fenix";
inputs = {
nixpkgs.follows = "nixpkgs";
rust-analyzer-src.follows = "";
};
};
};
outputs = {self, ...} @ inputs: let
lib = inputs.nixpkgs.lib;
lexePubLib = import ./nix/lib/default.nix {lib = lib;};
eachSystem = lexePubLib.eachSystem;
# The "host" nixpkgs set for each system.
#
# ```
# {
# "aarch64-darwin" = <pkgs>;
# "x86_64-linux" = <pkgs>;
# }
# ```
systemPkgs = inputs.nixpkgs.legacyPackages;
# Host nixpkgs set that allows "unfree" packages, like the Android SDK.
# Only used for building the Android app.
systemPkgsUnfree = eachSystem (system: lexePubLib.mkPkgsUnfree inputs.nixpkgs system);
# eachSystemPkgs :: (builder :: Nixpkgs -> AttrSet) -> AttrSet
eachSystemPkgs = builder: eachSystem (system: builder systemPkgs.${system});
# All lexe public monorepo packages and package helpers, for each host
# system.
systemLexePubPkgs = eachSystem (system:
import ./nix/pkgs/default.nix {
lib = inputs.nixpkgs.lib;
pkgs = systemPkgs.${system};
pkgsUnfree = systemPkgsUnfree.${system};
crane = inputs.crane;
fenixPkgs = inputs.fenix.packages.${system};
lexePubLib = lexePubLib;
});
in {
# The exposed lexe public monorepo packages.
# ex: `nix build .#node-release-sgx`
# ex: `nix run .#ftxsgx-elf2sgxs -- ...`
packages = eachSystem (
system: let
lexePubPkgs = systemLexePubPkgs.${system};
in
{
inherit
(lexePubPkgs)
bitcoind
blockstream-electrs
ftxsgx-elf2sgxs
node-debug-nosgx
node-debug-sgx
node-release-nosgx
node-release-sgx
;
}
// lib.optionalAttrs (system == "x86_64-linux") {
inherit
(lexePubPkgs)
run-sgx
run-sgx-test
sgx-detect
sgx-test
;
}
);
# lexe development shells
# ex: `nix develop`
devShells = eachSystem (system: let
lib = inputs.nixpkgs.lib;
pkgs = systemPkgs.${system};
lexePubPkgs = systemLexePubPkgs.${system};
lexePubDevShells = import ./nix/devShells {
lib = lib;
pkgs = pkgs;
lexePubPkgs = lexePubPkgs;
};
in rec {
# The default dev shell for `nix develop`.
default = sgx;
# compile Rust SGX enclaves
sgx = lexePubDevShells.sgx;
#
# app
#
# app flutter_rust_bridge codegen
app-rs-codegen = lexePubDevShells.app-rs-codegen;
# Android app development toolchains
app-android = lexePubDevShells.app-android;
# iOS/macOS app development toolchains
app-ios-macos = lexePubDevShells.app-ios-macos;
});
# The *.nix file formatter.
# Run with `nix fmt`.
formatter = eachSystemPkgs (pkgs: pkgs.alejandra);
};
}