summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--hosts/atlas/nginx.nix34
-rw-r--r--hosts/p-body/nginx.nix34
-rw-r--r--parts/deploy.nix2
-rw-r--r--parts/lib/default.nix2
-rw-r--r--parts/lib/utils/default.nix4
-rw-r--r--parts/lib/utils/deploy.nix (renamed from parts/lib/utils.nix)18
-rw-r--r--parts/lib/utils/nginx.nix22
7 files changed, 54 insertions, 62 deletions
diff --git a/hosts/atlas/nginx.nix b/hosts/atlas/nginx.nix
index fa06dc3..cdf483d 100644
--- a/hosts/atlas/nginx.nix
+++ b/hosts/atlas/nginx.nix
@@ -1,9 +1,10 @@
{
config,
- lib,
+ self,
...
}: let
inherit (config.networking) domain;
+ inherit (self.lib.utils.nginx) mkVHosts mkProxy;
in {
server = {
acme.enable = true;
@@ -18,33 +19,14 @@ in {
recommendedProxySettings = true;
recommendedTlsSettings = true;
- virtualHosts = let
- mkProxy = endpoint: port: {
- "${endpoint}" = {
- proxyPass = "http://localhost:${port}";
- proxyWebsockets = true;
- };
+ virtualHosts = mkVHosts {
+ "miniflux.${domain}" = {
+ locations = mkProxy "/" "7000";
};
- mkVHosts = let
- commonSettings = {
- enableACME = true;
- # workaround for https://github.com/NixOS/nixpkgs/issues/210807
- acmeRoot = null;
-
- addSSL = true;
- };
- in
- builtins.mapAttrs (_: lib.recursiveUpdate commonSettings);
- in
- mkVHosts {
- "miniflux.${domain}" = {
- locations = mkProxy "/" "7000";
- };
-
- "msix.${domain}" = {
- root = "/var/www/msix";
- };
+ "msix.${domain}" = {
+ root = "/var/www/msix";
};
+ };
};
}
diff --git a/hosts/p-body/nginx.nix b/hosts/p-body/nginx.nix
index d413b5d..d52473c 100644
--- a/hosts/p-body/nginx.nix
+++ b/hosts/p-body/nginx.nix
@@ -1,9 +1,10 @@
{
config,
- lib,
+ self,
...
}: let
inherit (config.networking) domain;
+ inherit (self.lib.utils.nginx) mkProxy mkVHosts;
in {
server = {
acme.enable = true;
@@ -18,33 +19,14 @@ in {
recommendedProxySettings = true;
recommendedTlsSettings = true;
- virtualHosts = let
- mkProxy = endpoint: port: {
- "${endpoint}" = {
- proxyPass = "http://localhost:${port}";
- proxyWebsockets = true;
- };
+ virtualHosts = mkVHosts {
+ "api.${domain}" = {
+ locations = mkProxy "/" "8080";
};
- mkVHosts = let
- commonSettings = {
- enableACME = true;
- # workaround for https://github.com/NixOS/nixpkgs/issues/210807
- acmeRoot = null;
-
- addSSL = true;
- };
- in
- builtins.mapAttrs (_: lib.recursiveUpdate commonSettings);
- in
- mkVHosts {
- "api.${domain}" = {
- locations = mkProxy "/" "8080";
- };
-
- "grafana.${domain}" = {
- locations = mkProxy "/" "4000";
- };
+ "grafana.${domain}" = {
+ locations = mkProxy "/" "4000";
};
+ };
};
}
diff --git a/parts/deploy.nix b/parts/deploy.nix
index 725c322..43eb08a 100644
--- a/parts/deploy.nix
+++ b/parts/deploy.nix
@@ -14,6 +14,6 @@ in {
flake.deploy = {
remoteBuild = true;
fastConnection = true;
- nodes = self.lib.utils.mkDeployNodes targets';
+ nodes = self.lib.utils.deploy.mkDeployNodes targets';
};
}
diff --git a/parts/lib/default.nix b/parts/lib/default.nix
index bdc485c..5f99521 100644
--- a/parts/lib/default.nix
+++ b/parts/lib/default.nix
@@ -1,6 +1,6 @@
{withSystem, ...} @ args: {
flake.lib = {
configs = import ./configs.nix args;
- utils = import ./utils.nix ({inherit withSystem;} // args);
+ utils = import ./utils ({inherit withSystem;} // args);
};
}
diff --git a/parts/lib/utils/default.nix b/parts/lib/utils/default.nix
new file mode 100644
index 0000000..cbb6eb9
--- /dev/null
+++ b/parts/lib/utils/default.nix
@@ -0,0 +1,4 @@
+args: {
+ deploy = import ./deploy.nix args;
+ nginx = import ./nginx.nix args;
+}
diff --git a/parts/lib/utils.nix b/parts/lib/utils/deploy.nix
index 7e3109f..aaa01f1 100644
--- a/parts/lib/utils.nix
+++ b/parts/lib/utils/deploy.nix
@@ -1,9 +1,13 @@
{inputs, ...}: let
- deployPkgs = pkgs:
- import pkgs.path {
+ inherit (builtins) mapAttrs;
+ inherit (inputs) deploy-rs;
+in {
+ mkDeployNodes = mapAttrs (_: system: let
+ inherit (system) pkgs;
+ deployPkgs = import pkgs.path {
inherit (pkgs) system;
overlays = [
- inputs.deploy-rs.overlay
+ deploy-rs.overlay
(_: prev: {
deploy-rs = {
inherit (pkgs) deploy-rs;
@@ -12,16 +16,14 @@
})
];
};
-in {
- mkDeployNodes = builtins.mapAttrs (_: system: let
- inherit (deployPkgs system.pkgs) deploy-rs;
+
type =
- if system.pkgs.stdenv.isLinux
+ if pkgs.stdenv.isLinux
then "nixos"
else "darwin";
in {
sshUser = "root";
hostname = system.config.networking.hostName;
- profiles.system.path = deploy-rs.lib.activate.${type} system;
+ profiles.system.path = deployPkgs.deploy-rs.lib.activate.${type} system;
});
}
diff --git a/parts/lib/utils/nginx.nix b/parts/lib/utils/nginx.nix
new file mode 100644
index 0000000..57be4fb
--- /dev/null
+++ b/parts/lib/utils/nginx.nix
@@ -0,0 +1,22 @@
+{lib, ...}: let
+ inherit (builtins) mapAttrs;
+ inherit (lib) recursiveUpdate;
+in {
+ mkProxy = endpoint: port: {
+ "${endpoint}" = {
+ proxyPass = "http://localhost:${toString port}";
+ proxyWebsockets = true;
+ };
+ };
+
+ mkVHosts = let
+ commonSettings = {
+ enableACME = true;
+ # workaround for https://github.com/NixOS/nixpkgs/issues/210807
+ acmeRoot = null;
+
+ addSSL = true;
+ };
+ in
+ mapAttrs (_: recursiveUpdate commonSettings);
+}