From d9ae1fa91ea7f686aa5c57707c1f729ad8834717 Mon Sep 17 00:00:00 2001 From: Aaron Bieber Date: Fri, 22 Nov 2024 08:16:23 -0700 Subject: [PATCH] h: move to the nixpkgs gts module / package --- default.nix | 6 +-- flake.nix | 2 - hosts/h/default.nix | 6 +-- modules/default.nix | 1 - modules/gotosocial.nix | 83 ------------------------------------------ pkgs/gotosocial.nix | 60 ------------------------------ 6 files changed, 5 insertions(+), 153 deletions(-) delete mode 100644 modules/gotosocial.nix delete mode 100644 pkgs/gotosocial.nix diff --git a/default.nix b/default.nix index 60f397c..a74f628 100644 --- a/default.nix +++ b/default.nix @@ -35,9 +35,9 @@ in ./bins ]; - disabledModules = [ - "services/web-apps/gotosocial.nix" - ]; + # disabledModules = [ + # "services/web-apps/gotosocial.nix" + # ]; options.myconf = { managementPubKeys = lib.mkOption rec { diff --git a/flake.nix b/flake.nix index bde8079..4a5282a 100644 --- a/flake.nix +++ b/flake.nix @@ -362,8 +362,6 @@ }; gokrazy = upkgs.callPackage ./pkgs/gokrazy.nix { inherit upkgs; }; gosignify = spkgs.callPackage ./pkgs/gosignify.nix { inherit spkgs; }; - gotosocial = - spkgs.callPackage ./pkgs/gotosocial.nix { inherit spkgs; }; zutty = upkgs.callPackage ./pkgs/zutty.nix { inherit upkgs; }; diff --git a/hosts/h/default.nix b/hosts/h/default.nix index a44a541..e78e376 100644 --- a/hosts/h/default.nix +++ b/hosts/h/default.nix @@ -409,7 +409,7 @@ in gotosocial = { enable = true; # https://github.com/superseriousbusiness/gotosocial/blob/v0.5.2/example/config.yaml - configuration = { + settings = { account-domain = "mammothcirc.us"; accounts-approval-required = false; accounts-reason-required = false; @@ -432,8 +432,6 @@ in storage-backend = "local"; storage-local-base-path = "/var/lib/gotosocial"; trusted-proxies = [ "127.0.0.1/32" "23.29.118.0/24" ]; - web-template-base-dir = "${config.services.gotosocial.package}/assets/web/template/"; - web-asset-base-dir = "${config.services.gotosocial.package}/assets/web/assets/"; landing-page-user = "qbit"; }; }; @@ -800,7 +798,7 @@ in locations."/" = { extraConfig = '' proxy_pass http://127.0.0.1:${ - toString config.services.gotosocial.configuration.port + toString config.services.gotosocial.settings.port }; proxy_set_header Host $host; proxy_set_header Upgrade $http_upgrade; diff --git a/modules/default.nix b/modules/default.nix index 1f353cd..a69879f 100644 --- a/modules/default.nix +++ b/modules/default.nix @@ -2,7 +2,6 @@ imports = [ ./backup.nix ./golink.nix - ./gotosocial.nix ./lock-action.nix ./rtlamr2mqtt.nix ./ssh-fido-agent.nix diff --git a/modules/gotosocial.nix b/modules/gotosocial.nix deleted file mode 100644 index 85e8d80..0000000 --- a/modules/gotosocial.nix +++ /dev/null @@ -1,83 +0,0 @@ -{ config -, lib -, pkgs -, ... -}: -with pkgs; let - cfg = config.services.gotosocial; - gotosocial = callPackage ../pkgs/gotosocial.nix { }; - settingsFormat = pkgs.formats.json { }; - settingsType = settingsFormat.type; - prettyJSON = conf: - pkgs.runCommandLocal "gotosocial-config.json" { } '' - echo '${ - builtins.toJSON conf - }' | ${pkgs.buildPackages.jq}/bin/jq 'del(._module)' > $out - ''; -in -{ - options = with lib; { - services.gotosocial = { - enable = mkEnableOption "Enable gotosocial"; - - user = mkOption { - type = with types; oneOf [ str int ]; - default = "gotosocial"; - description = '' - The user the service will use. - ''; - }; - - group = mkOption { - type = with types; oneOf [ str int ]; - default = "gotosocial"; - description = '' - The user the service will use. - ''; - }; - - configuration = mkOption { - type = settingsType; - description = '' - Specify the configuration for GoToSocial in Nix. - ''; - }; - - package = mkOption { - type = types.package; - default = gotosocial; - defaultText = literalExpression "pkgs.gotosocial"; - description = "The package to use for gotosocial"; - }; - }; - }; - - config = lib.mkIf cfg.enable { - users.groups.gotosocial = { }; - users.users.gotosocial = { - description = "Gotosocial service user"; - isSystemUser = true; - home = "/var/lib/gotosocial"; - createHome = true; - group = "gotosocial"; - }; - - systemd.services.gotosocial = { - enable = true; - description = "GoToSocial server"; - wantedBy = [ "multi-user.target" ]; - after = [ "postgresql.service" ]; - - serviceConfig = { - User = cfg.user; - Group = cfg.group; - - RuntimeDirectory = "/var/lib/gotosocial"; - - ExecStart = "${cfg.package}/bin/gotosocial --config-path ${ - prettyJSON cfg.configuration - } server start"; - }; - }; - }; -} diff --git a/pkgs/gotosocial.nix b/pkgs/gotosocial.nix deleted file mode 100644 index 1d5214e..0000000 --- a/pkgs/gotosocial.nix +++ /dev/null @@ -1,60 +0,0 @@ -{ lib -, buildGoModule -, fetchFromGitHub -, go -, ffmpeg -, ... -}: -let - gotosocialVersion = "0.17.0"; - gtswaHash = "sha256:1i6ks3dlmaq9g8a1fka26fgrcy9ps0kxmyvqhzjdkabwzwhqyah1"; - gtssHash = "sha256-uyqP3zhjcXKejGFAwZoTn2kY8IpX0QAAXNzb1VG6ve8="; - gotosocialWebAssets = builtins.fetchurl { - url = "https://github.com/superseriousbusiness/gotosocial/releases/download/v${gotosocialVersion}/gotosocial_${gotosocialVersion}_web-assets.tar.gz"; - sha256 = gtswaHash; - }; -in -with lib; -buildGoModule rec { - pname = "gotosocial"; - version = gotosocialVersion; - - src = fetchFromGitHub { - owner = "superseriousbusiness"; - repo = pname; - rev = "v${version}"; - hash = gtssHash; - }; - - ldflags = [ - "-s" - "-w" - "-extldflags '-static'" - "-X 'main.Commit=${version}'" - "-X 'main.Version=${version}'" - ]; - - propagatedBuildInputs = [ ffmpeg ]; - - proxyVendor = false; - vendorHash = null; - - doCheck = false; - - preBuild = '' - echo ${go}/bin/go - ${go}/bin/go version - ''; - - postInstall = '' - mkdir -p $out/assets - tar -C $out/assets/ -zxvf ${gotosocialWebAssets} - ''; - - meta = { - description = "Fast, fun, ActivityPub server, powered by Go."; - homepage = "https://github.com/superseriousbusiness/gotosocial"; - license = licenses.agpl3Only; - maintainers = with maintainers; [ qbit ]; - }; -}