Add systemd service and ensure db for discord bot

This commit is contained in:
thiloho
2023-09-10 20:52:11 +02:00
parent dc1627fe5e
commit b272880344
4 changed files with 29 additions and 106 deletions

87
flake.lock generated
View File

@@ -18,58 +18,6 @@
"type": "github"
}
},
"cachix": {
"locked": {
"lastModified": 1635350005,
"narHash": "sha256-tAMJnUwfaDEB2aa31jGcu7R7bzGELM9noc91L2PbVjg=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "1c1f5649bb9c1b0d98637c8c365228f57126f361",
"type": "github"
},
"original": {
"owner": "nixos",
"ref": "nixos-20.09",
"repo": "nixpkgs",
"type": "github"
}
},
"firefox": {
"inputs": {
"cachix": "cachix",
"flake-compat": "flake-compat",
"mozilla": "mozilla",
"nixpkgs": "nixpkgs_2"
},
"locked": {
"lastModified": 1693917765,
"narHash": "sha256-LtNhYwnIrp9UuSxv3AnYdOwGqypTYkW+20bdzCfzMdI=",
"owner": "colemickens",
"repo": "flake-firefox-nightly",
"rev": "131d2f932ced539afdb2390d6245f5c62d31e26d",
"type": "github"
},
"original": {
"owner": "colemickens",
"repo": "flake-firefox-nightly",
"type": "github"
}
},
"flake-compat": {
"locked": {
"lastModified": 1688025799,
"narHash": "sha256-ktpB4dRtnksm9F5WawoIkEneh1nrEvuxb5lJFt1iOyw=",
"owner": "nix-community",
"repo": "flake-compat",
"rev": "8bf105319d44f6b9f0d764efa4fdef9f1cc9ba1c",
"type": "github"
},
"original": {
"owner": "nix-community",
"repo": "flake-compat",
"type": "github"
}
},
"home-manager": {
"inputs": {
"nixpkgs": [
@@ -90,22 +38,6 @@
"type": "github"
}
},
"mozilla": {
"flake": false,
"locked": {
"lastModified": 1690536331,
"narHash": "sha256-aRIf2FB2GTdfF7gl13WyETmiV/J7EhBGkSWXfZvlxcA=",
"owner": "mozilla",
"repo": "nixpkgs-mozilla",
"rev": "db89c8707edcffefcd8e738459d511543a339ff5",
"type": "github"
},
"original": {
"owner": "mozilla",
"repo": "nixpkgs-mozilla",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1684787197,
@@ -137,28 +69,11 @@
"type": "github"
}
},
"nixpkgs_3": {
"locked": {
"lastModified": 1693663421,
"narHash": "sha256-ImMIlWE/idjcZAfxKK8sQA7A1Gi/O58u5/CJA+mxvl8=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "e56990880811a451abd32515698c712788be5720",
"type": "github"
},
"original": {
"owner": "nixos",
"ref": "nixos-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"root": {
"inputs": {
"aurora-blog-template": "aurora-blog-template",
"firefox": "firefox",
"home-manager": "home-manager",
"nixpkgs": "nixpkgs_3",
"nixpkgs": "nixpkgs_2",
"website": "website"
}
},

View File

@@ -12,7 +12,6 @@
flake = false;
};
aurora-blog-template.url = "github:thiloho/aurora";
firefox.url = "github:colemickens/flake-firefox-nightly";
};
outputs = inputs@{ nixpkgs, home-manager, ... }: {

View File

@@ -8,6 +8,10 @@
nix.settings.trusted-users = [ "thiloho" ];
environment.systemPackages = with pkgs; [
nodejs_20
];
networking = {
hostName = "server";
firewall = {
@@ -77,19 +81,6 @@
};
autoUpdateApps.enable = true;
};
# mysql.package = pkgs.mariadb;
# firefox-syncserver = {
# enable = true;
# database.createLocally = true;
# secrets = "/var/run/firefox-syncserver-secrets.txt";
# singleNode = {
# enable = true;
# enableNginx = true;
# enableTLS = true;
# hostname = "fsync.thilohohlt.com";
# url = "https://ffsync.thilohohlt.com";
# };
# };
};
security = {
@@ -102,6 +93,28 @@
'';
};
services.postgresql = {
enable = true;
package = pkgs.postgresql_15;
ensureDatabases = [ "dcbot" ];
authentication = pkgs.lib.mkOverride 10 ''
#type database DBuser auth-method
local all all trust
'';
};
systemd.services.denbot = {
description = "Thilo's Den discord bot";
wantedBy = ["multi-user.target"];
after = ["network-online.target"];
serviceConfig = {
ExecStart = "${pkgs.nodejs_20}/bin/node index.js --token=$CREDENTIALS_DIRECTORY/bot.token";
LoadCredential = "bot.token:/var/run/bot-token.txt";
WorkingDirectory = inputs.denbot;
Restart = "always";
};
};
users.users.thiloho.openssh.authorizedKeys.keys = [
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIMkvr+vT7Ik0fjquxb9xQBfVVWJPgrfC+vJZsyG2V+/G thiloho@pc"
];

View File

@@ -31,10 +31,7 @@
home-manager.users.thiloho = { pkgs, lib, config, ... }: {
programs = {
# firefox = {
# enable = true;
# package = pkgs.firefox-devedition;
# };
firefox.enable = true;
chromium = {
enable = true;
extensions = [
@@ -85,7 +82,6 @@
teamspeak5_client
discord
qbittorrent
inputs.firefox.packages.${pkgs.system}.firefox-nightly-bin
];
};
};