diff --git a/hosts/yodaTab/configuration.nix b/hosts/yodaTab/configuration.nix index 7113772..215c97a 100644 --- a/hosts/yodaTab/configuration.nix +++ b/hosts/yodaTab/configuration.nix @@ -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 diff --git a/hosts/yodaTux/configuration.nix b/hosts/yodaTux/configuration.nix index c363710..9235a01 100644 --- a/hosts/yodaTux/configuration.nix +++ b/hosts/yodaTux/configuration.nix @@ -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 diff --git a/hosts/yodaYoga/configuration.nix b/hosts/yodaYoga/configuration.nix index 1be910d..47cf713 100644 --- a/hosts/yodaYoga/configuration.nix +++ b/hosts/yodaYoga/configuration.nix @@ -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 diff --git a/modules/docker-pushrm-pkg.nix b/modules/docker-pushrm-pkg.nix new file mode 100644 index 0000000..f83823e --- /dev/null +++ b/modules/docker-pushrm-pkg.nix @@ -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 ]; + }; +} + diff --git a/modules/docker-pushrm.nix b/modules/docker-pushrm.nix new file mode 100644 index 0000000..903b363 --- /dev/null +++ b/modules/docker-pushrm.nix @@ -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 { } + ) + ]; +}