I’ve got the following overlay to install macOS Docker desktop app.
The postInstall phase fails with this message:
...
ln: failed to create symbolic link '/homeless-shelter/.nix-profile/bin/docker': No such file or directory
Without defining postInstall, Docker.app is happily installed, and symlinked into ~/.nix-profile/Applications/.
To add the executables to the PATH I was thinking that I’d try to symlink them into ~/.nix-profiles/bin/[docker | docker-compose].
Are there builtin functions I should be using? Or what is the right way to do this?
self: super: {
installApplication =
{ name, appname ? name, version, src, description, homepage,
postInstall ? "", sourceRoot ? ".", ... }:
with super; stdenv.mkDerivation {
name = "${name}-${version}";
version = "${version}";
src = src;
buildInputs = [ undmg unzip ];
sourceRoot = sourceRoot;
phases = [ "unpackPhase" "installPhase" "postInstall" ];
installPhase = ''
mkdir -p "$out/Applications/${appname}.app"
cp -pR * "$out/Applications/${appname}.app"
'';
postInstall = postInstall;
meta = with stdenv.lib; {
description = description;
homepage = homepage;
maintainers = with maintainers; [ jwiegley ];
platforms = platforms.darwin;
};
};
Docker = self.installApplication rec {
name = "Docker";
version = "2.2.0.4";
revision = "43472";
sourceRoot = "Docker.app";
src = super.fetchurl {
url = "https://download.docker.com/mac/stable/${revision}/Docker.dmg";
sha256 = "defb095871ef260ccdb77d9960ed8510bdb288124025404f6543b94ec683e160";
# https://github.com/Homebrew/homebrew-cask/blob/385b6e34d564582bf7708bd306e940693b287d42/Casks/docker.rb
};
description = ''
Docker CE for Mac is an easy-to-install desktop app for building,
debugging, and testing Dockerized apps on a Mac
'';
homepage = https://store.docker.com/editions/community/docker-ce-desktop-mac;
appcast = https://download.docker.com/mac/stable/appcast.xml;
postInstall = ''
ln -fs $out/Applications/${name}.app/Contents/Resources/bin/docker ~/.nix-profile/bin/docker
ln -fs $out/Applications/${name}.app/Contents/Resources/bin/docker-compose/docker-compose ~/.nix-profile/bin/docker-compose
'';
};
}