Repository navigation
feat: add initial NUR repository setup #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 }} | ||
| - 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 | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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; | ||
| }; | ||
| } | ||
| ``` | ||
|
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 | ||
| ``` | ||
|
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. | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 { }; | ||
| } |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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; | ||
| }; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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}; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| { | ||
| # Add your NixOS modules here | ||
| # | ||
| # my-module = ./my-module; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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) | ||
| ) | ||
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| { | ||
| # Add your overlays here | ||
| # | ||
| # my-overlay = import ./my-overlay; | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.