diff --git a/pkgs/development/tools/doctl/default.nix b/pkgs/development/tools/doctl/default.nix index 2aead3940ad8..f84167afca84 100644 --- a/pkgs/development/tools/doctl/default.nix +++ b/pkgs/development/tools/doctl/default.nix @@ -1,34 +1,43 @@ -{ stdenv, buildGoPackage, fetchFromGitHub }: +{ lib, buildGoPackage, fetchFromGitHub, installShellFiles }: buildGoPackage rec { pname = "doctl"; - version = "${major}.${minor}.${patch}"; - major = "1"; - minor = "35"; - patch = "0"; + version = "1.40.0"; + goPackagePath = "github.com/digitalocean/doctl"; - excludedPackages = ''\(doctl-gen-doc\|install-doctl\|release-doctl\)''; - buildFlagsArray = let t = goPackagePath; in '' - -ldflags= - -X ${t}.Major=${major} - -X ${t}.Minor=${minor} - -X ${t}.Patch=${patch} - -X ${t}.Label=release - ''; + subPackages = [ "cmd/doctl" ]; + + buildFlagsArray = '' + -ldflags= + -X ${goPackagePath}.Major=${lib.versions.major version} + -X ${goPackagePath}.Minor=${lib.versions.minor version} + -X ${goPackagePath}.Patch=${lib.versions.patch version} + -X ${goPackagePath}.Label=release + ''; + + nativeBuildInputs = [ installShellFiles ]; + + postInstall = '' + export HOME=$(mktemp -d) # attempts to write to /homeless-shelter + for shell in bash fish zsh; do + $bin/bin/doctl completion $shell > doctl.$shell + installShellCompletion doctl.$shell + done + ''; src = fetchFromGitHub { - owner = "digitalocean"; - repo = "doctl"; - rev = "v${version}"; - sha256 = "1blg4xd01vvr8smpii60jlk7rg1cg64115azixw9q022f7cnfiyw"; + owner = "digitalocean"; + repo = "doctl"; + rev = "v${version}"; + sha256 = "1x8rr3707mmbfnjn3ck0953xkkrfq5r8zflbxpkqlfz9k978z835"; }; - meta = { + meta = with lib; { description = "A command line tool for DigitalOcean services"; - homepage = https://github.com/digitalocean/doctl; - license = stdenv.lib.licenses.asl20; - platforms = stdenv.lib.platforms.all; - maintainers = [ stdenv.lib.maintainers.siddharthist ]; + homepage = "https://github.com/digitalocean/doctl"; + license = licenses.asl20; + platforms = platforms.all; + maintainers = [ maintainers.siddharthist ]; }; }