2024-03-02 22:05:30 +01:00
|
|
|
{
|
|
|
|
makeSystem,
|
|
|
|
nixpkgs,
|
2023-06-13 23:05:35 +02:00
|
|
|
}:
|
|
|
|
makeSystem {
|
|
|
|
system = "x86_64-linux";
|
|
|
|
name = "redis";
|
|
|
|
inherit nixpkgs;
|
2024-03-02 22:05:30 +01:00
|
|
|
config = {pkgs, ...}: {
|
|
|
|
dumb-init = {
|
|
|
|
enable = true;
|
|
|
|
type.services = {};
|
|
|
|
};
|
2023-06-13 23:05:35 +02:00
|
|
|
|
2024-03-02 22:05:30 +01:00
|
|
|
users.users."redis" = {
|
|
|
|
home = "/var/empty";
|
|
|
|
uid = 9001;
|
|
|
|
group = "redis";
|
|
|
|
};
|
2023-06-13 23:05:35 +02:00
|
|
|
|
2024-03-02 22:05:30 +01:00
|
|
|
users.groups."redis" = {
|
|
|
|
gid = 9001;
|
|
|
|
};
|
2023-06-13 23:05:35 +02:00
|
|
|
|
2024-03-02 22:05:30 +01:00
|
|
|
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}
|
|
|
|
'';
|
|
|
|
};
|
2023-06-13 23:05:35 +02:00
|
|
|
|
2024-03-02 22:05:30 +01:00
|
|
|
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
|
2023-06-13 23:05:35 +02:00
|
|
|
|
2024-03-02 22:05:30 +01:00
|
|
|
redis-cli acl setuser default on '>'"$(cat /secrets/redis_password)" allcommands allkeys
|
|
|
|
sleep 86400
|
|
|
|
'';
|
2023-06-13 23:05:35 +02:00
|
|
|
};
|
2024-03-02 22:05:30 +01:00
|
|
|
};
|
2023-06-13 23:05:35 +02:00
|
|
|
}
|