add docker-pushrm package

This commit is contained in:
Daniel Langbein 2023-09-21 13:09:15 +02:00
parent e4e8cd72ee
commit 3833e08014
Signed by: langfingaz
GPG Key ID: 6C47C753F0823002
5 changed files with 77 additions and 0 deletions

View File

@ -47,6 +47,7 @@ in
#../../modules/android.nix
#../../modules/podman.nix
#../../modules/docker.nix
#../../modules/docker-pushrm.nix
../../modules/lid-switch-handling.nix
../../modules/sendmail-mta.nix
../../modules/journalwatch.nix

View File

@ -47,6 +47,7 @@ in
../../modules/android.nix
#../../modules/podman.nix
../../modules/docker.nix
../../modules/docker-pushrm.nix
../../modules/lid-switch-handling.nix
../../modules/sendmail-mta.nix
../../modules/journalwatch.nix

View File

@ -49,6 +49,7 @@ in
#../../modules/android.nix
#../../modules/podman.nix
../../modules/docker.nix
#../../modules/docker-pushrm.nix
../../modules/lid-switch-handling.nix
../../modules/sendmail-mta.nix
../../modules/journalwatch.nix

View File

@ -0,0 +1,53 @@
{ pkgs, lib, buildGoModule, fetchFromGitHub }:
# TODO: `docker pushrm` does not work, however `docker-pushrm` does.
# docker-compose plugin: https://github.com/NixOS/nixpkgs/blob/master/pkgs/applications/virtualization/docker/compose.nix
buildGoModule rec {
pname = "docker-pushrm";
version = "1.9.0";
src = fetchFromGitHub {
owner = "christian-korneck";
repo = "docker-pushrm";
rev = "v${version}";
# To get the hash, set its value to "" and start a build.
# https://nixos.org/manual/nixpkgs/stable/#sec-source-hashes
hash = "sha256-caQoI0P4oMoTamKLnz2NE/B9yp3NXupnTXi4k4Zbs6s=";
};
# To get the hash, set its value to "" and start a build.
# https://nixos.org/manual/nixpkgs/stable/#sec-source-hashes
vendorHash = "sha256-ZwPW6pOzUBYWitUBMW59DrrPZdTDAgCiN04MdQYvX0U=";
# docker-sbom plugin: https://github.com/NixOS/nixpkgs/blob/50491a3493d365abd88ab08124cfc1be9f29ea42/pkgs/applications/virtualization/docker/sbom.nix#L26
#nativeBuildInputs = with pkgs; [ docker ];
# To reduce the size of the resulting binary, you can strip off information not needed during execution. Using -ldflags followed by -s -w flags makes the resulting binary slightly lighter.
# https://opensource.com/article/22/4/go-build-options
ldflags = [ "-s" "-w" ];
installPhase = ''
runHook preInstall
install -Dm0777 $GOPATH/bin/docker-pushrm $out/libexec/docker/cli-plugins/docker-pushrm
mkdir -p $out/bin
ln -s $out/libexec/docker/cli-plugins/docker-pushrm $out/bin/docker-pushrm
runHook postInstall
'';
meta = with lib; {
description = "'Docker Push Readme' - a Docker CLI plugin to update container repo docs";
lonDescription = ''
docker-pushrm is a Docker CLI plugin that adds a new docker pushrm (speak: "push readme") command to Docker.
It pushes the README file from the current working directory to a container registry server where it appears as repo description in the webinterface.
It currently supports Dockerhub (cloud), Red Hat Quay (cloud and self-hosted/OpenShift) and Harbor v2 (self-hosted).
For most registry types docker-pushrm uses authentication info from the Docker credentials store - so it "just works" for registry servers that you're already logged into with Docker.
(For some other registry types, you'll need to pass an API key via env var or config file).
'';
homepage = "https://github.com/christian-korneck/docker-pushrm";
license = licenses.mit;
maintainers = with maintainers; [ langbeindaniel ];
};
}

21
modules/docker-pushrm.nix Normal file
View File

@ -0,0 +1,21 @@
{ config, pkgs, lib, ... }:
{
lib.maintainers = {
langbeindaniel = {
name = "Daniel Langbein";
email = "daniel@systemli.org";
keys = [{
fingerprint = "94F3 D3DD AC22 8022 58FC 044B 6C47 C753 F082 3002";
}];
};
};
environment.systemPackages = with pkgs; [
(
# callPackage is a function that automagically figures out which arguments your function wants, and then provides them from its own set. This pill explains it well: https://nixos.org/guides/nix-pills/callpackage-design-pattern.html
# https://discourse.nixos.org/t/undefined-variable-fetchfromgithub/14315/2
pkgs.callPackage ./docker-pushrm-pkg.nix { }
)
];
}