From 33b65aa13e84f1131a81d9a14ab9b10991447eab Mon Sep 17 00:00:00 2001 From: adisbladis Date: Sat, 28 May 2022 21:50:18 +0800 Subject: [PATCH] root: Use new format for building self --- builder/fetch.sh | 2 +- default.nix | 7 +- gomod2nix.toml | 270 ++++++++++++++--------------------------------- 3 files changed, 86 insertions(+), 193 deletions(-) diff --git a/builder/fetch.sh b/builder/fetch.sh index c1aed36..5493a1c 100644 --- a/builder/fetch.sh +++ b/builder/fetch.sh @@ -3,7 +3,7 @@ source $stdenv/setup export HOME=$(mktemp -d) # Call once first outside of subshell for better error reporting -go mod download -x "$goPackagePath@$version" +go mod download "$goPackagePath@$version" dir=$(go mod download --json "$goPackagePath@$version" | jq -r .Dir) diff --git a/default.nix b/default.nix index 8ed038e..8c13939 100644 --- a/default.nix +++ b/default.nix @@ -1,6 +1,7 @@ -{ buildGoApplication, lib, makeWrapper, nix-prefetch-git }: +{ buildGoApplication, go, nix, lib, makeWrapper, nix-prefetch-git }: buildGoApplication { + inherit go; pname = "gomod2nix"; version = "0.1"; src = lib.cleanSourceWith { @@ -9,12 +10,14 @@ buildGoApplication { }; modules = ./gomod2nix.toml; + allowGoReference = true; + subPackages = [ "." ]; nativeBuildInputs = [ makeWrapper ]; postInstall = '' - wrapProgram $out/bin/gomod2nix --prefix PATH : ${lib.makeBinPath [ nix-prefetch-git ]} + wrapProgram $out/bin/gomod2nix --prefix PATH : ${lib.makeBinPath [ go ]} rm -f $out/bin/builder ''; } diff --git a/gomod2nix.toml b/gomod2nix.toml index 5a63c48..7dbc46c 100644 --- a/gomod2nix.toml +++ b/gomod2nix.toml @@ -1,191 +1,81 @@ -["github.com/BurntSushi/toml"] - sumVersion = "v0.3.1" - ["github.com/BurntSushi/toml".fetch] - type = "git" - url = "https://github.com/BurntSushi/toml" - rev = "3012a1dbe2e4bd1391d42b32f0577cb7bbc7f005" - sha256 = "1fjdwwfzyzllgiwydknf1pwjvy49qxfsczqx5gz3y0izs7as99j6" +schema = 1 -["github.com/alecthomas/assert"] - sumVersion = "v0.0.0-20170929043011-405dbfeb8e38" - ["github.com/alecthomas/assert".fetch] - type = "git" - url = "https://github.com/alecthomas/assert" - rev = "405dbfeb8e38effee6e723317226e93fff912d06" - sha256 = "1l567pi17k593nrd1qlbmiq8z9jy3qs60px2a16fdpzjsizwqx8l" - -["github.com/alecthomas/colour"] - sumVersion = "v0.0.0-20160524082231-60882d9e2721" - ["github.com/alecthomas/colour".fetch] - type = "git" - url = "https://github.com/alecthomas/colour" - rev = "60882d9e27213e8552dcff6328914fe4c2b44bc9" - sha256 = "0iq566534gbzkd16ixg7fk298wd766821vvs80838yifx9yml5vs" - -["github.com/alecthomas/kingpin"] - sumVersion = "v2.2.6+incompatible" - ["github.com/alecthomas/kingpin".fetch] - type = "git" - url = "https://github.com/alecthomas/kingpin" - rev = "947dcec5ba9c011838740e680966fd7087a71d0d" - sha256 = "0mndnv3hdngr3bxp7yxfd47cas4prv98sqw534mx7vp38gd88n5r" - -["github.com/alecthomas/repr"] - sumVersion = "v0.0.0-20180818092828-117648cd9897" - ["github.com/alecthomas/repr".fetch] - type = "git" - url = "https://github.com/alecthomas/repr" - rev = "117648cd9897bc621d6d52cd05727b9abdd5528a" - sha256 = "05v1rgzdqc8razf702laagrvhvx68xd9yxxmzd3dyz0d6425pdrp" - -["github.com/alecthomas/template"] - sumVersion = "v0.0.0-20160405071501-a0175ee3bccc" - ["github.com/alecthomas/template".fetch] - type = "git" - url = "https://github.com/alecthomas/template" - rev = "a0175ee3bccc567396460bf5acd36800cb10c49c" - sha256 = "0qjgvvh26vk1cyfq9fadyhfgdj36f1iapbmr5xp6zqipldz8ffxj" - -["github.com/alecthomas/units"] - sumVersion = "v0.0.0-20151022065526-2efee857e7cf" - ["github.com/alecthomas/units".fetch] - type = "git" - url = "https://github.com/alecthomas/units" - rev = "2efee857e7cfd4f3d0138cc3cbb1b4966962b93a" - sha256 = "1j65b91qb9sbrml9cpabfrcf07wmgzzghrl7809hjjhrmbzri5bl" - -["github.com/davecgh/go-spew"] - sumVersion = "v1.1.1" - ["github.com/davecgh/go-spew".fetch] - type = "git" - url = "https://github.com/davecgh/go-spew" - rev = "8991bc29aa16c548c550c7ff78260e27b9ab7c73" - sha256 = "0hka6hmyvp701adzag2g26cxdj47g21x6jz4sc6jjz1mn59d474y" - -["github.com/mattn/go-isatty"] - sumVersion = "v0.0.3" - ["github.com/mattn/go-isatty".fetch] - type = "git" - url = "https://github.com/mattn/go-isatty" - rev = "0360b2af4f38e8d38c7fce2a9f4e702702d73a39" - sha256 = "06w45aqz2a6yrk25axbly2k5wmsccv8cspb94bfmz4izvw8h927n" - -["github.com/orivej/e"] - sumVersion = "v0.0.0-20180728214217-ac3492690fda" - ["github.com/orivej/e".fetch] - type = "git" - url = "https://github.com/orivej/e" - rev = "ac3492690fda471c5eab817efd86badf5c3ac158" - sha256 = "11jizr28kfkr6zscjxg95pqi6cjp08aqnhs41sdhc98nww78ilkr" - -["github.com/orivej/go-nix"] - sumVersion = "v0.0.0-20180830055821-dae45d921a44" - ["github.com/orivej/go-nix".fetch] - type = "git" - url = "https://github.com/orivej/go-nix" - rev = "dae45d921a44e6ec05b4ea2b00d8e9efadf770c3" - sha256 = "17hfmsz8hs3h2d5c06j1bvbw8ijrhzm3iz911z5zydsl4x7y0cgy" - -["github.com/pkg/profile"] - sumVersion = "v1.2.1" - ["github.com/pkg/profile".fetch] - type = "git" - url = "https://github.com/pkg/profile" - rev = "5b67d428864e92711fcbd2f8629456121a56d91f" - sha256 = "0blqmvgqvdbqmh3fp9pfdxc9w1qfshrr0zy9whj0sn372bw64qnr" - -["github.com/pmezard/go-difflib"] - sumVersion = "v1.0.0" - ["github.com/pmezard/go-difflib".fetch] - type = "git" - url = "https://github.com/pmezard/go-difflib" - rev = "792786c7400a136282c1664665ae0a8db921c6c2" - sha256 = "0c1cn55m4rypmscgf0rrb88pn58j3ysvc2d0432dp3c6fqg6cnzw" - -["github.com/sergi/go-diff"] - sumVersion = "v1.0.0" - ["github.com/sergi/go-diff".fetch] - type = "git" - url = "https://github.com/sergi/go-diff" - rev = "1744e2970ca51c86172c8190fadad617561ed6e7" - sha256 = "0swiazj8wphs2zmk1qgq75xza6m19snif94h2m6fi8dqkwqdl7c7" - -["github.com/sirupsen/logrus"] - sumVersion = "v1.7.0" - ["github.com/sirupsen/logrus".fetch] - type = "git" - url = "https://github.com/sirupsen/logrus" - rev = "6699a89a232f3db797f2e280639854bbc4b89725" - sha256 = "1a59pw7zimvm8k423iq9l4f4qjj1ia1xc6pkmhwl2mxc46y2n442" - -["github.com/stretchr/testify"] - sumVersion = "v1.2.2" - ["github.com/stretchr/testify".fetch] - type = "git" - url = "https://github.com/stretchr/testify" - rev = "f35b8ab0b5a2cef36673838d662e249dd9c94686" - sha256 = "0dlszlshlxbmmfxj5hlwgv3r22x0y1af45gn1vd198nvvs3pnvfs" - -["golang.org/x/crypto"] - sumVersion = "v0.0.0-20191011191535-87dc89f01550" - ["golang.org/x/crypto".fetch] - type = "git" - url = "https://go.googlesource.com/crypto" - rev = "87dc89f01550277dc22b74ffcf4cd89fa2f40f4c" - sha256 = "0z4i1m2yn3f31ci7wvcm2rxkx2yiv7a78mfzklncmsz2k97rlh2g" - -["golang.org/x/mod"] - sumVersion = "v0.3.0" - ["golang.org/x/mod".fetch] - type = "git" - url = "https://go.googlesource.com/mod" - rev = "859b3ef565e237f9f1a0fb6b55385c497545680d" - sha256 = "0ldgbx2zpprbsfn6p8pfgs4nn87gwbfcv2z0fa7n8alwsq2yw78q" - -["golang.org/x/net"] - sumVersion = "v0.0.0-20190620200207-3b0461eec859" - ["golang.org/x/net".fetch] - type = "git" - url = "https://go.googlesource.com/net" - rev = "3b0461eec859c4b73bb64fdc8285971fd33e3938" - sha256 = "0l00c8l0a8xnv6qdpwfzxxsr58jggacgzdrwiprrfx2xqm37b6d5" - -["golang.org/x/sync"] - sumVersion = "v0.0.0-20190423024810-112230192c58" - ["golang.org/x/sync".fetch] - type = "git" - url = "https://go.googlesource.com/sync" - rev = "112230192c580c3556b8cee6403af37a4fc5f28c" - sha256 = "05i2k43j2d0llq768hg5pf3hb2yhfzp9la1w5wp0rsnnzblr0lfn" - -["golang.org/x/sys"] - sumVersion = "v0.0.0-20191026070338-33540a1f6037" - ["golang.org/x/sys".fetch] - type = "git" - url = "https://go.googlesource.com/sys" - rev = "33540a1f603772f9d4b761f416f5c10dade23e96" - sha256 = "0fjcv0vzvi6za0b4xmnk3932pr9f9gczzf03y0kgq3ry9rqg169y" - -["golang.org/x/text"] - sumVersion = "v0.3.0" - ["golang.org/x/text".fetch] - type = "git" - url = "https://go.googlesource.com/text" - rev = "f21a4dfb5e38f5895301dc265a8def02365cc3d0" - sha256 = "0r6x6zjzhr8ksqlpiwm5gdd7s209kwk5p4lw54xjvz10cs3qlq19" - -["golang.org/x/tools"] - sumVersion = "v0.0.0-20191119224855-298f0cb1881e" - ["golang.org/x/tools".fetch] - type = "git" - url = "https://go.googlesource.com/tools" - rev = "298f0cb1881e71e68bc5bc17757fabe78a426460" - sha256 = "0l4pqwib2wnfnix6nvxl0yrq87ipi7ff1rz6z5bxfzy9dki1nzmv" - -["golang.org/x/xerrors"] - sumVersion = "v0.0.0-20191011141410-1b5146add898" - ["golang.org/x/xerrors".fetch] - type = "git" - url = "https://go.googlesource.com/xerrors" - rev = "1b5146add8981d58be77b16229c0ff0f8bebd8c1" - sha256 = "0w2akj91krxjag0xdhsg78470888nicc5ismc2ap9jqpss6v1zih" +[mod] + [mod."github.com/BurntSushi/toml"] + version = "v0.3.1" + hash = "sha256-Rqak1dE/Aj/+Kx1/pl3Hifgt+Q3OzuZ5fJR+/x3nTbo=" + [mod."github.com/alecthomas/kong"] + version = "v0.5.0" + hash = "sha256-6OtTXBnZSVvbdgkAfah2EuX20Fg/2v3JRSnKq1QoJbA=" + [mod."github.com/alecthomas/participle/v2"] + version = "v2.0.0-alpha7" + hash = "sha256-Iy3/FxQ9kb0rp7N7olD/FuMNEja3OtPce61uGKjWReE=" + [mod."github.com/alecthomas/repr"] + version = "v0.0.0-20210801044451-80ca428c5142" + hash = "sha256-XUx+sN0wtc1j4t83sa5Z2MOBHxYQUUfsFfgfBeZqCUQ=" + [mod."github.com/davecgh/go-spew"] + version = "v1.1.1" + hash = "sha256-nhzSUrE1fCkN0+RL04N4h8jWmRFPPPWbCuDc7Ss0akI=" + [mod."github.com/google/go-cmp"] + version = "v0.5.5" + hash = "sha256-pyfTIu1fx6cGYHhm+yi8YP2TgERnnqKRjqSV7WGb1Yk=" + [mod."github.com/kr/pretty"] + version = "v0.1.0" + hash = "sha256-Fx+TaNrxW0VfzonT2jnd5MU09RRz7GJZkqAtJR6/pKI=" + [mod."github.com/kr/pty"] + version = "v1.1.1" + hash = "sha256-AVeS+ivwNzIrgWQaLtsmO2f2MYGpxIVqdac/EzaYI1Q=" + [mod."github.com/kr/text"] + version = "v0.1.0" + hash = "sha256-QT65kTrNypS5GPWGvgnCpGLPlVbQAL4IYvuqAKhepb4=" + [mod."github.com/nix-community/go-nix"] + version = "v0.0.0-20220528121639-b940fb0a12d8" + hash = "sha256-r6fq1mu0gRFqdI6msuAZp3ZoncAw5L16oBFPUA9vPYk=" + [mod."github.com/pkg/errors"] + version = "v0.9.1" + hash = "sha256-mNfQtcrQmu3sNg/7IwiieKWOgFQOVVe2yXgKBpe/wZw=" + [mod."github.com/pmezard/go-difflib"] + version = "v1.0.0" + hash = "sha256-/FtmHnaGjdvEIKAJtrUfEhV7EVo5A/eYrtdnUkuxLDA=" + [mod."github.com/sirupsen/logrus"] + version = "v1.7.0" + hash = "sha256-VClDP4DJDdMFTMGWR7I8L4hQRMU7cOphLRyUfxCvnNY=" + [mod."github.com/stretchr/objx"] + version = "v0.1.0" + hash = "sha256-az0Vd4MG3JXfaYbj0Q6AOmNkrXgmXDeQm8+BBiDXmdA=" + [mod."github.com/stretchr/testify"] + version = "v1.7.0" + hash = "sha256-t1I9uCrn9vSUu/z5IZuNyGShmbOcJ6UGc2f75ZBrHzE=" + [mod."golang.org/x/crypto"] + version = "v0.0.0-20191011191535-87dc89f01550" + hash = "sha256-T0CaT5ri68osnd9VdNTZ0Ys+exaVbX4iC8MN60UNkXw=" + [mod."golang.org/x/mod"] + version = "v0.3.0" + hash = "sha256-c+KKzeDUDxrKIx8un1DpETlTK+DmHP+zUjRZrgs0ejo=" + [mod."golang.org/x/net"] + version = "v0.0.0-20190620200207-3b0461eec859" + hash = "sha256-lVNbp7zOBVbvzA1fFR4SkUskYfAMt2eILoWuDgk0oS4=" + [mod."golang.org/x/sync"] + version = "v0.0.0-20190423024810-112230192c58" + hash = "sha256-1lGQ6frW6gwuLzwomu530IsFh7vlQWQOphQ0IQeZIhY=" + [mod."golang.org/x/sys"] + version = "v0.0.0-20220519141025-dcacdad47464" + hash = "sha256-N4P3QkaeRf05dFMadS1IvhkNV4VS6cf/zkTBY1zwWv4=" + [mod."golang.org/x/text"] + version = "v0.3.0" + hash = "sha256-0FFbaxF1ZuAQF3sCcA85e8MO6prFeHint36inija4NY=" + [mod."golang.org/x/tools"] + version = "v0.0.0-20191119224855-298f0cb1881e" + hash = "sha256-xhp3MWK3dr+PJgfOGaFAURPdw/ar+GRb+wHBnCG8Tg0=" + [mod."golang.org/x/xerrors"] + version = "v0.0.0-20191204190536-9bdfabe68543" + hash = "sha256-DCyizuMVp9AhKGv0vL/iRZz/R6jWFmQxDWj1NFeITvo=" + [mod."gopkg.in/check.v1"] + version = "v1.0.0-20180628173108-788fd7840127" + hash = "sha256-KsRJNTprd1UijnJusbHwQGM7Bdm45Jt/QL+cIUGNa2w=" + [mod."gopkg.in/yaml.v2"] + version = "v2.2.2" + hash = "sha256-SjNLmGSxoYabOi/zdjymW3mSgaxaS39btBQ3/aUIkgc=" + [mod."gopkg.in/yaml.v3"] + version = "v3.0.0-20210107192922-496545a6307b" + hash = "sha256-j8yDji+vqsitpRZirpb4w/Em8nstgf28wpwkcrOlxBk="