mirror of
https://github.com/LnL7/nix-darwin.git
synced 2025-03-31 04:04:45 +00:00
I’m not *completely* certain that this handles user agents correctly. There is a deprecated command, `launchctl asuser`, that executes a command in the Mach bootstrap context of another user`. <https://scriptingosx.com/2020/08/running-a-command-as-another-user/> claims that this is required when loading and unloading user agents, but I haven’t tested this. Our current launchd agent logic is pretty weird and broken already anyway, so unless this actively regresses things I’d lean towards keeping it like this until we can move over entirely to `launchctl bootstrap`/`launchctl kickstart`, which aren’t deprecated and can address individual users directly. Someone should definitely test it more extensively than I have, though.
28 lines
804 B
Nix
28 lines
804 B
Nix
{ config, lib, pkgs, ... }:
|
|
|
|
with lib;
|
|
|
|
let
|
|
redis = pkgs.runCommand "redis-0.0.0" {} "mkdir $out";
|
|
in
|
|
|
|
{
|
|
system.primaryUser = "test-redis-user";
|
|
|
|
services.redis.enable = true;
|
|
services.redis.package = redis;
|
|
services.redis.extraConfig = ''
|
|
maxmemory-policy allkeys-lru
|
|
stop-writes-on-bgsave-error no
|
|
'';
|
|
|
|
test = ''
|
|
echo >&2 "checking redis service in ~/Library/LaunchAgents"
|
|
grep "org.nixos.redis" ${config.out}/user/Library/LaunchAgents/org.nixos.redis.plist
|
|
grep "${redis}/bin/redis-server /etc/redis.conf" ${config.out}/user/Library/LaunchAgents/org.nixos.redis.plist
|
|
|
|
echo >&2 "checking config in /etc/redis.conf"
|
|
grep "maxmemory-policy allkeys-lru" ${config.out}/etc/redis.conf
|
|
grep "stop-writes-on-bgsave-error no" ${config.out}/etc/redis.conf
|
|
'';
|
|
}
|