From afc455b419d0b9dd0300079c64808bf2c77f0329 Mon Sep 17 00:00:00 2001 From: thiloho <123883702+thiloho@users.noreply.github.com> Date: Sat, 29 Jul 2023 22:33:53 +0200 Subject: [PATCH] Add nginx for static websites --- flake.lock | 53 ++++++++++++++++++++++++- flake.nix | 8 +++- nixos-configurations/server/default.nix | 47 +++++++++++++--------- 3 files changed, 88 insertions(+), 20 deletions(-) diff --git a/flake.lock b/flake.lock index 2343414..42bfd39 100644 --- a/flake.lock +++ b/flake.lock @@ -1,5 +1,23 @@ { "nodes": { + "aurora-blog-template": { + "inputs": { + "nixpkgs": "nixpkgs" + }, + "locked": { + "lastModified": 1686592676, + "narHash": "sha256-rUU3nwKtuQVUopwQ4ZVzfFujMqA9elih6BVugtpKAPQ=", + "owner": "thiloho", + "repo": "aurora", + "rev": "0017fcdfa743a65a5fd4da8871f33425f7c84f28", + "type": "github" + }, + "original": { + "owner": "thiloho", + "repo": "aurora", + "type": "github" + } + }, "home-manager": { "inputs": { "nixpkgs": [ @@ -21,6 +39,21 @@ } }, "nixpkgs": { + "locked": { + "lastModified": 1684787197, + "narHash": "sha256-tvGDj3zgpW5NGoVKvoTQvkhfFPDgkbzfX+zFUW8NeHw=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "e2614d8ebcdf9a9eae0efe074f4d745d28595886", + "type": "github" + }, + "original": { + "owner": "NixOS", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_2": { "locked": { "lastModified": 1689282004, "narHash": "sha256-VNhuyb10c9SV+3hZOlxwJwzEGytZ31gN9w4nPCnNvdI=", @@ -38,8 +71,26 @@ }, "root": { "inputs": { + "aurora-blog-template": "aurora-blog-template", "home-manager": "home-manager", - "nixpkgs": "nixpkgs" + "nixpkgs": "nixpkgs_2", + "website": "website" + } + }, + "website": { + "flake": false, + "locked": { + "lastModified": 1690057185, + "narHash": "sha256-Tcpi9P+7pEDC8/mJLOAuFJJf/ddXFjwmksoxRehm9FE=", + "owner": "thiloho", + "repo": "website", + "rev": "993d7e0c7cf62477036b023bac766174e9f39970", + "type": "github" + }, + "original": { + "owner": "thiloho", + "repo": "website", + "type": "github" } } }, diff --git a/flake.nix b/flake.nix index 1bc4fde..7e0b226 100644 --- a/flake.nix +++ b/flake.nix @@ -5,12 +5,18 @@ nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; home-manager.url = "github:nix-community/home-manager"; home-manager.inputs.nixpkgs.follows = "nixpkgs"; + website = { + url = "github:thiloho/website"; + flake = false; + }; + aurora-blog-template.url = "github:thiloho/aurora"; }; - outputs = { nixpkgs, home-manager, ... }: { + outputs = inputs@{ nixpkgs, home-manager, ... }: { nixosConfigurations = let mkSystem = entrypoint: nixpkgs.lib.nixosSystem { system = "x86_64-linux"; + specialArgs = { inherit inputs; }; modules = [ entrypoint home-manager.nixosModules.home-manager diff --git a/nixos-configurations/server/default.nix b/nixos-configurations/server/default.nix index 31301e7..24645b9 100644 --- a/nixos-configurations/server/default.nix +++ b/nixos-configurations/server/default.nix @@ -1,4 +1,4 @@ -{ ... }: +{ inputs, ... }: { imports = [ @@ -8,25 +8,36 @@ networking.hostName = "server"; - services.minecraft-server = { - enable = true; - eula = true; - declarative = true; - openFirewall = true; - whitelist = { - thilo_ho = "4e4d744d-7748-46bc-add8-b3e8ca3b4cf5"; + services = { + minecraft-server = { + enable = true; + eula = true; + declarative = true; + openFirewall = true; + whitelist = { + thilo_ho = "4e4d744d-7748-46bc-add8-b3e8ca3b4cf5"; + }; + serverProperties = { + difficulty = 3; + max-players = 10; + motd = "Minecraft server of Thilo."; + white-list = true; + }; }; - serverProperties = { - difficulty = 3; - max-players = 10; - motd = "Minecraft server of Thilo."; - white-list = true; + openssh = { + enable = true; + }; + nginx = { + enable = true; + virtualHosts = { + "thilohohlt.com" = { + root = inputs.website; + locations."/" = { + proxyPass = "http://localhost:1000"; + }; + }; + }; }; - }; - - services.openssh = { - enable = true; - settings.PasswordAuthentication = false; }; users.users.thiloho.openssh.authorizedKeys.keys = [