Skip to content

Commit 423a259

Browse files
committed
fix: wire Nix base-path packaging
1 parent 002fa82 commit 423a259

5 files changed

Lines changed: 76 additions & 3 deletions

File tree

flake.nix

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
# nix_validation_required filter.
4747
daemonWorkspacePaths = [
4848
"packages/release"
49+
"packages/path-config"
4950
"packages/contracts"
5051
"packages/registry-protocol"
5152
"packages/agui-adapter"
@@ -61,6 +62,7 @@
6162
# nix_validation_required filter.
6263
webWorkspacePaths = [
6364
"packages/release"
65+
"packages/path-config"
6466
"packages/components"
6567
"packages/contracts"
6668
"packages/host"
@@ -178,6 +180,30 @@
178180
checks = {
179181
daemon = daemon;
180182
web = web;
183+
moduleBasePath =
184+
let
185+
evaluated = nixpkgs.lib.nixosSystem {
186+
inherit system;
187+
modules = [
188+
self.nixosModules.default
189+
({...}: {
190+
system.stateVersion = "25.11";
191+
services.open-design = {
192+
enable = true;
193+
webFrontend = {
194+
enable = true;
195+
basePath = "/open-design/";
196+
};
197+
};
198+
})
199+
];
200+
};
201+
webBasePath = evaluated.config.services.open-design.webFrontend.package.passthru.webBasePath;
202+
in
203+
assert webBasePath == "/open-design";
204+
pkgs.runCommand "open-design-nixos-module-base-path" {} ''
205+
touch $out
206+
'';
181207
};
182208

183209
formatter = pkgs.nixpkgs-fmt;

nix/README.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -123,9 +123,11 @@ before serving the static package and proxying `/api`, `/artifacts`, and
123123
preserve or strip the prefix, but must route the complete browser-visible
124124
prefix consistently.
125125

126-
The Web package is compiled with its path at build time. The default flake
127-
package is root-based; for a non-root deployment override it with a Web package
128-
built with the matching `OD_WEB_BASE_PATH` value, for example by overriding the
126+
The Web package is compiled with its path at build time. The NixOS and Home
127+
Manager modules derive their default `webFrontend.package` with the normalized
128+
`basePath`, so the configuration above is self-contained. If you provide a
129+
custom `webFrontend.package` (or serve `packages.<system>.web` directly), build
130+
it with the matching `OD_WEB_BASE_PATH` value, for example by overriding the
129131
derivation's `env` in a flake overlay. The daemon checks the generated Web
130132
manifest and fails early when the package and service setting disagree.
131133
Packaged desktop remains root-path only.

nix/home-manager.nix

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,23 @@
2424
cfg = config.services.open-design;
2525
webBasePath = lib.removeSuffix "/" cfg.webFrontend.basePath;
2626

27+
flakePackages =
28+
if flake ? packages.${pkgs.stdenv.hostPlatform.system}
29+
then flake.packages.${pkgs.stdenv.hostPlatform.system}
30+
else {};
31+
defaultWebPackage =
32+
flakePackages.web or (throw
33+
"open-design: no web package available for ${pkgs.stdenv.hostPlatform.system}; set services.open-design.webFrontend.package explicitly");
34+
webPackageForBasePath = basePath:
35+
defaultWebPackage.overrideAttrs (old: {
36+
env = (old.env or {}) // {
37+
OD_WEB_BASE_PATH = lib.removeSuffix "/" basePath;
38+
};
39+
passthru = (old.passthru or {}) // {
40+
webBasePath = lib.removeSuffix "/" basePath;
41+
};
42+
});
43+
2744
commonOpts = moduleCommon {
2845
inherit lib pkgs flake;
2946
defaultDataDir = "${config.home.homeDirectory}/.od";
@@ -189,6 +206,11 @@ in {
189206

190207
config = lib.mkIf cfg.enable (lib.mkMerge [
191208
{
209+
# The flake web output is root-based by default. Derive the module's
210+
# default package with the configured browser prefix; an explicit
211+
# package override remains authoritative for custom builds.
212+
services.open-design.webFrontend.package = lib.mkDefault (webPackageForBasePath cfg.webFrontend.basePath);
213+
192214
home.packages = [cfg.package];
193215

194216
# Ensure the data directory exists ahead of first daemon launch.

nix/nixos.nix

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,23 @@
2323
cfg = config.services.open-design;
2424
webBasePath = lib.removeSuffix "/" cfg.webFrontend.basePath;
2525

26+
flakePackages =
27+
if flake ? packages.${pkgs.stdenv.hostPlatform.system}
28+
then flake.packages.${pkgs.stdenv.hostPlatform.system}
29+
else {};
30+
defaultWebPackage =
31+
flakePackages.web or (throw
32+
"open-design: no web package available for ${pkgs.stdenv.hostPlatform.system}; set services.open-design.webFrontend.package explicitly");
33+
webPackageForBasePath = basePath:
34+
defaultWebPackage.overrideAttrs (old: {
35+
env = (old.env or {}) // {
36+
OD_WEB_BASE_PATH = lib.removeSuffix "/" basePath;
37+
};
38+
passthru = (old.passthru or {}) // {
39+
webBasePath = lib.removeSuffix "/" basePath;
40+
};
41+
});
42+
2643
commonOpts = moduleCommon {
2744
inherit lib pkgs flake;
2845
defaultDataDir = "/var/lib/open-design";
@@ -201,6 +218,11 @@ in {
201218

202219
config = lib.mkIf cfg.enable (lib.mkMerge [
203220
{
221+
# The flake web output is root-based by default. Derive the module's
222+
# default package with the configured browser prefix; an explicit
223+
# package override remains authoritative for custom builds.
224+
services.open-design.webFrontend.package = lib.mkDefault (webPackageForBasePath cfg.webFrontend.basePath);
225+
204226
users.users.${cfg.user} = {
205227
isSystemUser = true;
206228
group = cfg.group;

nix/package-web.nix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ in
8484
passthru = {
8585
inherit nodejs;
8686
pnpmDeps = finalAttrs.pnpmDeps;
87+
inherit webBasePath;
8788
};
8889

8990
meta = with lib; {

0 commit comments

Comments
 (0)