Skip to content
Merged
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
46 changes: 46 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: "Build and populate cache"
on:
pull_request:
push:
branches:
- main
- master
workflow_dispatch:
permissions:
contents: read
jobs:
tests:
strategy:
matrix:
nixPath:
- nixpkgs=https://github.com/NixOS/nixpkgs/archive/refs/heads/nixpkgs-unstable.tar.gz
- nixpkgs=https://github.com/NixOS/nixpkgs/archive/refs/heads/nixos-unstable.tar.gz
- nixpkgs=https://github.com/NixOS/nixpkgs/archive/refs/heads/nixos-26.05.tar.gz
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@fbc6f3992d24b796d5a048ff273f7fcc4a7b6c09 # v5
with:
persist-credentials: false
- name: Install nix
uses: cachix/install-nix-action@630ae543ea3a38a9a4166f03376c02c50f408342 # v31
with:
nix_path: "${{ matrix.nixPath }}"
extra_nix_config: |
experimental-features = nix-command flakes
access-tokens = github.com=${{ secrets.GITHUB_TOKEN }}
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved
- name: Show nixpkgs version
run: nix-instantiate --eval -E '(import <nixpkgs> {}).lib.version'
- name: Check evaluation
run: |
nix-env -f . -qa \* --meta --xml \
--allowed-uris https://static.rust-lang.org \
--option restrict-eval true \
--option allow-import-from-derivation true \
--drv-path --show-trace \
-I nixpkgs=$(nix-instantiate --find-file nixpkgs) \
-I $PWD
- name: Check flake
run: nix flake check
- name: Build nix packages
run: nix shell -f '<nixpkgs>' nix-build-uncached -c nix-build-uncached ci.nix -A cacheOutputs
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2026 Railsware Products Studio LLC ("Mailtrap")

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
86 changes: 86 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
# mailtrap-nur

Mailtrap [NUR](https://github.com/nix-community/NUR)-style repository — Nix packages for Mailtrap tooling.

Layout follows [nix-community/nur-packages-template](https://github.com/nix-community/nur-packages-template).

## Packages

| Attribute | Description |
| --- | --- |
| `mailtrap-local` | Local email sandbox + catcher ([mailtrap/mailtrap-local](https://github.com/mailtrap/mailtrap-local)) |

`mailtrap-local` installs the prebuilt release binary (same artifacts as Homebrew / GitHub Releases), so you get the real embedded Web UI. Platforms: `x86_64`/`aarch64` on Linux and Darwin.

`pkgs/mailtrap-local/default.nix` is owned by goreleaser in [mailtrap-local](https://github.com/mailtrap/mailtrap-local): each tagged release opens a PR here (same flow as the Homebrew tap).

## Install

Flake (overlay into your own flake):

```nix
{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
mailtrap-nur.url = "github:mailtrap/mailtrap-nur";
};

outputs = { nixpkgs, mailtrap-nur, ... }:
let
system = "aarch64-darwin"; # or x86_64-linux, …
pkgs = import nixpkgs {
inherit system;
overlays = [ mailtrap-nur.overlays.default ];
};
in
{
packages.${system}.default = pkgs.mailtrap-local;
# or: packages.${system}.mailtrap-local = pkgs.mailtrap-local;
};
}
```
Comment thread
leonid-shevtsov marked this conversation as resolved.
Resolved

One-shot:

```bash
nix profile add github:mailtrap/mailtrap-nur#mailtrap-local
# Nix older than 2.25: nix profile install …
# or, without installing:
nix run github:mailtrap/mailtrap-nur#mailtrap-local
```

Both `mailtrap-local` and the `mailtrap-sendmail` symlink land in the profile.

Without flakes (`shell.nix`):

```nix
let
pkgs = import <nixpkgs> { };
mailtrap = import (builtins.fetchTarball "https://github.com/mailtrap/mailtrap-nur/archive/main.tar.gz") {
inherit pkgs;
};
in
mailtrap.mailtrap-local
```
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved

Or as a nixpkgs overlay (e.g. NixOS / home-manager `nixpkgs.overlays`):

```nix
[
(import "${builtins.fetchTarball "https://github.com/mailtrap/mailtrap-nur/archive/main.tar.gz"}/overlay.nix")
]
```

## Develop

```bash
nix-build -A mailtrap-local
nix build .#mailtrap-local
```

## Add another package

1. Create `pkgs/<name>/default.nix` (use `pkgs.callPackage` — take deps from the `pkgs` argument, do not `import <nixpkgs>` inside the package).
2. Export it from root `default.nix`.
3. Mark broken packages with `meta.broken = true` so CI stays green.
4. If the package only supports some platforms, keep `flake.nix` `systems` aligned with those binaries.
73 changes: 73 additions & 0 deletions ci.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
# This file provides all the buildable and cacheable packages and
# package outputs in your package set. These are what gets built by CI,
# so if you correctly mark packages as
#
# - broken (using `meta.broken`),
# - unfree (using `meta.license.free`), and
# - locally built (using `preferLocalBuild`)
#
# then your CI will be able to build and cache only those packages for
# which this is possible.

{ pkgs ? import <nixpkgs> { } }:

with builtins;
let
isReserved =
n:
n == "lib"
|| n == "overlays"
|| n == "nixosModules"
|| n == "homeModules"
|| n == "darwinModules"
|| n == "flakeModules";
isDerivation = p: isAttrs p && p ? type && p.type == "derivation";
isBuildable =
p:
let
licenseFromMeta = p.meta.license or [ ];
licenseList = if builtins.isList licenseFromMeta then licenseFromMeta else [ licenseFromMeta ];
in
!(p.meta.broken or false) && builtins.all (license: license.free or true) licenseList;
isCacheable = p: !(p.preferLocalBuild or false);
shouldRecurseForDerivations = p: isAttrs p && p.recurseForDerivations or false;

nameValuePair = n: v: {
name = n;
value = v;
};

concatMap = builtins.concatMap or (f: xs: concatLists (map f xs));

flattenPkgs =
s:
let
f =
p:
if shouldRecurseForDerivations p then
flattenPkgs p
else if isDerivation p then
[ p ]
else
[ ];
in
concatMap f (attrValues s);

outputsOf = p: map (o: p.${o}) p.outputs;

nurAttrs = import ./default.nix { inherit pkgs; };

nurPkgs = flattenPkgs (
listToAttrs (
map (n: nameValuePair n nurAttrs.${n}) (filter (n: !isReserved n) (attrNames nurAttrs))
)
);

in
rec {
buildPkgs = filter isBuildable nurPkgs;
cachePkgs = filter isCacheable buildPkgs;

buildOutputs = concatMap outputsOf buildPkgs;
cacheOutputs = concatMap outputsOf cachePkgs;
}
23 changes: 23 additions & 0 deletions default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# This file describes your repository contents.
# It should return a set of nix derivations
# and optionally the special attributes `lib`, `overlays`,
# `nixosModules`, `homeModules`, `darwinModules` and `flakeModules`.
# It should NOT import. Instead, you should take pkgs as an argument.
# Having pkgs default to <nixpkgs> is fine though, and it lets you use short
# commands such as:
# nix-build -A mailtrap-local

{ pkgs ? import <nixpkgs> { } }:

{
# The `lib`, `overlays`, `nixosModules`, `homeModules`,
# `darwinModules` and `flakeModules` names are special
lib = import ./lib { inherit pkgs; }; # functions
nixosModules = import ./nixos-modules; # NixOS modules
# homeModules = { }; # Home Manager modules
# darwinModules = { }; # nix-darwin modules
# flakeModules = { }; # flake-parts modules
overlays = import ./overlays; # nixpkgs overlays

mailtrap-local = pkgs.callPackage ./pkgs/mailtrap-local { };
}
27 changes: 27 additions & 0 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

33 changes: 33 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
description = "Mailtrap NUR repository";
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
outputs =
{ self, nixpkgs }:
let
# Only systems we ship prebuilt binaries for (see pkgs/*/meta.platforms).
# flakeExposed includes i686/riscv/etc. that would fail urlMap.${system}.
systems = [
"aarch64-darwin"
"aarch64-linux"
"x86_64-darwin"
"x86_64-linux"
];
forAllSystems = nixpkgs.lib.genAttrs systems;
in
{
legacyPackages = forAllSystems (
system:
import ./default.nix {
pkgs = import nixpkgs { inherit system; };
}
);
packages = forAllSystems (
system: nixpkgs.lib.filterAttrs (_: v: nixpkgs.lib.isDerivation v) self.legacyPackages.${system}
);
nixosModules = import ./nixos-modules;
# homeModules = import ./home-modules;
# darwinModules = import ./darwin-modules;
# flakeModules = import ./flake-modules;
overlays.default = import ./overlay.nix;
};
}
8 changes: 8 additions & 0 deletions lib/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{ pkgs }:

with pkgs.lib;
{
# Add your library functions here
#
# hexint = x: hexvals.${toLower x};
}
5 changes: 5 additions & 0 deletions nixos-modules/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
# Add your NixOS modules here
#
# my-module = ./my-module;
}
25 changes: 25 additions & 0 deletions overlay.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# You can use this file as a nixpkgs overlay. This is useful in the
# case where you don't want to add the whole NUR namespace to your
# configuration.

final: prev:
let
isReserved =
n:
n == "lib"
|| n == "overlays"
|| n == "nixosModules"
|| n == "homeModules"
|| n == "darwinModules"
|| n == "flakeModules";
nameValuePair = n: v: {
name = n;
value = v;
};
nurAttrs = import ./default.nix { pkgs = prev; };
in
builtins.listToAttrs (
map (n: nameValuePair n nurAttrs.${n}) (
builtins.filter (n: !isReserved n) (builtins.attrNames nurAttrs)
)
)
5 changes: 5 additions & 0 deletions overlays/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
# Add your overlays here
#
# my-overlay = import ./my-overlay;
}
Loading