This repository was archived by the owner on Mar 29, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathflake.nix
More file actions
178 lines (164 loc) · 6.63 KB
/
flake.nix
File metadata and controls
178 lines (164 loc) · 6.63 KB
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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
{
description = "Pi Apps - Clients for Pi";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
flake-parts.url = "github:hercules-ci/flake-parts";
git-hooks-nix = {
url = "github:cachix/git-hooks.nix";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs =
inputs@{ flake-parts, ... }:
flake-parts.lib.mkFlake { inherit inputs; } {
systems = [
"aarch64-darwin"
"aarch64-linux"
"x86_64-darwin"
];
imports = [
inputs.git-hooks-nix.flakeModule
];
perSystem =
{
config,
system,
pkgs,
...
}:
let
piPackages = import ./nix/packages.nix {inherit pkgs system;};
xcodeWrapper = pkgs.xcodeenv.composeXcodeWrapper {
versions = [ ];
};
swiftlintWrapper = pkgs.writeShellScriptBin "swiftlint" ''
export DYLD_FRAMEWORK_PATH="/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib"
export PATH="/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin:$PATH"
exec ${pkgs.swiftlint}/bin/swiftlint "$@"
'';
in
{
pre-commit.settings.hooks = {
swiftlint = {
enable = true;
name = "swiftlint";
description = "Lint Swift files";
entry = "${swiftlintWrapper}/bin/swiftlint --strict --no-cache";
files = "\\.swift$";
language = "system";
};
biome-check-relay = {
enable = true;
name = "biome-check-relay";
description = "Lint and format relay server TypeScript files";
entry = "cd server/relay && ${pkgs.pnpm}/bin/pnpm exec biome check --write --no-errors-on-unmatched --staged";
files = "^server/relay/.*\\.(ts|tsx|js|jsx|json|mjs)$";
language = "system";
pass_filenames = false;
};
biome-check-dashboard = {
enable = true;
name = "biome-check-dashboard";
description = "Lint and format dashboard TypeScript files";
entry = "cd clients/dashboard && ${pkgs.pnpm}/bin/pnpm exec biome check --write --no-errors-on-unmatched --staged";
files = "^clients/dashboard/.*\\.(ts|tsx|js|jsx|json|mjs)$";
language = "system";
pass_filenames = false;
};
ts-typecheck-relay = {
enable = true;
name = "ts-typecheck-relay";
description = "Type check relay server";
entry = "cd server/relay && ${pkgs.pnpm}/bin/pnpm exec tsc --noEmit";
files = "^server/relay/.*\\.(ts|tsx)$";
language = "system";
pass_filenames = false;
};
ts-typecheck-dashboard = {
enable = true;
name = "ts-typecheck-dashboard";
description = "Type check dashboard";
entry = "cd clients/dashboard && ${pkgs.pnpm}/bin/pnpm exec react-router typegen && ${pkgs.pnpm}/bin/pnpm exec tsc --noEmit";
files = "^clients/dashboard/.*\\.(ts|tsx)$";
language = "system";
pass_filenames = false;
};
};
packages =
pkgs.lib.optionalAttrs (system == "aarch64-linux") {
relay = piPackages.relay;
gondolin-assets = piPackages.gondolin-assets;
dashboard-oci = piPackages.dashboard-oci;
};
devShells.default = pkgs.mkShellNoCC {
packages = [
swiftlintWrapper
pkgs.xcodegen
pkgs.gnumake
pkgs.just
pkgs.nodejs_22
pkgs.pnpm
pkgs.pre-commit
pkgs.qemu
# Gondolin custom image build requirements
pkgs.zig
pkgs.lz4
pkgs.curl
pkgs.python3
pkgs.e2fsprogs
pkgs.websocat
pkgs.bun
];
shellHook = ''
export PATH="${xcodeWrapper}/bin:$PATH"
export DEVELOPER_DIR="/Applications/Xcode.app/Contents/Developer"
export DYLD_FRAMEWORK_PATH="/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib"
unset CC LD
${config.pre-commit.installationScript}
# Local dev directories (isolated from system XDG)
export PI_RELAY_DATA_DIR="$PWD/.dev/relay/data"
export PI_RELAY_CONFIG_DIR="$PWD/.dev/relay/config"
export PI_RELAY_CACHE_DIR="$PWD/.dev/relay/cache"
export PI_RELAY_STATE_DIR="$PWD/.dev/relay/state"
# Auto-detect Docker socket for Lima/colima
if [ -z "''${DOCKER_HOST:-}" ]; then
if [ -S "$HOME/.lima/default/sock/docker.sock" ]; then
export DOCKER_HOST="unix://$HOME/.lima/default/sock/docker.sock"
elif [ -S "$HOME/.colima/default/docker.sock" ]; then
export DOCKER_HOST="unix://$HOME/.colima/default/docker.sock"
fi
fi
# DOCKER_SOCK: socket path without unix:// prefix (for compose volumes)
export DOCKER_SOCK="''${DOCKER_HOST#unix://}"
echo ""
echo "Pi Apps Development Environment"
echo "================================"
echo ""
echo "Quickstart:"
echo " just - Show all available tasks"
echo " just setup - First-time setup"
echo " just dev - Start relay + dashboard"
echo ""
echo "Native (Swift):"
echo " just xcode - Open in Xcode"
echo " just build - Build macOS (debug)"
echo " just build-ios - Build iOS simulator"
echo ""
echo "Sandboxes:"
echo " just sandboxes build-docker sandbox-alpine-arm64"
echo " just sandboxes build-all-docker"
echo " just sandboxes build-gondolin"
echo ""
echo "Relay Server:"
echo " cd server/relay && pnpm install"
echo " cd server/relay && pnpm dev"
echo ""
echo "Dashboard:"
echo " cd clients/dashboard && pnpm install"
echo " cd clients/dashboard && pnpm dev"
echo ""
'';
};
};
};
}