ctucx.git: nixfiles

ctucx' nixfiles

commit 3819828df48cccc6fb15348c2dd883ffb4b4de22
parent 70ae813f486b7117b9b06162b755839006ca7636
Author: Leah (ctucx) <git@ctu.cx>
Date: Tue, 25 Jul 2023 12:10:10 +0200

pkgs/gotosocial: update version 0.8.0 -> 0.10.0
2 files changed, 11 insertions(+), 138 deletions(-)
D
pkgs/gotosocial/0001-hack-Allow-leah-s-socks-proxy-through.patch
|
123
-------------------------------------------------------------------------------
M
pkgs/gotosocial/default.nix
|
26
+++++++++++---------------
diff --git a/pkgs/gotosocial/0001-hack-Allow-leah-s-socks-proxy-through.patch b/pkgs/gotosocial/0001-hack-Allow-leah-s-socks-proxy-through.patch
@@ -1,123 +0,0 @@
-From 580e0d14ca5bfb69d44cc65b833d0214fdae9ece Mon Sep 17 00:00:00 2001
-From: tsmethurst <tobi.smethurst@protonmail.com>
-Date: Thu, 2 Mar 2023 15:55:22 +0100
-Subject: [PATCH] [hack] Allow leah's socks proxy through
-
----
- internal/netutil/validate.go      | 14 ++++++++++
- internal/netutil/validate_test.go | 44 ++++++++++++++++++++-----------
- 2 files changed, 42 insertions(+), 16 deletions(-)
-
-diff --git a/internal/netutil/validate.go b/internal/netutil/validate.go
-index 138e916c..4db5de5d 100644
---- a/internal/netutil/validate.go
-+++ b/internal/netutil/validate.go
-@@ -64,6 +64,10 @@ var (
- 		netip.MustParsePrefix("224.0.0.0/4"),     // Multicast
- 		netip.MustParsePrefix("240.0.0.0/4"),     // Reserved (includes broadcast / 255.255.255.255)
- 	}
-+
-+	IPv4Allowed = [...]netip.Prefix{
-+		netip.MustParsePrefix("172.17.0.1/32"), // Explicitly allow Leah's SOCKS proxy
-+	}
- )
- 
- // ValidateAddr will parse a netip.AddrPort from string, and return the result of ValidateIP() on addr.
-@@ -82,9 +86,19 @@ func ValidateIP(ip netip.Addr) bool {
- 	case ip.Is4():
- 		for _, reserved := range IPv4Reserved {
- 			if reserved.Contains(ip) {
-+				for _, allowed := range IPv4Allowed {
-+					if allowed.Contains(ip) {
-+						// A normally reserved ip addr
-+						// has been explicitly allowed.
-+						return true
-+					}
-+				}
-+				// No exception exists for this ip.
- 				return false
- 			}
- 		}
-+		// Neither reserved nor explicitly
-+		// allowed, default to allowed.
- 		return true
- 
- 	// IPv6: check if IP in IPv6 reserved nets
-diff --git a/internal/netutil/validate_test.go b/internal/netutil/validate_test.go
-index 37def4ce..6000cc08 100644
---- a/internal/netutil/validate_test.go
-+++ b/internal/netutil/validate_test.go
-@@ -7,33 +7,45 @@ import (
- 
- func TestValidateIP(t *testing.T) {
- 	tests := []struct {
--		name string
--		ip   netip.Addr
-+		name     string
-+		ip       netip.Addr
-+		expected bool
- 	}{
- 		// IPv4 tests
- 		{
--			name: "IPv4 this host on this network",
--			ip:   netip.MustParseAddr("0.0.0.0"),
-+			name:     "IPv4 this host on this network",
-+			ip:       netip.MustParseAddr("0.0.0.0"),
-+			expected: false,
- 		},
- 		{
--			name: "IPv4 dummy address",
--			ip:   netip.MustParseAddr("192.0.0.8"),
-+			name:     "IPv4 dummy address",
-+			ip:       netip.MustParseAddr("192.0.0.8"),
-+			expected: false,
- 		},
- 		{
--			name: "IPv4 Port Control Protocol Anycast",
--			ip:   netip.MustParseAddr("192.0.0.9"),
-+			name:     "IPv4 Port Control Protocol Anycast",
-+			ip:       netip.MustParseAddr("192.0.0.9"),
-+			expected: false,
- 		},
- 		{
--			name: "IPv4 Traversal Using Relays around NAT Anycast",
--			ip:   netip.MustParseAddr("192.0.0.10"),
-+			name:     "IPv4 Traversal Using Relays around NAT Anycast",
-+			ip:       netip.MustParseAddr("192.0.0.10"),
-+			expected: false,
- 		},
- 		{
--			name: "IPv4 NAT64/DNS64 Discovery 1",
--			ip:   netip.MustParseAddr("192.0.0.17"),
-+			name:     "IPv4 NAT64/DNS64 Discovery 1",
-+			ip:       netip.MustParseAddr("192.0.0.17"),
-+			expected: false,
- 		},
- 		{
--			name: "IPv4 NAT64/DNS64 Discovery 2",
--			ip:   netip.MustParseAddr("192.0.0.171"),
-+			name:     "IPv4 NAT64/DNS64 Discovery 2",
-+			ip:       netip.MustParseAddr("192.0.0.171"),
-+			expected: false,
-+		},
-+		{
-+			name:     "Leah's SOCKS proxy",
-+			ip:       netip.MustParseAddr("172.17.0.1"),
-+			expected: true,
- 		},
- 		// IPv6 tests
- 		{
-@@ -46,8 +58,8 @@ func TestValidateIP(t *testing.T) {
- 		tc := tc
- 		t.Run(tc.name, func(t *testing.T) {
- 			t.Parallel()
--			if valid := ValidateIP(tc.ip); valid != false {
--				t.Fatalf("Expected IP %s to be: %t, got: %t", tc.ip, false, valid)
-+			if valid := ValidateIP(tc.ip); valid != tc.expected {
-+				t.Fatalf("Expected IP %s to be: %t, got: %t", tc.ip, tc.expected, valid)
- 			}
- 		})
- 	}
--- 
-2.38.4
-
diff --git a/pkgs/gotosocial/default.nix b/pkgs/gotosocial/default.nix
@@ -1,19 +1,18 @@
-{ applyPatches, fetchFromGitHub, mkYarnPackage, buildGoModule, go_1_20, lib, pkgs, makeWrapper, installShellFiles, ... }:
+{ applyPatches, fetchFromGitHub, mkYarnPackage, buildGoModule, go_1_20, lib, ffmpeg, makeWrapper, installShellFiles, ... }:
 
-let
+buildGoModule rec {
   pname   = "gotosocial";
-  version = "0.8.0";
+  version = "0.10.0-${builtins.substring 0 6 rev}";
+  rev     = "v0.10.0";
 
   src = applyPatches {
     src = fetchFromGitHub {
       owner  = "superseriousbusiness";
       repo   = "gotosocial";
-      rev    = "v${version}";
-      sha256 = "sha256-wRo0qg/4nukhpAtC3qRR9zH+G4S7vMtveQueklOZrbM";
+      inherit rev;
+      sha256 = "sha256-SE+u89xAV6jJulU8XETlzTrqtwBYeMdNGyjk648b7h8";
     };
-    patches = [
-      ./0001-hack-Allow-leah-s-socks-proxy-through.patch
-    ];
+    patches = [];
   };
 
   frontend-assets =  mkYarnPackage {

@@ -23,7 +22,6 @@ let
     packageJSON = "${src}/web/source/package.json";
     yarnLock    = "${src}/web/source/yarn.lock";
 
-    #configurePhase = "true";
     buildPhase = ''
       mkdir assets source
       cp -r $src/assets/. ./assets

@@ -37,20 +35,18 @@ let
     installPhase = "cp -r assets $out";
   };
 
-in buildGoModule rec {
-  inherit pname version src;
-
   go = go_1_20;
 
   patches = [ ];
 
-  ldflags = ["-s" "-w" "-extldflags '-static'" "-X 'main.Commit=${version}'" "-X 'main.Version=${version}'"];
+  ldflags = ["-s" "-w" "-extldflags '-static'" "-X 'main.Commit=${rev}'" "-X 'main.Version=${version}'"];
   tags    = ["netgo" "osusergo" "static_build"];
 
   vendorSha256 = null;
 
-  nativeBuildInputs = [ installShellFiles ];
-  buildInputs       = [ makeWrapper ];
+	propagatedBuildInputs = [ ffmpeg ];
+  nativeBuildInputs     = [ installShellFiles ];
+  buildInputs           = [ makeWrapper ];
 
   doCheck = false;