diff --git a/default.nix b/default.nix new file mode 100644 index 0000000..2a72fad --- /dev/null +++ b/default.nix @@ -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; +} diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..64dfbf2 --- /dev/null +++ b/flake.lock @@ -0,0 +1,85 @@ +{ + "nodes": { + "flake-utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1710146030, + "narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "gomod2nix": { + "inputs": { + "flake-utils": [ + "flake-utils" + ], + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1717050755, + "narHash": "sha256-C9IEHABulv2zEDFA+Bf0E1nmfN4y6MIUe5eM2RCrDC0=", + "owner": "nix-community", + "repo": "gomod2nix", + "rev": "31b6d2e40b36456e792cd6cf50d5a8ddd2fa59a1", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "gomod2nix", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1717974879, + "narHash": "sha256-GTO3C88+5DX171F/gVS3Qga/hOs/eRMxPFpiHq2t+D8=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "c7b821ba2e1e635ba5a76d299af62821cbcb09f3", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "flake-utils": "flake-utils", + "gomod2nix": "gomod2nix", + "nixpkgs": "nixpkgs" + } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..d5d3df7 --- /dev/null +++ b/flake.nix @@ -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; + }; + }) + ); +} diff --git a/gomod2nix.toml b/gomod2nix.toml new file mode 100644 index 0000000..dd87811 --- /dev/null +++ b/gomod2nix.toml @@ -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=" diff --git a/shell.nix b/shell.nix new file mode 100644 index 0000000..d4f21a8 --- /dev/null +++ b/shell.nix @@ -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 + ]; +}