about summary refs log tree commit diff
path: root/modules
diff options
context:
space:
mode:
Diffstat (limited to 'modules')
-rw-r--r--modules/common/common/nix/default.nix15
-rw-r--r--modules/common/profiles/dev/default.nix4
-rw-r--r--modules/common/profiles/headful.nix3
-rw-r--r--modules/nixos/games/lutris.nix1
-rw-r--r--modules/nixos/loki.nix5
-rw-r--r--modules/nixos/promtail.nix62
6 files changed, 77 insertions, 13 deletions
diff --git a/modules/common/common/nix/default.nix b/modules/common/common/nix/default.nix
index 9f80838..b328e4c 100644
--- a/modules/common/common/nix/default.nix
+++ b/modules/common/common/nix/default.nix
@@ -4,7 +4,6 @@
   lib,
   localUsername ? lib.my.username,
   pkgs,
-  pkgsPR,
   this,
   ...
 }:
@@ -99,13 +98,16 @@ with lib; {
           patches = [./patches/alejandra-no-ads.patch];
         });
 
-        logcli = super.grafana-loki.overrideAttrs (_: _: {
+        logcli = super.grafana-loki.overrideAttrs (_: final: {
+          nativeBuildInputs = final.nativeBuildInputs ++ [pkgs.installShellFiles];
           subPackages = ["cmd/logcli"];
+          postInstall = ''
+            installShellCompletion --cmd logcli \
+              --bash <($out/bin/logcli --completion--script-bash) \
+              --zsh <($out/bin/logcli --completion-script-zsh)
+          '';
+          preFixup = null;
         });
-
-        inherit (pkgsPR "215704" "sha256-o2F/ZAugljJKlVIAHMTBK6+Lj6BiBwteA5OuaWPKXm0=") dendrite;
-
-        inherit (pkgsPR "216465" "sha256-ik3e+KM27hGkKWTOOUWj1YtiqHTJvl04dx0/X08P1A0=") amdvlk;
       }
       // (with super; let
         np = nodePackages;
@@ -135,6 +137,7 @@ with lib; {
 
   environment.systemPackages = with pkgs;
     optionals this.isHeadful [
+      hydra-check
       nix-top
       nix-tree
     ];
diff --git a/modules/common/profiles/dev/default.nix b/modules/common/profiles/dev/default.nix
index 366590f..210924a 100644
--- a/modules/common/profiles/dev/default.nix
+++ b/modules/common/profiles/dev/default.nix
@@ -38,14 +38,14 @@ in {
           templates.params = rec {
             author-name = my.fullname;
             author-email = my.email;
-            copyright = "Copyright (c) ${author-name} <${author-email}>";
+            copyright = "Copyright (c) 2023 ${author-name} <${author-email}>";
             github-username = my.username;
           };
         };
 
         ".stack/global-project/stack.yaml".text = generators.toYAML {} {
           packages = [];
-          resolver = "lts-20.3";
+          resolver = "lts-20.14";
         };
       };
 
diff --git a/modules/common/profiles/headful.nix b/modules/common/profiles/headful.nix
index 1c1f43b..809605c 100644
--- a/modules/common/profiles/headful.nix
+++ b/modules/common/profiles/headful.nix
@@ -33,10 +33,13 @@ in {
 
         packages = with pkgs; [
           fd
+          logcli
           ripgrep
           ripgrep-all
           sd
         ];
+
+        sessionVariables.LOKI_ADDR = "https://loki.${config.networking.domain}";
       };
 
       accounts.email = {
diff --git a/modules/nixos/games/lutris.nix b/modules/nixos/games/lutris.nix
index 72179fc..2737953 100644
--- a/modules/nixos/games/lutris.nix
+++ b/modules/nixos/games/lutris.nix
@@ -27,6 +27,7 @@ in {
         };
       })
       vkBasalt
+      winetricks
     ];
   };
 }
diff --git a/modules/nixos/loki.nix b/modules/nixos/loki.nix
index 1582164..fe3c2eb 100644
--- a/modules/nixos/loki.nix
+++ b/modules/nixos/loki.nix
@@ -73,6 +73,11 @@ in {
           };
         };
 
+        limits_config = {
+          max_streams_per_user = 0;
+          max_global_streams_per_user = 0;
+        };
+
         schema_config.configs = [
           {
             from = "2020-01-01";
diff --git a/modules/nixos/promtail.nix b/modules/nixos/promtail.nix
index 552df82..c038d7b 100644
--- a/modules/nixos/promtail.nix
+++ b/modules/nixos/promtail.nix
@@ -34,17 +34,69 @@ in {
           log_level = "warn";
         };
 
-        clients = [{url = "${cfg.loki.url}/loki/api/v1/push";}];
+        clients = [
+          {
+            url = "${cfg.loki.url}/loki/api/v1/push";
+            external_labels.host_id = config.networking.hostId;
+          }
+        ];
 
         positions.filename = "/tmp/positions.yaml";
 
         scrape_configs = [
           {
             job_name = "journal";
-            journal = {
-              max_age = "24h";
-              labels.job = "systemd-journal";
-            };
+            journal.max_age = "24h";
+            relabel_configs =
+              map (n: let
+                label = toLower n;
+              in {
+                source_labels = ["__journal_${label}"];
+                target_label =
+                  if hasPrefix "_" label
+                  then substring 1 (stringLength label - 1) label
+                  else label;
+              }) [
+                # Derived from systemd.journal fields[1][2].
+                #
+                # [1]: https://www.freedesktop.org/software/systemd/man/systemd.journal-fields.html
+                # [2]: https://github.com/coreos/go-systemd/blob/main/sdjournal/journal.go#L335
+
+                "MESSAGE"
+                "MESSAGE_ID"
+                "PRIORITY"
+                # "CODE_FILE"
+                # "CODE_LINE"
+                # "CODE_FUNC"
+                "ERRNO"
+                "SYSLOG_FACILITY"
+                "SYSLOG_IDENTIFIER"
+                "SYSLOG_PID"
+                "_PID"
+                "_UID"
+                "_GID"
+                # "_COMM"
+                # "_EXE"
+                "_CMDLINE"
+                # "_CAP_EFFECTIVE"
+                # "_AUDIT_SESSION"
+                # "_AUDIT_LOGINUID"
+                # "_SYSTEMD_CGROUP"
+                # "_SYSTEMD_SESSION"
+                "_SYSTEMD_UNIT"
+                "_SYSTEMD_USER_UNIT"
+                # "_SYSTEMD_OWNER_UID"
+                # "_SYSTEMD_SLICE"
+                # "_SELINUX_CONTEXT"
+                # "_SOURCE_REALTIME_TIMESTAMP"
+                "_BOOT_ID"
+                "_MACHINE_ID"
+                "_HOSTNAME"
+                "_TRANSPORT"
+                # "__CURSOR"
+                # "__REALTIME_TIMESTAMP"
+                # "__MONOTONIC_TIMESTAMP"
+              ];
           }
         ];
       };

Consider giving Nix/NixOS a try! <3