diff --git a/config/host-config/nostromo/factorio.nix b/config/host-config/nostromo/factorio.nix index c26178f..cd72c9e 100644 --- a/config/host-config/nostromo/factorio.nix +++ b/config/host-config/nostromo/factorio.nix @@ -1,5 +1,6 @@ { config, lib, pkgs, ... }: +with lib; let # gdiw = let # version = "0.17.5"; @@ -103,54 +104,181 @@ let # }; mods = let - modFromFile = file: - pkgs.stdenv.mkDerivation { - name = baseNameOf file; + modFromFile = { file, deps, ... }: + let basename = baseNameOf file; + in pkgs.stdenv.mkDerivation { + name = basename; src = file; phases = [ "installPhase" ]; - installPhase = "cp $src $out"; + installPhase = '' + mkdir $out + cp $src $out/${basename} + ''; + inherit deps; }; - modzip = filename: modFromFile (../../../static/factorio + "/${filename}"); - in { - advanced-autonomous-industries = modzip "aai-industry_0.5.19.zip"; - alien-biomes = modzip "alien-biomes_0.6.7.zip"; - aircraft = modzip "Aircraft_1.8.4.zip"; - armored-biters = modzip "ArmoredBiters_1.1.6.zip"; - bobs-enemies = modzip "bobenemies_1.1.5.zip"; - bottleneck = modzip "Bottleneck_0.11.7.zip"; - bullet-trails = modzip "bullet-trails_0.6.2.zip"; - even-distribution = modzip "even-distribution_1.0.10.zip"; - flow-control = modzip "Flow Control_3.1.3.zip"; - fluid-must-flow = modzip "FluidMustFlow_1.3.1.zip"; - gdiw = modzip "GDIW_0.17.5.zip"; - hovercrafts = modzip "Hovercrafts_1.2.2.zip"; - industrial-revolution-2 = modzip "IndustrialRevolution_2.3.2.zip"; - krastorio2 = modzip "Krastorio2_1.3.6.zip"; - larger-lamps = modzip "DeadlockLargerLamp_1.5.0.zip"; - miniloader = modzip "miniloader_1.15.6.zip"; - planet-imaging-satellite = modzip "planetImagingSatellite_1.0.3.zip"; - rampant = modzip "Rampant_3.1.2.zip"; - recipe-book = modzip "RecipeBook_3.4.5.zip"; - space-exploration = modzip "space-exploration_0.6.89.zip"; - stackers = modzip "deadlock-beltboxes-loaders_2.4.2.zip"; - trees = modzip "trees_4.5.1.zip"; - vehicle-snap = modzip "VehicleSnap_1.18.4.zip"; + modzip = { filename, deps ? [ ], ... }: + modFromFile { + file = (../../../static/factorio + "/${filename}"); + inherit deps; + }; + in rec { + advanced-autonomous-industries = + modzip { filename = "aai-industry_0.5.19.zip"; }; + alien-biomes = modzip { filename = "alien-biomes_0.6.7.zip"; }; + aircraft = modzip { filename = "Aircraft_1.8.4.zip"; }; + armored-biters = modzip { filename = "ArmouredBiters_1.1.6.zip"; }; + big-data-string = modzip { filename = "big-data-string_1.0.1.zip"; }; + bobs-enemies = modzip { filename = "bobenemies_1.1.5.zip"; }; + bottleneck = modzip { filename = "Bottleneck_0.11.7.zip"; }; + bullet-trails = modzip { filename = "bullet-trails_0.6.2.zip"; }; + even-distribution = modzip { filename = "even-distribution_1.0.10.zip"; }; + flib = modzip { filename = "flib_0.11.2.zip"; }; + flow-control = modzip { filename = "Flow Control_3.1.3.zip"; }; + fluid-must-flow = modzip { filename = "FluidMustFlow_1.3.1.zip"; }; + gdiw = modzip { filename = "GDIW_1.1.0.zip"; }; + hovercrafts = modzip { filename = "Hovercrafts_1.2.2.zip"; }; + industrial-revolution-2 = + modzip { filename = "IndustrialRevolution_2.3.2.zip"; }; + krastorio2 = modzip { + filename = "Krastorio2_1.3.6.zip"; + deps = [ krastorio2-assets flib ]; + }; + krastorio2-assets = modzip { filename = "Krastorio2Assets_1.2.0.zip"; }; + larger-lamps = modzip { filename = "DeadlockLargerLamp_1.5.0.zip"; }; + miniloader = modzip { filename = "miniloader_1.15.6.zip"; }; + planet-imaging-satellite = + modzip { filename = "planetImagingSatellite_1.0.3.zip"; }; + rampant = modzip { filename = "Rampant_3.1.2.zip"; }; + recipe-book = modzip { filename = "RecipeBook_3.4.5.zip"; }; + space-exploration = modzip { filename = "space-exploration_0.6.89.zip"; }; + stackers = modzip { filename = "deadlock-beltboxes-loaders_2.4.2.zip"; }; + trees = modzip { + filename = "Trees_4.5.1.zip"; + deps = [ big-data-string ]; + }; + vehicle-snap = modzip { filename = "VehicleSnap_1.18.4.zip"; }; + }; + + worldGenSeed = 5298; + + mapGenSettings = { + autoplace_controls = { + coal = { + size = 4; + richness = "high"; + }; + copper-ore = { + size = 10; + richness = "high"; + }; + crude-oil = { + size = 10; + richness = "high"; + }; + iron-ore = { + size = 10; + richness = "high"; + }; + stone = { + size = 4; + richness = "high"; + }; + uranium-ore = { + size = 4; + richness = "high"; + }; + }; + seed = (toString worldGenSeed); }; in { - config.services.factorio = { - enable = true; - public = false; - port = 34197; - lan = false; - game-name = "Fudo Factorio"; - description = "Fudo Factorio Server"; - admins = [ "fudoniten" "arkayuu" ]; - openFirewall = true; - autosave-interval = 10; - loadLatestSave = true; - package = pkgs.factorio-headless-experimental; - # mods = [ bottleneck gdiw ]; - mods = with mods; [ bottleneck gdiw ]; + config = { + services.factorio = { + enable = true; + + # 'factorio' points to an old game + stateDirName = "krastorio2"; + + package = pkgs.factorio-headless-experimental.override { + username = "fudoniten"; + token = lib.removeSuffix "\n" (readFile + config.fudo.secrets.files.blobs."factorio-token-fudoniten.txt"); + }; + + public = false; + port = 34197; + lan = true; + game-name = "Fudo Factorio"; + description = "Fudo Factorio Server"; + admins = [ "fudoniten" "Arkayuu" ]; + openFirewall = true; + autosave-interval = 30; + loadLatestSave = true; + mods = with mods; [ + alien-biomes + aircraft + armored-biters + bottleneck + bullet-trails + fluid-must-flow + krastorio2 + # industrial-revolution-2 + larger-lamps + stackers + trees + ]; + }; + + systemd.services.factorio = let + cfg = config.services.factorio; + serverSettings = { + name = cfg.game-name; + description = cfg.description; + visibility = { + public = cfg.public; + lan = cfg.lan; + }; + username = cfg.username; + password = cfg.password; + token = cfg.token; + game_password = cfg.game-password; + require_user_verification = cfg.requireUserVerification; + max_upload_in_kilobytes_per_second = 0; + minimum_latency_in_ticks = 0; + ignore_player_limit_for_returning_players = false; + allow_commands = "admins-only"; + autosave_interval = cfg.autosave-interval; + autosave_slots = 5; + afk_autokick_interval = 0; + auto_pause = true; + only_admins_can_pause_the_game = false; + autosave_only_on_server = true; + non_blocking_saving = cfg.nonBlockingSaving; + } // cfg.extraSettings; + in { + serviceConfig.ExecStart = mkForce (toString [ + "${cfg.package}/bin/factorio" + "--config=${cfg.configFile}" + "--port=${toString cfg.port}" + "--bind=${toString cfg.bind}" + (optionalString (!cfg.loadLatestSave) + "--start-server=/var/lib/${cfg.stateDirName}/saves/${cfg.saveName}.zip") + "--server-settings=${ + pkgs.writeText "factorio-server-settings.json" (builtins.toJSON + (filterAttrsRecursive (n: v: v != null) serverSettings)) + }" + (optionalString cfg.loadLatestSave "--start-server-load-latest") + (optionalString (cfg.mods != [ ]) + "--mod-directory=${pkgs.factorio-utils.mkModDirDrv cfg.mods}") + (optionalString (cfg.admins != [ ]) "--server-adminlist=${ + pkgs.writeText "factorio-server-adminlist.json" + (builtins.toJSON cfg.admins) + }") + "--map-gen-settings=${ + pkgs.writeText "factorio-map-gen-settings.json" + (builtins.toJSON mapGenSettings) + }" + ]); + }; }; } diff --git a/config/host-config/nutboy3.nix b/config/host-config/nutboy3.nix index 2aa10e1..cda76d2 100644 --- a/config/host-config/nutboy3.nix +++ b/config/host-config/nutboy3.nix @@ -258,5 +258,16 @@ in { # loadLatestSave = true; # package = pkgs.factorio-headless-experimental; # }; + + services.nginx.virtualHosts = { + "selby.ca" = { + enableACME = true; + locations."/".return = "301 https://selbyhomecentre.com$request_uri"; + }; + "www.selby.ca" = { + enableACME = true; + locations."/".return = "301 https://selbyhomecentre.com$request_uri"; + }; + }; }; } diff --git a/config/profile-config/common-ui.nix b/config/profile-config/common-ui.nix index 8d5e6b8..2da993f 100644 --- a/config/profile-config/common-ui.nix +++ b/config/profile-config/common-ui.nix @@ -90,11 +90,20 @@ in { fonts.fontDir.enable = enable-gui; # Stupid hack - home-manager.users.jasper.home.packages = let - factorio = pkgs.factorio.override { - username = "Exceeding9987"; - token = lib.removeSuffix "\n" - (readFile config.fudo.secrets.files.blobs."factorio-token.txt"); - }; - in [ factorio ]; + home-manager.users = { + jasper.home.packages = let + factorio = pkgs.factorio.override { + username = "Exceeding9987"; + token = lib.removeSuffix "\n" (readFile + config.fudo.secrets.files.blobs."factorio-token-exceeding9987.txt"); + }; + in [ factorio ]; + niten.home.packages = let + factorio = pkgs.factorio.override { + username = "fudoniten"; + token = lib.removeSuffix "\n" (readFile + config.fudo.secrets.files.blobs."factorio-token-fudoniten.txt"); + }; + in [ factorio ]; + }; } diff --git a/config/service/forum_selby_ca.nix b/config/service/forum_selby_ca.nix new file mode 100644 index 0000000..09ca842 --- /dev/null +++ b/config/service/forum_selby_ca.nix @@ -0,0 +1,38 @@ +{ config, lib, pkgs, ... }: + +with lib; +let cfg = config.fudo.services.forum_selby_ca; +in { + options.fudo.services.forum_selby_ca = with types; { + enable = mkEnableOption "Enable the Selby forum on this host."; + + state-directory = mkOption { + type = str; + description = "Path at which to store forum data."; + }; + }; + + config = mkIf cfg.enable { + + containers.forum_selby_ca = { + autoStart = true; + + bindMounts = { + + }; + + config = { config, pkgs, ... }: { + + services.mysql = { + enable = true; + dataDir = "${cfg.state-directory}/mysql"; + ensureUsers = [{ + name = "forum_selby_ca"; + ensurePermissions = { "forum_selby_ca.*" = "ALL PRIVILEGES"; }; + }]; + ensureDatabases = [ "forum_selby_ca" ]; + }; + }; + }; + }; +} diff --git a/flake.lock b/flake.lock index 7335856..3259cd5 100644 --- a/flake.lock +++ b/flake.lock @@ -4,7 +4,7 @@ "flake": false, "locked": { "lastModified": 0, - "narHash": "sha256-Eju+PnIrgZwO9YXdqiCk+p5z3lXza/IIloltIcNBfwk=", + "narHash": "sha256-Ri2mFXWPNLpuOJDer0FSVmDyswjZ6xUHoFq7eqlt1Ao=", "path": "/state/secrets/blobs", "type": "path" }, @@ -260,11 +260,11 @@ "ws-butler": "ws-butler" }, "locked": { - "lastModified": 1664622347, - "narHash": "sha256-pJTnEG68PhrXjpkfz/784BlcxaHgV06b1cUVGRxhMdw=", + "lastModified": 1669340080, + "narHash": "sha256-/YLYpng6mZ2/NgaCiL3BCQK1cegbUNrQx1Cc1i+nQ8E=", "owner": "nix-community", "repo": "nix-doom-emacs", - "rev": "b65e204ce9d20b376acc38ec205d08007eccdaef", + "rev": "3c02175dd06714c15ddd2f73708de9b4dacc6aa9", "type": "github" }, "original": { @@ -276,17 +276,17 @@ "doom-emacs_2": { "flake": false, "locked": { - "lastModified": 1660901074, - "narHash": "sha256-3apl0eQlfBj3y0gDdoPp2M6PXYnhxs0QWOHp8B8A9sc=", + "lastModified": 1662497747, + "narHash": "sha256-4n7E1fqda7cn5/F2jTkOnKw1juG6XMS/FI9gqODL3aU=", "owner": "doomemacs", "repo": "doomemacs", - "rev": "c44bc81a05f3758ceaa28921dd9c830b9c571e61", + "rev": "3853dff5e11655e858d0bfae64b70cb12ef685ac", "type": "github" }, "original": { "owner": "doomemacs", - "ref": "master", "repo": "doomemacs", + "rev": "3853dff5e11655e858d0bfae64b70cb12ef685ac", "type": "github" } }, @@ -309,11 +309,11 @@ "emacs-overlay": { "flake": false, "locked": { - "lastModified": 1664478431, - "narHash": "sha256-XTPklm/+e2UfIitB0+s/fKTheMJSw3G1p+t0SsBCuo4=", + "lastModified": 1669319842, + "narHash": "sha256-JSfABiy5/7usgQSy/ua3XbsjJ6F9Dd3P4nJiE56gFME=", "owner": "nix-community", "repo": "emacs-overlay", - "rev": "6c78924bc5b6daaf98c0dbe63bdfcf80e6433f4b", + "rev": "49d5cbd389a3fb843793cd7503ad7abdb4f40a9d", "type": "github" }, "original": { @@ -466,11 +466,11 @@ "flake-compat_3": { "flake": false, "locked": { - "lastModified": 1650374568, - "narHash": "sha256-Z+s0J8/r907g149rllvwhb4pKi8Wam5ij0st8PwAh+E=", + "lastModified": 1668681692, + "narHash": "sha256-Ht91NGdewz8IQLtWZ9LCeNXMSXHUss+9COoqu6JLmXU=", "owner": "edolstra", "repo": "flake-compat", - "rev": "b4a34015c698c7793d592d66adbab377907a2be8", + "rev": "009399224d5e398d03b22badca40a37ac85412a1", "type": "github" }, "original": { @@ -481,11 +481,11 @@ }, "flake-utils": { "locked": { - "lastModified": 1659877975, - "narHash": "sha256-zllb8aq3YO3h8B/U0/J1WBgAL8EX5yWf5pMj3G0NAmc=", + "lastModified": 1667395993, + "narHash": "sha256-nuEHfE/LcWyuSWnS8t12N1wc105Qtau+/OdUAjtQ0rA=", "owner": "numtide", "repo": "flake-utils", - "rev": "c0e246b9b83f637f4681389ecabcb2681b4f3af0", + "rev": "5aed5285a952e0b949eb3ba02c12fa4fcfef535f", "type": "github" }, "original": { @@ -603,11 +603,11 @@ ] }, "locked": { - "lastModified": 1666377418, - "narHash": "sha256-/nx0Ui2CA52wm5hHP7GmeVNIwFQOCyPk/1s8HPbVFIY=", + "lastModified": 1669829872, + "narHash": "sha256-mH1rqA2dt5UtzBkyM+T9jmOKu7M1Q4lvEh84NkBBeiU=", "ref": "master", - "rev": "804ef2cc23ad82c6b416cae972c61eebd0896c46", - "revCount": 238, + "rev": "9a4de0bd4a40d7bd6d77e657f438153948f7faf8", + "revCount": 246, "type": "git", "url": "https://git.fudo.org/fudo-nix/home.git" }, @@ -691,8 +691,8 @@ "ssh-keypairs": "ssh-keypairs" }, "locked": { - "lastModified": 1665447952, - "narHash": "sha256-QgkvQIONER5HdRY5Vz3YmJ4U6N4obOkVJdE22kV6WL0=", + "lastModified": 1668018156, + "narHash": "sha256-aNQKjFpnF24YwIADh2fgRZ81We7oGQZqun6lqO1rQeg=", "path": "/state/secrets", "type": "path" }, @@ -751,11 +751,11 @@ ] }, "locked": { - "lastModified": 1665996265, - "narHash": "sha256-/k9og6LDBQwT+f/tJ5ClcWiUl8kCX5m6ognhsAxOiCY=", + "lastModified": 1667907331, + "narHash": "sha256-bHkAwkYlBjkupPUFcQjimNS8gxWSWjOTevEuwdnp5m0=", "owner": "nix-community", "repo": "home-manager", - "rev": "b81e128fc053ab3159d7b464d9b7dedc9d6a6891", + "rev": "6639e3a837fc5deb6f99554072789724997bc8e5", "type": "github" }, "original": { @@ -797,11 +797,11 @@ "nix-straight": { "flake": false, "locked": { - "lastModified": 1656684255, - "narHash": "sha256-ZefQiv4Ipu2VkLjs1oyelTLU7kBVJgkcQd+yBpJU0yo=", + "lastModified": 1666982610, + "narHash": "sha256-xjgIrmUsekVTE+MpZb5DMU8DQf9DJ/ZiR0o30L9/XCc=", "owner": "nix-community", "repo": "nix-straight.el", - "rev": "fb8dd5c44cde70abd13380766e40af7a63888942", + "rev": "ad10364d64f472c904115fd38d194efe1c3f1226", "type": "github" }, "original": { @@ -842,11 +842,11 @@ }, "nixpkgsUnstable": { "locked": { - "lastModified": 1666447894, - "narHash": "sha256-i9WHX4w/et4qPMzEXd9POmnO0/bthjr7R4cblKNHGms=", + "lastModified": 1669542132, + "narHash": "sha256-DRlg++NJAwPh8io3ExBJdNW7Djs3plVI5jgYQ+iXAZQ=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "95aeaf83c247b8f5aa561684317ecd860476fcd6", + "rev": "a115bb9bd56831941be3776c8a94005867f316a7", "type": "github" }, "original": { @@ -902,11 +902,11 @@ }, "nixpkgs_5": { "locked": { - "lastModified": 1666401273, - "narHash": "sha256-AG3MoIjcWwz1SPjJ2nymWu4NmeVj9P40OpB1lsmxFtg=", + "lastModified": 1669677308, + "narHash": "sha256-n788Cx+W6J1CtQofJD/KUY1c2WcJx6GqyJ+++1y9B3k=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "3933d8bb9120573c0d8d49dc5e890cb211681490", + "rev": "f214b8c9455e90b70bafd4ed9a58d448c243e8bb", "type": "github" }, "original": { @@ -980,11 +980,11 @@ "org": { "flake": false, "locked": { - "lastModified": 1664493874, - "narHash": "sha256-8zLosjfQX0aR5HprtCeiSqN1pfB+GEUF9AULk6WRcR4=", + "lastModified": 1668865287, + "narHash": "sha256-q7TfqUuEdZsD+JkF8Cr0Lnn0po6qo2zXMZDieocLpeQ=", "owner": "emacs-straight", "repo": "org-mode", - "rev": "fe1f4f2ccf040deff9c57288d987f17cc2da321f", + "rev": "0737112852afe835a5a5833a2dd0a6852c04e0f0", "type": "github" }, "original": { @@ -1077,11 +1077,11 @@ "revealjs": { "flake": false, "locked": { - "lastModified": 1664012352, - "narHash": "sha256-Pu5p6HqIO2wvWiTEhsQyIuwlWEIa1GjO3EDXosznyYE=", + "lastModified": 1668674340, + "narHash": "sha256-JEXPS67bgKnnRdA37mC18PyGm4EWVQ/BrWeBZLVKPvU=", "owner": "hakimel", "repo": "reveal.js", - "rev": "468132320d6e072abd1297d7cc24766a2b7a832d", + "rev": "9f1f7789bfbf689d9c1615e523d5c6262771e90f", "type": "github" }, "original": { diff --git a/flake.nix b/flake.nix index 925d07e..742b455 100644 --- a/flake.nix +++ b/flake.nix @@ -76,7 +76,12 @@ }; pkgsUnstable = unstable; }) - (final: prev: { nyxt = unstable.nyxt; }) + (final: prev: { + nyxt = unstable.nyxt; + factorio-experimental = unstable.factorio-experimental; + factorio-headless-experimental = + unstable.factorio-headless-experimental; + }) ]; }; diff --git a/static/factorio/Krastorio2Assets_1.2.0.zip b/static/factorio/Krastorio2Assets_1.2.0.zip new file mode 100644 index 0000000..f0bfdeb Binary files /dev/null and b/static/factorio/Krastorio2Assets_1.2.0.zip differ diff --git a/static/factorio/big-data-string_1.0.1.zip b/static/factorio/big-data-string_1.0.1.zip new file mode 100644 index 0000000..cd01d10 Binary files /dev/null and b/static/factorio/big-data-string_1.0.1.zip differ diff --git a/static/factorio/flib_0.11.2.zip b/static/factorio/flib_0.11.2.zip new file mode 100644 index 0000000..4d30653 Binary files /dev/null and b/static/factorio/flib_0.11.2.zip differ