Compare commits

...

5 commits

Author SHA1 Message Date
18a45773bb forgejo/module.nix: inherit mkEnableOption 2025-04-18 14:44:08 +02:00
92ba05f9cf tower/configuration.nix: enable grafana 2025-04-18 14:44:08 +02:00
00fa8006c0 tower/configuration.nix: set timeout duration of 30 2025-04-18 14:44:08 +02:00
60627d3594 boot/module.nix: add timeout option
On desktop systems, it is convenient to have the timeout
at zero, and just spam space when trying to start
a previous generation. On servers however, it is preferable
to have some time to choose the generation, which is
quite convenient if you have to acess is remotely via a
web interface, which tend to be quite slow and unresponsive.
2025-04-18 14:44:08 +02:00
5cb6dac8ea services/grafana: init 2025-04-18 14:44:08 +02:00
5 changed files with 77 additions and 5 deletions

View file

@ -29,8 +29,14 @@
locate.enable = true; locate.enable = true;
}; };
system = { system = {
boot.grub.enable = true; boot = {
services.forgejo.enable = true; grub.enable = true;
timeout = 30;
};
services = {
forgejo.enable = true;
grafana.enable = true;
};
programs = { programs = {
editors = { editors = {
helix.enable = true; helix.enable = true;

View file

@ -6,6 +6,7 @@
}: let }: let
inherit (pkgs) fetchurl; inherit (pkgs) fetchurl;
inherit (lib.modules) mkIf; inherit (lib.modules) mkIf;
inherit (lib.options) mkEnableOption;
inherit (config.services.forgejo) customDir user group; inherit (config.services.forgejo) customDir user group;
cfg = config.modules.system.services.forgejo; cfg = config.modules.system.services.forgejo;
@ -16,7 +17,7 @@
acmeRoot = "/var/lib/acme/challenges-forgejo"; acmeRoot = "/var/lib/acme/challenges-forgejo";
dataDir = "/srv/data/forgejo"; dataDir = "/srv/data/forgejo";
in { in {
options.modules.system.services.forgejo.enable = lib.mkEnableOption "forgejo"; options.modules.system.services.forgejo.enable = mkEnableOption "forgejo";
config = mkIf cfg.enable { config = mkIf cfg.enable {
modules.system.services = { modules.system.services = {

View file

@ -0,0 +1,52 @@
{
config,
lib,
pkgs,
...
}: let
inherit (lib.modules) mkIf;
inherit (lib.options) mkEnableOption;
cfg = config.modules.system.services.grafana;
in {
options.modules.system.services.grafana.enable = mkEnableOption "Grafana, a graphing service";
config = mkIf cfg.enable {
networking.firewall.allowedTCPPorts = [config.services.grafana.settings.server.http_port];
modules.system.services.database.postgresql.enable = true;
services.grafana = {
enable = true;
package = pkgs.grafana;
port = 4021;
domain = "localhost";
settings = {
server = {
http_addr = "127.0.0.1";
http_port = 4021;
root_url = "https://info.copeberg.org";
domain = "info.copeberg.org";
enforce_domain = true;
};
database = {
type = "postgres";
host = "/run/postgresql";
name = "grafana";
user = "grafana";
ssl_mode = "disable";
};
analytics = {
reporting_enabled = false;
check_for_updates = false;
};
# users.allow_signup = false;
};
};
};
}

View file

@ -27,6 +27,7 @@ in {
ensureDatabases = [ ensureDatabases = [
"git" "git"
"grafana"
]; ];
ensureUsers = [ ensureUsers = [
@ -44,6 +45,10 @@ in {
name = "git"; name = "git";
ensureDBOwnership = true; ensureDBOwnership = true;
} }
{
name = "grafana";
ensureDBOwnership = true;
}
]; ];
settings = { settings = {
# taken from https://pgconfigurator.cybertec.at/ # taken from https://pgconfigurator.cybertec.at/

View file

@ -5,13 +5,21 @@
... ...
}: let }: let
inherit (lib.modules) mkForce; inherit (lib.modules) mkForce;
inherit (lib.options) mkEnableOption; inherit (lib.options) mkOption mkEnableOption;
inherit (lib.types) int;
cfg = config.modules.system.boot; cfg = config.modules.system.boot;
in { in {
options.modules.system.boot = { options.modules.system.boot = {
grub.enable = mkEnableOption "Grub, a bloated boot loader"; grub.enable = mkEnableOption "Grub, a bloated boot loader";
systemd-boot.enable = mkEnableOption "Poetteringboot"; systemd-boot.enable = mkEnableOption "Poetteringboot";
timeout = mkOption {
description = ''
Set the boot loader's timeout. This is 0 by default, but preferably longer on remote servers to make switching to previous generations easier.
'';
type = int;
default = 0;
};
}; };
config = { config = {
assertions = [ assertions = [
@ -33,7 +41,7 @@ in {
loader = { loader = {
efi.canTouchEfiVariables = true; efi.canTouchEfiVariables = true;
# I love spamming space # I love spamming space
timeout = 0; timeout = cfg.timeout;
systemd-boot = { systemd-boot = {
enable = cfg.systemd-boot.enable; enable = cfg.systemd-boot.enable;
editor = mkForce false; editor = mkForce false;