about summary refs log tree commit diff
path: root/nixpkgs/pkgs/tools/admin/granted/default.nix
diff options
context:
space:
mode:
Diffstat (limited to 'nixpkgs/pkgs/tools/admin/granted/default.nix')
-rw-r--r--nixpkgs/pkgs/tools/admin/granted/default.nix60
1 files changed, 60 insertions, 0 deletions
diff --git a/nixpkgs/pkgs/tools/admin/granted/default.nix b/nixpkgs/pkgs/tools/admin/granted/default.nix
new file mode 100644
index 000000000000..ed2bc901826d
--- /dev/null
+++ b/nixpkgs/pkgs/tools/admin/granted/default.nix
@@ -0,0 +1,60 @@
+{ bash
+, buildGoModule
+, fetchFromGitHub
+, fish
+, lib
+, makeWrapper
+, xdg-utils
+}:
+
+buildGoModule rec {
+  pname = "granted";
+  version = "0.13.0";
+
+  src = fetchFromGitHub {
+    owner = "common-fate";
+    repo = pname;
+    rev = "v${version}";
+    sha256 = "sha256-UoU2+RBR6vBLRx5gJsVUswoEtZ8chCn+bSv+k4SCGyU=";
+  };
+
+  vendorHash = "sha256-P7HeJUdVlqrTEMVXGlvcCr9ezEmqIw5AX/+xdcFQoH4=";
+
+  nativeBuildInputs = [ makeWrapper ];
+
+  ldflags = [
+    "-s"
+    "-w"
+    "-X github.com/common-fate/granted/internal/build.Version=v${version}"
+    "-X github.com/common-fate/granted/internal/build.Commit=${src.rev}"
+    "-X github.com/common-fate/granted/internal/build.Date=1970-01-01-00:00:01"
+    "-X github.com/common-fate/granted/internal/build.BuiltBy=Nix"
+  ];
+
+  subPackages = [
+    "cmd/granted"
+  ];
+
+  postInstall = ''
+    # Install shell script
+    install -Dm755 $src/scripts/assume $out/bin/assume
+    substituteInPlace $out/bin/assume \
+      --replace /bin/bash ${bash}/bin/bash
+
+    wrapProgram $out/bin/assume \
+      --suffix PATH : ${lib.makeBinPath [ xdg-utils ]}
+
+    # Install fish script
+    install -Dm755 $src/scripts/assume.fish $out/share/assume.fish
+    substituteInPlace $out/share/assume.fish \
+      --replace /bin/fish ${fish}/bin/fish
+  '';
+
+  meta = with lib; {
+    description = "The easiest way to access your cloud.";
+    homepage = "https://github.com/common-fate/granted";
+    changelog = "https://github.com/common-fate/granted/releases/tag/${version}";
+    license = licenses.mit;
+    maintainers = [ maintainers.ivankovnatsky ];
+  };
+}