31516eb9cd
Without this, we would end up with "double" store paths like this: /nix/store/848js1fvbjniv5n00hifmhgzzszl97vv--nix-store-ad6piq18wdkxnfzsbyn88ixvv7gfb1dp-main.go.drv We really only care about the `main.go` bit though. Change-Id: Ib0644781a0e232a45e1cae3dd05b9b828c9087ee Reviewed-on: https://cl.tvl.fyi/c/depot/+/1321 Tested-by: BuildkiteCI Reviewed-by: ericvolp12 <ericvolp12@gmail.com>
34 lines
880 B
Nix
34 lines
880 B
Nix
# SPDX-License-Identifier: Apache-2.0
|
|
#
|
|
# A crude wrapper around //nix/buildGo that supports the Go 2 alpha.
|
|
#
|
|
# The way the alpha is implemented is via a transpiler from typed to
|
|
# untyped Go.
|
|
{ depot, pkgs, ... }:
|
|
|
|
let
|
|
inherit (builtins)
|
|
baseNameOf
|
|
stringLength
|
|
substring;
|
|
|
|
inherit (depot.nix.buildGo) gpackage program;
|
|
|
|
go2goext = file: substring 0 ((stringLength file) - 1) file;
|
|
go2go = file: pkgs.runCommandNoCC "${go2goext (baseNameOf file)}" {} ''
|
|
cp ${file} .
|
|
${pkgs.go}/bin/go tool go2go translate *.go2
|
|
mv *.go $out
|
|
'';
|
|
|
|
in rec {
|
|
program = { name, srcs, deps ? [], x_defs ? {} }: depot.nix.buildGo.program {
|
|
inherit name deps x_defs;
|
|
srcs = map go2go srcs;
|
|
};
|
|
|
|
package = { name, srcs, deps ? [], path ? name, sfiles ? [] }: depot.nix.buildGo.package {
|
|
inherit name deps path sfiles;
|
|
srcs = map go2go srcs;
|
|
};
|
|
}
|