mirror of
https://git.sr.ht/~magic_rb/dotfiles
synced 2024-11-29 11:36:16 +01:00
47 lines
1 KiB
Nix
47 lines
1 KiB
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
|
||
|
'';
|
||
|
};
|
||
|
};
|
||
|
}
|