From 2505f0ea2ed13f963297cfd9e6c3a52e642ba1fb Mon Sep 17 00:00:00 2001 From: Chris Kruining Date: Tue, 10 Sep 2024 23:59:12 +0200 Subject: [PATCH] finished mc config --- default.nix | 5 + flake.lock | 143 ++++++++++++++++++++++++--- flake.nix | 2 + hosts/chris-pc/default.nix | 3 +- modules/desktop/browsers/zen.nix | 104 +++++++++---------- modules/services/games/minecraft.nix | 40 +++++++- 6 files changed, 228 insertions(+), 69 deletions(-) diff --git a/default.nix b/default.nix index 19d448f..cf965ae 100644 --- a/default.nix +++ b/default.nix @@ -10,6 +10,7 @@ in inputs.home-manager.nixosModules.home-manager inputs.nixvim.nixosModules.nixvim inputs.stylix.nixosModules.stylix + inputs.nix-minecraft.nixosModules.minecraft-servers (mkAliasOptionModule ["hm"] ["home-manager" "users" config.user.name]) (mkAliasOptionModule ["home"] ["hm" "home"]) (mkAliasOptionModule ["create" "configFile"] ["hm" "xdg" "configFile"]) @@ -17,6 +18,10 @@ in ] ++ (mapModulesRec' (toString ./modules) import); + nixpkgs.overlays = [ + inputs.nix-minecraft.overlay + ]; + environment.variables = { SNEEUWVLOK = config.sneeuwvlok.dir; NIXPKGS_ALLOW_UNFREE = "1"; diff --git a/flake.lock b/flake.lock index 96dceab..6973692 100644 --- a/flake.lock +++ b/flake.lock @@ -210,6 +210,22 @@ } }, "flake-compat_2": { + "flake": false, + "locked": { + "lastModified": 1673956053, + "narHash": "sha256-4gtG9iQuiKITOjNQQeQIpoIB6b16fm+504Ch3sNKLd8=", + "owner": "edolstra", + "repo": "flake-compat", + "rev": "35bb57c0c8d8b62bbfd284272c928ceb64ddbde9", + "type": "github" + }, + "original": { + "owner": "edolstra", + "repo": "flake-compat", + "type": "github" + } + }, + "flake-compat_3": { "locked": { "lastModified": 1696426674, "narHash": "sha256-kvjfFW7WAETZlt09AgDn1MrtKzP7t90Vf7vypd3OL1U=", @@ -223,7 +239,7 @@ "url": "https://flakehub.com/f/edolstra/flake-compat/1.tar.gz" } }, - "flake-compat_3": { + "flake-compat_4": { "flake": false, "locked": { "lastModified": 1673956053, @@ -282,6 +298,24 @@ "inputs": { "systems": "systems_2" }, + "locked": { + "lastModified": 1681202837, + "narHash": "sha256-H+Rh19JDwRtpVPAWp64F+rlEtxUWBAQW28eAi3SRSzg=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "cfacdce06f30d2b68473a46042957675eebb3401", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "flake-utils_3": { + "inputs": { + "systems": "systems_3" + }, "locked": { "lastModified": 1710146030, "narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=", @@ -296,7 +330,7 @@ "type": "github" } }, - "flake-utils_3": { + "flake-utils_4": { "inputs": { "systems": [ "stylix", @@ -520,6 +554,26 @@ "type": "github" } }, + "nix-minecraft": { + "inputs": { + "flake-compat": "flake-compat_2", + "flake-utils": "flake-utils_2", + "nixpkgs": "nixpkgs_2" + }, + "locked": { + "lastModified": 1725846230, + "narHash": "sha256-zk4fRuYct4FcCrXM7uguQLhoqytM4y0MoUeiPBbVlZc=", + "owner": "Infinidoge", + "repo": "nix-minecraft", + "rev": "7ba553bbdf244f0c88f3306cf4e5dc36d2c0fc37", + "type": "github" + }, + "original": { + "owner": "Infinidoge", + "repo": "nix-minecraft", + "type": "github" + } + }, "nixpkgs": { "locked": { "lastModified": 1724224976, @@ -568,6 +622,22 @@ } }, "nixpkgs_2": { + "locked": { + "lastModified": 1715266358, + "narHash": "sha256-doPgfj+7FFe9rfzWo1siAV2mVCasW+Bh8I1cToAXEE4=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "f1010e0469db743d14519a1efd37e23f8513d714", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_3": { "locked": { "lastModified": 1724479785, "narHash": "sha256-pP3Azj5d6M5nmG68Fu4JqZmdGt4S4vqI5f8te+E/FTw=", @@ -583,7 +653,7 @@ "type": "github" } }, - "nixpkgs_3": { + "nixpkgs_4": { "locked": { "lastModified": 1723415338, "narHash": "sha256-K/BVeDLkpswRSBh3APxc2gBNVFEMXGpnkuQz666FiTM=", @@ -599,10 +669,26 @@ "type": "github" } }, + "nixpkgs_5": { + "locked": { + "lastModified": 1725634671, + "narHash": "sha256-v3rIhsJBOMLR8e/RNWxr828tB+WywYIoajrZKFM+0Gg=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "574d1eac1c200690e27b8eb4e24887f8df7ac27c", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, "nixvim": { "inputs": { "devshell": "devshell", - "flake-compat": "flake-compat_2", + "flake-compat": "flake-compat_3", "flake-parts": "flake-parts", "git-hooks": "git-hooks", "home-manager": "home-manager_2", @@ -629,7 +715,7 @@ }, "nuschtosSearch": { "inputs": { - "flake-utils": "flake-utils_2", + "flake-utils": "flake-utils_3", "nixpkgs": [ "nixvim", "nixpkgs" @@ -677,11 +763,13 @@ "fenix": "fenix", "firefox": "firefox", "home-manager": "home-manager", - "nixpkgs": "nixpkgs_2", + "nix-minecraft": "nix-minecraft", + "nixpkgs": "nixpkgs_3", "nixpkgs-unstable": "nixpkgs-unstable", "nixvim": "nixvim", "plasma-manager": "plasma-manager", - "stylix": "stylix" + "stylix": "stylix", + "zen-browser": "zen-browser" } }, "rust-analyzer-src": { @@ -710,12 +798,12 @@ "base16-kitty": "base16-kitty", "base16-tmux": "base16-tmux", "base16-vim": "base16-vim", - "flake-compat": "flake-compat_3", - "flake-utils": "flake-utils_3", + "flake-compat": "flake-compat_4", + "flake-utils": "flake-utils_4", "gnome-shell": "gnome-shell", "home-manager": "home-manager_3", - "nixpkgs": "nixpkgs_3", - "systems": "systems_3" + "nixpkgs": "nixpkgs_4", + "systems": "systems_4" }, "locked": { "lastModified": 1724702977, @@ -776,6 +864,21 @@ "type": "github" } }, + "systems_4": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + }, "treefmt-nix": { "inputs": { "nixpkgs": [ @@ -796,6 +899,24 @@ "repo": "treefmt-nix", "type": "github" } + }, + "zen-browser": { + "inputs": { + "nixpkgs": "nixpkgs_5" + }, + "locked": { + "lastModified": 1726001766, + "narHash": "sha256-ADvEWfo0AuHR06ah1nnzOyhsG05/b5QpUc7vFNbiEfM=", + "owner": "MarceColl", + "repo": "zen-browser-flake", + "rev": "06505a088396e2c0b9ad100302502783a6bcdb40", + "type": "github" + }, + "original": { + "owner": "MarceColl", + "repo": "zen-browser-flake", + "type": "github" + } } }, "root": "root", diff --git a/flake.nix b/flake.nix index f2fbbc4..fc13724 100644 --- a/flake.nix +++ b/flake.nix @@ -31,6 +31,8 @@ }; zen-browser.url = "github:MarceColl/zen-browser-flake"; + + nix-minecraft.url = "github:Infinidoge/nix-minecraft"; }; outputs = inputs @ { self, nixpkgs, nixpkgs-unstable, ... }: diff --git a/hosts/chris-pc/default.nix b/hosts/chris-pc/default.nix index c084a64..10a44d2 100644 --- a/hosts/chris-pc/default.nix +++ b/hosts/chris-pc/default.nix @@ -18,6 +18,8 @@ dotnet.enable = true; }; + services.games.minecraft.enable = true; + desktop = { plasma.enable = true; type = "wayland"; @@ -46,7 +48,6 @@ browsers = { default = "firefox"; firefox.enable = true; - firefox.privacy.enable = true; }; }; diff --git a/modules/desktop/browsers/zen.nix b/modules/desktop/browsers/zen.nix index 9214328..f42d5b4 100644 --- a/modules/desktop/browsers/zen.nix +++ b/modules/desktop/browsers/zen.nix @@ -5,9 +5,9 @@ let inherit (lib.modules) mkIf mkMerge; inherit (lib.strings) concatStrings; - cfg = config.modules.desktop.browsers.firefox; + cfg = config.modules.desktop.browsers.zen; in { - options.modules.desktop.browsers.firefox = let + options.modules.desktop.browsers.zen = let inherit (lib.options) mkEnableOption; inherit (lib.types) attrsOf oneOf bool int lines str; inherit (lib.my) mkOpt mkOpt'; @@ -37,62 +37,56 @@ in { inherit (inputs.zen.packages.${pkgs.system}.specific) zen; in [ zen - (makeDesktopItem { - name = "zen"; - desktopName = "Zen"; - genericName = "Launch a Zen instance"; - icon = "zen"; - exec = "${lib.getExe zen-bin}"; - categories = ["Network" "WebBrowser"]; - }) +# (makeDesktopItem { +# name = "zen"; +# desktopName = "Zen"; +# genericName = "Launch a Zen instance"; +# icon = "zen"; +# exec = "${lib.getExe zen-bin}"; +# categories = ["Network" "WebBrowser"]; +# }) ]; # Use a stable profile name so we can target it in themes - home.file = let - cfgPath = ".mozilla/firefox"; - in { - firefox-profiles = { - target = "${cfgPath}/profiles.ini"; - text = '' - [Profile0] - Name=default - IsRelative=1 - Path=${cfg.profileName}.default - Default=1 - - [General] - StartWithLastProfile=1 - Version=2 - ''; - }; - - user-js = mkIf (cfg.settings != {} || cfg.extraConfig != "") { - target = "${cfgPath}/${cfg.profileName}.default/user.js"; - text = '' - ${concatStrings (mapAttrsToList (name: value: '' - user_pref("${name}", ${toJSON value}); - '') - cfg.settings)} - ${cfg.extraConfig} - ''; - }; - - user-chrome = mkIf (cfg.userChrome != "") { - target = "${cfgPath}/${cfg.profileName}.default/chrome/userChrome.css"; - text = cfg.userChrome; - }; - - user-content = mkIf (cfg.userContent != "") { - target = "${cfgPath}/${cfg.profileName}.default/chrome/userContent.css"; - text = cfg.userContent; - }; - }; - }) - - (mkIf cfg.privacy.enable { - user.packages = attrValues { - inherit (pkgs) librewolf; - }; +# home.file = let +# cfgPath = ".mozilla/firefox"; +# in { +# firefox-profiles = { +# target = "${cfgPath}/profiles.ini"; +# text = '' +# [Profile0] +# Name=default +# IsRelative=1 +# Path=${cfg.profileName}.default +# Default=1 +# +# [General] +# StartWithLastProfile=1 +# Version=2 +# ''; +# }; +# +# user-js = mkIf (cfg.settings != {} || cfg.extraConfig != "") { +# target = "${cfgPath}/${cfg.profileName}.default/user.js"; +# text = '' +# ${concatStrings (mapAttrsToList (name: value: '' +# user_pref("${name}", ${toJSON value}); +# '') +# cfg.settings)} +# ${cfg.extraConfig} +# ''; +# }; +# +# user-chrome = mkIf (cfg.userChrome != "") { +# target = "${cfgPath}/${cfg.profileName}.default/chrome/userChrome.css"; +# text = cfg.userChrome; +# }; +# +# user-content = mkIf (cfg.userContent != "") { +# target = "${cfgPath}/${cfg.profileName}.default/chrome/userContent.css"; +# text = cfg.userContent; +# }; +# }; }) ]; } diff --git a/modules/services/games/minecraft.nix b/modules/services/games/minecraft.nix index cb15f0c..106ed98 100644 --- a/modules/services/games/minecraft.nix +++ b/modules/services/games/minecraft.nix @@ -9,10 +9,46 @@ in enable = mkEnableOption "Minecraft"; }; - config = mkIf config.modules.services.auth.enable { - services.minecraft = { + config = mkIf config.modules.services.games.minecraft.enable { + services.minecraft-servers = { enable = true; eula = true; + + dataDir = "/var/lib/minecraft"; + + servers = { + vanilla = { + enable = true; + autoStart = true; + + package = pkgs.fabricServers.fabric-1_18_2.override { loaderVersion = "0.14.9"; }; + + serverProperties = { + gamemode = "survival"; + difficulty = 3; + motd = "Chris' vanilla server"; + white-list = true; + simulation-distance = 10; + server-port = 25501; + }; + + whitelist = { + ChrisPBacon = "e6128495-075b-44a9-87f6-8d844d5ea0e4"; + }; + + jvmOpts = "-Xms4092M -Xmx4092M -XX:+UseG1GC"; + + symlinks = let + inherit (lib.attrsets) attrValues; + inherit (pkgs) linkFarmFromDrvs fetchurl; + in{ + mods = linkFarmFromDrvs "mods" (attrValues { + Terraforged = fetchurl { url = "https://cdn.modrinth.com/data/FIlZB9L0/versions/EVe9wYaj/Terra-fabric-6.4.3-BETA%2Bab60f14ff.jar"; sha512 = "90dc1215b352fcbce0219dab616dc2be28eaff4622233cbfadd6060aa52432f2ba86f05f1118314b46102b3ab3c6f8070e6780cf6512a8961ac47c235dd764f9"; }; + DistantHorizons = fetchurl { url = "https://cdn.modrinth.com/data/uCdwusMi/versions/jptcCdp2/DistantHorizons-2.2.1-a-1.20.4-forge-fabric.jar"; sha512 = "47368d91099d0b5f364339a69f4e425f8fb1e3a7c3250a8b649da76135e68a22f1a76b191c87e15a5cdc0a1d36bc57f2fa825490d96711d09d96807be97d575d"; }; + }); + }; + }; + }; }; }; }