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

ofborg: add basic test

This commit is contained in:
Daiderd Jordan 2018-03-05 23:00:50 +01:00
parent 2bcccfab29
commit 84a3fcadd0
No known key found for this signature in database
GPG key ID: D02435D05B810C96
3 changed files with 37 additions and 6 deletions

View file

@ -91,18 +91,18 @@ in
# FIXME: create logfiles automatically if defined. # FIXME: create logfiles automatically if defined.
system.activationScripts.preActivation.text = '' system.activationScripts.preActivation.text = ''
mkdir -p "${user.home}" mkdir -p '${user.home}'
touch "${cfg.logFile}" touch '${cfg.logFile}'
chown ${toString user.uid}:${toString user.gid} "${user.home}" "${cfg.logFile}" chown ${toString user.uid}:${toString user.gid} '${user.home}' '${cfg.logFile}'
''; '';
system.activationScripts.postActivation.text = '' system.activationScripts.postActivation.text = ''
if ! test -f "${cfg.configFile}"; then if ! test -f '${cfg.configFile}'; then
echo >&2 "warning: ofborg config \"${cfg.configFile}\" does not exist" echo >&2 "warning: ofborg config \"${cfg.configFile}\" does not exist"
fi fi
chmod 600 "${cfg.configFile}" chmod 600 '${cfg.configFile}'
chown ${toString user.uid}:${toString user.gid} "${cfg.configFile}" chown ${toString user.uid}:${toString user.gid} '${cfg.configFile}'
''; '';
}; };

View file

@ -99,6 +99,7 @@ let
tests.programs-zsh = makeTest ./tests/programs-zsh.nix; tests.programs-zsh = makeTest ./tests/programs-zsh.nix;
tests.services-activate-system = makeTest ./tests/services-activate-system.nix; tests.services-activate-system = makeTest ./tests/services-activate-system.nix;
tests.services-buildkite-agent = makeTest ./tests/services-buildkite-agent.nix; tests.services-buildkite-agent = makeTest ./tests/services-buildkite-agent.nix;
tests.services-ofborg = makeTest ./tests/services-ofborg.nix;
tests.services-skhd = makeTest ./tests/services-skhd.nix; tests.services-skhd = makeTest ./tests/services-skhd.nix;
tests.system-defaults-write = makeTest ./tests/system-defaults-write.nix; tests.system-defaults-write = makeTest ./tests/system-defaults-write.nix;
tests.system-keyboard-mapping = makeTest ./tests/system-keyboard-mapping.nix; tests.system-keyboard-mapping = makeTest ./tests/system-keyboard-mapping.nix;

30
tests/services-ofborg.nix Normal file
View file

@ -0,0 +1,30 @@
{ config, pkgs, ... }:
let
ofborg = pkgs.runCommand "ofborg-0.0.0" {} "mkdir $out";
in
{
services.ofborg.enable = true;
services.ofborg.package = ofborg;
users.knownGroups = [ "ofborg" ];
users.knownUsers = [ "ofborg" ];
test = ''
echo >&2 "checking ofborg service in /Library/LaunchDaemons"
grep "org.nixos.ofborg" ${config.out}/Library/LaunchDaemons/org.nixos.ofborg.plist
grep "<string>ofborg</string>" ${config.out}/Library/LaunchDaemons/org.nixos.ofborg.plist
echo >&2 "checking for user in /activate"
grep "OfBorg service user" ${config.out}/activate
echo >&2 "checking for logfile permissions in /activate"
grep "touch '/var/log/ofborg.log'" ${config.out}/activate
grep "chown .* '/var/log/ofborg.log'" ${config.out}/activate
echo >&2 "checking config.json permissions in /activate"
grep "chmod 600 '/var/lib/ofborg/config.json'" ${config.out}/activate
grep "chown .* '/var/lib/ofborg/config.json'" ${config.out}/activate
'';
}