modules/homebrew: add postinstall option for brews and casks
Both `brew bundle` formula and cask installers support a `postinstall` option -- a shell command to run after the package is installed or upgraded. The command only executes when the package actually changed, not on every `brew bundle` run. Examples from the Homebrew docs added to the `homebrew.brews` and `homebrew.casks` option examples and tests.
This commit is contained in:
parent
a3fd89f1bb
commit
c65c24c87c
2 changed files with 39 additions and 0 deletions
|
|
@ -476,6 +476,16 @@ let
|
|||
linked and keg-only.
|
||||
'';
|
||||
};
|
||||
postinstall = mkNullOrStrOption {
|
||||
description = ''
|
||||
A shell command to run after the formula is installed or upgraded. The command is passed
|
||||
to the system shell and only executes when the formula actually changed (was freshly
|
||||
installed or upgraded), not on every {command}`brew bundle` run.
|
||||
'';
|
||||
};
|
||||
# `version_file` is intentionally not exposed: it writes the installed version to a file
|
||||
# path relative to the `brew bundle` working directory, which is not meaningful during
|
||||
# nix-darwin system activation.
|
||||
|
||||
brewfileLine = mkInternalOption { type = types.nullOr types.str; };
|
||||
};
|
||||
|
|
@ -517,6 +527,13 @@ let
|
|||
itself.
|
||||
'';
|
||||
};
|
||||
postinstall = mkNullOrStrOption {
|
||||
description = ''
|
||||
A shell command to run after the cask is installed or upgraded. The command is passed to
|
||||
the system shell and only executes when the cask was actually installed or upgraded, not
|
||||
on every {command}`brew bundle` run.
|
||||
'';
|
||||
};
|
||||
|
||||
brewfileLine = mkInternalOption { type = types.nullOr types.str; };
|
||||
};
|
||||
|
|
@ -681,6 +698,12 @@ in
|
|||
link = true;
|
||||
conflicts_with = [ "mysql" ];
|
||||
}
|
||||
|
||||
# `brew install`, run a post-install command on version changes
|
||||
{
|
||||
name = "postgresql@16";
|
||||
postinstall = "\''${HOMEBREW_PREFIX}/opt/postgresql@16/bin/postgres -D \''${HOMEBREW_PREFIX}/var/postgresql@16";
|
||||
}
|
||||
]
|
||||
'';
|
||||
description = ''
|
||||
|
|
@ -712,6 +735,12 @@ in
|
|||
name = "opera";
|
||||
greedy = true;
|
||||
}
|
||||
|
||||
# `brew install --cask`, run a post-install command on install or upgrade
|
||||
{
|
||||
name = "google-cloud-sdk";
|
||||
postinstall = "\''${HOMEBREW_PREFIX}/bin/gcloud components update";
|
||||
}
|
||||
]
|
||||
'';
|
||||
description = ''
|
||||
|
|
|
|||
|
|
@ -50,6 +50,10 @@ in
|
|||
link = true;
|
||||
conflicts_with = [ "mysql" ];
|
||||
}
|
||||
{
|
||||
name = "postgresql@16";
|
||||
postinstall = "\${HOMEBREW_PREFIX}/opt/postgresql@16/bin/postgres -D \${HOMEBREW_PREFIX}/var/postgresql@16";
|
||||
}
|
||||
];
|
||||
|
||||
homebrew.casks = [
|
||||
|
|
@ -62,6 +66,10 @@ in
|
|||
name = "opera";
|
||||
greedy = true;
|
||||
}
|
||||
{
|
||||
name = "google-cloud-sdk";
|
||||
postinstall = "\${HOMEBREW_PREFIX}/bin/gcloud components update";
|
||||
}
|
||||
];
|
||||
|
||||
homebrew.masApps = {
|
||||
|
|
@ -92,11 +100,13 @@ in
|
|||
${mkTest "imagemagick" ''brew "imagemagick"''}
|
||||
${mkTest "denji/nginx/nginx-full" ''brew "denji/nginx/nginx-full", args: ["with-rmtp"], link: :overwrite, restart_service: :always''}
|
||||
${mkTest "mysql@5.6" ''brew "mysql@5.6", conflicts_with: ["mysql"], link: true, restart_service: true''}
|
||||
${mkTest "postgresql@16" ''brew "postgresql@16", postinstall: "''${HOMEBREW_PREFIX}/opt/postgresql@16/bin/postgres -D ''${HOMEBREW_PREFIX}/var/postgresql@16"''}
|
||||
|
||||
echo "checking cask entries in Brewfile" >&2
|
||||
${mkTest "google-chrome" ''cask "google-chrome"''}
|
||||
${mkTest "firefox" ''cask "firefox", args: { appdir: "~/my-apps/Applications" }''}
|
||||
${mkTest "opera" ''cask "opera", greedy: true''}
|
||||
${mkTest "google-cloud-sdk" ''cask "google-cloud-sdk", postinstall: "''${HOMEBREW_PREFIX}/bin/gcloud components update"''}
|
||||
|
||||
echo "checking mas entries in Brewfile" >&2
|
||||
${mkTest "1Password for Safari" ''mas "1Password for Safari", id: 1569813296''}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue