This flake is a simple wrapper around redis-server that provides scripts to start and stop a development Redis server. All data is stored in a user-configurable directory and is not persisted across sessions.
Following packages are available inside this flake's outputs:
start-redis
starts a Redis server inside$REDIS_DATA
on host$REDIS_HOST
(default: 127.0.0.1) and port$REDIS_PORT
(default: 6379)stop-redis
stops the Redis serverredis-cli-wrapped
launchesredis-cli
with the configured$REDIS_HOST
and$REDIS_PORT
- Add
github:Daste745/nix-redis-dev-db
as an input - Add
start-redis
andstop-redis
to your dev shell'spackages
- Add a redis package to your dev shell's
packages
- Export
REDIS_DATA
,REDIS_HOST
(optional) andREDIS_PORT
(optional) to your shell (e.g. using a shellHook) - Use
start-redis
to start the Redis server andstop-redis
to stop it
Example flake for x86_64-linux. This can be expanded to other systems as well.
{
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
redis-dev-db = {
url = "github:Daste745/nix-redis-dev-db";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs =
inputs:
let
system = "x86_64-linux";
pkgs = import inputs.nixpkgs { inherit system; };
redis-dev-db = inputs.redis-dev-db.outputs.packages.${system};
in
{
devShells.${system}.default = pkgs.mkShell {
packages = [
# A redis package needs to be provided manually - it's not included in start-redis/stop-redis
pkgs.redis
redis-dev-db.start-redis
redis-dev-db.stop-redis
redis-dev-db.redis-cli-wrapped
];
shellHook = ''
# If the directory is not tracked by git, swap this for the absolute path to the directory
export REDIS_DATA=$(git rev-parse --show-toplevel)/REDIS_DATA
# Optional - default is 127.0.0.1
export REDIS_HOST=127.0.0.1
# Optional - default is 6379
export REDIS_PORT=6379
'';
};
};
}
- Heavily inspired by hermann-p/nix-postgres-dev-db