about summary refs log tree commit diff
path: root/pkgs/misc/fastly/default.nix
diff options
context:
space:
mode:
authorSoner Sayakci <s.sayakci@shopware.com>2022-04-24 09:50:16 +0000
committerRafael Fernández López <ereslibre@ereslibre.es>2022-06-29 16:39:49 +0200
commit9d7932e349942db74ec2c3a7030085c77d7a3716 (patch)
tree45d9c4cd56825583e0f3385177d7bd032b986879 /pkgs/misc/fastly/default.nix
parentf2a54d2d8ad8192375257acf69059a1bf3b28577 (diff)
fastly: init at 3.1.0
Diffstat (limited to 'pkgs/misc/fastly/default.nix')
-rw-r--r--pkgs/misc/fastly/default.nix56
1 files changed, 56 insertions, 0 deletions
diff --git a/pkgs/misc/fastly/default.nix b/pkgs/misc/fastly/default.nix
new file mode 100644
index 0000000000000..1a376271d18d5
--- /dev/null
+++ b/pkgs/misc/fastly/default.nix
@@ -0,0 +1,56 @@
+{ lib, fetchFromGitHub, installShellFiles, buildGoModule }:
+
+buildGoModule rec {
+  pname = "fastly";
+  version = "3.1.0";
+
+  src = fetchFromGitHub {
+    owner = "fastly";
+    repo = "cli";
+    rev = "v${version}";
+    sha256 = "sha256-Su4ZwiuI+pMoLAGhc3dWcwgcfwe5cZGTg8kEnpM4JbA=";
+    # The git commit is part of the `fastly version` original output;
+    # leave that output the same in nixpkgs. Use the `.git` directory
+    # to retrieve the commit SHA, and remove the directory afterwards,
+    # since it is not needed after that.
+    leaveDotGit = true;
+    postFetch = ''
+      cd "$out"
+      git rev-parse --short HEAD > $out/COMMIT
+      find "$out" -name .git -print0 | xargs -0 rm -rf
+    '';
+  };
+
+  subPackages = [ "cmd/fastly" ];
+
+  vendorSha256 = "sha256-5MvJS10f7YLvO+wCmUJleU27hCJbsNrOIfUZnniGw+E=";
+
+  nativeBuildInputs = [ installShellFiles ];
+
+  # Flags as provided by the build automation of the project:
+  #   https://github.com/fastly/cli/blob/7844f9f54d56f8326962112b5534e5c40e91bf09/.goreleaser.yml#L14-L18
+  ldflags = [
+    "-s"
+    "-w"
+    "-X github.com/fastly/cli/pkg/revision.AppVersion=v${version}"
+    "-X github.com/fastly/cli/pkg/revision.Environment=release"
+  ];
+  preBuild = ''
+    ldflags+=" -X github.com/fastly/cli/pkg/revision.GitCommit=$(cat COMMIT)"
+    ldflags+=" -X 'github.com/fastly/cli/pkg/revision.GoVersion=$(go version)'"
+  '';
+
+  postInstall = ''
+    export HOME="$(mktemp -d)"
+    installShellCompletion --cmd fastly \
+      --bash <($out/bin/fastly --completion-script-bash) \
+      --zsh <($out/bin/fastly --completion-script-zsh)
+  '';
+
+  meta = with lib; {
+    description = "Command line tool for interacting with the Fastly API";
+    license = licenses.asl20;
+    homepage = "https://github.com/fastly/cli";
+    maintainers = with maintainers; [ ereslibre shyim ];
+  };
+}