Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
01026c5
Add Nix configuration and setup documentation for reproducible builds
ozankaymak Oct 20, 2025
25c1971
Refactor Nix configuration for reproducible builds and add rustPlatfo…
ozankaymak Oct 20, 2025
b65dbfc
Refactor flake.nix for improved reproducibility and determinism in bu…
ozankaymak Oct 20, 2025
2a6df95
Enhance reproducibility in Nix and Rust configurations by updating RE…
ozankaymak Oct 20, 2025
e2f0aff
Enhance cross-compilation support in Nix configuration by adding Wind…
ozankaymak Oct 21, 2025
b91b5dd
Update Cargo.toml and flake.nix for improved dependencies and cross-c…
ozankaymak Oct 21, 2025
4931eda
Remove outdated SETUP.md for reproducible builds and consolidate setu…
ozankaymak Oct 22, 2025
d7e52de
Merge branch 'main' into ozan/repr-experiments
ozankaymak Oct 22, 2025
3c8837c
Update package description and adjust Rust toolchain version for cons…
ozankaymak Oct 22, 2025
99180a5
Update dependencies in Cargo.lock and refactor AES encryption code fo…
ozankaymak Oct 22, 2025
ab8d41b
Refactor reproducible builds documentation and update flake.nix for e…
ozankaymak Oct 24, 2025
d621de8
Update reproducible builds documentation and flake.nix to clarify pla…
ozankaymak Oct 24, 2025
d63e626
Small fmt
ozankaymak Oct 24, 2025
2eb3e64
fix small mistake
ozankaymak Oct 24, 2025
0e94f91
Merge branch 'main' into ozan/repr-experiments
ozankaymak Oct 27, 2025
b1ae132
Enhance macOS cross-compilation support in Nix configuration and docu…
ozankaymak Oct 27, 2025
2c8ae34
Update reproducible builds documentation with new hash values for pla…
ozankaymak Oct 27, 2025
1a16c5f
Reproducible builds CI and user docs (#174)
ozankaymak Nov 3, 2025
21bd235
Exclude additional non-build-affecting files from the build process
ozankaymak Nov 3, 2025
d8f2c1e
Update documented hashes
ozankaymak Nov 3, 2025
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
13 changes: 13 additions & 0 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[target.x86_64-pc-windows-gnu]
linker = "x86_64-w64-mingw32-gcc"
runner = "wine64"
rustflags = [
"-C", "debuginfo=0",
"-C", "opt-level=3",
"-C", "codegen-units=1",
# force dynamic CRT/winpthreads (do NOT use +crt-static)
"-C", "target-feature=-crt-static",
# make sure the linker flips back to dynamic for system libs
"-C", "link-arg=-Wl,-Bdynamic",
"-C", "link-arg=-Wl,--defsym,__ImageBase=0"
]
264 changes: 264 additions & 0 deletions .github/workflows/reproducible-builds.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,264 @@
name: Reproducible Builds Verification

# Platform coverage:
# - Linux: x86_64, ARM64 (aarch64), Windows cross-compile (via Nix)
# - Windows: Native build (x86_64-pc-windows-msvc via cargo)
# - macOS: Intel (x86_64), Apple Silicon (arm64) (via Nix)

on:
pull_request:
branches:
- main
types: [opened, synchronize, reopened, ready_for_review]

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
verify-reproducibility-windows:
name: Verify Reproducible Windows Build (Native)
runs-on: windows-latest
if: github.event.pull_request.draft == false

steps:
- name: Collect Workflow Telemetry
uses: catchpoint/workflow-telemetry-action@v2
with:
comment_on_pr: false

- uses: actions/checkout@v4

- name: Install Rust toolchain
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: "1.89.0"
components: rustfmt, rust-src

- name: Build
shell: bash
env:
SOURCE_DATE_EPOCH: "1"
RUSTFLAGS: "-C debuginfo=0 -C opt-level=3 -C codegen-units=1 -C strip=none -C link-arg=/PDBALTPATH:clementine-cli.pdb -C link-arg=/Brepro"
run: |
echo "Building for Windows native (x86_64-pc-windows-msvc) with reproducible settings..."
cargo build --release
echo "Build complete"

- name: Calculate build hash
id: hash
shell: bash
run: |
HASH=$(sha256sum target/release/clementine-cli.exe | awk '{print $1}')
echo "hash=$HASH" >> $GITHUB_OUTPUT
echo "Build hash: $HASH"

- name: Upload binary artifact
if: success()
uses: actions/upload-artifact@v4
with:
name: clementine-cli-windows-native
path: target/release/clementine-cli.exe
retention-days: 7

verify-hash-documentation-linux:
Comment on lines +20 to +64

Check warning

Code scanning / CodeQL

Workflow does not contain permissions Medium

Actions job or workflow does not limit the permissions of the GITHUB_TOKEN. Consider setting an explicit permissions block, using the following as a minimal starting point: {contents: read}

Copilot Autofix

AI 5 days ago

To fix this issue, we should add a permissions: block to the workflow to restrict the GITHUB_TOKEN to the minimum required privileges. In this workflow, read-only access to repository contents is sufficient for the listed actions and steps (checkout, build, hash calculation, and uploading artifacts). No steps indicate a need for write-access to issues or pull requests.

The minimal fix is to insert at the workflow root a block:

permissions:
  contents: read

This will apply the restriction to all jobs in the workflow unless overridden within a job. The block should be added after the name: and before the on: key to conform to GitHub Actions workflow conventions.

No imports or additional definitions are required.
Files/regions/lines to change:

  • File: .github/workflows/reproducible-builds.yml
  • Line to insert after name: Reproducible Builds Verification (line 1).

Suggested changeset 1
.github/workflows/reproducible-builds.yml

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/.github/workflows/reproducible-builds.yml b/.github/workflows/reproducible-builds.yml
--- a/.github/workflows/reproducible-builds.yml
+++ b/.github/workflows/reproducible-builds.yml
@@ -1,4 +1,6 @@
 name: Reproducible Builds Verification
+permissions:
+  contents: read
 
 # Platform coverage:
 # - Linux: x86_64, ARM64 (aarch64), Windows cross-compile (via Nix)
EOF
@@ -1,4 +1,6 @@
name: Reproducible Builds Verification
permissions:
contents: read

# Platform coverage:
# - Linux: x86_64, ARM64 (aarch64), Windows cross-compile (via Nix)
Copilot is powered by AI and may make mistakes. Always verify output.
name: Build & Verify Documented Hashes (Linux/Windows-Nix)
runs-on: ubuntu-latest
if: github.event.pull_request.draft == false
strategy:
fail-fast: false
matrix:
platform:
- x86_64-linux-gnu
- aarch64-linux-gnu
- arm-linux-gnueabihf
- riscv64-linux-gnu
- win64

steps:
- name: Collect Workflow Telemetry
uses: catchpoint/workflow-telemetry-action@v2
with:
comment_on_pr: false

- uses: actions/checkout@v4

- name: Install Nix
uses: cachix/install-nix-action@v31
with:
extra_nix_config: |
experimental-features = nix-command flakes

- name: Setup Cachix (optional binary cache)
uses: cachix/cachix-action@v13
with:
name: clementine-cli
skipPush: true
continue-on-error: true

- name: Build ${{ matrix.platform }}
run: |
echo "Building ${{ matrix.platform }} to verify documented hash..."
nix build .#${{ matrix.platform }}
echo "Build complete"

- name: Upload binary artifact
if: success()
uses: actions/upload-artifact@v4
with:
name: clementine-cli-${{ matrix.platform }}
path: result/bin/*
retention-days: 7

- name: Verify documented hash for ${{ matrix.platform }}
run: |
ACTUAL_HASH=$(nix hash path ./result)

# Extract documented hash from reproducible-builds.md
# Platform names are in bold (**platform**) in the markdown table
# Table format: | **platform** | `hash` |
DOCUMENTED_HASH=$(grep "\*\*${{ matrix.platform }}\*\*" docs/reproducible-builds.md | sed 's/.*`\(sha256-[^`]*\)`.*/\1/')

echo "Platform: ${{ matrix.platform }}"
echo "Documented hash: $DOCUMENTED_HASH"
echo "Actual hash: $ACTUAL_HASH"
echo ""

if [ -z "$DOCUMENTED_HASH" ]; then
echo "ERROR: No documented hash found for ${{ matrix.platform }}"
echo "Please add the hash to docs/reproducible-builds.md Expected Hashes table:"
echo " $ACTUAL_HASH"
exit 1
elif [ "$DOCUMENTED_HASH" != "$ACTUAL_HASH" ]; then
echo "ERROR: Documented hash does not match actual build hash!"
echo "The hash in docs/reproducible-builds.md is outdated."
echo ""
echo "Please update docs/reproducible-builds.md with the new hash:"
echo " Platform: ${{ matrix.platform }}"
echo " Old hash: $DOCUMENTED_HASH"
echo " New hash: $ACTUAL_HASH"
exit 1
else
echo "OK: Documented hash matches actual build for ${{ matrix.platform }}"
fi

verify-hash-documentation-macos:
Comment on lines +65 to +145

Check warning

Code scanning / CodeQL

Workflow does not contain permissions Medium

Actions job or workflow does not limit the permissions of the GITHUB_TOKEN. Consider setting an explicit permissions block, using the following as a minimal starting point: {contents: read}

Copilot Autofix

AI 5 days ago

The best way to fix this problem is to add a root-level permissions: block to the workflow file. This sets the minimal required GITHUB_TOKEN permission for all jobs in the workflow, unless overridden per job. Since this workflow does not modify repository contents or issues, the minimal recommended setting is contents: read. This should be inserted just after the workflow name: (on line 2), before the on: settings, following GitHub Actions best practices. No new imports or functionality changes are required; the only edit is to add the permissions block.


Suggested changeset 1
.github/workflows/reproducible-builds.yml

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/.github/workflows/reproducible-builds.yml b/.github/workflows/reproducible-builds.yml
--- a/.github/workflows/reproducible-builds.yml
+++ b/.github/workflows/reproducible-builds.yml
@@ -1,4 +1,6 @@
 name: Reproducible Builds Verification
+permissions:
+  contents: read
 
 # Platform coverage:
 # - Linux: x86_64, ARM64 (aarch64), Windows cross-compile (via Nix)
EOF
@@ -1,4 +1,6 @@
name: Reproducible Builds Verification
permissions:
contents: read

# Platform coverage:
# - Linux: x86_64, ARM64 (aarch64), Windows cross-compile (via Nix)
Copilot is powered by AI and may make mistakes. Always verify output.
name: Build & Verify Documented Hashes (macOS)
runs-on: macos-latest
if: github.event.pull_request.draft == false
strategy:
fail-fast: false
matrix:
platform:
- x86_64-apple-darwin
- arm64-apple-darwin

steps:
- name: Collect Workflow Telemetry
uses: catchpoint/workflow-telemetry-action@v2
with:
comment_on_pr: false

- uses: actions/checkout@v4

- name: Install Nix
uses: cachix/install-nix-action@v31
with:
extra_nix_config: |
experimental-features = nix-command flakes

- name: Setup Cachix (optional binary cache)
uses: cachix/cachix-action@v13
with:
name: clementine-cli
skipPush: true
continue-on-error: true

- name: Build ${{ matrix.platform }}
run: |
echo "Building ${{ matrix.platform }} to verify documented hash..."
nix build .#${{ matrix.platform }}
echo "Build complete"

- name: Upload binary artifact
if: success()
uses: actions/upload-artifact@v4
with:
name: clementine-cli-${{ matrix.platform }}
path: result/bin/*
retention-days: 7

- name: Verify documented hash for ${{ matrix.platform }}
run: |
ACTUAL_HASH=$(nix hash path ./result)

# Extract documented hash from reproducible-builds.md
# Platform names are in bold (**platform**) in the markdown table
# Table format: | **platform** | `hash` |
DOCUMENTED_HASH=$(grep "\*\*${{ matrix.platform }}\*\*" docs/reproducible-builds.md | sed 's/.*`\(sha256-[^`]*\)`.*/\1/')

echo "Platform: ${{ matrix.platform }}"
echo "Documented hash: $DOCUMENTED_HASH"
echo "Actual hash: $ACTUAL_HASH"
echo ""

if [ -z "$DOCUMENTED_HASH" ]; then
echo "ERROR: No documented hash found for ${{ matrix.platform }}"
echo "Please add the hash to docs/reproducible-builds.md Expected Hashes table:"
echo " $ACTUAL_HASH"
exit 1
elif [ "$DOCUMENTED_HASH" != "$ACTUAL_HASH" ]; then
echo "ERROR: Documented hash does not match actual build hash!"
echo "The hash in docs/reproducible-builds.md is outdated."
echo ""
echo "Please update docs/reproducible-builds.md with the new hash:"
echo " Platform: ${{ matrix.platform }}"
echo " Old hash: $DOCUMENTED_HASH"
echo " New hash: $ACTUAL_HASH"
exit 1
else
echo "OK: Documented hash matches actual build for ${{ matrix.platform }}"
fi

build-summary:
Comment on lines +146 to +223

Check warning

Code scanning / CodeQL

Workflow does not contain permissions Medium

Actions job or workflow does not limit the permissions of the GITHUB_TOKEN. Consider setting an explicit permissions block, using the following as a minimal starting point: {contents: read}

Copilot Autofix

AI 5 days ago

To resolve this issue, add an explicit permissions key at the root level of the workflow file .github/workflows/reproducible-builds.yml, immediately below the name field and above the on: trigger. This permissions block should grant only the minimum necessary access to the GITHUB_TOKEN. For the provided workflow, none of the jobs require write access to contents, but uploading artifacts is permitted with minimal read permissions.
The ideal fix is to add:

permissions:
  contents: read

directly after the name: ... line as a minimal starting point. If the jobs later require additional scopes (e.g., pull-requests: write), those can be added, but for now, restricting to read access on repository contents satisfies the least-privilege principle and the CodeQL guidance.

No other code, methods, or imports need to be added to implement this change.

Suggested changeset 1
.github/workflows/reproducible-builds.yml

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/.github/workflows/reproducible-builds.yml b/.github/workflows/reproducible-builds.yml
--- a/.github/workflows/reproducible-builds.yml
+++ b/.github/workflows/reproducible-builds.yml
@@ -1,4 +1,6 @@
 name: Reproducible Builds Verification
+permissions:
+  contents: read
 
 # Platform coverage:
 # - Linux: x86_64, ARM64 (aarch64), Windows cross-compile (via Nix)
EOF
@@ -1,4 +1,6 @@
name: Reproducible Builds Verification
permissions:
contents: read

# Platform coverage:
# - Linux: x86_64, ARM64 (aarch64), Windows cross-compile (via Nix)
Copilot is powered by AI and may make mistakes. Always verify output.
name: Build Summary
runs-on: ubuntu-latest
needs: [verify-reproducibility-windows, verify-hash-documentation-linux, verify-hash-documentation-macos]
if: always()

steps:
- name: Check results
run: |
WINDOWS_RESULT="${{ needs.verify-reproducibility-windows.result }}"
DOCS_LINUX_RESULT="${{ needs.verify-hash-documentation-linux.result }}"
DOCS_MACOS_RESULT="${{ needs.verify-hash-documentation-macos.result }}"

echo "Build Results Summary:"
echo " Windows (native): $WINDOWS_RESULT"
echo " Nix Builds & Docs (Linux/Win): $DOCS_LINUX_RESULT"
echo " Nix Builds & Docs (macOS): $DOCS_MACOS_RESULT"
echo ""

# All jobs must succeed
if [ "$WINDOWS_RESULT" = "success" ] && [ "$DOCS_LINUX_RESULT" = "success" ] && [ "$DOCS_MACOS_RESULT" = "success" ]; then
echo "OK: All verifications passed!"
echo ""
echo "Reproducible builds completed and verified:"
echo " - Windows (x86_64-pc-windows-msvc) native via cargo"
echo " - All Nix platforms (Linux, Windows-cross, macOS)"
echo ""
echo "Documentation verified:"
echo " - All platform hashes match docs/reproducible-builds.md"
exit 0
else
echo "ERROR: Verification failed on one or more checks"
echo ""
if [ "$DOCS_LINUX_RESULT" != "success" ] || [ "$DOCS_MACOS_RESULT" != "success" ]; then
echo " Documentation hash mismatch detected!"
echo " This means the code/dependencies changed and docs need updating."
echo " Please update docs/reproducible-builds.md with new hashes."
echo ""
fi
echo "Check the individual job logs for details"
exit 1
fi
Comment on lines +224 to +264

Check warning

Code scanning / CodeQL

Workflow does not contain permissions Medium

Actions job or workflow does not limit the permissions of the GITHUB_TOKEN. Consider setting an explicit permissions block, using the following as a minimal starting point: {}

Copilot Autofix

AI 5 days ago

To fix the problem, we need to explicitly set the permissions key in the workflow file. The permissions can be set globally (at the workflow level), or individually per job. In this case, since the error is flagged for the build-summary job, and none of the jobs have the permissions key, it is best to add a permissions block at the workflow root level just after the workflow name, before the on key. This will set minimal permissions (usually contents: read) for all jobs in the workflow. If specific jobs require more permissions, they can add a permissions block with broader scopes, but from the provided jobs, this does not seem necessary.

Required changes:

  • Add at the root of the workflow (near the top, after name:), the block:
    permissions:
      contents: read

This restricts the access of the GITHUB_TOKEN to read-only for repository contents for all jobs.

No methods, imports, or definitions are necessary for this YAML change.


Suggested changeset 1
.github/workflows/reproducible-builds.yml

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/.github/workflows/reproducible-builds.yml b/.github/workflows/reproducible-builds.yml
--- a/.github/workflows/reproducible-builds.yml
+++ b/.github/workflows/reproducible-builds.yml
@@ -1,4 +1,6 @@
 name: Reproducible Builds Verification
+permissions:
+  contents: read
 
 # Platform coverage:
 # - Linux: x86_64, ARM64 (aarch64), Windows cross-compile (via Nix)
EOF
@@ -1,4 +1,6 @@
name: Reproducible Builds Verification
permissions:
contents: read

# Platform coverage:
# - Linux: x86_64, ARM64 (aarch64), Windows cross-compile (via Nix)
Copilot is powered by AI and may make mistakes. Always verify output.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,7 @@
/target
./bridge_cli_config.toml

# Nix build artifacts
result
result-*
.direnv
Loading
Loading