aboutsummaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
Diffstat (limited to 'modules')
-rw-r--r--modules/services/nixos/default.nix2
-rw-r--r--modules/services/nixos/ganyupload/README13
-rw-r--r--modules/services/nixos/ganyupload/default.nix47
-rw-r--r--modules/services/nixos/ganyupload/go.mod3
-rw-r--r--modules/services/nixos/ganyupload/main.go104
-rw-r--r--modules/services/nixos/ganyupload/pkg.nix6
-rw-r--r--modules/services/nixos/ngircd.nix27
-rw-r--r--modules/services/options.nix13
-rw-r--r--modules/system/nixos/boot.nix2
-rw-r--r--modules/system/nixos/polkit.nix2
-rw-r--r--modules/terminal/hjem/programs/broot.nix2
-rw-r--r--modules/terminal/hjem/programs/helix.nix6
-rw-r--r--modules/user/nixos/default.nix2
13 files changed, 207 insertions, 22 deletions
diff --git a/modules/services/nixos/default.nix b/modules/services/nixos/default.nix
index 32efb1c..c3652b5 100644
--- a/modules/services/nixos/default.nix
+++ b/modules/services/nixos/default.nix
@@ -9,9 +9,11 @@
./cgit
./jta
+ ./ganyupload
./polaris.nix
./agate.nix
./minecraft.nix
+ ./ngircd.nix
./copyparty.nix
./qbittorrent.nix
];
diff --git a/modules/services/nixos/ganyupload/README b/modules/services/nixos/ganyupload/README
new file mode 100644
index 0000000..ac9a50d
--- /dev/null
+++ b/modules/services/nixos/ganyupload/README
@@ -0,0 +1,13 @@
+Ganyupload - File Upload Service
+
+Upload files using curl with a PUT request:
+
+ curl -X PUT --data-binary @myfile.txt https://upld.williamsfam.us.com/myfile.txt
+
+The server will respond with "ok" on success.
+
+You can use any path you want:
+
+ curl -X PUT --data-binary @document.pdf https://upld.williamsfam.us.com/docs/document.pdf
+
+Nested directories will be created automatically.
diff --git a/modules/services/nixos/ganyupload/default.nix b/modules/services/nixos/ganyupload/default.nix
new file mode 100644
index 0000000..0138100
--- /dev/null
+++ b/modules/services/nixos/ganyupload/default.nix
@@ -0,0 +1,47 @@
+{
+ pkgs,
+ config,
+ lib,
+ ...
+}: let
+ cfg = config.collinux.services.ganyupload;
+
+ package = pkgs.callPackage ./pkg.nix {};
+in {
+ imports = [
+ (import ../mkCaddyCfg.nix cfg)
+ ];
+
+ config = lib.mkIf cfg.enable {
+ users.groups."ganyupload" = {};
+ users.users."ganyupload" = {
+ isSystemUser = true;
+ group = "ganyupload";
+ home = "/var/lib/ganyupload";
+ createHome = true;
+ homeMode = "755";
+ };
+
+ systemd.services."ganyupload" = {
+ description = "Ganymede File Upload Service";
+ restartIfChanged = true;
+ wants = ["network-online.target" "caddy.service"];
+ after = ["network-online.target" "caddy.service"];
+
+ environment = {
+ PORT = toString cfg.port;
+ UPLOAD_DIR = "/media/ganyupload";
+ };
+
+ serviceConfig = {
+ User = "ganyupload";
+ Type = "simple";
+
+ WorkingDirectory = "/var/lib/ganyupload";
+ ExecStart = "${package}/bin/ganyupload";
+ };
+
+ wantedBy = ["multi-user.target"];
+ };
+ };
+}
diff --git a/modules/services/nixos/ganyupload/go.mod b/modules/services/nixos/ganyupload/go.mod
new file mode 100644
index 0000000..715e1b7
--- /dev/null
+++ b/modules/services/nixos/ganyupload/go.mod
@@ -0,0 +1,3 @@
+module git.ganymede/ganyupload
+
+go 1.25.5
diff --git a/modules/services/nixos/ganyupload/main.go b/modules/services/nixos/ganyupload/main.go
new file mode 100644
index 0000000..6aa219e
--- /dev/null
+++ b/modules/services/nixos/ganyupload/main.go
@@ -0,0 +1,104 @@
+package main
+
+import (
+ _ "embed"
+ "io"
+ "log"
+ "net/http"
+ "os"
+ "path/filepath"
+ "strings"
+)
+
+//go:embed README
+var readme string
+
+var uploadDir = "."
+
+func handleRoot(w http.ResponseWriter, r *http.Request) {
+ if r.Method != http.MethodGet {
+ http.Error(w, "method not allowed", http.StatusMethodNotAllowed)
+ return
+ }
+
+ w.Header().Set("Content-Type", "text/plain; charset=utf-8")
+ w.Write([]byte(readme))
+}
+
+func handleUpload(w http.ResponseWriter, r *http.Request) {
+ // Show README on GET /
+ if r.Method == http.MethodGet && r.URL.Path == "/" {
+ handleRoot(w, r)
+ return
+ }
+
+ if r.Method != http.MethodPut {
+ http.Error(w, "method not allowed", http.StatusMethodNotAllowed)
+ return
+ }
+
+ // Extract filename from URL path, preventing path traversal
+ filename := strings.TrimPrefix(r.URL.Path, "/")
+ if filename == "" {
+ http.Error(w, "filename required", http.StatusBadRequest)
+ return
+ }
+
+ // Prevent path traversal
+ filename = filepath.Clean(filename)
+ if strings.HasPrefix(filename, "..") {
+ http.Error(w, "invalid filename", http.StatusBadRequest)
+ return
+ }
+
+ fullPath := filepath.Join(uploadDir, filename)
+
+ // Ensure the directory exists
+ dir := filepath.Dir(fullPath)
+ if err := os.MkdirAll(dir, 0755); err != nil {
+ log.Printf("failed to create directory: %v", err)
+ http.Error(w, "internal server error", http.StatusInternalServerError)
+ return
+ }
+
+ // Create the file
+ f, err := os.Create(fullPath)
+ if err != nil {
+ log.Printf("failed to create file: %v", err)
+ http.Error(w, "internal server error", http.StatusInternalServerError)
+ return
+ }
+ defer f.Close()
+
+ // Copy request body to file
+ written, err := io.Copy(f, r.Body)
+ if err != nil {
+ log.Printf("failed to write file: %v", err)
+ http.Error(w, "internal server error", http.StatusInternalServerError)
+ return
+ }
+
+ w.Header().Set("Content-Type", "text/plain; charset=utf-8")
+ w.WriteHeader(http.StatusCreated)
+ w.Write([]byte("ok\n"))
+
+ log.Printf("uploaded %s (%d bytes)", filename, written)
+}
+
+func main() {
+ if envUploadDir := os.Getenv("UPLOAD_DIR"); envUploadDir != "" {
+ uploadDir = envUploadDir
+ }
+
+ port := os.Getenv("PORT")
+ if port == "" {
+ port = "8080"
+ }
+
+ http.HandleFunc("/", handleUpload)
+
+ log.Printf("starting ganyupload on port %s, upload directory: %s", port, uploadDir)
+ if err := http.ListenAndServe(":"+port, nil); err != nil {
+ log.Fatalf("server error: %v", err)
+ }
+}
diff --git a/modules/services/nixos/ganyupload/pkg.nix b/modules/services/nixos/ganyupload/pkg.nix
new file mode 100644
index 0000000..18be8ed
--- /dev/null
+++ b/modules/services/nixos/ganyupload/pkg.nix
@@ -0,0 +1,6 @@
+{pkgs ? import <nixpkgs> {system = "x86_64-linux";}, ...}:
+pkgs.buildGoModule {
+ name = "ganyupload";
+ src = ./.;
+ vendorHash = null;
+}
diff --git a/modules/services/nixos/ngircd.nix b/modules/services/nixos/ngircd.nix
index 014dd68..d06a497 100644
--- a/modules/services/nixos/ngircd.nix
+++ b/modules/services/nixos/ngircd.nix
@@ -6,31 +6,28 @@
cfg = config.collinux.services.ngircd;
in
lib.mkIf cfg.enable {
+ networking.firewall.allowedTCPPorts = [cfg.port];
+
services.ngircd = {
enable = true;
config = ''
[Global]
- Name = irc.williamsfam.us.com
+ Name = williamsfam.us.com
Info = Ganymede IRC Chat
AdminInfo1 = Collin
- Listen = 127.0.0.1
+ Listen = 0.0.0.0
Ports = ${toString cfg.port}
- [Options]
- PAM = yes
- PAMIsOptional = no
+ [Channel]
+ Name = #general
+ AutoJoin = yes
- [Operator]
- Name = collin
- Password = # users authenticate with PAM
- Mask = *@*
+ [Options]
+ RequireAuth = no
+ Ident = no
+ AllowedHosts = *
+ PAM = no
'';
};
-
- users.users.ngircd.extraGroups = ["shadow"];
-
- security.pam.services.ngircd = {
- unixAuth = true;
- };
}
diff --git a/modules/services/options.nix b/modules/services/options.nix
index bb43180..8918781 100644
--- a/modules/services/options.nix
+++ b/modules/services/options.nix
@@ -114,6 +114,11 @@ in {
default_port = 8072;
};
+ ganyupload = webserviceOptions {
+ service_name = "ganyupload";
+ default_port = 8073;
+ };
+
copyparty =
(webserviceOptions {
service_name = "copyparty";
@@ -141,6 +146,14 @@ in {
};
};
+ ngircd = {
+ enable = mkEnableOption "ncircd IRC server";
+ port = mkOption {
+ type = lib.types.port;
+ default = 6667;
+ };
+ };
+
minecraft = {
enable = mkEnableOption "Minecraft bedrock server";
listenAddr = mkOption {
diff --git a/modules/system/nixos/boot.nix b/modules/system/nixos/boot.nix
index 709a1ca..71bac70 100644
--- a/modules/system/nixos/boot.nix
+++ b/modules/system/nixos/boot.nix
@@ -77,7 +77,7 @@ in {
enable = true;
mutable = true; # necessary for installing secrets into etc
};
- system.nixos-init.enable = true;
+ # system.nixos-init.enable = true;
# store journald logs in memory
services.journald.extraConfig = ''
diff --git a/modules/system/nixos/polkit.nix b/modules/system/nixos/polkit.nix
index 29a06f4..5bd8e33 100644
--- a/modules/system/nixos/polkit.nix
+++ b/modules/system/nixos/polkit.nix
@@ -69,7 +69,5 @@ in {
defaultDenyRule
];
};
-
- soteria.enable = true;
};
}
diff --git a/modules/terminal/hjem/programs/broot.nix b/modules/terminal/hjem/programs/broot.nix
index 4836d50..59f16aa 100644
--- a/modules/terminal/hjem/programs/broot.nix
+++ b/modules/terminal/hjem/programs/broot.nix
@@ -57,7 +57,7 @@
{
name = "justfile";
key = "ctrl-j";
- execution = ''just --choose --chooser "fzf --height=25% --color=bg:-1 --preview 'just --show {}'"'';
+ execution = "just --choose";
working_dir = "{root}";
leave_broot = false;
}
diff --git a/modules/terminal/hjem/programs/helix.nix b/modules/terminal/hjem/programs/helix.nix
index 89d18f4..db6beba 100644
--- a/modules/terminal/hjem/programs/helix.nix
+++ b/modules/terminal/hjem/programs/helix.nix
@@ -33,8 +33,10 @@
command = "${pkgs.superhtml}/bin/superhtml";
args = ["lsp"];
};
- golsp = {
- command = "${pkgs.gopls}/bin/gopls";
+ golsp.command = "${pkgs.gopls}/bin/gopls";
+ tinymist = {
+ command = "${pkgs.tinymist}/bin/tinymist";
+ config.exportPdf = "onType";
};
dhall-lsp-server.command = "${pkgs.dhall-lsp-server}/bin/dhall-lsp-server";
};
diff --git a/modules/user/nixos/default.nix b/modules/user/nixos/default.nix
index 68238d6..fbc6001 100644
--- a/modules/user/nixos/default.nix
+++ b/modules/user/nixos/default.nix
@@ -15,7 +15,7 @@ in {
extraGroups = ["networkmanager" "disks" "input" "video" "dialout" "kvm"] ++ (lib.optional cfg.isAdmin "wheel");
};
};
- services.userborn.enable = true;
+ # services.userborn.enable = true;
# sudo
security = {