mirror of
https://git.sr.ht/~magic_rb/dotfiles
synced 2024-12-04 22:14:58 +01:00
aff0158ef7
Signed-off-by: magic_rb <magic_rb@redalder.org>
45 lines
960 B
Nix
45 lines
960 B
Nix
{
|
|
makeSystem,
|
|
nixpkgs,
|
|
}:
|
|
makeSystem {
|
|
system = "x86_64-linux";
|
|
name = "redis";
|
|
inherit nixpkgs;
|
|
config = {pkgs, ...}: {
|
|
dumb-init = {
|
|
enable = true;
|
|
type.services = {};
|
|
};
|
|
|
|
users.users."redis" = {
|
|
home = "/var/empty";
|
|
uid = 9001;
|
|
group = "redis";
|
|
};
|
|
|
|
users.groups."redis" = {
|
|
gid = 9001;
|
|
};
|
|
|
|
init.services.redis = {
|
|
enabled = true;
|
|
shutdownOnExit = true;
|
|
script = pkgs.writeShellScript "redis-run" ''
|
|
cd /var/lib/redis
|
|
chpst -U redis:redis ${pkgs.redis}/bin/redis-server ${./redis.conf}
|
|
'';
|
|
};
|
|
|
|
init.services.redis-setup = {
|
|
enabled = true;
|
|
script = pkgs.writeShellScript "redis-run" ''
|
|
export PATH="${pkgs.redis}/bin:$PATH"
|
|
nc -z 127.0.0.1 6379 -w 10 -v || exit 1
|
|
|
|
redis-cli acl setuser default on '>'"$(cat /secrets/redis_password)" allcommands allkeys
|
|
sleep 86400
|
|
'';
|
|
};
|
|
};
|
|
}
|