Services: function-ize domain parsing
This commit is contained in:
parent
10c0e42954
commit
fc7889bdf1
|
@ -1,8 +1,9 @@
|
|||
# Modules common to all systems
|
||||
{
|
||||
pkgs,
|
||||
config,
|
||||
inputs,
|
||||
lib,
|
||||
pkgs,
|
||||
...
|
||||
}:
|
||||
|
||||
|
@ -15,13 +16,27 @@
|
|||
zellij # Terminal multiplexer
|
||||
];
|
||||
|
||||
# Allow packages from the unstable repo by using 'pkgs.unstable'
|
||||
nixpkgs.overlays = [
|
||||
(final: _prev: {
|
||||
# Allow packages from the unstable repo by using 'pkgs.unstable'
|
||||
unstable = import inputs.nixpkgs-unstable {
|
||||
system = final.system;
|
||||
config.allowUnfree = true;
|
||||
};
|
||||
|
||||
# Define custom functions using 'pkgs.util'
|
||||
util = {
|
||||
# Parses the domain from a URL
|
||||
getDomainFromURL =
|
||||
url:
|
||||
let
|
||||
parsedURL = (lib.strings.splitString "." url);
|
||||
in
|
||||
builtins.concatStringsSep "." [
|
||||
(builtins.elemAt parsedURL 1)
|
||||
(builtins.elemAt parsedURL 2)
|
||||
];
|
||||
};
|
||||
})
|
||||
];
|
||||
|
||||
|
|
|
@ -31,14 +31,7 @@ in
|
|||
|
||||
services = {
|
||||
nginx.virtualHosts."${cfg.url}" = {
|
||||
useACMEHost =
|
||||
let
|
||||
parsedURL = (lib.strings.splitString "." cfg.url);
|
||||
in
|
||||
builtins.concatStringsSep "." [
|
||||
(builtins.elemAt parsedURL 1)
|
||||
(builtins.elemAt parsedURL 2)
|
||||
];
|
||||
useACMEHost = pkgs.util.getDomainFromURL cfg.url;
|
||||
forceSSL = true;
|
||||
locations."/" = {
|
||||
proxyPass = "http://127.0.0.1:4040";
|
||||
|
|
|
@ -1,4 +1,9 @@
|
|||
{ config, lib, ... }:
|
||||
{
|
||||
config,
|
||||
lib,
|
||||
pkgs,
|
||||
...
|
||||
}:
|
||||
|
||||
let
|
||||
cfg = config.aux.system.services.deluge;
|
||||
|
@ -25,14 +30,7 @@ in
|
|||
config = lib.mkIf cfg.enable {
|
||||
services = {
|
||||
nginx.virtualHosts."${cfg.url}" = {
|
||||
useACMEHost =
|
||||
let
|
||||
parsedURL = (lib.strings.splitString "." cfg.url);
|
||||
in
|
||||
builtins.concatStringsSep "." [
|
||||
(builtins.elemAt parsedURL 1)
|
||||
(builtins.elemAt parsedURL 2)
|
||||
];
|
||||
useACMEHost = pkgs.util.getDomainFromURL cfg.url;
|
||||
forceSSL = true;
|
||||
locations."/" = {
|
||||
proxyPass = "http://127.0.0.1:8112";
|
||||
|
|
|
@ -72,14 +72,7 @@ in
|
|||
} // lib.optionalAttrs (cfg.home != null) { stateDir = cfg.home; };
|
||||
|
||||
nginx.virtualHosts."${cfg.url}" = {
|
||||
useACMEHost =
|
||||
let
|
||||
parsedURL = (lib.strings.splitString "." cfg.url);
|
||||
in
|
||||
builtins.concatStringsSep "." [
|
||||
(builtins.elemAt parsedURL 1)
|
||||
(builtins.elemAt parsedURL 2)
|
||||
];
|
||||
useACMEHost = pkgs.util.getDomainFromURL cfg.url;
|
||||
forceSSL = true;
|
||||
locations."/" = {
|
||||
proxyPass = "http://127.0.0.1:3000";
|
||||
|
|
|
@ -1,4 +1,9 @@
|
|||
{ config, lib, ... }:
|
||||
{
|
||||
config,
|
||||
lib,
|
||||
pkgs,
|
||||
...
|
||||
}:
|
||||
|
||||
let
|
||||
cfg = config.aux.system.services.home-assistant;
|
||||
|
@ -49,14 +54,7 @@ in
|
|||
};
|
||||
};
|
||||
nginx.virtualHosts."${cfg.url}" = {
|
||||
useACMEHost =
|
||||
let
|
||||
parsedURL = (lib.strings.splitString "." cfg.url);
|
||||
in
|
||||
builtins.concatStringsSep "." [
|
||||
(builtins.elemAt parsedURL 1)
|
||||
(builtins.elemAt parsedURL 2)
|
||||
];
|
||||
useACMEHost = pkgs.util.getDomainFromURL cfg.url;
|
||||
forceSSL = true;
|
||||
locations."/" = {
|
||||
proxyPass = "http://[::1]:8123";
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
pkgs,
|
||||
config,
|
||||
lib,
|
||||
self,
|
||||
...
|
||||
}:
|
||||
let
|
||||
|
@ -34,14 +35,7 @@ in
|
|||
|
||||
services = {
|
||||
nginx.virtualHosts."${cfg.url}" = {
|
||||
useACMEHost =
|
||||
let
|
||||
parsedURL = (lib.strings.splitString "." cfg.url);
|
||||
in
|
||||
builtins.concatStringsSep "." [
|
||||
(builtins.elemAt parsedURL 1)
|
||||
(builtins.elemAt parsedURL 2)
|
||||
];
|
||||
useACMEHost = pkgs.util.getDomainFromURL cfg.url;
|
||||
forceSSL = true;
|
||||
locations."/" = {
|
||||
proxyPass = "http://127.0.0.1:8096";
|
||||
|
|
|
@ -50,14 +50,7 @@ in
|
|||
(lib.mkIf (cfg.enable && cfg.type == "parent") {
|
||||
services = {
|
||||
nginx.virtualHosts."${cfg.url}" = {
|
||||
useACMEHost =
|
||||
let
|
||||
parsedURL = (lib.strings.splitString "." cfg.url);
|
||||
in
|
||||
builtins.concatStringsSep "." [
|
||||
(builtins.elemAt parsedURL 1)
|
||||
(builtins.elemAt parsedURL 2)
|
||||
];
|
||||
useACMEHost = pkgs.util.getDomainFromURL cfg.url;
|
||||
forceSSL = true;
|
||||
basicAuth = {
|
||||
"${cfg.auth.user}" = cfg.auth.password;
|
||||
|
|
Loading…
Reference in a new issue