diff --git a/.github/workflows/nix-builds.yaml b/.github/workflows/nix-builds.yaml new file mode 100644 index 000000000000..ba63f5e7f3d7 --- /dev/null +++ b/.github/workflows/nix-builds.yaml @@ -0,0 +1,76 @@ +# Generated by simit. Manual edits will be reported as ci=drift. +name: Nix installable builds + +on: + push: + branches: ["**"] + pull_request: + workflow_dispatch: + +permissions: + contents: read + +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.head.repo.full_name || github.repository }}-${{ github.event.pull_request.head.ref || github.ref_name }} + cancel-in-progress: true + +jobs: + build: + runs-on: ubuntu-24.04 + timeout-minutes: 90 + strategy: + fail-fast: false + max-parallel: 2 + matrix: + installable: + - ".#t3code" + - ".#checks.x86_64-linux.desktop-launcher" + env: + NIX_CONFIG: "experimental-features = nix-command flakes" + steps: + - name: Checkout + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + + with: + repository: ${{ github.event.pull_request.head.repo.full_name || github.repository }} + ref: ${{ github.event.pull_request.head.sha || github.sha }} + persist-credentials: false + - name: Prepare Nix build evidence + env: + INSTALLABLE: ${{ matrix.installable }} + run: | + SIMIT_NIX_BUILD_RESULTS="$RUNNER_TEMP/simit-nix-build-${{ strategy.job-index }}" + printf '%s\n' "SIMIT_NIX_BUILD_RESULTS=$SIMIT_NIX_BUILD_RESULTS" >> "$GITHUB_ENV" + mkdir -p "$SIMIT_NIX_BUILD_RESULTS" + git rev-parse HEAD > "$SIMIT_NIX_BUILD_RESULTS/revision" + printf '%s\n' "$INSTALLABLE" > "$SIMIT_NIX_BUILD_RESULTS/installable" + - name: Install Nix + uses: cachix/install-nix-action@13d8dd58da0234aa297dedd986986ccb8e7f3e24 # v31.11.1 + + - name: Configure GitHub input transport + run: | + git config --global --add url.https://github.com/.insteadOf ssh://git@github.com/ + git config --global --add url.https://github.com/.insteadOf git@github.com: + + - name: Build ${{ matrix.installable }} + env: + INSTALLABLE: ${{ matrix.installable }} + run: | + set -euo pipefail + exec 3> >(tee "$SIMIT_NIX_BUILD_RESULTS/build.log" >&2) + log_pid=$! + status=0 + nix build --no-link --no-update-lock-file --max-jobs 2 --cores 2 --print-build-logs --json "$INSTALLABLE" 2>&3 | tee "$SIMIT_NIX_BUILD_RESULTS/result.json" || status=$? + exec 3>&- + wait "$log_pid" + exit "$status" + - name: Upload Nix build evidence + if: always() + uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2 + + with: + name: nix-build-${{ strategy.job-index }} + retention-days: 7 + if-no-files-found: warn + path: | + ${{ runner.temp }}/simit-nix-build-${{ strategy.job-index }} diff --git a/.repos/alchemy-effect/submodules/distilled b/.repos/alchemy-effect/submodules/distilled deleted file mode 160000 index e02e9d405b88..000000000000 --- a/.repos/alchemy-effect/submodules/distilled +++ /dev/null @@ -1 +0,0 @@ -Subproject commit e02e9d405b8848909f4f746b61b12a663f631c7c diff --git a/.repos/alchemy-effect/submodules/floci b/.repos/alchemy-effect/submodules/floci deleted file mode 160000 index 493909133db0..000000000000 --- a/.repos/alchemy-effect/submodules/floci +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 493909133db04153348eabc503f4e30cf0033d96 diff --git a/flake.nix b/flake.nix index 916575748f7c..853aa4a06de7 100644 --- a/flake.nix +++ b/flake.nix @@ -4,47 +4,83 @@ # Same nixpkgs revision canix pins, so prebuilt closures share dependencies. inputs.nixpkgs.url = "github:NixOS/nixpkgs/02c087f3fe673c9e317f206a627cb6b910336dbe"; - outputs = - { self, nixpkgs }: - let - systems = [ - "x86_64-linux" - "aarch64-linux" - ]; - forAll = f: nixpkgs.lib.genAttrs systems (system: f nixpkgs.legacyPackages.${system}); + outputs = { + self, + nixpkgs, + }: let + systems = [ + "x86_64-linux" + "aarch64-linux" + ]; + forAll = f: nixpkgs.lib.genAttrs systems (system: f nixpkgs.legacyPackages.${system}); - # Override nixpkgs' t3code (package.nix wrapper + unwrapped.nix) with this tree. - # Provider toggles (enableClaude, enableCodex, ...) stay available via - # `.override` on the result. - mkT3code = - pkgs: - let - pnpm = pkgs.pnpm_12; - unwrapped = pkgs.t3code.unwrapped.overrideAttrs ( - final: prev: { - version = (builtins.fromJSON (builtins.readFile ./apps/server/package.json)).version; - # cleanSource gives the source a `name`; resource-monitor.nix reads src.name. - src = nixpkgs.lib.cleanSource self; - nativeBuildInputs = (builtins.filter (p: p != pkgs.pnpm_11) prev.nativeBuildInputs) ++ [ pnpm ]; - pnpmDeps = pkgs.fetchPnpmDeps { - inherit pnpm; - inherit (final) pname version src pnpmWorkspaces; - fetcherVersion = 4; - hash = "sha256-uTgZxFRAW8EktSHo6pOZKWo2T3argSAFdW2nAsXkgqM="; - }; - } - ); - in - # ponytail: resource monitor off; its cargoHash tracks nixpkgs' source, enable once it is overridden too. - pkgs.t3code.override { - t3code-unwrapped = unwrapped; - enableResourceMonitor = false; - }; + # Override nixpkgs' t3code (package.nix wrapper + unwrapped.nix) with this tree. + # Provider toggles (enableClaude, enableCodex, ...) stay available via + # `.override` on the result. + mkT3code = pkgs: let + pnpm = pkgs.pnpm_12; + unwrapped = pkgs.t3code.unwrapped.overrideAttrs ( + final: prev: { + version = (builtins.fromJSON (builtins.readFile ./apps/server/package.json)).version; + # cleanSource gives the source a `name`; resource-monitor.nix reads src.name. + src = nixpkgs.lib.cleanSource self; + nativeBuildInputs = (builtins.filter (p: p != pkgs.pnpm_11) prev.nativeBuildInputs) ++ [pnpm]; + pnpmDeps = pkgs.fetchPnpmDeps { + inherit pnpm; + inherit (final) pname version src pnpmWorkspaces; + fetcherVersion = 4; + hash = "sha256-uTgZxFRAW8EktSHo6pOZKWo2T3argSAFdW2nAsXkgqM="; + }; + } + ); in - { - packages = forAll (pkgs: rec { - t3code = mkT3code pkgs; - default = t3code; + # ponytail: resource monitor off; its cargoHash tracks nixpkgs' source, enable once it is overridden too. + (pkgs.t3code.override { + t3code-unwrapped = unwrapped; + enableResourceMonitor = false; + }).overrideAttrs (prev: { + buildCommand = + prev.buildCommand + + '' + wrapProgram "$out/bin/t3code-desktop" \ + --set T3CODE_DESKTOP_LAUNCHER_PATH "$out/bin/t3code-desktop" + ''; }); - }; + in { + packages = forAll (pkgs: rec { + t3code = mkT3code pkgs; + default = t3code; + }); + checks = forAll (pkgs: let + probe = + pkgs.runCommand "t3code-launcher-probe" { + version = "test"; + passthru = {}; + inherit (pkgs.t3code.unwrapped) meta; + } '' + mkdir -p "$out/bin" + cat > "$out/bin/t3code-desktop" <<'EOF' + #!${pkgs.runtimeShell} + printf '%s\n' "''${T3CODE_DESKTOP_LAUNCHER_PATH-}" "$@" + EOF + chmod +x "$out/bin/t3code-desktop" + ''; + withProviders = self.packages.${pkgs.stdenv.hostPlatform.system}.t3code.override { + t3code-unwrapped = probe; + }; + withoutProviders = withProviders.override { + enableCodex = false; + enableGitHub = false; + enableGit = false; + }; + in { + desktop-launcher = pkgs.runCommand "t3code-desktop-launcher-test" {} '' + url='t3code://pair?pairingUrl=https%3A%2F%2Fexample.test%2Fpair%23token%3Dfixture' + for package in ${withProviders} ${withoutProviders}; do + test "$(T3CODE_DESKTOP_LAUNCHER_PATH=/wrong "$package/bin/t3code-desktop" "$url")" = "$(printf '%s\n' "$package/bin/t3code-desktop" "$url")" + done + touch "$out" + ''; + }); + }; } diff --git a/simit.toml b/simit.toml new file mode 100644 index 000000000000..113e38710e71 --- /dev/null +++ b/simit.toml @@ -0,0 +1,15 @@ +[ci] +platform = "github" +provider = "actions" +runtime = "nix" +runner = "ubuntu-24.04" +nix_builds = [".#t3code", ".#checks.x86_64-linux.desktop-launcher"] + +[ci.nix_build] +only = true +timeout_minutes = 90 +max_parallel = 2 +max_jobs = 2 +cores = 2 +capture_results = true +artifact_retention_days = 7