add JuiceFS custom mount service configuration
This commit is contained in:
parent
c2adf02a55
commit
49d0088595
@ -2,5 +2,14 @@
|
||||
{
|
||||
# Import all the package modules
|
||||
imports = [
|
||||
./juicefs.nix
|
||||
];
|
||||
|
||||
# Enable JuiceFS
|
||||
services.juicefsCustom = {
|
||||
enable = true;
|
||||
redisUrl = "redis://:your-redis-password@localhost:6379/0";
|
||||
mountPoint = "/mnt/object_storage";
|
||||
cacheDir = "/var/jfsCache";
|
||||
};
|
||||
}
|
||||
|
104
config/nixos/packages/server/juicefs.nix
Normal file
104
config/nixos/packages/server/juicefs.nix
Normal file
@ -0,0 +1,104 @@
|
||||
{ config, pkgs, lib, ... }:
|
||||
|
||||
with lib;
|
||||
|
||||
let
|
||||
cfg = config.services.juicefsCustom;
|
||||
in {
|
||||
options.services.juicefsCustom = {
|
||||
enable = mkEnableOption "JuiceFS custom mount service";
|
||||
|
||||
mountPoint = mkOption {
|
||||
type = types.str;
|
||||
default = "/mnt/object_storage";
|
||||
description = "Directory where JuiceFS should mount the filesystem";
|
||||
};
|
||||
|
||||
cacheDir = mkOption {
|
||||
type = types.str;
|
||||
default = "/var/jfsCache";
|
||||
description = "Directory for JuiceFS cache";
|
||||
};
|
||||
|
||||
cacheSize = mkOption {
|
||||
type = types.int;
|
||||
default = 204800;
|
||||
description = "Cache size in MiB";
|
||||
};
|
||||
|
||||
redisUrl = mkOption {
|
||||
type = types.str;
|
||||
default = "redis://:PASSWORD@localhost:6379/0";
|
||||
description = "Redis URL for metadata storage (replace PASSWORD with actual password)";
|
||||
};
|
||||
|
||||
bufferSize = mkOption {
|
||||
type = types.int;
|
||||
default = 1024;
|
||||
description = "Buffer size in MiB";
|
||||
};
|
||||
|
||||
prefetch = mkOption {
|
||||
type = types.int;
|
||||
default = 4;
|
||||
description = "Prefetch size";
|
||||
};
|
||||
|
||||
attrCache = mkOption {
|
||||
type = types.int;
|
||||
default = 3;
|
||||
description = "Attribute cache expiration time in seconds";
|
||||
};
|
||||
|
||||
entryCache = mkOption {
|
||||
type = types.int;
|
||||
default = 3;
|
||||
description = "Entry cache expiration time in seconds";
|
||||
};
|
||||
|
||||
openCache = mkOption {
|
||||
type = types.int;
|
||||
default = 3;
|
||||
description = "Open file cache expiration time in seconds";
|
||||
};
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
# Install JuiceFS package
|
||||
environment.systemPackages = [ pkgs.juicefs ];
|
||||
|
||||
# Create the mount and cache directories
|
||||
systemd.tmpfiles.rules = [
|
||||
"d ${cfg.mountPoint} 0755 root root -"
|
||||
"d ${cfg.cacheDir} 0755 root root -"
|
||||
];
|
||||
|
||||
# Add the JuiceFS systemd service
|
||||
systemd.services.juicefs = {
|
||||
description = "JuiceFS Mount Service";
|
||||
wantedBy = [ "multi-user.target" ];
|
||||
before = [ "docker.service" ];
|
||||
after = [ "network.target" ];
|
||||
|
||||
serviceConfig = {
|
||||
Type = "simple";
|
||||
ExecStart = "${pkgs.juicefs}/bin/juicefs mount ${cfg.redisUrl} ${cfg.mountPoint} "
|
||||
+ "--cache-dir=${cfg.cacheDir} "
|
||||
+ "--buffer-size=${toString cfg.bufferSize} "
|
||||
+ "--prefetch=${toString cfg.prefetch} "
|
||||
+ "--cache-size=${toString cfg.cacheSize} "
|
||||
+ "--attr-cache=${toString cfg.attrCache} "
|
||||
+ "--entry-cache=${toString cfg.entryCache} "
|
||||
+ "--open-cache=${toString cfg.openCache}";
|
||||
Restart = "on-failure";
|
||||
};
|
||||
};
|
||||
|
||||
# Setup Redis service if it doesn't exist elsewhere in your config
|
||||
services.redis = {
|
||||
enable = true;
|
||||
bind = "127.0.0.1";
|
||||
port = 6379;
|
||||
};
|
||||
};
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user