Compare commits

...

5 commits

Author SHA1 Message Date
50a2dcb82e trivionomicon: soju: add soju to the trivionomicon 2025-09-13 19:57:03 +02:00
Alejandro Soto
427a928f6c trivionomicon/pkgs: add snapborg 2025-08-31 19:20:13 -06:00
Alejandro Soto
49dae97575 trivionomicon/flake: fix overlay stacking 2025-08-31 10:38:53 -06:00
Alejandro Soto
4e039920c8 Merge commit 'eb85e81598' into t14 2025-08-26 21:37:17 -06:00
Alejandro Soto
e4eb342725 trivionomicon/flake: make 'mkSystem' available to library users 2025-08-25 23:25:25 -06:00
7 changed files with 169 additions and 20 deletions

View file

@ -9,11 +9,11 @@
nixpkgs, nixpkgs,
flake-utils, flake-utils,
}: let }: let
mapOverlayOverride = namespace: overlay: final: prev: let mapOverlayOverride = prefix: overlay: final: prev: let
overlayPkgs = overlay final prev; overlayPkgs = overlay final prev;
in in
{ {
"${namespace}" = builtins.removeAttrs overlayPkgs ["override"]; "${prefix}" = (prev.${prefix} or {}) // builtins.removeAttrs overlayPkgs ["override"];
} }
// (overlayPkgs.override or {}); // (overlayPkgs.override or {});
@ -30,7 +30,7 @@
packages = packages =
(import nixpkgs { (import nixpkgs {
inherit system; inherit system;
overlays = [(mapOverlayOverride doctrineNoPkgs.prefix (import ./pkgs))]; overlays = [self.overlays.default];
}).${ }).${
doctrineNoPkgs.prefix doctrineNoPkgs.prefix
}; };
@ -121,7 +121,7 @@
} }
# NB: Preserve the relative order # NB: Preserve the relative order
{ {
overlay = self.overlays.default; overlay = mapOverlayOverride prefix (import ./pkgs);
condition = true; condition = true;
} }
{ {
@ -164,24 +164,12 @@
} }
// optionalAttrs (paths ? nixosSource) { // optionalAttrs (paths ? nixosSource) {
nixosConfigurations = let nixosConfigurations = let
nixosSystem = {modules}:
lib.makeOverridable nixpkgs.lib.nixosSystem {
inherit modules pkgs system;
specialArgs = {
inherit flakes;
doctrine = mkDoctrine {
inherit pkgs;
namespace = "sys";
};
};
};
hostConfig = platform: hostConfig = platform:
nixosSystem { self.lib.mkSystem {
inherit flakes pkgs;
doctrine = doctrineNoPkgs;
modules = [ modules = [
self.nixosModules.default
nixosSourcePath nixosSourcePath
platform platform
]; ];
@ -213,6 +201,29 @@
in in
lib.mapAttrs home (importAll {root = hmPlatformsPath;}); lib.mapAttrs home (importAll {root = hmPlatformsPath;});
}; };
mkSystem = {
pkgs,
flakes,
doctrine,
modules,
}:
flakes.nixpkgs.lib.makeOverridable flakes.nixpkgs.lib.nixosSystem {
inherit pkgs;
inherit (pkgs) system;
modules = [self.nixosModules.default] ++ modules;
specialArgs = {
inherit flakes;
doctrine = self.lib.mkDoctrine {
inherit pkgs;
inherit (doctrine) prefix;
namespace = "sys";
};
};
};
}; };
}; };
} }

13
modules/soju/default.nix Normal file
View file

@ -0,0 +1,13 @@
{
config,
lib,
pkgs,
doctrine,
...
}:
doctrine.lib.mkModule {
inherit config;
name = "soju";
sys = ./sys.nix;
options = ./options.nix;
}

16
modules/soju/options.nix Normal file
View file

@ -0,0 +1,16 @@
{lib, ...}:
with lib.types; {
sys = {
fullyQualifiedDomain = lib.mkOption {
type = str;
example = "soju.trivionomicon.com";
description = "fully qualified domain name to be used by soju";
};
port = lib.mkOption {
type = int;
default = 6697;
description = "port to be used by soju";
};
};
}

45
modules/soju/sys.nix Normal file
View file

@ -0,0 +1,45 @@
{
lib,
pkgs,
config,
...
}:
with lib; {
security.acme.certs."${cfg.fullyQualifiedDomain}" = {
reloadServices = ["soju.service"];
group = "soju";
};
networking.firewall.allowedTCPPorts = [cfg.port];
services.soju = let
sojuCertDir = config.security.acme.certs."${cfg.fullyQualifiedDomain}".directory;
in {
enable = true;
hostName = "${cfg.fullyQualifiedDomain}";
listen = ["ircs://[::]:${cfg.port}"];
tlsCertificate = "${sojuCertDir}/fullchain.pem";
tlsCertificateKey = "${sojuCertDir}/key.pem";
};
systemd.services.soju = {
after = ["acme-${cfg.fullyQualifiedDomain}.service"];
serviceConfig = {
DynamicUser = mkForce false; # fuck dynamic users
User = "soju";
Group = "soju";
ProtectSystem = "strict";
ProtectHome = "read-only";
PrivateTmp = true;
RemoveIPC = true;
};
};
users = {
users.soju = {
isSystemUser = true;
group = "soju";
};
groups.soju = {};
};
}

View file

@ -5,5 +5,6 @@ in {
override = {}; override = {};
athena-bccr = callPackage ./athena-bccr {}; athena-bccr = callPackage ./athena-bccr {};
snapborg = final.python3Packages.callPackage ./snapborg {};
spliit = callPackage ./spliit {}; spliit = callPackage ./spliit {};
} }

View file

@ -0,0 +1,29 @@
From c363931656938f9cc3354b8e2797fe9abac1b0e3 Mon Sep 17 00:00:00 2001
From: Alejandro Soto <alejandro@34project.org>
Date: Sun, 31 Aug 2025 13:30:45 -0600
Subject: [PATCH] Remove "env" arg from subprocess calls
---
snapborg/borg.py | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/snapborg/borg.py b/snapborg/borg.py
index 89a3d84..b74ddf7 100644
--- a/snapborg/borg.py
+++ b/snapborg/borg.py
@@ -173,11 +173,10 @@ def launch_borg(args, password=None, print_output=False, dryrun=False, cwd=None)
# TODO: parse output from JSON log lines
try:
if print_output:
- subprocess.run(cmd, env=env, check=True, cwd=cwd)
+ subprocess.run(cmd, check=True, cwd=cwd)
else:
subprocess.check_output(cmd,
stderr=subprocess.STDOUT,
- env=env,
cwd=cwd)
except CalledProcessError as e:
if e.returncode == 1:
--
2.49.0

34
pkgs/snapborg/default.nix Normal file
View file

@ -0,0 +1,34 @@
{
borgbackup,
buildPythonApplication,
fetchFromGitHub,
lib,
packaging,
pyyaml,
}:
buildPythonApplication {
pname = "snapborg";
version = "0.1.0-unstable-20250331";
src = fetchFromGitHub {
repo = "snapborg";
owner = "enzingerm";
rev = "7e860395319f995161a6e0c7954ce47635e3cd59";
hash = "sha256-RzYL4IHulk1Q/ALWFs6YCTeCO8ohwqXH2NMHRctRVSA=";
};
patches = [
./0001-Remove-env-arg-from-subprocess-calls.patch # Fixes broken $PATH when calling borg
];
propagatedBuildInputs = [
borgbackup
packaging
pyyaml
];
preFixup = ''
makeWrapperArgs+=(--prefix PATH : ${lib.makeBinPath [borgbackup]})
'';
}