setup factorio server

This commit is contained in:
Christoph Hollizeck 2024-04-20 12:17:20 +02:00
parent 600aed0b28
commit 2d6fecf8f6
No known key found for this signature in database
4 changed files with 47 additions and 40 deletions

View file

@ -382,11 +382,11 @@
]
},
"locked": {
"lastModified": 1713077896,
"narHash": "sha256-Noot8H0EZEAFRQWyGxh9ryvhK96xpIqKbh78X447JWs=",
"lastModified": 1713166971,
"narHash": "sha256-t0P/rKlsE5l1O3O2LYtAelLzp7PeoPCSzsIietQ1hSM=",
"owner": "nix-community",
"repo": "home-manager",
"rev": "630a0992b3627c64e34f179fab68e3d48c6991c0",
"rev": "1c43dcfac48a2d622797f7ab741670fdbcf8f609",
"type": "github"
},
"original": {
@ -477,11 +477,11 @@
},
"nixpkgs": {
"locked": {
"lastModified": 1712791164,
"narHash": "sha256-3sbWO1mbpWsLepZGbWaMovSO7ndZeFqDSdX0hZ9nVyw=",
"lastModified": 1713297878,
"narHash": "sha256-hOkzkhLT59wR8VaMbh1ESjtZLbGi+XNaBN6h49SPqEc=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "1042fd8b148a9105f3c0aca3a6177fd1d9360ba5",
"rev": "66adc1e47f8784803f2deb6cacd5e07264ec2d5c",
"type": "github"
},
"original": {
@ -809,11 +809,11 @@
},
"unstable_2": {
"locked": {
"lastModified": 1712791164,
"narHash": "sha256-3sbWO1mbpWsLepZGbWaMovSO7ndZeFqDSdX0hZ9nVyw=",
"lastModified": 1712963716,
"narHash": "sha256-WKm9CvgCldeIVvRz87iOMi8CFVB1apJlkUT4GGvA0iM=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "1042fd8b148a9105f3c0aca3a6177fd1d9360ba5",
"rev": "cfd6b5fc90b15709b780a5a1619695a88505a176",
"type": "github"
},
"original": {

View file

@ -0,0 +1,36 @@
{
lib,
config,
pkgs,
...
}:
with lib;
with lib.wyrdgard;
let
cfg = config.wyrdgard.apps.factorio-server;
inherit (config.wyrdgard.user) name;
in
{
options.wyrdgard.apps.factorio-server = with types; {
enable = mkEnableOption "Enable Factorio Headless Server";
};
config = mkIf cfg.enable {
environment.systemPackages = with pkgs; [ factorio-headless-experimental ];
services.factorio = {
enable = true;
openFirewall = true;
public = true;
lan = true;
bind = "[::]";
nonBlockingSaving = true;
autosave-interval = 5;
loadLatestSave = true;
username = "DaHolli";
token = "4d4624ca9a23396e1955c1b4b364ff";
game-name = "Alles Nix!";
game-password = "1234";
};
};
}

View file

@ -10,37 +10,14 @@ with lib;
with lib.wyrdgard;
let
cfg = config.wyrdgard.nix;
substituters-submodule = types.submodule (
{ name, ... }:
{
options = with types; {
key = mkOpt (nullOr str) null "The trusted public key for this substituter.";
};
}
);
in
{
options.wyrdgard.nix = with types; {
enable = mkBoolOpt true "Whether or not to manage nix configuration.";
package = mkOpt package pkgs.nixUnstable "Which nix package to use.";
default-substituter = {
url = mkOpt str "https://cache.nixos.org" "The url for the substituter.";
key =
mkOpt str "cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY="
"The trusted public key for the substituter.";
};
extra-substituters = mkOpt (attrsOf substituters-submodule) { } "Extra substituters to configure.";
};
config = mkIf cfg.enable {
assertions = mapAttrsToList (name: value: {
assertion = value.key != null;
message = "wyrdgard.nix.extra-substituters.${name}.key must be set";
}) cfg.extra-substituters;
environment.systemPackages = with pkgs; [
snowfallorg.flake
nixfmt
@ -53,7 +30,7 @@ in
users = [
"root"
config.wyrdgard.user.name
] ++ optional config.services.hydra.enable "hydra";
];
in
{
package = cfg.package;
@ -68,13 +45,6 @@ in
auto-optimise-store = true;
trusted-users = users;
allowed-users = users;
substituters = [
cfg.default-substituter.url
] ++ (mapAttrsToList (name: value: name) cfg.extra-substituters);
trusted-public-keys = [
cfg.default-substituter.key
] ++ (mapAttrsToList (name: value: value.key) cfg.extra-substituters);
}
// (lib.optionalAttrs config.wyrdgard.tools.direnv.enable {
keep-outputs = true;

View file

@ -23,6 +23,7 @@ with lib.wyrdgard;
discord = enabled;
_1password = enabled;
onedrive = enabled;
factorio-server = enabled;
};
system = {