seaweedfs
This commit is contained in:
@@ -25,6 +25,7 @@
|
|||||||
./wireguard.nix
|
./wireguard.nix
|
||||||
./docker.nix
|
./docker.nix
|
||||||
./docker-device-mapper.nix
|
./docker-device-mapper.nix
|
||||||
|
./seaweedfs-mount.nix
|
||||||
];
|
];
|
||||||
|
|
||||||
# Use the systemd-boot EFI boot loader.
|
# Use the systemd-boot EFI boot loader.
|
||||||
@@ -39,6 +40,12 @@
|
|||||||
boot.kernelModules = [ "rbd" "nbd" ];
|
boot.kernelModules = [ "rbd" "nbd" ];
|
||||||
|
|
||||||
hardware.bluetooth.enable = true;
|
hardware.bluetooth.enable = true;
|
||||||
|
hardware.bluetooth.settings = {
|
||||||
|
General = {
|
||||||
|
Experimental = true;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
networking.hostName = config.vars.hostname;
|
networking.hostName = config.vars.hostname;
|
||||||
networking.hostId = config.vars.hostid;
|
networking.hostId = config.vars.hostid;
|
||||||
@@ -101,6 +108,7 @@
|
|||||||
zsh
|
zsh
|
||||||
zoxide
|
zoxide
|
||||||
fzf
|
fzf
|
||||||
|
intel-gpu-tools
|
||||||
];
|
];
|
||||||
|
|
||||||
# Open ports in the firewall.
|
# Open ports in the firewall.
|
||||||
|
|||||||
@@ -24,4 +24,4 @@
|
|||||||
# intel-compute-runtime-legacy1
|
# intel-compute-runtime-legacy1
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
116
seaweedfs-mount.nix
Normal file
116
seaweedfs-mount.nix
Normal file
@@ -0,0 +1,116 @@
|
|||||||
|
# /etc/nixos/modules/seaweedfs-mount.nix
|
||||||
|
#
|
||||||
|
# This module sets up a systemd service to mount a SeaweedFS filer
|
||||||
|
# via FUSE directly on the NixOS host.
|
||||||
|
|
||||||
|
{ config, pkgs, lib, ... }:
|
||||||
|
|
||||||
|
let
|
||||||
|
# Use lib.mkOption to create configurable settings for our module.
|
||||||
|
# This makes it reusable and easy to adjust from configuration.nix.
|
||||||
|
cfg = config.services.seaweedfs-mount;
|
||||||
|
in
|
||||||
|
{
|
||||||
|
# Define the options that can be set in configuration.nix
|
||||||
|
options.services.seaweedfs-mount = {
|
||||||
|
enable = lib.mkEnableOption "SeaweedFS FUSE mount service";
|
||||||
|
|
||||||
|
filerAddresses = lib.mkOption {
|
||||||
|
type = lib.types.listOf lib.types.str;
|
||||||
|
example = [ "seaweedfs_filer_nix1:8888" "seaweedfs_filer_nix2:8888" ];
|
||||||
|
description = "List of filer addresses (hostname:port) to connect to.";
|
||||||
|
};
|
||||||
|
|
||||||
|
mountPoint = lib.mkOption {
|
||||||
|
type = lib.types.path;
|
||||||
|
default = "/mnt/service/seaweedfs";
|
||||||
|
description = "The absolute path where the SeaweedFS volume will be mounted.";
|
||||||
|
};
|
||||||
|
|
||||||
|
cacheDir = lib.mkOption {
|
||||||
|
type = lib.types.path;
|
||||||
|
default = "/data/seaweedfs/cache";
|
||||||
|
description = "Directory for local FUSE cache.";
|
||||||
|
};
|
||||||
|
|
||||||
|
volumeDir = lib.mkOption {
|
||||||
|
type = lib.types.path;
|
||||||
|
default = "/data/seaweedfs/volume";
|
||||||
|
description = "Directory for local volume.";
|
||||||
|
};
|
||||||
|
|
||||||
|
user = lib.mkOption {
|
||||||
|
type = lib.types.str;
|
||||||
|
default = "root";
|
||||||
|
description = "The user to run the mount process as.";
|
||||||
|
};
|
||||||
|
|
||||||
|
group = lib.mkOption {
|
||||||
|
type = lib.types.str;
|
||||||
|
default = "root";
|
||||||
|
description = "The group to run the mount process as.";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
# This part of the module will be activated only if services.seaweedfs-mount.enable = true;
|
||||||
|
config = lib.mkIf cfg.enable {
|
||||||
|
|
||||||
|
# 1. Ensure the FUSE kernel module is loaded at boot.
|
||||||
|
boot.kernelModules = [ "fuse" ];
|
||||||
|
|
||||||
|
# 2. Ensure the seaweedfs package is available in the system path.
|
||||||
|
environment.systemPackages = [ pkgs.seaweedfs ];
|
||||||
|
|
||||||
|
# 3. Create the necessary directories before the service starts.
|
||||||
|
systemd.tmpfiles.rules = [
|
||||||
|
"d ${cfg.mountPoint} 0755 ${cfg.user} ${cfg.group} -"
|
||||||
|
"d ${cfg.cacheDir} 0755 ${cfg.user} ${cfg.group} -"
|
||||||
|
"d ${cfg.volumeDir} 0755 ${cfg.user} ${cfg.group} -"
|
||||||
|
];
|
||||||
|
|
||||||
|
# 4. Define the systemd service itself.
|
||||||
|
systemd.services.seaweedfs-mount = {
|
||||||
|
description = "SeaweedFS FUSE Mount Service";
|
||||||
|
|
||||||
|
# Start after the network is fully available.
|
||||||
|
wantedBy = [ "multi-user.target" ];
|
||||||
|
after = [ "network-online.target" ];
|
||||||
|
wants = [ "network-online.target" ];
|
||||||
|
|
||||||
|
# Service configuration details.
|
||||||
|
serviceConfig = {
|
||||||
|
# The user and group to run the command as.
|
||||||
|
User = cfg.user;
|
||||||
|
Group = cfg.group;
|
||||||
|
|
||||||
|
# The core command to start the mount process.
|
||||||
|
# We build the -filer string by joining the list of addresses with commas.
|
||||||
|
ExecStart = ''
|
||||||
|
${pkgs.seaweedfs}/bin/weed mount \
|
||||||
|
-dir=${cfg.mountPoint} \
|
||||||
|
-cacheDir=${cfg.cacheDir} \
|
||||||
|
-filer=${lib.concatStringsSep "," cfg.filerAddresses} \
|
||||||
|
-allowOthers=true \
|
||||||
|
-map.uid="1000:0" \
|
||||||
|
-map.gid="1000:0" \
|
||||||
|
-dirAutoCreate \
|
||||||
|
-cacheCapacityMB=15000 \
|
||||||
|
-filer.path=/
|
||||||
|
'';
|
||||||
|
|
||||||
|
# Command to cleanly unmount on service stop.
|
||||||
|
ExecStop = "${pkgs.util-linux}/bin/umount ${cfg.mountPoint}";
|
||||||
|
|
||||||
|
# *** This is the key part for your request ***
|
||||||
|
# Always restart the service if it fails.
|
||||||
|
Restart = "always";
|
||||||
|
# Wait 10 seconds before attempting to restart.
|
||||||
|
RestartSec = "10s";
|
||||||
|
|
||||||
|
# Required for FUSE mounts to work correctly under systemd.
|
||||||
|
Type = "simple";
|
||||||
|
KillMode = "process";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
21
seaweedfs.nix
Normal file
21
seaweedfs.nix
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
{ config, pkgs, ... }: {
|
||||||
|
|
||||||
|
# Enable and configure the SeaweedFS mount
|
||||||
|
services.seaweedfs-mount = {
|
||||||
|
enable = true;
|
||||||
|
filerAddresses = [
|
||||||
|
"filer_nix1:8888"
|
||||||
|
"filer_nix2:8888"
|
||||||
|
"filer_nix3:8888"
|
||||||
|
"filer_nixnas:8888"
|
||||||
|
];
|
||||||
|
mountPoint = "/mnt/service/seaweedfs";
|
||||||
|
};
|
||||||
|
|
||||||
|
networking.extraHosts = ''
|
||||||
|
192.168.178.5 filer_nix1
|
||||||
|
192.168.178.6 filer_nix2
|
||||||
|
192.168.178.7 filer_nix3
|
||||||
|
192.168.178.8 filer_nixnas
|
||||||
|
'';
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user