about summary refs log tree commit diff
path: root/modules
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--modules/common/common/shell/functions.bash56
-rw-r--r--modules/common/editorconfig.nix10
-rw-r--r--modules/common/emacs/default.nix10
-rw-r--r--modules/common/emacs/doom/config.el32
-rw-r--r--modules/nixos/default.nix2
-rw-r--r--modules/nixos/incus.nix62
-rw-r--r--modules/nixos/lxc.nix18
-rw-r--r--modules/nixos/matrix/default.nix1
-rw-r--r--modules/nixos/matrix/synapse.nix92
-rw-r--r--modules/nixos/podman.nix26
10 files changed, 110 insertions, 199 deletions
diff --git a/modules/common/common/shell/functions.bash b/modules/common/common/shell/functions.bash
index d947d0f..f354adb 100644
--- a/modules/common/common/shell/functions.bash
+++ b/modules/common/common/shell/functions.bash
@@ -1,59 +1,59 @@
 function where() {
-    local s
-    s="$(type -P "$1")"
-    realpath "$s"
+  local s
+  s="$(type -P "$1")"
+  realpath "$s"
 }
 complete -F _command where
 
 function what() {
-    local s
-    s="$(where "$1")"
-    printf "%s\n" "${s%/*/*}"
+  local s
+  s="$(where "$1")"
+  printf "%s\n" "${s%/*/*}"
 }
 complete -F _command what
 
 function cat() {
-    if (($# == 1)) && [[ -d $1 ]]; then
-        ll "$1"
-    else
-        command cat "$@"
-    fi
+  if (($# == 1)) && [[ -d $1 ]]; then
+    ll "$1"
+  else
+    command cat "$@"
+  fi
 }
 
 function cd() {
-    builtin cd "$@" &&
-        if ((${#FUNCNAME[@]} == 1)); then
-            ls
-        fi
+  builtin cd "$@" &&
+    if ((${#FUNCNAME[@]} == 1)); then
+      ls
+    fi
 }
 
 function mkcd() {
-    mkdir -p "$1" && builtin cd "$1"
+  mkdir -p "$1" && builtin cd "$1"
 }
 
 function mvcd() {
-    mv -i -- "$PWD" "$1" && builtin cd .
+  mv -i -- "$PWD" "$1" && builtin cd .
 }
 
 function bak() {
-    local f
-    for f; do
-        cp -ai -- "$f" "$f.bak"
-    done
+  local f
+  for f; do
+    cp -ai -- "$f" "$f.bak"
+  done
 }
 
 function ubak() {
-    local f
-    for f; do
-        [[ $f == *.bak ]] || f="$f.bak"
-        mv -i -- "$f" "${f%.bak}"
-    done
+  local f
+  for f; do
+    [[ $f == *.bak ]] || f="$f.bak"
+    mv -i -- "$f" "${f%.bak}"
+  done
 }
 
 function dec2hex() {
-    printf "0x%X\n" "$1"
+  printf "0x%X\n" "$1"
 }
 
 function hex2dec() {
-    printf "%d\n" "0x$1"
+  printf "%d\n" "0x$1"
 }
diff --git a/modules/common/editorconfig.nix b/modules/common/editorconfig.nix
index 822acf6..537912f 100644
--- a/modules/common/editorconfig.nix
+++ b/modules/common/editorconfig.nix
@@ -29,7 +29,7 @@ in {
         };
 
         # https://go.dev/doc/effective_go#formatting
-        "*.go" = {
+        "{*.go,go.mod}" = {
           indent_size = 2;
           indent_style = "tab";
         };
@@ -66,7 +66,7 @@ in {
           indent_style = "space";
         };
 
-        "*.{asm,s}" = {
+        "*.{asm,s,S}" = {
           indent_size = 4;
           indent_style = "spaces";
         };
@@ -90,6 +90,12 @@ in {
           indent_style = "space";
         };
 
+        # https://nickel-lang.org/user-manual/syntax
+        "*.ncl" = {
+          indent_size = 2;
+          indent_style = "space";
+        };
+
         # https://developer.hashicorp.com/terraform/language/syntax/style
         "*.{tf,hcl}" = {
           indent_size = 2;
diff --git a/modules/common/emacs/default.nix b/modules/common/emacs/default.nix
index 082b3c3..439a6bc 100644
--- a/modules/common/emacs/default.nix
+++ b/modules/common/emacs/default.nix
@@ -71,6 +71,7 @@ in {
                     cmigemo # :lang japanese
                     config.hm.programs.emacs.package # !doom
                     config.nix.package # !doom
+                    delve # :lang go :tools debugger
                     dockerfile-language-server-nodejs # :tools (docker +lsp)
                     dockfmt # :tools docker :editor format
                     editorconfig-core-c # :tools editorconfig
@@ -198,7 +199,6 @@ in {
                       org-plantuml-jar-path plantuml-jar-path
                       org-plantuml-executable-path plantuml-executable-path)
 
-
                 ;; :app irc
                 (setq circe-default-nick "${my.username}"
                       circe-default-realname "${my.email}"
@@ -248,14 +248,6 @@ in {
           # https://github.com/akermu/emacs-libvterm
           if [[ "$INSIDE_EMACS" = vterm ]] && [[ -n "$EMACS_VTERM_PATH" ]] && [[ -f "$EMACS_VTERM_PATH/etc/emacs-vterm-bash.sh" ]]; then
               source "$EMACS_VTERM_PATH/etc/emacs-vterm-bash.sh"
-
-              message() {
-                  vterm_cmd message "%s" "$*"
-              }
-
-              find-file() {
-                  vterm_cmd find-file "$(realpath "''${@:-.}")"
-              }
           fi
 
           # Not sourced from inside Emacs for some reason. Maybe it's not
diff --git a/modules/common/emacs/doom/config.el b/modules/common/emacs/doom/config.el
index 13eb5ba..70116f8 100644
--- a/modules/common/emacs/doom/config.el
+++ b/modules/common/emacs/doom/config.el
@@ -64,41 +64,15 @@
                                  ("HOLD" . +org-todo-onhold)
                                  ("PROJ" . +org-todo-project)
                                  ("KILL" . +org-todo-cancel))
-        org-capture-templates '(("t" "Personal todo" entry
+        org-capture-templates '(("t" "Todo" entry
                                  (file+headline +org-capture-todo-file "Inbox")
                                  "* TODO %?\n%i\n%a" :prepend t)
-                                ("n" "Personal notes" entry
+                                ("n" "Note" entry
                                  (file+headline +org-capture-notes-file "Inbox")
                                  "* %u %?\n%i\n%a" :prepend t)
                                 ("j" "Journal" entry
                                  (file+olp+datetree +org-capture-journal-file)
-                                 "* %U %?\n%i\n%a" :prepend t)
-                                ("p" "Templates for projects")
-                                ("pt" "Project-local todo" entry
-                                 (file+headline +org-capture-project-todo-file "Inbox")
-                                 "* TODO %?\n%i\n%a" :prepend t)
-                                ("pn" "Project-local notes" entry
-                                 (file+headline +org-capture-project-notes-file "Inbox")
-                                 "* %U %?\n%i\n%a" :prepend t)
-                                ("pc" "Project-local changelog" entry
-                                 (file+headline +org-capture-project-changelog-file "Unreleased")
-                                 "* %U %?\n%i\n%a" :prepend t)
-                                ("o" "Centralized templates for projects")
-                                ("ot" "Project todo" entry
-                                 (function +org-capture-central-project-todo-file)
-                                 "* TODO %?\n %i\n %a"
-                                 :heading "Tasks"
-                                 :prepend nil)
-                                ("on" "Project notes" entry
-                                 (function +org-capture-central-project-notes-file)
-                                 "* %U %?\n %i\n %a"
-                                 :heading "Notes"
-                                 :prepend t)
-                                ("oc" "Project changelog" entry
-                                 (function +org-capture-central-project-changelog-file)
-                                 "* %U %?\n %i\n %a"
-                                 :heading "Changelog"
-                                 :prepend t))))
+                                 "* %U %?\n%i\n%a" :prepend t))))
 
 (add-hook! 'org-mode-hook 'auto-fill-mode)
 
diff --git a/modules/nixos/default.nix b/modules/nixos/default.nix
index ee63ba1..93f0974 100644
--- a/modules/nixos/default.nix
+++ b/modules/nixos/default.nix
@@ -29,7 +29,7 @@ _: {
     ./libvirtd.nix
     ./lidarr.nix
     ./loki.nix
-    ./lxc.nix
+    ./incus.nix
     ./matrix
     ./monitoring
     ./mpd.nix
diff --git a/modules/nixos/incus.nix b/modules/nixos/incus.nix
new file mode 100644
index 0000000..ada113f
--- /dev/null
+++ b/modules/nixos/incus.nix
@@ -0,0 +1,62 @@
+{
+  config,
+  lib,
+  ...
+}:
+with lib; let
+  cfg = config.nixfiles.modules.incus;
+in {
+  options.nixfiles.modules.incus.enable = mkEnableOption "Incus";
+
+  config = mkIf cfg.enable {
+    ark.directories = ["/var/lib/incus"];
+
+    virtualisation.incus = {
+      enable = true;
+
+      preseed = mkDefault {
+        networks = [
+          {
+            name = "incusbr0";
+            type = "bridge";
+            config = {
+              "ipv4.address" = "10.0.30.1/24";
+              "ipv4.nat" = true;
+              "ipv6.address" = "fc30::1/64";
+              "ipv6.nat" = true;
+            };
+          }
+        ];
+        storage_pools = [
+          {
+            name = "default";
+            driver = "dir";
+            config.source = "/var/lib/incus/storage-pools/default";
+          }
+        ];
+        profiles = [
+          {
+            name = "default";
+            devices = {
+              eth0 = {
+                type = "nic";
+                name = "eth0";
+                network = "incusbr0";
+              };
+              root = {
+                type = "disk";
+                pool = "default";
+                size = "15GiB";
+                path = "/";
+              };
+            };
+          }
+        ];
+      };
+    };
+
+    networking.firewall.trustedInterfaces = ["incusbr0"];
+
+    my.extraGroups = ["incus-admin"];
+  };
+}
diff --git a/modules/nixos/lxc.nix b/modules/nixos/lxc.nix
deleted file mode 100644
index 1306497..0000000
--- a/modules/nixos/lxc.nix
+++ /dev/null
@@ -1,18 +0,0 @@
-{
-  config,
-  lib,
-  ...
-}:
-with lib; let
-  cfg = config.nixfiles.modules.lxc;
-in {
-  options.nixfiles.modules.lxc.enable = mkEnableOption "LXC/Incus";
-
-  config = mkIf cfg.enable {
-    ark.directories = ["/var/lib/incus"];
-
-    virtualisation.incus.enable = true;
-
-    my.extraGroups = ["incus-admin"];
-  };
-}
diff --git a/modules/nixos/matrix/default.nix b/modules/nixos/matrix/default.nix
index 879243e..e7d5a02 100644
--- a/modules/nixos/matrix/default.nix
+++ b/modules/nixos/matrix/default.nix
@@ -2,6 +2,5 @@ _: {
   imports = [
     ./dendrite.nix
     ./element.nix
-    ./synapse.nix
   ];
 }
diff --git a/modules/nixos/matrix/synapse.nix b/modules/nixos/matrix/synapse.nix
deleted file mode 100644
index 02592de..0000000
--- a/modules/nixos/matrix/synapse.nix
+++ /dev/null
@@ -1,92 +0,0 @@
-{
-  config,
-  lib,
-  ...
-}:
-with lib; let
-  cfg = config.nixfiles.modules.matrix.synapse;
-in {
-  options.nixfiles.modules.matrix.synapse = {
-    enable = mkEnableOption "Synapse Matrix server";
-
-    domain = mkOption {
-      description = "Domain name sans protocol scheme.";
-      type = with types; str;
-      default = config.networking.domain;
-    };
-  };
-
-  config = let
-    bind_address = "127.0.0.1";
-    port = 8448;
-  in
-    mkIf cfg.enable {
-      ark.directories = ["/var/lib/matrix-synapse"];
-
-      nixfiles.modules = {
-        nginx = {
-          enable = true;
-          upstreams.synapse.servers."${bind_address}:${toString port}" = {};
-          virtualHosts.${cfg.domain}.locations = {
-            "~ ^(/_matrix|/_synapse/client)".proxyPass = "http://synapse";
-            "= /.well-known/matrix/server" = {
-              extraConfig = ''
-                add_header Content-Type application/json;
-              '';
-              return = "200 '${generators.toJSON {} {
-                "m.server" = "${cfg.domain}:443";
-              }}'";
-            };
-            "= /.well-known/matrix/client" = {
-              extraConfig = ''
-                add_header Content-Type application/json;
-                add_header Access-Control-Allow-Origin *;
-              '';
-              return = "200 '${generators.toJSON {} {
-                "m.homeserver".base_url = "https://${cfg.domain}";
-              }}'";
-            };
-          };
-        };
-        postgresql.enable = true;
-      };
-
-      services = let
-        db = "synapse";
-      in {
-        matrix-synapse = {
-          enable = true;
-          server_name = config.networking.domain;
-
-          database_type = "psycopg2";
-          database_name = db;
-          database_user = db;
-
-          listeners = [
-            {
-              inherit bind_address port;
-              type = "http";
-              tls = false;
-              x_forwarded = true;
-              resources = [
-                {
-                  names = ["client" "federation"];
-                  compress = false;
-                }
-              ];
-            }
-          ];
-        };
-
-        postgresql = {
-          ensureDatabases = [db];
-          ensureUsers = [
-            {
-              name = db;
-              ensureDBOwnership = true;
-            }
-          ];
-        };
-      };
-    };
-}
diff --git a/modules/nixos/podman.nix b/modules/nixos/podman.nix
index f6ee6bf..60f208e 100644
--- a/modules/nixos/podman.nix
+++ b/modules/nixos/podman.nix
@@ -34,25 +34,13 @@ in {
     my.extraGroups = ["podman"];
 
     hm.xdg.configFile = {
-      # This removes a really annoying registry search. 100% of the time I
-      # would need to look up stuff from the Docker and not Quay!
-      "containers/registries.conf".text = ''
-        [registries.search]
-        registries = ["docker.io"]
-      '';
-
-      # As for plain OverlayFS in Podman over ZFS[1]... I guess we are waiting
-      # for Podman to catch up now.
-      #
-      # [1]: https://github.com/openzfs/zfs/pull/14070#issuecomment-1309116666
-      "containers/storage.conf".text = optionalString config.boot.zfs.enabled ''
-        [storage]
-        driver = "overlay"
-
-        [storage.options]
-        mount_program = "${getExe' pkgs.fuse-overlayfs "fuse-overlayfs"}"
-        mountopt = "noatime,nodev,nosuid"
-      '';
+      "containers/registries.conf".source = pkgs.writers.writeTOML "containers-registries.toml" {
+        registries.search.registries = ["docker.io"];
+      };
+
+      "containers/storage.conf".source = pkgs.writers.writeTOML "containers-storage.toml" {
+        storage.driver = "overlay";
+      };
     };
   };
 }

Consider giving Nix/NixOS a try! <3