Skip to content
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

Turn this repository into a Nix flake #26

Draft
wants to merge 5 commits into
base: master
Choose a base branch
from
Draft
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
37 changes: 34 additions & 3 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,12 @@ on:
pull_request:

jobs:
main:
name: Main
docker:
name: Docker
runs-on: ubuntu-22.04
permissions:
pull-requests: write
contents: read

steps:
- name: Checkout
id: checkout
Expand Down Expand Up @@ -67,3 +66,35 @@ jobs:
./trac2gitea --help 2>&1 | grep -q '^Usage' \
&& echo 'PASS' \
|| { echo 'FAIL'; exit 1; }

nix:
name: Nix
runs-on: ubuntu-22.04
permissions:
pull-requests: write
contents: read
strategy:
matrix:
nix_channel:
- nixos-stable
- nixos-unstable
steps:
- name: Checkout
id: checkout
uses: actions/checkout@v4

- name: Install Nix
id: install_nix
uses: cachix/install-nix-action@v27
with:
nix_path: nixpkgs=channel:${{ matrix.nix_channel }}

- name: Check
id: check
run: |
nix flake check

- name: Build
id: build
run: |
nix-build
21 changes: 21 additions & 0 deletions default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{ pkgs ? (
let
inherit (builtins) fetchTree fromJSON readFile;
inherit ((fromJSON (readFile ./flake.lock)).nodes) nixpkgs gomod2nix;
in
import (fetchTree nixpkgs.locked) {
overlays = [
(import "${fetchTree gomod2nix.locked}/overlay.nix")
];
}
)
, buildGoApplication ? pkgs.buildGoApplication
}:

buildGoApplication {
pname = "trac2gitea";
version = "0.1";
pwd = ./.;
src = ./.;
modules = ./gomod2nix.toml;
}
85 changes: 85 additions & 0 deletions flake.lock

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

29 changes: 29 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
description = "A basic gomod2nix flake for trac2gitea";

inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
inputs.flake-utils.url = "github:numtide/flake-utils";
inputs.gomod2nix.url = "github:nix-community/gomod2nix";
inputs.gomod2nix.inputs.nixpkgs.follows = "nixpkgs";
inputs.gomod2nix.inputs.flake-utils.follows = "flake-utils";

outputs = { self, nixpkgs, flake-utils, gomod2nix }:
(flake-utils.lib.eachDefaultSystem
(system:
let
pkgs = nixpkgs.legacyPackages.${system};

# The current default sdk for macOS fails to compile go projects, so we use a newer one for now.
# This has no effect on other platforms.
callPackage = pkgs.darwin.apple_sdk_11_0.callPackage or pkgs.callPackage;
in
{
packages.default = callPackage ./. {
inherit (gomod2nix.legacyPackages.${system}) buildGoApplication;
};
devShells.default = callPackage ./shell.nix {
inherit (gomod2nix.legacyPackages.${system}) mkGoEnv gomod2nix;
};
})
);
}
102 changes: 102 additions & 0 deletions gomod2nix.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
schema = 3

[mod]
[mod."github.com/emirpasic/gods"]
version = "v1.12.0"
hash = "sha256-IavlXdTPaXr/n0ZjfPm3SmpndU70l5RnrINvqQ7GuEQ="
[mod."github.com/go-ini/ini"]
version = "v1.67.0"
hash = "sha256-V10ahGNGT+NLRdKUyRg1dos5RxLBXBk1xutcnquc/+4="
[mod."github.com/go-sql-driver/mysql"]
version = "v1.7.0"
hash = "sha256-xcCINvN+wEiLLmp9ltfLbDEs+/TidoBCQLODw3lMyzE="
[mod."github.com/golang-sql/civil"]
version = "v0.0.0-20220223132316-b832511892a9"
hash = "sha256-IEz9BkkHyFfs9R4aMxH/c/tD510qSyFEaKrpO4arWpQ="
[mod."github.com/golang-sql/sqlexp"]
version = "v0.1.0"
hash = "sha256-FhKWdt7vwzTbIsx2u+AzrKO1VFxTw/lbgD9/V5G76jw="
[mod."github.com/jackc/pgpassfile"]
version = "v1.0.0"
hash = "sha256-H0nFbC34/3pZUFnuiQk9W7yvAMh6qJDrqvHp+akBPLM="
[mod."github.com/jackc/pgservicefile"]
version = "v0.0.0-20221227161230-091c0ba34f0a"
hash = "sha256-rBtUw15WPPDp2eulHXH5e2zCIed1OPFYwlCpgDOnGRM="
[mod."github.com/jackc/pgx/v5"]
version = "v5.3.1"
hash = "sha256-0v6gXZIirv80mlnUx3ycxB2/TLvv3rUnm98Ke1ZjYDQ="
[mod."github.com/jbenet/go-context"]
version = "v0.0.0-20150711004518-d14ea06fba99"
hash = "sha256-VANNCWNNpARH/ILQV9sCQsBWgyL2iFT+4AHZREpxIWE="
[mod."github.com/jinzhu/inflection"]
version = "v1.0.0"
hash = "sha256-3h3pHib5MaCXKyKLIMyQnSptDJ16kPjCOQPoEBoQsZg="
[mod."github.com/jinzhu/now"]
version = "v1.1.5"
hash = "sha256-NNLqoFx9FczBBDpD0O0aSHnC/YDZ9E/xQ340o7u63IM="
[mod."github.com/kevinburke/ssh_config"]
version = "v0.0.0-20190725054713-01f96b0aa0cd"
hash = "sha256-X5L36JG7T2deBkHBABUYf2rQKle8ve35bH/FQeWUrq8="
[mod."github.com/mattn/go-sqlite3"]
version = "v1.14.22"
hash = "sha256-CWF2Hjg43658NhaePWbGzS19gHJXjuTroG5c0W3hgYQ="
[mod."github.com/microsoft/go-mssqldb"]
version = "v0.21.0"
hash = "sha256-cAUiV2kw/0M9jldWtqdDC+gboAwGNUS3dNHSDM5EKgo="
[mod."github.com/mitchellh/go-homedir"]
version = "v1.1.0"
hash = "sha256-oduBKXHAQG8X6aqLEpqZHs5DOKe84u6WkBwi4W6cv3k="
[mod."github.com/pkg/errors"]
version = "v0.8.1"
hash = "sha256-oe3iddfoLRwpC3ki5fifHf2ZFprtg99iNak50shiuDw="
[mod."github.com/sergi/go-diff"]
version = "v1.0.0"
hash = "sha256-I8rbJFKm44u/wS/gz+2yX9882xXcBdb9mKEKq5OoJRU="
[mod."github.com/spf13/pflag"]
version = "v1.0.5"
hash = "sha256-w9LLYzxxP74WHT4ouBspH/iQZXjuAh2WQCHsuvyEjAw="
[mod."github.com/src-d/gcfg"]
version = "v1.4.0"
hash = "sha256-mXSyOVMB6hSuTddVkBV4+skshppmSu4Klzz7OnVJkhA="
[mod."github.com/xanzy/ssh-agent"]
version = "v0.2.1"
hash = "sha256-WwVQw4YDBvsLk8vTsqSJXVSRUhMm69erv1ubVralErI="
[mod."go.uber.org/mock"]
version = "v0.4.0"
hash = "sha256-mJN2cPmAMTZQzOnTpJ8zi9QH2m3OAKI4IpnQW9QYS8s="
[mod."golang.org/x/crypto"]
version = "v0.8.0"
hash = "sha256-gZ225jF4mxRLlba6OzdTvrsP6kLYf/xOjWMFavCF6tY="
[mod."golang.org/x/net"]
version = "v0.9.0"
hash = "sha256-EG5GRDq282twyce8uugsDTjMz1pNn6zPcyVTZmSiJ14="
[mod."golang.org/x/sys"]
version = "v0.7.0"
hash = "sha256-GotRHJaas/q3L+tFam0q3oQ1rc8GDStt7wnz9h8MTEU="
[mod."golang.org/x/text"]
version = "v0.9.0"
hash = "sha256-tkhDeMsSQZr3jo7vmKehWs3DvWetwXR0IB+DCLbQ4nk="
[mod."gopkg.in/src-d/go-billy.v4"]
version = "v4.3.2"
hash = "sha256-W1n8AsBrIhWBe3Jz5ZR1DTwLrE9q0vBR/Uqk4/yYppg="
[mod."gopkg.in/src-d/go-git.v4"]
version = "v4.13.1"
hash = "sha256-uj7etQusc05Tezv5lW7rU+22I9WVQdn6h4PhC6dZzgE="
[mod."gopkg.in/warnings.v0"]
version = "v0.1.2"
hash = "sha256-ATVL9yEmgYbkJ1DkltDGRn/auGAjqGOfjQyBYyUo8s8="
[mod."gorm.io/driver/mysql"]
version = "v1.5.0"
hash = "sha256-/p12Sj0arPFJp0Ka8aY1OTacCPCW9/NGTWaGPyrKiWM="
[mod."gorm.io/driver/postgres"]
version = "v1.5.0"
hash = "sha256-t1stGhKLrMwbOxLsh1LkSM9Wu9QMOOnSwkR8l851o/M="
[mod."gorm.io/driver/sqlite"]
version = "v1.5.0"
hash = "sha256-iHSonxWbuLBba8AFat0mKBXmUBsDLh/V3jqYM8JX3IE="
[mod."gorm.io/driver/sqlserver"]
version = "v1.4.3"
hash = "sha256-RUJnLstMhz31hxBv4YD3hC4fHlskcQ89IsvoRv78FxU="
[mod."gorm.io/gorm"]
version = "v1.25.0"
hash = "sha256-8ORQqnnDhdy9/ubT6dPNVehkkmy8+ff7ynB24myC2Wk="
24 changes: 24 additions & 0 deletions shell.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{ pkgs ? (
let
inherit (builtins) fetchTree fromJSON readFile;
inherit ((fromJSON (readFile ./flake.lock)).nodes) nixpkgs gomod2nix;
in
import (fetchTree nixpkgs.locked) {
overlays = [
(import "${fetchTree gomod2nix.locked}/overlay.nix")
];
}
)
, mkGoEnv ? pkgs.mkGoEnv
, gomod2nix ? pkgs.gomod2nix
}:

let
goEnv = mkGoEnv { pwd = ./.; };
in
pkgs.mkShell {
packages = [
goEnv
gomod2nix
];
}
Loading