Skip to content

feat: add initial NUR repository setup - #1

Merged
leonid-shevtsov merged 1 commit into
mainfrom
chore/initial-nur-setup
Aug 6, 2026
Merged

leonid-shevtsov merged 1 commit into
mainfrom
chore/initial-nur-setup

Conversation

@leonid-shevtsov

@leonid-shevtsov leonid-shevtsov commented Jul 29, 2026 •

Copy link
Copy Markdown
Contributor

What & why

Bootstrap a Mailtrap NUR-style Nix package repo so we can distribute mailtrap-local (and later other tools) via Nix, with release updates driven from goreleaser.

  • Scaffold from the nix-community NUR template: default.nix, flake, overlay, CI eval/build workflow.
  • Add mailtrap-local as a prebuilt GitHub Releases package (same artifacts as Homebrew), owned by goreleaser PRs on each tag.

How to test

Human QA on macOS, against this PR branch (not main):

github:mailtrap/mailtrap-nur/chore/initial-nur-setup#mailtrap-local

Install Nix (once per machine)

Recommended on macOS: Determinate Nix (flakes + nix command enabled by default).

GUI (preferred): download the universal pkg from https://install.determinate.systems/ and run it.

CLI:

curl --proto '=https' --tlsv1.2 -sSf -L https://install.determinate.systems/nix | sh -s -- install

Then open a new Terminal tab and check:

nix --version

Alternative: official installer at https://nixos.org/download/ (macOS) — after install, ensure flakes are on (experimental-features = nix-command flakes in ~/.config/nix/nix.conf).

0. Prep

  • Nix installed (nix --version works)
  • Note arch: Apple Silicon = aarch64-darwin, Intel = x86_64-darwin
    uname -m   # arm64 → aarch64-darwin; x86_64 → x86_64-darwin
  • Free ports 3535 / 3550 (or use alt ports below)
  • If brew mailtrap-local already installed, stop it so ports do not conflict:
    brew services stop mailtrap-local 2>/dev/null; true

1. Flake resolve + build

  • From a clean shell:
    nix flake metadata github:mailtrap/mailtrap-nur/chore/initial-nur-setup
    nix build github:mailtrap/mailtrap-nur/chore/initial-nur-setup#mailtrap-local --print-out-paths
  • Build succeeds and prints a store path. On failure, paste the full error (hash mismatch / wrong system / quarantine / network).

Optional (local checkout of this branch):

cd /path/to/mailtrap-nur
git checkout chore/initial-nur-setup
nix build .#mailtrap-local --print-out-paths

2. One-shot run (nix run)

nix run github:mailtrap/mailtrap-nur/chore/initial-nur-setup#mailtrap-local -- --version
  • Prints version matching the package (currently 0.2.0)
  • Start the daemon (use alt ports if busy):
    nix run github:mailtrap/mailtrap-nur/chore/initial-nur-setup#mailtrap-local -- \
      --http-listen 127.0.0.1:3550 \
      --smtp-listen 127.0.0.1:3535 \
      --db /tmp/mailtrap-local-qa.db
  • No Gatekeeper / "cannot be opened" / killed-by-macOS. If quarantine blocks:
    xattr -l "$(command -v mailtrap-local)"
    # Nix store usually has no quarantine; note if present

3. Web UI (real embedded SPA)

With the process running:

4. SMTP catch

New terminal:

python3 - <<'PY'
import smtplib
from email.message import EmailMessage
msg = EmailMessage()
msg["From"] = "qa@example.com"
msg["To"] = "you@example.com"
msg["Subject"] = "nix-qa smoke"
msg.set_content("hello from mailtrap-nur QA")
with smtplib.SMTP("127.0.0.1", 3535) as s:
    s.send_message(msg)
print("sent")
PY
  • Command exits 0
  • Message appears in UI inbox
  • Open message: subject/body/headers OK

5. mailtrap-sendmail symlink

out=$(nix build github:mailtrap/mailtrap-nur/chore/initial-nur-setup#mailtrap-local --print-out-paths --no-link)
ls -l "$out/bin/"
"$out/bin/mailtrap-sendmail" -t -i <<'EOF'
From: qa@example.com
To: you@example.com
Subject: sendmail-qa

body via sendmail mode
EOF
  • mailtrap-local and mailtrap-sendmail both in $out/bin
  • Symlink target is mailtrap-local
  • Second message shows in UI (daemon still running on same DB/ports)

6. Profile install (persist on PATH)

nix profile install github:mailtrap/mailtrap-nur/chore/initial-nur-setup#mailtrap-local
hash -r
which mailtrap-local
mailtrap-local --version
which mailtrap-sendmail
  • Both on PATH
  • Version matches
  • New Terminal tab: mailtrap-local --version still works

Cleanup when done:

nix profile list
# then: nix profile remove <index-or-name>

7. Overlay path (flake consumer)

Minimal test flake in a tmp dir:

# flake.nix
{
  inputs = {
    nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
    mailtrap-nur.url = "github:mailtrap/mailtrap-nur/chore/initial-nur-setup";
  };
  outputs = { nixpkgs, mailtrap-nur, ... }:
    let
      system = "aarch64-darwin"; # change if Intel
      pkgs = import nixpkgs {
        inherit system;
        overlays = [ mailtrap-nur.overlays.default ];
      };
    in {
      packages.${system}.default = pkgs.mailtrap-local;
    };
}
nix build .#default --print-out-paths
./result/bin/mailtrap-local --version
  • Overlay exposes pkgs.mailtrap-local
  • Same binary/version as direct #mailtrap-local

8. macOS-specific failure watch

  • Apple Silicon: fetches …_darwin_arm64.tar.gz (not amd64 under Rosetta unless intentional)
  • Intel Mac: …_darwin_amd64.tar.gz
  • Wrong SHA / 404 on release asset → fail loud at build (check version in pkgs/mailtrap-local/default.nix)
  • Not mixing with Homebrew binary:
    type -a mailtrap-local

Pass bar

Build+run on this Mac arch, UI is real, SMTP + sendmail both land mail. Profile + overlay recommended once each.

Summary by CodeRabbit

  • New Features
    • Added the mailtrap-local package (version 0.2.0) with support for Linux and macOS.
    • Added Nix flake outputs, package access, NixOS module support, and an overlay for easier integration.
  • Documentation
    • Added installation, usage, development, and contribution guidance.
  • Chores
    • Added MIT license information.
    • Added automated checks for supported Nix package sets, flake validation, and build verification.

@coderabbitai

coderabbitai Bot commented Jul 29, 2026 •

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: bdb8cf4f-bccf-403e-9752-5f7da17faff6

📥 Commits

Reviewing files that changed from the base of the PR and between c4f8fd4 and 8ae1445.

⛔ Files ignored due to path filters (1)
  • flake.lock is excluded by !**/*.lock
📒 Files selected for processing (11)
  • .github/workflows/build.yml
  • LICENSE
  • README.md
  • ci.nix
  • default.nix
  • flake.nix
  • lib/default.nix
  • nixos-modules/default.nix
  • overlay.nix
  • overlays/default.nix
  • pkgs/mailtrap-local/default.nix
🚧 Files skipped from review as they are similar to previous changes (11)
  • LICENSE
  • README.md
  • lib/default.nix
  • overlays/default.nix
  • pkgs/mailtrap-local/default.nix
  • nixos-modules/default.nix
  • .github/workflows/build.yml
  • default.nix
  • flake.nix
  • ci.nix
  • overlay.nix

📝 Walkthrough

Walkthrough

This change establishes a Nix repository for Mailtrap tooling. It packages mailtrap-local version 0.2.0, adds flake and overlay interfaces, adds CI evaluation and build workflows, and documents installation, development, contribution, and licensing.

Changes

Repository foundation

Layer / File(s) Summary
Package definition
default.nix, pkgs/mailtrap-local/default.nix
Defines repository attributes and platform-specific mailtrap-local binaries with a mailtrap-sendmail symlink.
Nix exports and overlays
flake.nix, overlay.nix, lib/default.nix, nixos-modules/default.nix, overlays/default.nix
Adds per-system flake packages, module and library placeholders, and an overlay that exports non-reserved repository attributes.
CI package selection and builds
ci.nix, .github/workflows/build.yml
Selects buildable and cacheable derivations and runs restricted evaluation, flake checks, and builds across three nixpkgs versions.
Documentation and licensing
README.md, LICENSE
Documents packages, installation, development commands, contribution steps, and MIT licensing terms.

Estimated code review effort: 3 (Moderate) | ~20 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely summarizes the main change: adding the initial NUR repository setup.
Description check ✅ Passed The description explains the motivation, changes, and detailed testing steps; the optional images section is omitted.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@leonid-shevtsov
leonid-shevtsov force-pushed the chore/initial-nur-setup branch from ace337f to a449fc7 Compare July 29, 2026 09:19
@@ -0,0 +1,58 @@
# This file was generated by GoReleaser. DO NOT EDIT.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file would be typically updated by PR from GoReleaser, but for now we're seeding the current version as is to have the package present.

Once the pipeline is fully in place we'll make a new release to do it properly.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 4

🧹 Nitpick comments (1)
.github/workflows/build.yml (1)

33-43: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Exercise the flake interface in CI.

The current checks only evaluate default.nix and ci.nix; they can pass while flake.nix outputs are broken. Add a nix flake check or targeted flake evaluation after fixing the system mismatch.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/workflows/build.yml around lines 33 - 43, Add a CI step after
resolving the system mismatch that runs `nix flake check` (or an equivalent
targeted evaluation) against the repository’s flake interface. Keep the existing
`Check evaluation` and `Build nix packages` steps intact while ensuring flake
outputs are exercised during workflow validation.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In @.github/workflows/build.yml:
- Around line 22-30: Update the checkout step using actions/checkout@v5 to set
persist-credentials to false, and restrict the workflow’s permissions to
read-only where possible while preserving the existing build behavior.

In `@flake.nix`:
- Around line 7-17: Restrict the forAllSystems systems list used by
legacyPackages and packages to the four platforms declared in mailtrap-local’s
meta.platforms, rather than iterating over nixpkgs.lib.systems.flakeExposed.
Update the shared system-attribute generation near forAllSystems so unsupported
targets cannot evaluate urlMap.${system}; preserve the existing package
filtering and per-system imports for supported platforms.

In `@README.md`:
- Around line 21-40: Update the README flake example’s outputs attrset to expose
mailtrap-local as an actual package output, using the existing
pkgs.mailtrap-local package and the configured system attribute so copied flakes
can build or run it.
- Around line 52-57: Update the non-flake Nix example around the mailtrap
binding so the mailtrap assignment is valid top-level syntax, wrapping it in a
let...in expression or attribute set while preserving the existing pkgs
inheritance and mailtrap.mailtrap-local usage.

---

Nitpick comments:
In @.github/workflows/build.yml:
- Around line 33-43: Add a CI step after resolving the system mismatch that runs
`nix flake check` (or an equivalent targeted evaluation) against the
repository’s flake interface. Keep the existing `Check evaluation` and `Build
nix packages` steps intact while ensuring flake outputs are exercised during
workflow validation.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 09b726da-1221-494b-99c4-fc323c2f7946

📥 Commits

Reviewing files that changed from the base of the PR and between 3f5bb56 and ace337f.

⛔ Files ignored due to path filters (1)
  • flake.lock is excluded by !**/*.lock
📒 Files selected for processing (11)
  • .github/workflows/build.yml
  • LICENSE
  • README.md
  • ci.nix
  • default.nix
  • flake.nix
  • lib/default.nix
  • nixos-modules/default.nix
  • overlay.nix
  • overlays/default.nix
  • pkgs/mailtrap-local/default.nix

Comment thread .github/workflows/build.yml Resolved
Comment thread flake.nix Resolved
Comment thread README.md Resolved
Comment thread README.md Resolved
@leonid-shevtsov
leonid-shevtsov force-pushed the chore/initial-nur-setup branch 2 times, most recently from 6846445 to c4aa03f Compare July 30, 2026 08:25

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (2)
flake.nix (1)

3-3: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Commit flake.lock for the nixpkgs input.

Line 3 uses an unlocked branch reference, and no lock file is included in the supplied changes. Generate and commit flake.lock so CI and consumers resolve the same nixpkgs revision; Nix documents lock files as the mechanism for pinning unlocked flake inputs. (releases.nixos.org)

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@flake.nix` at line 3, Generate a flake.lock for the nixpkgs input declared by
inputs.nixpkgs.url, then include the generated lock file in the change so the
branch reference resolves to a pinned revision.
.github/workflows/build.yml (1)

22-26: 🔒 Security & Privacy | 🔵 Trivial | ⚡ Quick win

Pin third-party actions to immutable commits.

actions/checkout@v5 and cachix/install-nix-action@v31 are mutable tag references. Pin them to full commit SHAs, retaining version comments, so CI behavior cannot change without a repository diff.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/workflows/build.yml around lines 22 - 26, Update the GitHub Actions
steps using actions/checkout and cachix/install-nix-action to reference their
full immutable commit SHAs instead of mutable version tags, while retaining
comments identifying the corresponding versions.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@README.md`:
- Around line 51-60: Update the Nix example heading and surrounding guidance so
the shown derivation is presented only as shell.nix content, not as
~/.config/nixpkgs/config.nix; alternatively, provide a separate valid config.nix
wrapper or overlay example while preserving the existing mailtrap-local
derivation.

---

Nitpick comments:
In @.github/workflows/build.yml:
- Around line 22-26: Update the GitHub Actions steps using actions/checkout and
cachix/install-nix-action to reference their full immutable commit SHAs instead
of mutable version tags, while retaining comments identifying the corresponding
versions.

In `@flake.nix`:
- Line 3: Generate a flake.lock for the nixpkgs input declared by
inputs.nixpkgs.url, then include the generated lock file in the change so the
branch reference resolves to a pinned revision.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: f2b40e8d-da22-4008-8691-5aa4a007e8a0

📥 Commits

Reviewing files that changed from the base of the PR and between ace337f and 6846445.

⛔ Files ignored due to path filters (1)
  • flake.lock is excluded by !**/*.lock
📒 Files selected for processing (11)
  • .github/workflows/build.yml
  • LICENSE
  • README.md
  • ci.nix
  • default.nix
  • flake.nix
  • lib/default.nix
  • nixos-modules/default.nix
  • overlay.nix
  • overlays/default.nix
  • pkgs/mailtrap-local/default.nix
🚧 Files skipped from review as they are similar to previous changes (1)
  • overlay.nix

Comment thread README.md Resolved
@leonid-shevtsov
leonid-shevtsov force-pushed the chore/initial-nur-setup branch from c4aa03f to dd81f33 Compare July 30, 2026 11:32

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
.github/workflows/build.yml (1)

45-46: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

Exercise the packaged binary’s version contract.

The workflow builds mailtrap-local but never executes it, so it does not validate the PR’s required 0.2.0 runtime version. Add a post-build check using the CLI’s version command and assert that its output contains 0.2.0.

Proposed check
       - name: Build nix packages
         run: nix shell -f '<nixpkgs>' nix-build-uncached -c nix-build-uncached ci.nix -A cacheOutputs
+      - name: Check mailtrap-local version
+        run: nix run .#mailtrap-local -- --version | grep -F '0.2.0'
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/workflows/build.yml around lines 45 - 46, Update the “Build nix
packages” workflow step to execute the packaged mailtrap-local binary after
building it, invoke its CLI version command, and assert that the output contains
“0.2.0”.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In @.github/workflows/build.yml:
- Around line 45-46: Update the “Build nix packages” workflow step to execute
the packaged mailtrap-local binary after building it, invoke its CLI version
command, and assert that the output contains “0.2.0”.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: bdfa2853-c2f1-4128-8dca-52f1214052bc

📥 Commits

Reviewing files that changed from the base of the PR and between 6846445 and dd81f33.

⛔ Files ignored due to path filters (1)
  • flake.lock is excluded by !**/*.lock
📒 Files selected for processing (11)
  • .github/workflows/build.yml
  • LICENSE
  • README.md
  • ci.nix
  • default.nix
  • flake.nix
  • lib/default.nix
  • nixos-modules/default.nix
  • overlay.nix
  • overlays/default.nix
  • pkgs/mailtrap-local/default.nix
🚧 Files skipped from review as they are similar to previous changes (1)
  • README.md

Co-authored-by: Cursor <cursoragent@cursor.com>
@leonid-shevtsov
leonid-shevtsov force-pushed the chore/initial-nur-setup branch from dd81f33 to 8ae1445 Compare August 6, 2026 04:54
@coderabbitai

coderabbitai Bot commented Aug 6, 2026

Copy link
Copy Markdown

Note

GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer.

@leonid-shevtsov
leonid-shevtsov merged commit 9f9a652 into main Aug 6, 2026
3 checks passed
@leonid-shevtsov
leonid-shevtsov deleted the chore/initial-nur-setup branch August 6, 2026 04:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants