NixOS / nixpkgs

Nix Packages collection & NixOS
MIT License
18.33k stars 14.3k forks source link

Redis stack #195970

Open Satont opened 2 years ago

Satont commented 2 years ago

Project description I'd like to see redis stack in the nix-os repositories. Stack allows users use RedisInsight, RediSearch, RedisJSON, RedisGraph, RedisTimeSeries, RedisBloom

Metadata

aliyss commented 6 months ago

Just in case someone needs to do stuff like load json, here's what I did:

Build RedisJSON from source

Step 1

git clone the repository

Step 2

Create a shell.nix file inside the repository. I don't know if this is complete... Works for me, but I have cargo installed system-wide.

Contents:

{pkgs ? import <nixpkgs> {}}:
pkgs.mkShell {
  buildInputs = with pkgs; [openssl pkg-config cargo rustc rustfmt gcc clippy clang];
  LIBCLANG_PATH = pkgs.lib.makeLibraryPath [pkgs.llvmPackages_latest.libclang.lib];
  RUST_BACKTRACE = 1;
}

Step 3

cargo build --release

Configure Server to run with loadmodule

Step 4

// services/redis.nix

{...}: {
  services.redis = {
    servers = {
      aliyss-assistant = {
        enable = true;
        port = 6379;
        settings = {
          loadmodule = ["/etc/systemd/redis/librejson.so"];
        };
      };
    };
  };
}

Step 5

I just copied the full contents of target/release from Step 3, but I don't think that's necessary.

// configuration.nix

{...}: {
  imports = [
    ./services/redis.nix
  ];

  environment.etc."systemd/redis/librejson.so" = {
    source = ./services/redis/release/librejson.so;
    mode = "755";
  };
}