feat: change data directories, add disko for usb storage

This commit is contained in:
Ryan Yin
2024-07-31 11:52:48 +08:00
parent b671c05db9
commit 8c795c7d0d
10 changed files with 77 additions and 26 deletions

View File

@@ -17,7 +17,7 @@ in {
# Reload Caddy instead of restarting it when configuration file changes.
enableReload = true;
user = "caddy"; # User account under which caddy runs.
dataDir = "/var/lib/caddy";
dataDir = "/data/apps/caddy";
logDir = "/var/log/caddy";
# Additional lines of configuration appended to the global config section of the Caddyfile.
@@ -36,7 +36,7 @@ in {
# https://caddyserver.com/docs/caddyfile/directives/file_server
virtualHosts."file.writefor.fun".extraConfig = ''
root * /var/lib/caddy/fileserver/
root * /data/apps/caddy/fileserver/
${hostCommonConfig}
file_server browse {
hide .git
@@ -83,15 +83,15 @@ in {
# Create Directories
systemd.tmpfiles.rules = [
"d /var/lib/caddy/fileserver/ 0755 caddy caddy"
"d /data/apps/caddy/fileserver/ 0755 caddy caddy"
# directory for virtual machine's images
"d /var/lib/caddy/fileserver/vms 0755 caddy caddy"
"d /data/apps/caddy/fileserver/vms 0755 caddy caddy"
];
# Add all my wallpapers into /var/lib/caddy/fileserver/wallpapers
# Add all my wallpapers into /data/apps/caddy/fileserver/wallpapers
# Install the homepage-dashboard configuration files
system.activationScripts.installCaddyWallpapers = ''
mkdir -p /var/lib/caddy/fileserver/wallpapers
${pkgs.rsync}/bin/rsync -avz --chmod=D2755,F644 ${wallpapers}/ /var/lib/caddy/fileserver/wallpapers/
mkdir -p /data/apps/caddy/fileserver/wallpapers
${pkgs.rsync}/bin/rsync -avz --chmod=D2755,F644 ${wallpapers}/ /data/apps/caddy/fileserver/wallpapers/
'';
}

View File

@@ -2,6 +2,7 @@
mylib,
myvars,
pkgs,
disko,
...
}:
#############################################################
@@ -12,7 +13,11 @@
let
hostName = "aquamarine"; # Define your hostname.
in {
imports = mylib.scanPaths ./.;
imports =
(mylib.scanPaths ./.)
++ [
disko.nixosModules.default
];
# supported file systems, so we can mount any removable disks with these filesystems
boot.supportedFilesystems = [

View File

@@ -0,0 +1,58 @@
# auto disk partitioning:
# nix run github:nix-community/disko -- --mode disko ./disko-fs.nix
{
disko.devices = {
disk.data-apps = {
type = "disk";
device = "/dev/disk/by-id/ata-WDC_WD40EJRX-89T1XY0_WD-WCC7K0XDCZE6";
content = {
type = "gpt";
partitions.data-apps = {
size = "100%";
content = {
type = "btrfs";
# extraArgs = ["-f"]; # Override existing partition
subvolumes = {
"@persistent" = {
mountpoint = "/data/apps";
mountOptions = ["compress-force=zstd:1" "noatime"];
};
"@backups" = {
mountpoint = "/data/backups";
mountOptions = ["compress-force=zstd:1" "noatime"];
};
"@snapshots" = {
mountpoint = "/data/apps-snapshots";
mountOptions = ["compress-force=zstd:1" "noatime"];
};
};
};
};
};
};
disk.data-fileshare = {
type = "disk";
device = "/dev/disk/by-id/ata-WDC_WD40EZRZ-22GXCB0_WD-WCC7K7VV9613";
content = {
type = "gpt";
partitions.data-fileshare = {
size = "100%";
content = {
type = "btrfs";
# extraArgs = ["-f"]; # Override existing partition
subvolumes = {
"@persistent" = {
mountpoint = "/data/fileshare";
mountOptions = ["compress-force=zstd:1" "noatime"];
};
"@snapshots" = {
mountpoint = "/data/fileshare-snapshots";
mountOptions = ["compress-force=zstd:1" "noatime"];
};
};
};
};
};
};
};
}

View File

@@ -1,12 +0,0 @@
{
fileSystems."/data/downloads" = {
device = "/dev/disk/by-label/Downloads";
fsType = "ntfs-3g";
options = ["rw" "uid=1000"];
};
fileSystems."/data/games" = {
device = "/dev/disk/by-label/Games";
fsType = "ntfs-3g";
options = ["rw" "uid=1000"];
};
}

View File

@@ -5,7 +5,7 @@ in {
enable = true;
user = "gitea";
group = "gitea";
stateDir = "/var/lib/gitea";
stateDir = "/data/apps/gitea";
appName = "Ryan Yin's Gitea Service";
lfs.enable = true;
# Enable a timer that runs gitea dump to generate backup-files of the current gitea database and repositories.

View File

@@ -5,7 +5,7 @@
}: {
services.grafana = {
enable = true;
dataDir = "/var/lib/grafana";
dataDir = "/data/apps/grafana";
# DeclarativePlugins = with pkgs.grafanaPlugins; [ grafana-piechart-panel ];
settings = {
server = {

View File

@@ -1,5 +1,5 @@
{pkgs, ...}: let
configDir = "/var/lib/homepage-dashboard";
configDir = "/data/apps/homepage-dashboard";
in {
# https://github.com/NixOS/nixpkgs/blob/nixos-unstable/nixos/modules/services/misc/homepage-dashboard.nix
services.homepage-dashboard = {

View File

@@ -5,7 +5,7 @@
services.sftpgo = {
enable = true;
user = "sftpgo";
dataDir = "/var/lib/sftpgo";
dataDir = "/data/apps/sftpgo";
extraArgs = [
"--log-level"
"info"

View File

@@ -3,7 +3,7 @@
myvars,
...
}: let
dataDir = "/var/lib/transmission";
dataDir = "/data/apps/transmission";
name = "transmission";
in {
# the headless Transmission BitTorrent daemon

View File

@@ -6,7 +6,7 @@
settings = {
"UPTIME_KUMA_HOST" = "127.0.0.1";
"UPTIME_KUMA_PORT" = "3350";
"DATA_DIR" = "/var/lib/uptime-kuma/";
"DATA_DIR" = "/data/apps/uptime-kuma/";
};
};
}