ctucx.git: nixfiles

ctucx' nixfiles

commit 2fc4a22034ed191cc0797c77399c3da0c6800912
parent 3145ef255d66296b17633abe167c24da7a009d5c
Author: Leah (ctucx) <leah@ctu.cx>
Date: Tue, 13 Sep 2022 18:58:21 +0200

pkgs/gotosocial: include version in build
2 files changed, 28 insertions(+), 13 deletions(-)
M
modules/gotosocial.nix
|
8
+++++---
M
pkgs/gotosocial/default.nix
|
33
+++++++++++++++++++++++----------
diff --git a/modules/gotosocial.nix b/modules/gotosocial.nix
@@ -103,7 +103,9 @@ in {
       '')
     ];
 
-    systemd.services = {
+    systemd.services = let
+      configFile = settingsFormat.generate "gotosocial-config.yaml" cfg.settings;
+    in {
       gotosocial-export = {
         description   = "gotosocial export";
 

@@ -119,7 +121,7 @@ in {
           StateDirectory = "gotosocial gotosocial/storage";
           StateDirectoryMode = "700";
 
-          ExecStart = "${cfg.package}/bin/gotosocial --config-path /etc/gotosocial/config.yaml admin export --path /var/lib/gotosocial/backup.json";
+          ExecStart = "${cfg.package}/bin/gotosocial --config-path ${configFile} admin export --path /var/lib/gotosocial/backup.json";
         };
       };
 

@@ -140,7 +142,7 @@ in {
           ReadWritePaths     = [ cfg.settings.storage-local-base-path ];
           StateDirectoryMode = "700";
 
-          ExecStart = "${cfg.package}/bin/gotosocial --config-path ${settingsFormat.generate "gotosocial-config.yaml" cfg.settings} server start";
+          ExecStart = "${cfg.package}/bin/gotosocial --config-path ${configFile} server start";
 
           NoNewPrivileges = true;
           PrivateTmp      = true;
diff --git a/pkgs/gotosocial/default.nix b/pkgs/gotosocial/default.nix
@@ -1,4 +1,4 @@
-{ fetchFromGitHub, mkYarnPackage, buildGo118Module, lib, pkgs, ... }:
+{ fetchFromGitHub, mkYarnPackage, buildGo118Module, lib, pkgs, makeWrapper, installShellFiles, ... }:
 
 let
   pname   = "gotosocial";

@@ -38,23 +38,36 @@ let
 in buildGo118Module rec {
   inherit pname version src;
 
+  ldflags = ["-s" "-w" "-extldflags '-static'" "-X 'main.Commit=${version}'" "-X 'main.Version=${version}'"];
+  tags    = ["netgo" "osusergo" "static_build"];
+
   vendorSha256 = null;
 
-  doCheck     = false;
+  nativeBuildInputs = [ installShellFiles ];
+  buildInputs       = [ makeWrapper ];
+
+  doCheck = false;
+
+  installCheckPhase = ''
+    runHook preCheck
+    $out/bin/gotosocial --help
+	runHook postCheck
+  '';
 
-  installPhase = ''
-    mkdir -p $out
-    mkdir -p $out/share
+  postInstall = ''
+    mkdir -p $out/share/web
 
-    dir="$GOPATH/bin"
-    [ -e "$dir" ] && cp -r $dir $out
+    cp -r ./web/template     $out/share/web/
+    ln -sf ${frontend-assets} $out/share/web/assets
 
-    cp -r ./web/template     $out/share/
-    cp -r ${frontend-assets} $out/share/assets
+    installShellCompletion --cmd gotosocial \
+      --bash <($out/bin/gotosocial completion bash) \
+      --fish <($out/bin/gotosocial completion fish) \
+      --zsh <($out/bin/gotosocial completion zsh)
   '';
 
   meta = with lib; {
-    description = "Golang fediverse server.";
+    description = "An ActivityPub social network server, written in Golang.";
     homepage    = "https://github.com/superseriousbusiness/gotosocial";
     license     = licenses.agpl3;
     platforms   = platforms.linux;