From f2361363e726d1d70fe984c1dbccc168d181061c Mon Sep 17 00:00:00 2001 From: mast3r Date: Thu, 7 Mar 2024 01:17:36 +0100 Subject: [PATCH 1/8] added httpd server --- modules/default.nix | 1 + modules/httpd.nix | 33 +++++++++++++++++++++++++++++++++ system/configuration.nix | 1 + system/graphical.nix | 11 +++++++++++ system/programs.nix | 4 ++++ 5 files changed, 50 insertions(+) create mode 100644 modules/httpd.nix create mode 100644 system/graphical.nix diff --git a/modules/default.nix b/modules/default.nix index 084dbac..aa0ee0a 100644 --- a/modules/default.nix +++ b/modules/default.nix @@ -1,5 +1,6 @@ { imports = [ ./stregsystemet.nix + ./httpd.nix ]; } diff --git a/modules/httpd.nix b/modules/httpd.nix new file mode 100644 index 0000000..044d9c0 --- /dev/null +++ b/modules/httpd.nix @@ -0,0 +1,33 @@ +{pkgs, ...}: let + domain = "fklub.dk"; + +in { + services.httpd = { + enable = true; + virtualHosts = { + localhost = { + listen = [ + { + port = 80; + ip = "*"; + } + ]; + locations."/" = { + proxyPass = "http://localhost:8000/"; + }; + }; + #localhost = { + # listen = [ + # { + # port = 80; + # ip = "*"; + # } + # ]; + # locations."/" = { + # proxyPass = "http://localhost:8081/"; + # }; + #}; + + }; + }; +} diff --git a/system/configuration.nix b/system/configuration.nix index e5b3a40..f7ed744 100644 --- a/system/configuration.nix +++ b/system/configuration.nix @@ -4,6 +4,7 @@ imports = [ ./programs.nix ./users.nix + #./graphical.nix # Uncomment this file to test frontends in the virtual machine. DO NOT USE ON THE LIVE SYSTEM, ITS A RESOURCE HOG ../modules ]; diff --git a/system/graphical.nix b/system/graphical.nix new file mode 100644 index 0000000..3a426f7 --- /dev/null +++ b/system/graphical.nix @@ -0,0 +1,11 @@ +{ + services.xserver = { + enable = true; + displayManager.sddm.enable = true; + desktopManager.xfce.enable = true; + layout = "dk"; + + }; + + programs.firefox.enable = true; +} diff --git a/system/programs.nix b/system/programs.nix index b421ee9..4f7b08c 100644 --- a/system/programs.nix +++ b/system/programs.nix @@ -3,5 +3,9 @@ { environment.systemPackages = with pkgs; [ neofetch + lynx + vim + wget + bat ]; } From c0ec50f3d05dee768f0bddc81eef22494ab58897 Mon Sep 17 00:00:00 2001 From: mast3r Date: Thu, 7 Mar 2024 12:49:01 +0100 Subject: [PATCH 2/8] changed webserver to nginx to conform with dokuwiki. added a portmap module which specifies the ports used for the webserver. --- modules/default.nix | 3 ++- modules/fikien.nix | 9 +++++++++ modules/httpd.nix | 33 --------------------------------- modules/nginx.nix | 31 +++++++++++++++++++++++++++++++ modules/portmap.nix | 8 ++++++++ modules/stregsystemet.nix | 4 ++-- 6 files changed, 52 insertions(+), 36 deletions(-) create mode 100644 modules/fikien.nix delete mode 100644 modules/httpd.nix create mode 100644 modules/nginx.nix create mode 100644 modules/portmap.nix diff --git a/modules/default.nix b/modules/default.nix index aa0ee0a..0389c2b 100644 --- a/modules/default.nix +++ b/modules/default.nix @@ -1,6 +1,7 @@ { imports = [ ./stregsystemet.nix - ./httpd.nix + ./nginx.nix + ./fikien.nix ]; } diff --git a/modules/fikien.nix b/modules/fikien.nix new file mode 100644 index 0000000..df50689 --- /dev/null +++ b/modules/fikien.nix @@ -0,0 +1,9 @@ +{ + services.dokuwiki.sites."localhost" = { + enable = true; + settings = { + title = "test wiki"; + useacl = true; + }; + }; +} diff --git a/modules/httpd.nix b/modules/httpd.nix deleted file mode 100644 index 044d9c0..0000000 --- a/modules/httpd.nix +++ /dev/null @@ -1,33 +0,0 @@ -{pkgs, ...}: let - domain = "fklub.dk"; - -in { - services.httpd = { - enable = true; - virtualHosts = { - localhost = { - listen = [ - { - port = 80; - ip = "*"; - } - ]; - locations."/" = { - proxyPass = "http://localhost:8000/"; - }; - }; - #localhost = { - # listen = [ - # { - # port = 80; - # ip = "*"; - # } - # ]; - # locations."/" = { - # proxyPass = "http://localhost:8081/"; - # }; - #}; - - }; - }; -} diff --git a/modules/nginx.nix b/modules/nginx.nix new file mode 100644 index 0000000..f8e78df --- /dev/null +++ b/modules/nginx.nix @@ -0,0 +1,31 @@ +{pkgs, ...}: let + portmap = import ./portmap.nix {}; + + defaultListen = [{ port = 80; addr = "${portmap.domain}"; }]; + +in { + services.nginx = { + enable = true; + virtualHosts = { + "${portmap.domain}" = { + listen = defaultListen; + }; + "stregsystem.${portmap.domain}" = { + listen = defaultListen; + + locations."/" = { + proxyPass = "http://localhost:${portmap.ports.stregsystemet}/"; + }; + }; + # it will only run on localhost, its for debugging + "routing.localhost" = { + listen = [{ port = 80; addr = "localhost"; }]; + locations."/".index = "${pkgs.writeText "/var/fit/index.html" '' + Fikien
+ Stregsystemet + ''}"; + root = "/."; + }; + }; + }; +} diff --git a/modules/portmap.nix b/modules/portmap.nix new file mode 100644 index 0000000..e21aba3 --- /dev/null +++ b/modules/portmap.nix @@ -0,0 +1,8 @@ +{}: { + domain = "localhost"; + ports = { + stregsystemet = "8080"; + fikien = "8081"; + }; +} + diff --git a/modules/stregsystemet.nix b/modules/stregsystemet.nix index 9305737..23c7fe3 100644 --- a/modules/stregsystemet.nix +++ b/modules/stregsystemet.nix @@ -1,12 +1,12 @@ {pkgs, ...}: let stregsystemet = pkgs.callPackage ../pkgs/stregsystemet {}; - + portmap = import ./portmap.nix {}; in { systemd.services.stregsystemet = { enable = true; serviceConfig = { - ExecStart = "${stregsystemet}/bin/stregsystemet testserver ${stregsystemet}/share/stregsystemet/stregsystem/fixtures/testdata.json"; + ExecStart = "${stregsystemet}/bin/stregsystemet testserver ${stregsystemet}/share/stregsystemet/stregsystem/fixtures/testdata.json --addrport ${portmap.domain}:${portmap.ports.stregsystemet}"; }; wantedBy = [ "default.target" ]; }; From 6f763f041d75d0d48d1f43046fe403c81af5d85b Mon Sep 17 00:00:00 2001 From: mast3r Date: Thu, 7 Mar 2024 14:11:01 +0100 Subject: [PATCH 3/8] made the nginx configuration more general and added a comment to run the system locally for testing --- modules/nginx.nix | 7 +++++-- modules/portmap.nix | 4 +++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/modules/nginx.nix b/modules/nginx.nix index f8e78df..f40ea7d 100644 --- a/modules/nginx.nix +++ b/modules/nginx.nix @@ -21,8 +21,11 @@ in { "routing.localhost" = { listen = [{ port = 80; addr = "localhost"; }]; locations."/".index = "${pkgs.writeText "/var/fit/index.html" '' - Fikien
- Stregsystemet +
+

F-Klubben | Routing

+ Fikien
+ Stregsystemet +
''}"; root = "/."; }; diff --git a/modules/portmap.nix b/modules/portmap.nix index e21aba3..cfc1f31 100644 --- a/modules/portmap.nix +++ b/modules/portmap.nix @@ -1,5 +1,7 @@ {}: { - domain = "localhost"; + domain = "fklub.dk"; + #domain = "localhost"; # Comment the line above an uncomment this to run locally + ports = { stregsystemet = "8080"; fikien = "8081"; From 1ff0b8f7bedb94a08c6463f414874a729bc14c2f Mon Sep 17 00:00:00 2001 From: mast3r Date: Thu, 7 Mar 2024 14:35:34 +0100 Subject: [PATCH 4/8] removed unneccessary packages --- system/programs.nix | 4 ---- 1 file changed, 4 deletions(-) diff --git a/system/programs.nix b/system/programs.nix index 4f7b08c..b421ee9 100644 --- a/system/programs.nix +++ b/system/programs.nix @@ -3,9 +3,5 @@ { environment.systemPackages = with pkgs; [ neofetch - lynx - vim - wget - bat ]; } From c28dd789b9e48571b67b5d1352f07cc81f59397d Mon Sep 17 00:00:00 2001 From: mast3r Date: Thu, 7 Mar 2024 14:46:42 +0100 Subject: [PATCH 5/8] changed fiki to also include from portmap --- modules/fikien.nix | 6 ++++-- modules/nginx.nix | 2 ++ system/users.nix | 6 +++++- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/modules/fikien.nix b/modules/fikien.nix index df50689..36f4929 100644 --- a/modules/fikien.nix +++ b/modules/fikien.nix @@ -1,5 +1,7 @@ -{ - services.dokuwiki.sites."localhost" = { +let + portmap = import ./portmap.nix {}; +in { + services.dokuwiki.sites."${portmap.domain}" = { enable = true; settings = { title = "test wiki"; diff --git a/modules/nginx.nix b/modules/nginx.nix index f40ea7d..afdfa5e 100644 --- a/modules/nginx.nix +++ b/modules/nginx.nix @@ -7,9 +7,11 @@ in { services.nginx = { enable = true; virtualHosts = { + # Fikien "${portmap.domain}" = { listen = defaultListen; }; + # Stregsystemet "stregsystem.${portmap.domain}" = { listen = defaultListen; diff --git a/system/users.nix b/system/users.nix index cad9907..c60915f 100644 --- a/system/users.nix +++ b/system/users.nix @@ -1,4 +1,4 @@ -{ ... }: +{pkgs, ... }: let users = {}; @@ -16,5 +16,9 @@ in { description = "Thomas"; extraGroups = [ "wheel" ]; hashedPassword = "$6$rounds=2000000$htFKKf65jcKCw09Z$JNmYnL5lIBZP6dvqYXUmj0vzzaiRteXOwlJzkcYcRCYdT5Zt8TVJWvtT4w4Q8suBneVOLEjxsMIf0yEY4BDrz1"; + packages = with pkgs; [ + lynx + vim + ]; }; } From de61fb1e8ce980c02f4fb218dc9f9c7f7720ce06 Mon Sep 17 00:00:00 2001 From: mast3r Date: Thu, 7 Mar 2024 14:47:43 +0100 Subject: [PATCH 6/8] changed name of index file --- modules/nginx.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/nginx.nix b/modules/nginx.nix index afdfa5e..b2d5cd1 100644 --- a/modules/nginx.nix +++ b/modules/nginx.nix @@ -22,7 +22,7 @@ in { # it will only run on localhost, its for debugging "routing.localhost" = { listen = [{ port = 80; addr = "localhost"; }]; - locations."/".index = "${pkgs.writeText "/var/fit/index.html" '' + locations."/".index = "${pkgs.writeText "index.html" ''

F-Klubben | Routing

Fikien
From c65fe4a52866324877cfe88e67f6cb8afac3127a Mon Sep 17 00:00:00 2001 From: Mast3r_waf1z <32744171+Mast3rwaf1z@users.noreply.github.com> Date: Thu, 7 Mar 2024 16:34:34 +0100 Subject: [PATCH 7/8] Update modules/portmap.nix Co-authored-by: Tobias SN <15670490+TobiasSN@users.noreply.github.com> --- modules/portmap.nix | 1 - 1 file changed, 1 deletion(-) diff --git a/modules/portmap.nix b/modules/portmap.nix index cfc1f31..9af5f9e 100644 --- a/modules/portmap.nix +++ b/modules/portmap.nix @@ -4,7 +4,6 @@ ports = { stregsystemet = "8080"; - fikien = "8081"; }; } From 66d7ca440d535d0cfb5474d292c2b6f5aff6bc83 Mon Sep 17 00:00:00 2001 From: mast3r Date: Mon, 11 Mar 2024 15:09:00 +0100 Subject: [PATCH 8/8] added ci --- .github/workflows/main.yml | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 .github/workflows/main.yml diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000..4821a96 --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,20 @@ +name: NixOS Package Building + +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] + +jobs: + build-stregsystemet: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4.1.1 + + - uses: cachix/install-nix-action@v25 + with: + nix_path: nixpkgs=channel:nixos-23.11 + + - name: build-stregsystemet + run: nix build -f ./pkgs/stregsystemet \ No newline at end of file