From 9b93a4a9734eb0a17d1695bc29ffb0cd5513ce38 Mon Sep 17 00:00:00 2001 From: Aaron Bieber Date: Mon, 12 Dec 2022 06:45:26 -0700 Subject: [PATCH] h: switch to env file for golink --- modules/golink.nix | 6 ++++-- pkgs/golink.nix | 6 ++---- pkgs/golink_keyfile.diff | 35 ----------------------------------- 3 files changed, 6 insertions(+), 41 deletions(-) delete mode 100644 pkgs/golink_keyfile.diff diff --git a/modules/golink.nix b/modules/golink.nix index 857653f..a83cff6 100644 --- a/modules/golink.nix +++ b/modules/golink.nix @@ -24,7 +24,7 @@ in { ''; }; - keyFile = mkOption { + envFile = mkOption { type = types.path; default = "/run/secrets/golink"; description = '' @@ -81,8 +81,10 @@ in { CacheDirectory = "golink"; CacheDirectoryMode = "0755"; + EnvironmentFile = cfg.envFile; + ExecStart = - "${cfg.package}/bin/golink -sqlitedb ${cfg.dataDir}/golink.db -keyfile ${cfg.keyFile}"; + "${cfg.package}/bin/golink -sqlitedb ${cfg.dataDir}/golink.db"; }; }; }; diff --git a/pkgs/golink.nix b/pkgs/golink.nix index 7713512..1863ec1 100644 --- a/pkgs/golink.nix +++ b/pkgs/golink.nix @@ -10,12 +10,10 @@ buildGoModule rec { src = fetchFromGitHub { owner = "tailscale"; repo = pname; - rev = "0755e37a910b73b586544e2805c075dcec7d0207"; - sha256 = "sha256-zzup/TR9iRNPrEEOzhIL5PTF8iKF8NlPqXBuRKt8AEc="; + rev = "5fefe2519ffd9f1c6a3dd86a764d69717ee66d20"; + sha256 = "sha256-H4mwyQVFH/Yp6gIpN1o+L7S3Rupwbxl5CCLltcBh1Vk="; }; - patches = [ ./golink_keyfile.diff ]; - vendorSha256 = vendorHash; proxyVendor = true; diff --git a/pkgs/golink_keyfile.diff b/pkgs/golink_keyfile.diff deleted file mode 100644 index d073d1d..0000000 --- a/pkgs/golink_keyfile.diff +++ /dev/null @@ -1,35 +0,0 @@ -diff --git a/golink.go b/golink.go -index 3bc3353..fb0e791 100644 ---- a/golink.go -+++ b/golink.go -@@ -37,6 +37,7 @@ var ( - sqlitefile = flag.String("sqlitedb", "", "path of SQLite database to store links") - dev = flag.String("dev-listen", "", "if non-empty, listen on this addr and run in dev mode; auto-set sqlitedb if empty and don't use tsnet") - snapshot = flag.String("snapshot", "", "file path of snapshot file") -+ keyfile = flag.String("keyfile", "", "file path of file containing tskey") - ) - - var stats struct { -@@ -116,6 +117,13 @@ func Run() error { - Hostname: "go", - Logf: func(format string, args ...any) {}, - } -+ if *keyfile != "" { -+ keyData, err := os.ReadFile(*keyfile) -+ if err != nil { -+ log.Fatalf("error reading keyfile file %q: %v", *keyfile, err) -+ } -+ srv.AuthKey = string(keyData) -+ } - if *verbose { - srv.Logf = log.Printf - } -@@ -353,7 +361,7 @@ type expandEnv struct { - var expandFuncMap = texttemplate.FuncMap{ - "PathEscape": url.PathEscape, - "QueryEscape": url.QueryEscape, -- "TrimSuffix": strings.TrimSuffix, -+ "TrimSuffix": strings.TrimSuffix, - } - - // expandLink returns the expanded long URL to redirect to, executing any