Merge branch 'main' of github.com:asosnovsky/nixos-setup
This commit is contained in:
commit
7bd24844e5
11 files changed
+253
-66
No files matched your search
@@ -0,0 +1,98 @@
|
||||
{ config, lib, pkgs, ... }:
|
||||
|
||||
with lib;
|
||||
|
||||
let cfg = config.homelab.services.audiobookshelf;
|
||||
in {
|
||||
options = {
|
||||
homelab.services.audiobookshelf = {
|
||||
enable = mkEnableOption
|
||||
"Audiobookshelf, self-hosted audiobook and podcast server.";
|
||||
|
||||
package = mkPackageOption pkgs "audiobookshelf" { };
|
||||
|
||||
configDir = mkOption {
|
||||
description =
|
||||
"Path to Audiobookshelf config folder";
|
||||
type = types.str;
|
||||
};
|
||||
|
||||
metadtaDir = mkOption {
|
||||
description =
|
||||
"Path to Audiobookshelf config folder";
|
||||
type = types.str;
|
||||
};
|
||||
|
||||
host = mkOption {
|
||||
description = "The host Audiobookshelf binds to.";
|
||||
default = "127.0.0.1";
|
||||
example = "0.0.0.0";
|
||||
type = types.str;
|
||||
};
|
||||
|
||||
port = mkOption {
|
||||
description = "The TCP port Audiobookshelf will listen on.";
|
||||
default = 8000;
|
||||
type = types.port;
|
||||
};
|
||||
|
||||
user = mkOption {
|
||||
description = "User account under which Audiobookshelf runs.";
|
||||
default = "audiobookshelf";
|
||||
type = types.str;
|
||||
};
|
||||
|
||||
group = mkOption {
|
||||
description = "Group under which Audiobookshelf runs.";
|
||||
default = "audiobookshelf";
|
||||
type = types.str;
|
||||
};
|
||||
|
||||
openFirewall = mkOption {
|
||||
description =
|
||||
"Open ports in the firewall for the Audiobookshelf web interface.";
|
||||
default = false;
|
||||
type = types.bool;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
systemd.services.audiobookshelf = {
|
||||
description =
|
||||
"Audiobookshelf is a self-hosted audiobook and podcast server";
|
||||
|
||||
after = [ "network.target" ];
|
||||
wantedBy = [ "multi-user.target" ];
|
||||
|
||||
serviceConfig = {
|
||||
Type = "simple";
|
||||
User = cfg.user;
|
||||
Group = cfg.group;
|
||||
StateDirectory = cfg.dataDir;
|
||||
WorkingDirectory = "/var/lib/${cfg.dataDir}";
|
||||
ExecStart =
|
||||
"${cfg.package}/bin/audiobookshelf --host ${cfg.host} --port ${
|
||||
toString cfg.port
|
||||
} --config ${cfg.configDir} --metadata ${cfg.metadtaDir}";
|
||||
Restart = "on-failure";
|
||||
};
|
||||
};
|
||||
|
||||
users.users = mkIf (cfg.user == "audiobookshelf") {
|
||||
audiobookshelf = {
|
||||
isSystemUser = true;
|
||||
group = cfg.group;
|
||||
home = "/var/lib/${cfg.dataDir}";
|
||||
};
|
||||
};
|
||||
|
||||
users.groups =
|
||||
mkIf (cfg.group == "audiobookshelf") { audiobookshelf = { }; };
|
||||
|
||||
networking.firewall =
|
||||
mkIf cfg.openFirewall { allowedTCPPorts = [ cfg.port ]; };
|
||||
};
|
||||
|
||||
meta.maintainers = with maintainers; [ wietsedv ];
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
{ ... }:
|
||||
{
|
||||
imports = [
|
||||
./audiobookshelf.nix
|
||||
];
|
||||
}
|
||||
@@ -1,4 +1,8 @@
|
||||
{ hostName, homeMangerVersion, user }:
|
||||
{ hostName
|
||||
, homeManagerVersion
|
||||
, user
|
||||
, enableDevelopmentKit ? false
|
||||
}:
|
||||
{ pkgs, ... }:
|
||||
let
|
||||
gitconfigs =
|
||||
@@ -7,7 +11,7 @@ let
|
||||
in
|
||||
{
|
||||
home-manager.users.root = {
|
||||
home.stateVersion = homeMangerVersion;
|
||||
home.stateVersion = homeManagerVersion;
|
||||
programs.git = {
|
||||
enable = true;
|
||||
userName = "root";
|
||||
@@ -22,7 +26,7 @@ in
|
||||
home-manager.users.${user.name} = {
|
||||
home = {
|
||||
sessionVariables = { MAMBA_ROOT_PREFIX = "$HOME/.local/micromamba"; };
|
||||
stateVersion = homeMangerVersion;
|
||||
stateVersion = homeManagerVersion;
|
||||
shellAliases = {
|
||||
cat = "bat";
|
||||
conda = "micromamba";
|
||||
@@ -30,17 +34,17 @@ in
|
||||
packages = with pkgs; [
|
||||
jq
|
||||
nixfmt-classic
|
||||
kubectl
|
||||
terraform
|
||||
rye
|
||||
devenv
|
||||
micromamba
|
||||
neofetch
|
||||
ipfetch
|
||||
nixd
|
||||
devbox
|
||||
] ++ (if enableDevelopmentKit then [
|
||||
rye
|
||||
uv
|
||||
];
|
||||
devbox
|
||||
micromamba
|
||||
terraform
|
||||
kubectl
|
||||
] else [ ]);
|
||||
};
|
||||
programs = {
|
||||
bat.enable = true;
|
||||
@@ -78,10 +82,10 @@ in
|
||||
zsh = {
|
||||
enable = true;
|
||||
autosuggestion.enable = true;
|
||||
initExtra = ''
|
||||
initExtra = (if enableDevelopmentKit then ''
|
||||
export MAMBA_ROOT_PREFIX="$HOME/.local/micromamba"
|
||||
source <(micromamba shell hook --root-prefix=$MAMBA_ROOT_PREFIX)
|
||||
'';
|
||||
'' else "");
|
||||
};
|
||||
zsh.oh-my-zsh = {
|
||||
enable = true;
|
||||
+13
-6
@@ -2,6 +2,8 @@
|
||||
, systemStateVersion
|
||||
, hostName
|
||||
, system
|
||||
, enableNetworkDrives ? false
|
||||
, enableHomelabServices ? false
|
||||
# Desktop Module
|
||||
, desktop ? {
|
||||
enable = false;
|
||||
@@ -11,7 +13,10 @@
|
||||
enable = false;
|
||||
}
|
||||
# Home Manager
|
||||
, home-manager ? { enable = false; }
|
||||
, home-manager ? {
|
||||
enable = false;
|
||||
enableDevelopmentKit = false;
|
||||
}
|
||||
, ...
|
||||
}:
|
||||
{ ... }: {
|
||||
@@ -38,21 +43,23 @@
|
||||
hostName = hostName;
|
||||
firewall = os.firewall;
|
||||
enableFonts = os.enableFonts;
|
||||
enableNetowrking = os.enableNetowrking;
|
||||
enableNetworking = os.enableNetworking;
|
||||
enableSSH = os.enableSSH;
|
||||
hardware = os.hardware;
|
||||
containerRuntime = os.containerRuntime;
|
||||
})
|
||||
]
|
||||
else
|
||||
[ ]) ++ (if home-manager.enable then
|
||||
[
|
||||
(import ./home-manager/common.nix {
|
||||
(import ./home-manager {
|
||||
user = user;
|
||||
homeMangerVersion = home-manager.version;
|
||||
homeManagerVersion = home-manager.version;
|
||||
enableDevelopmentKit = home-manager.enableDevelopmentKit;
|
||||
hostName = hostName;
|
||||
})
|
||||
]
|
||||
else
|
||||
[ ]);
|
||||
[ ])
|
||||
++ (if enableNetworkDrives then [ (import ./network-drives.nix) ] else [ ])
|
||||
++ (if enableHomelabServices then [ (import ./hl-services) ] else [ ]);
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
{ ... }: {
|
||||
fileSystems."/mnt/EightTerra/DownloadedTorrents" = {
|
||||
device = "tnas1.lab.internal:/mnt/EightTerra/DownloadedTorrents";
|
||||
fsType = "nfs";
|
||||
options = [ "x-systemd.automount" "noauto" ];
|
||||
};
|
||||
|
||||
fileSystems."/mnt/EightTerra/k3s-cluster" = {
|
||||
device = "tnas1.lab.internal:/mnt/EightTerra/k3s-cluster";
|
||||
fsType = "nfs";
|
||||
options = [ "x-systemd.automount" "noauto" ];
|
||||
};
|
||||
}
|
||||
@@ -2,7 +2,7 @@
|
||||
, hostName
|
||||
, firewall
|
||||
, enableFonts ? true
|
||||
, enableNetowrking ? true
|
||||
, enableNetworking ? true
|
||||
, enableSSH ? true
|
||||
, containerRuntime ? null
|
||||
, hardware ? { enable = false; }
|
||||
@@ -18,7 +18,7 @@
|
||||
})
|
||||
] ++ (if enableFonts then [ ./fonts.nix ] else [ ])
|
||||
++ (if hardware.enable then [ ./hardware.nix ] else [ ])
|
||||
++ (if enableNetowrking then
|
||||
++ (if enableNetworking then
|
||||
[
|
||||
(import ./networking.nix {
|
||||
hostName = hostName;
|
||||
|
||||
Reference in new issue
Block a user