Skip to content

Commit

Permalink
Flake it - does not build, but devShell works
Browse files Browse the repository at this point in the history
Likely facing a reproduciblity issue with mockgen to create code at
build time!

Signed-off-by: Benoit Donneaux <[email protected]>
  • Loading branch information
btlogy committed Jun 13, 2024
1 parent 76fb048 commit 9e44b79
Show file tree
Hide file tree
Showing 5 changed files with 261 additions and 0 deletions.
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
];
}

0 comments on commit 9e44b79

Please sign in to comment.