nixpkgs/pkgs/by-name/do/docker-credential-helpers/package.nix
aleksana 571c71e6f7 treewide: migrate packages to pkgs/by-name, take 1
We are migrating packages that meet below requirements:

1. using `callPackage`
2. called path is a directory
3. overriding set is empty (`{ }`)
4. not containing path expressions other than relative path (to
makenixpkgs-vet happy)
5. not referenced by nix files outside of the directory, other
than`pkgs/top-level/all-packages.nix`
6. not referencing nix files outside of the directory
7. not referencing `default.nix` (since it's changed to `package.nix`)
8. `outPath` doesn't change after migration

The tool is here: https://github.com/Aleksanaa/by-name-migrate.
2024-11-09 20:04:51 +08:00

54 lines
1.5 KiB
Nix

{ lib, stdenv, buildGoModule, fetchFromGitHub, pkg-config, libsecret, testers, docker-credential-helpers }:
buildGoModule rec {
pname = "docker-credential-helpers";
version = "0.8.2";
src = fetchFromGitHub {
owner = "docker";
repo = pname;
rev = "v${version}";
sha256 = "sha256-LFXSfb4JnlacSZVnIf+5/A+KefARYadEGDzGtcSDJBw=";
};
vendorHash = null;
nativeBuildInputs = lib.optionals stdenv.hostPlatform.isLinux [ pkg-config ];
buildInputs = lib.optionals stdenv.hostPlatform.isLinux [ libsecret ];
ldflags = [
"-s"
"-w"
"-X github.com/docker/docker-credential-helpers/credentials.Version=${version}"
];
buildPhase =
let
cmds = if stdenv.hostPlatform.isDarwin then [ "osxkeychain" "pass" ] else [ "secretservice" "pass" ];
in
''
for cmd in ${builtins.toString cmds}; do
go build -ldflags "${builtins.toString ldflags}" -trimpath -o bin/docker-credential-$cmd ./$cmd/cmd
done
'';
installPhase = ''
install -Dm755 -t $out/bin bin/docker-credential-*
'';
passthru.tests.version = testers.testVersion {
package = docker-credential-helpers;
command = "docker-credential-pass version";
};
meta = with lib; {
description = "Suite of programs to use native stores to keep Docker credentials safe";
homepage = "https://github.com/docker/docker-credential-helpers";
license = licenses.mit;
maintainers = [ ];
} // lib.optionalAttrs stdenv.hostPlatform.isDarwin {
mainProgram = "docker-credential-osxkeychain";
};
}