A small Nix flake that packages
docker-extras, the
docker extras Docker CLI plugin, from its prebuilt release archives. It
gives you nix build, nix run, an overlay, and a home-manager module that
makes docker extras work.
A flake cannot pin the SHA-256 of a release archive inside the same tagged commit that the archive is built from. The tag freezes its tree before the archive exists. docker-extras.nix keeps the pin in a separate repo, as duo.nix does:
- a committed
VERSION.json(pure eval) - an
update.shthat prefetches the already-published archives - a scheduled workflow that commits and tags when the version changes
Nobody builds docker-extras from source, and the packaged version always matches a published release.
- Each docker-extras release publishes one
docker-extras-<os>-<arch>.tar.gzper system, holdingplugin/docker-extrasandLICENSE, plus aSHA256SUMSfile. VERSION.jsonholds the release tag, and the archive URL and SHA-256 hash for each system. Nix verifies the hash on every build.update.shalso refuses any hash that does not match the release'sSHA256SUMS.- The binary is a static Go build. It is installed byte-for-byte, with no
patchelf and no wrapper, and it runs on any Linux host, NixOS included.
meta.sourceProvenanceisbinaryNativeCode. - Package layout:
libexec/docker/cli-plugins/docker-extras: the Docker CLI pluginbin/docker-extras: the same binary, fornix runand direct callsshare/licenses/docker-extras/LICENSE
aarch64-darwin, aarch64-linux, x86_64-linux.
No
x86_64-darwin. docker-extras publishes an Intel-macOS archive, but nixpkgs 26.11 (thenixos-unstableinput here) droppedx86_64-darwin. On Intel macOS, use the docker-extras installer script from the release page.
Docker looks for CLI plugins in ~/.docker/cli-plugins (or
$DOCKER_CONFIG/cli-plugins), not on PATH. So installing the package alone
does not give you docker extras. Use the home-manager module, or link the
plugin yourself.
# flake.nix
{
inputs.docker-extras.url = "github:procrastivity/docker-extras.nix";
# ...
}
# home.nix (with inputs passed as extraSpecialArgs)
{ inputs, ... }:
{
imports = [ inputs.docker-extras.homeManagerModules.default ];
programs.docker-extras.enable = true;
}| Option | Default | Meaning |
|---|---|---|
programs.docker-extras.enable |
false |
link the plugin into the Docker plugin directory |
programs.docker-extras.package |
this flake's package | the package to link |
programs.docker-extras.pluginName |
"extras" |
Docker command name: "tools" gives docker tools |
programs.docker-extras.dockerConfigDir |
".docker" |
Docker config directory, relative to home; change it only when DOCKER_CONFIG points elsewhere |
The binary takes its command name from its own file name, so pluginName
only changes the link name.
nix build github:procrastivity/docker-extras.nix
mkdir -p ~/.docker/cli-plugins
ln -sf "$(readlink -f result)/libexec/docker/cli-plugins/docker-extras" ~/.docker/cli-plugins/docker-extras
docker extras volume seed --helpnix run github:procrastivity/docker-extras.nix -- volume seed --help{ inputs, ... }:
{
nixpkgs.overlays = [ inputs.docker-extras.overlays.default ];
# pkgs.docker-extras is now available
}./update.sh asks GitHub for the latest stable vX.Y.Z release of
docker-extras. When it differs from rev in VERSION.json, the script:
- downloads the release's
SHA256SUMS; - prefetches each archive and checks its hash against
SHA256SUMS; - writes
VERSION.json; - builds the host package (
nix build .#docker-extras).
When nothing changed, it does nothing. It works without authentication, but it
uses GITHUB_TOKEN when that is set, to avoid rate limits.
The .github/workflows/cron.yml workflow runs
update.sh daily (and on manual dispatch). It commits and pushes an annotated
tag only when the version changes.