Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
213 changes: 213 additions & 0 deletions app/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -996,6 +996,219 @@ cloud_mode_input_v2 = ["cloud_mode"]
handoff_cloud_cloud = ["cloud_mode_setup_v2"]
git_credential_refresh = []

# Declarative packaging build profiles consumed by `flake.nix` and the bundle
# scripts. Feature atoms stay in `build_feature_groups`; profiles combine
# composable cross-cutting groups plus optional direct `features`.
[package.metadata.warp.build_feature_groups]
# Artifact shape.
app = [
"release_bundle",
"gui",
]
cli = [
"release_bundle",
"standalone",
]
gui_entrypoint = [
"gui",
]
release_artifact = [
"release_bundle",
]

# Platform/official-distribution features.
linux_official = [
"crash_reporting",
]
windows_official = [
"crash_reporting",
]
macos_official = [
"cocoa_sentry",
]
macos_common = [
"extern_plist",
]

# Additional build behavior.
agent_debug = [
"agent_mode_debug",
]
linux_dev_diagnostics = [
"agent_mode_debug",
"jemalloc_pprof",
]
macos_dev_diagnostics = [
"agent_mode_debug",
"jemalloc_pprof",
"heap_usage_tracking",
]
macos_heap_diagnostics = [
"jemalloc_pprof",
"heap_usage_tracking",
]
preview_channel = [
"preview_channel",
]
remote_tty = [
"remote_tty",
]
remote_server = [
"crash_reporting",
"standalone",
"agent_mode_debug",
"remote_codebase_indexing",
]
warp_control = [
"warp_control_cli",
]
nld_v1 = [
"nld_classifier_v1",
"nld_heuristic_v1",
]
nld_v2 = [
"nld_classifier_v2",
"nld_heuristic_v2",
]
nld_v3 = [
"nld_classifier_v3",
"nld_heuristic_v2",
]

[package.metadata.warp.build_profiles.linux.local.app]
groups = ["app", "linux_official", "agent_debug", "nld_v3"]

[package.metadata.warp.build_profiles.linux.dev.app]
groups = ["app", "linux_official", "linux_dev_diagnostics", "nld_v3"]

[package.metadata.warp.build_profiles.linux.preview.app]
groups = ["app", "linux_official", "preview_channel", "nld_v2"]

[package.metadata.warp.build_profiles.linux.stable.app]
groups = ["app", "linux_official", "nld_v1"]

[package.metadata.warp.build_profiles.linux.oss.app]
groups = ["app", "nld_v1"]

[package.metadata.warp.build_profiles.linux.local.cli]
groups = ["cli", "linux_official", "agent_debug"]

[package.metadata.warp.build_profiles.linux.dev.cli]
groups = ["cli", "linux_official", "linux_dev_diagnostics"]

[package.metadata.warp.build_profiles.linux.preview.cli]
groups = ["cli", "linux_official", "preview_channel"]

[package.metadata.warp.build_profiles.linux.stable.cli]
groups = ["cli", "linux_official"]

[package.metadata.warp.build_profiles.linux.oss.cli]
groups = ["cli"]

[package.metadata.warp.build_profiles.linux.local.warpctrl]
groups = ["cli", "linux_official", "agent_debug", "warp_control"]

[package.metadata.warp.build_profiles.linux.dev.warpctrl]
groups = ["cli", "linux_official", "linux_dev_diagnostics", "warp_control"]

[package.metadata.warp.build_profiles.linux.preview.warpctrl]
groups = ["cli", "linux_official", "preview_channel", "warp_control"]

[package.metadata.warp.build_profiles.linux.stable.warpctrl]
groups = ["cli", "linux_official", "warp_control"]

[package.metadata.warp.build_profiles.linux.oss.warpctrl]
groups = ["cli", "warp_control"]

[package.metadata.warp.build_profiles.macos.local.app]
groups = ["app", "macos_common", "macos_official", "agent_debug", "nld_v3"]

[package.metadata.warp.build_profiles.macos.dev.app]
groups = ["app", "macos_common", "macos_official", "macos_dev_diagnostics", "nld_v3"]

[package.metadata.warp.build_profiles.macos.preview.app]
groups = ["app", "macos_common", "macos_official", "preview_channel", "macos_heap_diagnostics", "nld_v2"]

[package.metadata.warp.build_profiles.macos.stable.app]
groups = ["app", "macos_common", "macos_official", "macos_heap_diagnostics", "nld_v1"]

[package.metadata.warp.build_profiles.macos.oss.app]
groups = ["app", "macos_common", "nld_v1"]

[package.metadata.warp.build_profiles.macos.local.cli]
groups = ["cli", "macos_common", "macos_official", "agent_debug"]

[package.metadata.warp.build_profiles.macos.dev.cli]
groups = ["cli", "macos_common", "macos_official", "macos_dev_diagnostics"]

[package.metadata.warp.build_profiles.macos.preview.cli]
groups = ["cli", "macos_common", "macos_official", "preview_channel", "macos_heap_diagnostics"]

[package.metadata.warp.build_profiles.macos.stable.cli]
groups = ["cli", "macos_common", "macos_official", "macos_heap_diagnostics"]

[package.metadata.warp.build_profiles.macos.oss.cli]
groups = ["cli", "macos_common"]

[package.metadata.warp.build_profiles.macos.local.warpctrl]
groups = ["cli", "macos_common", "macos_official", "agent_debug", "warp_control"]

[package.metadata.warp.build_profiles.macos.dev.warpctrl]
groups = ["cli", "macos_common", "macos_official", "macos_dev_diagnostics", "warp_control"]

[package.metadata.warp.build_profiles.macos.preview.warpctrl]
groups = ["cli", "macos_common", "macos_official", "preview_channel", "macos_heap_diagnostics", "warp_control"]

[package.metadata.warp.build_profiles.macos.stable.warpctrl]
groups = ["cli", "macos_common", "macos_official", "macos_heap_diagnostics", "warp_control"]

[package.metadata.warp.build_profiles.macos.oss.warpctrl]
groups = ["cli", "macos_common", "warp_control"]

[package.metadata.warp.build_profiles.windows.local.app]
groups = ["app", "windows_official", "nld_v3"]

[package.metadata.warp.build_profiles.windows.dev.app]
groups = ["app", "windows_official", "agent_debug", "nld_v3"]

[package.metadata.warp.build_profiles.windows.preview.app]
groups = ["app", "windows_official", "preview_channel", "nld_v2"]

[package.metadata.warp.build_profiles.windows.stable.app]
groups = ["app", "windows_official", "nld_v1"]

[package.metadata.warp.build_profiles.windows.oss.app]
groups = ["app", "nld_v1"]

# Run-entrypoint feature profiles used by `script/run`.
[package.metadata.warp.build_profiles.run.local]
groups = ["gui_entrypoint"]

[package.metadata.warp.build_profiles.run.oss]
groups = ["gui_entrypoint"]

# Additional build profiles used by web/remote-server packaging paths.
[package.metadata.warp.build_profiles.wasm.local]
groups = ["app", "remote_tty"]

[package.metadata.warp.build_profiles.wasm.dev]
groups = ["app"]

[package.metadata.warp.build_profiles.wasm.preview]
groups = ["app", "preview_channel"]

[package.metadata.warp.build_profiles.wasm.stable]
groups = ["app"]

[package.metadata.warp.build_profiles.wasm.oss]
groups = ["app"]

[package.metadata.warp.build_profiles.remote_server.deploy]
groups = ["release_artifact", "remote_server"]

[package.metadata.warp.build_profiles.remote_server.integration]
groups = ["remote_server"]

[package.metadata.bundle.bin.warp-oss]
category = "public.app-category.developer-tools"
copyright = "© 2025, Denver Technologies, Inc"
Expand Down
43 changes: 39 additions & 4 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -123,10 +123,45 @@
zlib
];

buildFeatures = [
"release_bundle"
"gui"
];
warpMetadata = appCargoToml.package.metadata.warp;
buildFeatureGroups = warpMetadata.build_feature_groups;
buildProfiles = warpMetadata.build_profiles;
nixBuildProfile = "linux.oss.app";
profileGroupNames = profile: profile.groups or [ ];
hasProfileFeatures =
profile: builtins.isAttrs profile && (profile ? groups || profile ? features);
hasUnsupportedBaseGroup =
profile: builtins.isAttrs profile && profile ? base;
resolveBuildProfileFeatures =
profilePath:
let
profilePathSegments = lib.splitString "." profilePath;
profileExists = lib.attrsets.hasAttrByPath profilePathSegments buildProfiles;
profile = lib.attrsets.getAttrFromPath profilePathSegments buildProfiles;
groupNames = profileGroupNames profile;
missingGroups = builtins.filter (group: !(builtins.hasAttr group buildFeatureGroups)) groupNames;
groupFeatures = lib.concatMap (group: buildFeatureGroups.${group}) (
builtins.filter (group: builtins.hasAttr group buildFeatureGroups) groupNames
);
directFeatures = profile.features or [ ];
features = lib.lists.uniqueStrings (groupFeatures ++ directFeatures);
missingFeatures = builtins.filter (
feature: !(builtins.hasAttr feature appCargoToml.features)
) features;
in
if !profileExists then
throw "app/Cargo.toml package.metadata.warp.build_profiles.${profilePath} is missing"
else if hasUnsupportedBaseGroup profile then
throw "app/Cargo.toml package.metadata.warp.build_profiles.${profilePath} uses unsupported base build group; use groups instead"
else if !(hasProfileFeatures profile) then
throw "app/Cargo.toml package.metadata.warp.build_profiles.${profilePath} is not a leaf build profile"
else if missingGroups != [ ] then
throw "app/Cargo.toml package.metadata.warp.build_profiles.${profilePath} references undefined build feature groups: ${lib.concatStringsSep ", " missingGroups}"
else if missingFeatures != [ ] then
throw "app/Cargo.toml package.metadata.warp.build_profiles.${profilePath} references undefined Cargo features: ${lib.concatStringsSep ", " missingFeatures}"
else
features;
buildFeatures = resolveBuildProfileFeatures nixBuildProfile;

warp-terminal-experimental = rustPlatform.buildRustPackage {
pname = "warp-terminal-experimental";
Expand Down
57 changes: 57 additions & 0 deletions script/cargo_build_profiles.jq
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
def descend($segments):
reduce $segments[] as $segment (
.;
if type == "object" and has($segment) then .[$segment] else null end
);

def unique_preserve_order:
reduce .[] as $item ([]; if index($item) == null then . + [$item] else . end);

def profile_group_names:
.groups // [];

def has_profile_features:
type == "object" and (has("groups") or has("features"));

def has_unsupported_base_group:
type == "object" and has("base");

def resolve_profile($package; $profile_path):
($package.metadata.warp.build_profiles | descend($profile_path | split("."))) as $profile
| if $profile == null then
error("Missing Cargo build profile: \($profile_path)")
elif ($profile | has_unsupported_base_group) then
error("Cargo build profile uses unsupported base build group; use groups instead: \($profile_path)")
elif ($profile | has_profile_features | not) then
error("Cargo build profile path is not a leaf build profile: \($profile_path)")
else
($package.metadata.warp.build_feature_groups // {}) as $feature_groups
| ($profile | profile_group_names) as $group_names
| reduce $group_names[] as $group_name (
{ features: [], missing_groups: [] };
if ($feature_groups | has($group_name)) then
.features += ($feature_groups[$group_name] // [])
else
.missing_groups += [$group_name]
end
) as $group_result
| if ($group_result.missing_groups | length) > 0 then
error("Cargo build profile \($profile_path) references undefined build feature groups: \($group_result.missing_groups | join(", "))")
else
(($group_result.features + ($profile.features // [])) | unique_preserve_order) as $features
| ($package.features | keys) as $available_features
| [
$features[]
| select((. as $feature | $available_features | index($feature)) | not)
] as $missing_features
| if ($missing_features | length) > 0 then
error("Cargo build profile \($profile_path) references undefined Cargo features: \($missing_features | join(", "))")
else
$features | join(",")
end
end
end;

.packages[]
| select(.name == "warp")
| resolve_profile(.; $profile_path)
16 changes: 16 additions & 0 deletions script/cargo_bundle_features.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/usr/bin/env bash
#
# Resolve declarative Cargo build profiles from app/Cargo.toml.
#
# The profile path is a dot-separated path under
# `package.metadata.warp.build_profiles`, for example:
# linux.oss.app
# macos.dev.cli
# windows.preview.app

resolve_cargo_bundle_features() {
local workspace_root_dir="$1"
local profile_path="$2"

"$workspace_root_dir/script/check_cargo_build_profiles" --profile "$profile_path"
}
Loading