Skip to content

Commit 725aff9

Browse files
abueideclaude
andauthored
feat(segkit): add Nix flake and declare as plugin dependency (#68)
* feat(segkit): add Nix flake for segkit and declare as plugin dependency Add a flake.nix to segkit/ so it can be installed via Nix as a devbox package. Both the android and ios plugins now declare segkit as a package dependency using the GitHub flake reference, ensuring it's automatically available on PATH for all plugin consumers. The rewrite-plugin-urls.sh script is extended to rewrite the segkit GitHub flake ref to a local path ref for CI testing against the current branch. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * fix(segkit): use Apache-2.0 license to match repo Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 8536dde commit 725aff9

6 files changed

Lines changed: 105 additions & 1 deletion

File tree

plugins/android/plugin.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
"REPORTS_DIR": "reports"
3030
},
3131
"packages": {
32+
"github:segment-integrations/mobile-devtools?dir=segkit&ref=main": "",
3233
"bash": "latest",
3334
"coreutils": "latest",
3435
"gnused": "latest",

plugins/ios/plugin.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
"LANG": "en_US.UTF-8"
2424
},
2525
"packages": {
26+
"github:segment-integrations/mobile-devtools?dir=segkit&ref=main": "",
2627
"bash": "latest",
2728
"coreutils": "latest",
2829
"gnused": "latest",

scripts/dev/rewrite-plugin-urls.sh

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,19 @@ case "$mode" in
6565
fi
6666
fi
6767

68+
# Rewrite segkit package references in plugin.json files
69+
segkit_github="github:segment-integrations/mobile-devtools?dir=segkit&ref=main"
70+
for plugin_file in plugins/android/plugin.json plugins/ios/plugin.json; do
71+
if [ -f "$plugin_file" ] && grep -q "$segkit_github" "$plugin_file"; then
72+
echo " Rewriting segkit ref in: $plugin_file"
73+
# Replace the github flake ref with a local path ref
74+
jq --arg gh "$segkit_github" '.packages = (.packages | to_entries | map(
75+
if .key == $gh then .key = "path:./segkit" else . end
76+
) | from_entries)' "$plugin_file" > "$plugin_file.tmp" \
77+
&& mv "$plugin_file.tmp" "$plugin_file"
78+
fi
79+
done
80+
6881
echo "✓ Rewrote plugin URLs to local paths"
6982
;;
7083

@@ -117,6 +130,18 @@ case "$mode" in
117130
&& mv "plugins/react-native/plugin.json.tmp" "plugins/react-native/plugin.json"
118131
fi
119132

133+
# Restore segkit package references in plugin.json files
134+
segkit_github="github:segment-integrations/mobile-devtools?dir=segkit&ref=main"
135+
for plugin_file in plugins/android/plugin.json plugins/ios/plugin.json; do
136+
if [ -f "$plugin_file" ] && grep -q "path:./segkit" "$plugin_file"; then
137+
echo " Restoring segkit ref in: $plugin_file"
138+
jq --arg gh "$segkit_github" '.packages = (.packages | to_entries | map(
139+
if .key == "path:./segkit" then .key = $gh else . end
140+
) | from_entries)' "$plugin_file" > "$plugin_file.tmp" \
141+
&& mv "$plugin_file.tmp" "$plugin_file"
142+
fi
143+
done
144+
120145
echo "✓ Restored plugin URLs to GitHub format"
121146
;;
122147

segkit/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name = "segkit"
33
version = "0.1.0"
44
edition = "2024"
55
description = "Segment SDK developer toolkit"
6-
license = "MIT"
6+
license = "Apache-2.0"
77
repository = "https://github.com/segment-integrations/mobile-devtools"
88

99
[[bin]]

segkit/flake.lock

Lines changed: 27 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

segkit/flake.nix

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
{
2+
description = "Segment SDK developer toolkit (segkit CLI)";
3+
4+
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
5+
6+
outputs =
7+
{ self, nixpkgs }:
8+
let
9+
systems = [
10+
"x86_64-linux"
11+
"aarch64-linux"
12+
"x86_64-darwin"
13+
"aarch64-darwin"
14+
];
15+
16+
forAllSystems =
17+
f:
18+
builtins.listToAttrs (
19+
map (system: {
20+
name = system;
21+
value = f system;
22+
}) systems
23+
);
24+
in
25+
{
26+
packages = forAllSystems (
27+
system:
28+
let
29+
pkgs = import nixpkgs { inherit system; };
30+
in
31+
{
32+
default = pkgs.rustPlatform.buildRustPackage {
33+
pname = "segkit";
34+
version = "0.1.0";
35+
src = ./.;
36+
cargoLock.lockFile = ./Cargo.lock;
37+
doCheck = false;
38+
39+
meta = {
40+
description = "Segment SDK developer toolkit";
41+
license = pkgs.lib.licenses.asl20;
42+
mainProgram = "segkit";
43+
};
44+
};
45+
46+
segkit = self.packages.${system}.default;
47+
}
48+
);
49+
};
50+
}

0 commit comments

Comments
 (0)