1
0
mirror of https://github.com/goreleaser/goreleaser.git synced 2025-02-03 13:11:48 +02:00
Carlos Alexandro Becker 1e0d269c97
fix(nix): sourceRoot when using archives.wrap_in_directory (#4550)
If `archives.[*].wrap_in_directory` is set, it'll create a folder inside
the archive file, usually something like `app_goos_goarch`.

In those cases, the root of the archive is not constant, so we create a
`sourceRootMap` and use it instead.

In cases where the `sourceRoot` is constant, the generated derivation
will be the same.

refs https://github.com/orgs/goreleaser/discussions/4549

Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>
2024-01-18 12:59:04 -03:00

140 lines
3.2 KiB
Nix

# This file was generated by GoReleaser. DO NOT EDIT.
# vim: set ft=nix ts=2 sw=2 sts=2 et sta
{
system ? builtins.currentSystem
, pkgs
, lib
, fetchurl
, installShellFiles
{{- if .Dependencies }}
, makeWrapper
, stdenvNoCC
{{- end -}}
{{- range $index, $element := .Dependencies }}
, {{ . -}}
{{- end }}
}:
let
shaMap = {
{{- with .Archives.linux386.Sha }}
i686-linux = "{{ . }}";
{{- end }}
{{- with .Archives.linuxamd64.Sha }}
x86_64-linux = "{{ . }}";
{{- end }}
{{- with .Archives.linuxarm6.Sha }}
armv6l-linux = "{{ . }}";
{{- end }}
{{- with .Archives.linuxarm7.Sha }}
armv7l-linux = "{{ . }}";
{{- end }}
{{- with .Archives.linuxarm64.Sha }}
aarch64-linux = "{{ . }}";
{{- end }}
{{- with .Archives.darwinamd64.Sha }}
x86_64-darwin = "{{ . }}";
{{- end }}
{{- with .Archives.darwinarm64.Sha }}
aarch64-darwin = "{{ . }}";
{{- end }}
};
urlMap = {
{{- with .Archives.linux386.URL }}
i686-linux = "{{ . }}";
{{- end }}
{{- with .Archives.linuxamd64.URL }}
x86_64-linux = "{{ . }}";
{{- end }}
{{- with .Archives.linuxarm6.URL }}
armv6l-linux = "{{ . }}";
{{- end }}
{{- with .Archives.linuxarm7.URL }}
armv7l-linux = "{{ . }}";
{{- end }}
{{- with .Archives.linuxarm64.URL }}
aarch64-linux = "{{ . }}";
{{- end }}
{{- with .Archives.darwinamd64.URL }}
x86_64-darwin = "{{ . }}";
{{- end }}
{{- with .Archives.darwinarm64.URL }}
aarch64-darwin = "{{ . }}";
{{- end }}
};
{{- if not .SourceRoot }}
sourceRootMap = {
{{- with .SourceRoots.linux386 }}
i686-linux = "{{ . }}";
{{- end }}
{{- with .SourceRoots.linuxamd64 }}
x86_64-linux = "{{ . }}";
{{- end }}
{{- with .SourceRoots.linuxarm6 }}
armv6l-linux = "{{ . }}";
{{- end }}
{{- with .SourceRoots.linuxarm7 }}
armv7l-linux = "{{ . }}";
{{- end }}
{{- with .SourceRoots.linuxarm64 }}
aarch64-linux = "{{ . }}";
{{- end }}
{{- with .SourceRoots.darwinamd64 }}
x86_64-darwin = "{{ . }}";
{{- end }}
{{- with .SourceRoots.darwinarm64 }}
aarch64-darwin = "{{ . }}";
{{- end }}
};
{{- end }}
in
pkgs.stdenvNoCC.mkDerivation {
pname = "{{ .Name }}";
version = "{{ .Version }}";
src = fetchurl {
url = urlMap.${system};
sha256 = shaMap.${system};
};
sourceRoot = {{ with .SourceRoot }}"{{ . }}"{{ else }}sourceRootMap.${system}{{ end }};
nativeBuildInputs = [ {{ range $input, $plat := .Inputs }}{{ . }} {{ end }}];
installPhase = ''
{{- range $index, $element := .Install }}
{{ . -}}
{{- end }}
'';
{{- with .PostInstall }}
postInstall = ''
{{- range $index, $element := . }}
{{ . -}}
{{- end }}
'';
{{- end }}
system = system;
meta = {
{{- with .Description }}
description = "{{ . }}";
{{- end }}
{{- with .Homepage }}
homepage = "{{ . }}";
{{- end }}
{{- with .License }}
license = lib.licenses.{{ . }};
{{- end }}
sourceProvenance = [ lib.sourceTypes.binaryNativeCode ];
platforms = [
{{- range $index, $plat := .Platforms }}
"{{ . }}"
{{- end }}
];
};
}