1
0
Fork 0
mirror of https://github.com/LnL7/nix-darwin.git synced 2024-12-14 11:57:34 +00:00

Add somes tests for homebrew module

This commit is contained in:
Malo Bourgon 2022-08-23 15:21:09 -07:00
parent 46032bad42
commit 55e198cf5a
2 changed files with 102 additions and 0 deletions

View file

@ -101,6 +101,7 @@ let
tests.autossh = makeTest ./tests/autossh.nix;
tests.checks-nix-gc = makeTest ./tests/checks-nix-gc.nix;
tests.environment-path = makeTest ./tests/environment-path.nix;
tests.homebrew = makeTest ./tests/homebrew.nix;
tests.launchd-daemons = makeTest ./tests/launchd-daemons.nix;
tests.launchd-setenv = makeTest ./tests/launchd-setenv.nix;
tests.networking-hostname = makeTest ./tests/networking-hostname.nix;

101
tests/homebrew.nix Normal file
View file

@ -0,0 +1,101 @@
{ config, lib, ... }:
let
mkTest = filter: result: ''
if ! echo "$bf" | grep -F '${filter}' | grep -F '${result}' > /dev/null; then
echo Expected:
echo '${result}'
echo Actual:
echo "$bf" | grep -F '${filter}'
exit 1
fi
'';
in
{
homebrew.enable = true;
# Examples taken from https://github.com/Homebrew/homebrew-bundle
homebrew.taps = [
"homebrew/cask"
{
name = "user/tap-repo1";
clone_target = "https://user@bitbucket.org/user/homebrew-tap-repo1.git";
}
{
name = "user/tap-repo2";
clone_target = "https://user@bitbucket.org/user/homebrew-tap-repo2.git";
force_auto_update = true;
}
];
homebrew.caskArgs = {
appdir = "~/Applications";
require_sha = true;
};
homebrew.brews = [
"imagemagick"
{
name = "denji/nginx/nginx-full";
args = [ "with-rmtp" ];
restart_service = "changed";
}
{
name = "mysql@5.6";
restart_service = true;
link = true;
conflicts_with = [ "mysql" ];
}
];
homebrew.casks = [
"google-chrome"
{
name = "firefox";
args = { appdir = "~/my-apps/Applications"; };
}
{
name = "opera";
greedy = true;
}
];
homebrew.masApps = {
"1Password for Safari" = 1569813296;
Xcode = 497799835;
};
homebrew.whalebrews = [
"whalebrew/wget"
];
test = ''
bf=${lib.escapeShellArg config.homebrew.brewfile}
echo "checking tap entries in Brewfile" >&2
${mkTest "homebrew/cask" ''tap "homebrew/cask"''}
${mkTest "user/tap-repo1" ''tap "user/tap-repo1", "https://user@bitbucket.org/user/homebrew-tap-repo1.git"''}
${mkTest "user/tap-repo2" ''tap "user/tap-repo2", "https://user@bitbucket.org/user/homebrew-tap-repo2.git", force_auto_update: true''}
echo "checking cask_args entry in Brewfile" >&2
${mkTest "cask_args" ''cask_args appdir: "~/Applications", require_sha: true''}
echo "checking brew entries in Brewfile" >&2
${mkTest "imagemagick" ''brew "imagemagick"''}
${mkTest "denji/nginx/nginx-full" ''brew "denji/nginx/nginx-full", args: ["with-rmtp"], restart_service: :changed''}
${mkTest "mysql@5.6" ''brew "mysql@5.6", conflicts_with: ["mysql"], link: true, restart_service: true''}
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''}
echo "checking mas entries in Brewfile" >&2
${mkTest "1Password for Safari" ''mas "1Password for Safari", id: 1569813296''}
${mkTest "Xcode" ''mas "Xcode", id: 497799835''}
echo "checking whalebrew entries in Brewfile" >&2
${mkTest "whalebrew/wget" ''whalebrew "whalebrew/wget"''}
'';
}