~abyxcos/nas.nix

6c9afc48a5f1acb494b4cad1dfc47fecbbffc7e9 — root 1 year, 14 days ago 2ca54c0
Add a function to write out the nginx vhosts section. Cleans up the config and saves much typing.
1 files changed, 19 insertions(+), 20 deletions(-)

M configuration.nix
M configuration.nix => configuration.nix +19 -20
@@ 4,9 4,15 @@

{ config, pkgs, ... }:

let options = {
let
	unstableTarball = fetchTarball https://github.com/NixOS/nixpkgs/archive/nixos-unstable.tar.gz;
}; in {
	nginxProxy = port: {
		# forceSSL = true;
		# enableACME = true;
		locations."/".proxyPass = "http://localhost:${toString port}";
		# locations."/".proxyWebsockets = true;
	};
in {
	imports =
		[
			# Include the results of the hardware scan.


@@ 22,7 28,7 @@ let options = {

	nixpkgs.config = {
		packageOverrides = pkgs: {
			unstable = import options.unstableTarball {
			unstable = import unstableTarball {
				config = config.nixpkgs.config;
			};
		};


@@ 64,7 70,7 @@ let options = {
	# nixos-rebuild switch --option substitute false
	networking = {
		hostName = "nas"; # Define your hostname.
		domain = "bouncingkiwi.net";
		domain = "mnetic.ch";
		hostId = "e058e4cd";
		#networkmanager.enable = true;



@@ 153,14 159,16 @@ let options = {
	services.navidrome.enable = true;
	services.navidrome.package = pkgs.unstable.navidrome;
	services.navidrome.settings = {
		Address = "0.0.0.0";
		MusicFolder = "/mnt/guava/music";
		Address = "0.0.0.0";
		Port = 4533;
	};
	services.nginx.virtualHosts."music.mnetic.ch" = {
		locations."/".proxyPass = "http://localhost:4533/";
	};
	services.nginx.virtualHosts."navidrome.mnetic.ch" = nginxProxy 4533;
	services.nginx.virtualHosts."music.mnetic.ch" = nginxProxy 4533;

	services.jellyfin.enable = true;
	services.nginx.virtualHosts."jellyfin.mnetic.ch" = nginxProxy 8096;
	services.nginx.virtualHosts."movies.mnetic.ch" = nginxProxy 8096;

	# Add users with: `smbpasswd -a <user>`
	services.samba = {


@@ 191,15 199,7 @@ let options = {
			dns.base_domain = "headscale.mnetic.ch";
		};
	};

	services.nginx.virtualHosts."headscale.mnetic.ch" = {
		#forceSSL = true;
		#enableACME = true;
		locations."/" = {
			proxyPass = "http://localhost:${toString config.services.headscale.port}";
			proxyWebsockets = true;
		};
	};
	services.nginx.virtualHosts."headscale.mnetic.ch" = nginxProxy 7610;

	services.avahi.enable = true;
	services.avahi = {


@@ 233,9 233,8 @@ let options = {
			ENABLED = true;
		};
	};
	services.nginx.virtualHosts."git.mnetic.ch" = {
		locations."/".proxyPass = "http://localhost:3000/";
	};
	services.nginx.virtualHosts."forgejo.mnetic.ch" = nginxProxy 3000;
	services.nginx.virtualHosts."git.mnetic.ch" = nginxProxy 3000;

	# https://forgejo.org/2023-02-27-forgejo-actions/
	# https://forgejo.org/docs/v1.20/admin/actions/