forked from nexu-io/open-design
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathflake.nix
More file actions
188 lines (177 loc) · 5.62 KB
/
Copy pathflake.nix
File metadata and controls
188 lines (177 loc) · 5.62 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
179
180
181
182
183
184
185
186
187
188
{
description = "Open Design — local-first design product. Daemon (`od` CLI) + Next.js static web frontend.";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";
dream2nix = {
url = "github:nix-community/dream2nix";
inputs.nixpkgs.follows = "nixpkgs";
};
home-manager = {
url = "github:nix-community/home-manager";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs = {
self,
nixpkgs,
flake-utils,
dream2nix,
home-manager,
}: let
filterProjectSource = includePaths:
nixpkgs.lib.cleanSourceWith {
src = self;
filter = path: type: let
root = toString self;
pathStr = toString path;
rel = nixpkgs.lib.removePrefix (root + "/") pathStr;
matches = includePath:
rel == includePath
|| nixpkgs.lib.hasPrefix (includePath + "/") rel
|| (type == "directory" && nixpkgs.lib.hasPrefix (rel + "/") includePath);
in
rel == ""
|| builtins.any matches includePaths;
};
perSystem = flake-utils.lib.eachDefaultSystem (system: let
pkgs = import nixpkgs {inherit system;};
nodejs = pkgs.nodejs_24;
# Keep in sync with .github/workflows/ci.yml change_scopes
# nix_validation_required filter.
daemonWorkspacePaths = [
"packages/contracts"
"packages/registry-protocol"
"packages/agui-adapter"
"packages/plugin-runtime"
"packages/sidecar-proto"
"packages/sidecar"
"packages/platform"
"packages/diagnostics"
"apps/daemon"
];
# Keep in sync with .github/workflows/ci.yml change_scopes
# nix_validation_required filter.
webWorkspacePaths = [
"packages/components"
"packages/contracts"
"packages/host"
"packages/platform"
"packages/sidecar"
"packages/sidecar-proto"
"apps/web"
];
daemonSrc = filterProjectSource ([
"package.json"
"pnpm-lock.yaml"
"pnpm-workspace.yaml"
"tsconfig.json"
"assets"
"plugins"
"skills"
"design-systems"
"design-templates"
"craft"
"prompt-templates"
]
++ daemonWorkspacePaths);
webSrc = filterProjectSource ([
"package.json"
"pnpm-lock.yaml"
"pnpm-workspace.yaml"
"tsconfig.json"
]
++ webWorkspacePaths);
# nixpkgs ships pnpm 10.33.0; the repo's package.json declares
# `engines.pnpm: ">=10.33.2 <11"` and pnpm refuses to install
# against an older binary. Override the upstream tarball to
# the exact version pinned by `packageManager`. Bump the url
# + hash in lockstep with package.json#packageManager.
#
# When bumping versions, run the following to get a new hash:
#
# ```bash
# nix store prefetch-file --hash-type sha256 \
# https://registry.npmjs.org/pnpm/-/pnpm-${NEW_VERSION}.tgz
# ```
pnpm_10 = pkgs.pnpm_10.overrideAttrs (_old: rec {
version = "10.33.2";
src = pkgs.fetchurl {
url = "https://registry.npmjs.org/pnpm/-/pnpm-${version}.tgz";
hash = "sha256-envPE9f2zrOUbAOXg3PZm+n94cr8MAC9/tTE95EWdhA=";
};
});
daemon = pkgs.callPackage ./nix/package-daemon.nix {
inherit dream2nix nixpkgs system nodejs pnpm_10;
src = daemonSrc;
workspacePaths = daemonWorkspacePaths;
};
web = pkgs.callPackage ./nix/package-web.nix {
inherit dream2nix nixpkgs system nodejs pnpm_10;
src = webSrc;
workspacePaths = webWorkspacePaths;
};
in {
packages = {
inherit daemon web;
default = daemon;
};
# Wrap `od` with `--no-open` for `nix run`: the daemon package
# builds the daemon workspace only, not `apps/web/out/`, so the
# browser would otherwise auto-open onto an empty static dir.
#
# Set OD_DATA_DIR to a writable location when unset. The Nix store
# is read-only at runtime, so the daemon cannot write to its default
# `<projectRoot>/.od` location under `nix run`.
apps.default = {
type = "app";
program = "${pkgs.writeShellScript "od-nix-run" ''
export OD_DATA_DIR="''${OD_DATA_DIR:-$HOME/.od}"
exec ${daemon}/bin/od --no-open "$@"
''}";
meta.description = "Open Design local daemon (`od`)";
};
devShells.default = pkgs.mkShell {
packages = [
nodejs
pnpm_10
];
shellHook = ''
echo "🎨 Open Design dev shell loaded!"
echo ""
echo "Language runtimes:"
echo " - 🐢 Node.js: $(node --version 2>/dev/null || echo 'not found')"
echo " - 📦 pnpm: $(pnpm --version 2>/dev/null || echo 'not found')"
echo ""
echo "Quick start:"
echo " - 🚀 pnpm install"
echo " - 🚀 pnpm tools-dev # local lifecycle entry point"
echo ""
'';
};
checks = {
daemon = daemon;
web = web;
};
formatter = pkgs.nixpkgs-fmt;
});
moduleCommon = import ./nix/module-common.nix;
in
perSystem
// {
homeManagerModules = rec {
open-design = import ./nix/home-manager.nix {
inherit moduleCommon;
flake = self;
};
default = open-design;
};
nixosModules = rec {
open-design = import ./nix/nixos.nix {
inherit moduleCommon;
flake = self;
};
default = open-design;
};
};
}