Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add peertube #84189

Closed
wants to merge 20 commits into from
Closed

Add peertube #84189

wants to merge 20 commits into from

Conversation

matthiasbeyer
Copy link
Contributor

This is a starting point for closing #46987. It is a complete rip-off of the nur package from @immae !

I still get an error though:

hash mismatch in fixed-output derivation '/nix/store/g731scscirib2qnnnzyn6pn08x4z9pvi-node-v10.19.0-headers.tar.gz':
  wanted: sha256:16f20ya3ys6w5w6y6l4536f7jrgk4gz46bf71w1r1xxb26a54m32
  got:    sha256:1df3yhlwlvai0m9kvjyknjg11hnw0kj0rnhyzbwvsfjnmr6z8r76

but its better than nothing, innit? Ideas and especially patches are more than welcome!

@immae
Copy link
Contributor

immae commented Apr 3, 2020

I did changes recently (like, yesterday :D ) to this package to make it work in 19.09 (still in progress for further), but I did not push it yet, it might be good to wait a little so that I can push the changes?

};

patchedPackages = stdenv.mkDerivation (fetchedGithub ./peertube.json // rec {
patches = if ldap then [ ./ldap.patch ././yarn_fix_bluebird_ldap.patch ] else [ ./yarn_fix_bluebird.patch ];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This hack is a personnal one (I added ldap support to peertube because I needed it), it may not have its place here in a distribution package? (the patch was refused upstream)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree.

@immae
Copy link
Contributor

immae commented Apr 3, 2020

I forgot: thanks a lot for taking the steps to include it in the nixpkgs, it’s a task I delayed for quite some time to avoid overloading the already-full list of PRs...

@immae
Copy link
Contributor

immae commented Apr 3, 2020

Actually the diff for peertube was quite simple:

commit 26bf6168eb03157f370d847b82b753d236678cbb (HEAD -> upgrade_nixos)
Author: Ismaël Bouya <_>
Date:   Wed Mar 25 11:57:48 2020 +0100

    Upgrade nixos

diff --git a/pkgs/webapps/peertube/default.nix b/pkgs/webapps/peertube/default.nix
index a04d490..8995419 100644
--- a/pkgs/webapps/peertube/default.nix
+++ b/pkgs/webapps/peertube/default.nix
@@ -3,7 +3,7 @@
 let
   nodeHeaders = fetchurl {
     url = "https://nodejs.org/download/release/v${nodejs.version}/node-v${nodejs.version}-headers.tar.gz";
-    sha256 = "16f20ya3ys6w5w6y6l4536f7jrgk4gz46bf71w1r1xxb26a54m32";
+    sha256 = "1g6zi96k8sbim8wa8rzskxy44mgpcv1mn2bs8p4mq36w3kwglwyj";
   };
   patchedPackages = stdenv.mkDerivation (mylibs.fetchedGithub ./peertube.json // rec {
     patches = if ldap then [ ./ldap.patch ././yarn_fix_bluebird_ldap.patch ] else [ ./yarn_fix_bluebird.patch ];
@@ -33,8 +33,8 @@ let
         buildInputs = [ nodePackages.node-pre-gyp ];
         postInstall = let
           bcrypt_lib = fetchurl {
-            url = "https://github.com/kelektiv/node.bcrypt.js/releases/download/v3.0.2/bcrypt_lib-v3.0.2-node-v57-linux-x64-glibc.tar.gz";
-            sha256 = "04bj3yn1wi8a6izihskyks0bb4nls3mndgb2yj12iraiv5dmg097";
+            url = "https://github.com/kelektiv/node.bcrypt.js/releases/download/v3.0.2/bcrypt_lib-v3.0.2-node-v64-linux-x64-glibc.tar.gz";
+            sha256 = "0i0dx4h52fqi3mda2zzqrxp2fh7spbvf7h88mjk218h8d7vl53yx";
           };
         in
           ''

The first chunk you already noticed it in your PR description, it corresponds to the fact that in 19.03 the default node version was 8.X while it is 10.X in later nixpkgs channels. There might be a better way to handle it, but at least it will fail during build.

The second chunk about bcrypt is important and will fail only at runtime: the node api version (57 -> 64) changed between 8 and 10, but it won’t appear at build time. We should definitely add an assert somewhere to make sure we don’t miss it...

NB: you may add me as a maintainer if you wish, I’m okay with keeping the maintenance

@matthiasbeyer
Copy link
Contributor Author

Hm, any ideas why ofborg fails here? It builds fine on my machine!

@immae
Copy link
Contributor

immae commented Apr 5, 2020

Hm, any ideas why ofborg fails here? It builds fine on my machine!

I’m not in the maintainer list yet :)

@matthiasbeyer
Copy link
Contributor Author

@immae you're okay with me adding this to the PR:

diff --git a/maintainers/maintainer-list.nix b/maintainers/maintainer-list.nix
index f0a00b4e39e..667819252db 100644
--- a/maintainers/maintainer-list.nix
+++ b/maintainers/maintainer-list.nix
@@ -3184,6 +3184,12 @@
     githubId = 4085046;
     name = "Imuli";
   };
+  immae = {
+    email = REDACTED;
+    github = "immae";
+    githubId = 510202;
+    name = "Immae";
+  };
   infinisil = {
     email = REDACTED;
     github = "infinisil";

(I redacted the mails to not leak stuff here)

@immae
Copy link
Contributor

immae commented Apr 5, 2020

It’s fine for me, thanks ! Please use ismael _ bouya.org as e-mail address

@immae
Copy link
Contributor

immae commented Apr 5, 2020

Note: I will finish my upgrade of my whole system to nixos-unstable tonight, including the peertube service. That will permit me to make sure that it runs smoothly in this version (even though I see no reason why not), and I can then confirm that everything is in order

@matthiasbeyer
Copy link
Contributor Author

Awesome 🎉

@immae
Copy link
Contributor

immae commented Apr 6, 2020

So I had to make a minor change to follow "recent" standards (namely deprecation of types.loaOf):

-    users.users = lib.optionalAttrs (cfg.user == name) (lib.singleton {                                               
-      inherit name;
-      inherit uid;
-      group = cfg.group;
-      description = "Peertube user";
-      home = cfg.dataDir;
-      useDefaultShell = true;
-    });                                                                                                               
-    users.groups = lib.optionalAttrs (cfg.group == name) (lib.singleton {                                             
-      inherit name;
-      inherit gid;
-    });
+    users.users = lib.optionalAttrs (cfg.user == name) {                                                              
+      "${name}" = {                                                                                                   
+        inherit uid;
+        group = cfg.group;                                                                                            
+        description = "Peertube user";
+        home = cfg.dataDir;                                                                                           
+        useDefaultShell = true;
+      };
+    };
+    users.groups = lib.optionalAttrs (cfg.group == name) {
+      "${name}" = {                                                                                                   
+        inherit gid;
+      };
+    };

Apart from that, this PR should provide a working peertube instance 😄

src = fetchFromGitHub json.github;
};

yarn2nixPackage = let
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this is good. Instead the tool should be part of nixpkgs.

Another problem is: If the source is required to evaluate the derivation (not build it, just evaluate) then that means that nix needs to download the source even to just build the .drv file

An idea would be to add the yarn.lock to nixpkgs aswell as the tool and then pull the yarn.lock from nixpkgs, so evaluation does not depend on external dependecies

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Inspiration can be taken from https://github.com/mkg20001/nix-node-package/blob/master/nix/default.nix which solves that problem and also the one where the nodeHeaders are pulled separately

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@immae care to contribute this? I'm new to the node packaging infra and thus do not entirely understand how to approach this.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is the yarn2nix-moretea which contains exactly what we need and didn’t exist at the time when I wrote this package, I’ll try to make a use of it and give feedback (there seem to be some kind of issues with yarn packages coming from github)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, this cannot work, because one of the dependencies ( https://github.com/Chocobozzz/jsonld-signatures/ ) has been removed by his author. To deal with that, I will need to upgrad epeertube to latest version, which may take a little longer than expected (but it will arrive at some point). In my case the dependency is already in my store, but there is no way that it is the case in the hydra yet.

I’ll keep this thread updated but it may take a few more days.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't you be able to use mkYarnPackage here?

@matthiasbeyer
Copy link
Contributor Author

Would we benefit from something like this: matthiasbeyer@7e72019

???

@immae
Copy link
Contributor

immae commented Apr 6, 2020

Would we benefit from something like this: matthiasbeyer@7e72019

???

The idea is good, but I think it’s too much. You should have a look at this nice RFC: https://github.com/NixOS/rfcs/blob/e719102ace17c2b4a8b98efe0f08e344a7713dec/rfcs/0042-config-option.md to find a balance between "too much options" and "nothing configurable"

@immae
Copy link
Contributor

immae commented Apr 9, 2020

So, as promised @matthiasbeyer , I finished to repackage peertube to latest version (v2.1.1). You can find it there:
https://git.immae.eu/?p=perso/Immae/Config/Nix.git;a=tree;f=pkgs/webapps/peertube;h=74a7ca515c74a90d6ab5de3979cf305d97e8d331;hb=b639cc33725fed62988b616909843bea7f7aebe3
(note that it changed completely, you should update all files)

I addressed the issue of the yarn2nix package as pointed by @mkg20001 . I also greatly improved (in my opinion) the packaging (also thanks to upstream/yarn2nix improvements I admit)

If I am remaining as maintainer of the package, I would like to keep the ldap / sendmail flags for the package (depending on wether it is in accordance with nixpkgs guidelines of course). The default version will build vanillia peertube, while ldap or sendmail flag would add the patches implementing the named feature. Note that they will be supported upstream at some point, so it’s just a way to have the feature before they’re implemented upstream.

About the "light" flag I don’t really know what to do. Peertube comes with a bunch of translations, which will be all built by default, but it will take hours to build them. The light=true version will build only English, and the light="fr-FR" will build English + the given language (The peertube build script only support French, but I patched it to accept anything). Same here, I don’t really know what is the best option to build / according to the guidelines.

@matthiasbeyer
Copy link
Contributor Author

Thanks. We'll see how I can update this PR with your changes. It might get complicated because I don't know what changed (because I don't know the git commit when I started my efforts...)

@immae
Copy link
Contributor

immae commented Apr 9, 2020

Thanks. We'll see how I can update this PR with your changes. It might get complicated because I don't know what changed (because I don't know the git commit when I started my efforts...)

Basically it’s a completely different layout, so you should take the whole directory as is.

The only thing you’ll need to re-add is the mylibs.fetchedGitHub function, the rest is now "standard" nixpkgs. (I don’t know if github permits to do it, but I may also push to your branch if you give me the rights)

@immae
Copy link
Contributor

immae commented Apr 9, 2020

If you replace the content of pkgs/servers/peertube/ in your PR with my whole pkgs/webapps/peertube folder, and replace source in default.nix with:

source = rec {
  version = "v2.1.1";
  name = "peertube-${version}";
  src = fetchFromGitHub {
    owner = "Chocobozzz";
    repo = "PeerTube";
    rev = "76f7b571c04c03ba422bd5790944fe80dbb24067";
    sha256 = "147gm1j657fkpv2ix1bmkhl7ld5h224q7hgdj9ffj3z14mqgk8hj";
    fetchSubmodules = true;
  };
};

Then it should work as intended :)

@immae
Copy link
Contributor

immae commented Apr 13, 2020

Thanks for the update @matthiasbeyer

I made one more small change recently: can you add a line

ln -sf ${cfg.package}/config/default.yaml ${cfg.dataDir}/config/default.yaml

just after the similar one in the script of the systemd configuration? ref: Chocobozzz/PeerTube#2614 (comment)

@immae
Copy link
Contributor

immae commented Apr 13, 2020

Also, can you specify how the "light" fix fails? for me it works correctly, I may have missed something...

@matthiasbeyer
Copy link
Contributor Author

Also, can you specify how the "light" fix fails? for me it works correctly, I may have missed something...

the sed command fails completely to do its job.

Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
@samlich
Copy link
Contributor

samlich commented Sep 30, 2020

Reverting to v2.1.1 and changing to nodejs version 12 fixes the SCSS issue for me. This also requires changing bcrypt_lib's download url from v64 to v72.

Also, is the server-yarn-packages.nix generated from the yarn.lock in the root of PeerTube? I'm having difficulty regenerating it to update PeerTube. I think yarn-packages.nix can be removed.

The only other changes are to enable Postgres and Redis and create the Postgres database. It runs, but I haven't tested much more than that.

@matthiasbeyer
Copy link
Contributor Author

Can you send me patches for what you did?

@samlich
Copy link
Contributor

samlich commented Sep 30, 2020

I also regenerated client-yarn-packages.nix, but it was only whitespace changes.

Edit: added back host ${cfg.database} ${cfg.user} 127.0.0.1/32 trust line as apparently that was the relevant one.

diff --git a/nixos/modules/misc/ids.nix b/nixos/modules/misc/ids.nix
index 394da9a3889..c310c2dac78 100644
--- a/nixos/modules/misc/ids.nix
+++ b/nixos/modules/misc/ids.nix
@@ -346,6 +346,7 @@ in
       paperless = 315;
       #mailman = 316;  # removed 2019-08-30
       zigbee2mqtt = 317;
+      peertube = 318;
 
       # When adding a uid, make sure it doesn't match an existing gid. And don't use uids above 399!
 
@@ -647,6 +648,7 @@ in
       paperless = 315;
       #mailman = 316;  # removed 2019-08-30
       zigbee2mqtt = 317;
+      peertube = 318;
 
       # When adding a gid, make sure it doesn't match an existing
       # uid. Users and groups with the same name should have equal
diff --git a/nixos/modules/services/web-apps/peertube/default.nix b/nixos/modules/services/web-apps/peertube/default.nix
index 19e3d5baaba..9cbeaf4aa6b 100644
--- a/nixos/modules/services/web-apps/peertube/default.nix
+++ b/nixos/modules/services/web-apps/peertube/default.nix
@@ -31,31 +31,40 @@ in
       '';
     };
 
+    database = lib.mkOption {
+      type = lib.types.str;
+      default = "peertube_prod";
+      description = ''
+        The Postgres database where Peertube stores its data.
+      '';
+    };
+
     configFile = lib.mkOption {
       type = lib.types.path;
       description = ''
         The configuration file path for Peertube.
-        '';
+      '';
     };
 
     package = lib.mkOption {
       type = lib.types.package;
-      default = pkgs.webapps.peertube;
+      # default = pkgs.webapps.peertube;
+      default = pkgs.peertube;
       description = ''
         Peertube package to use.
-        '';
+      '';
     };
 
     # Output variables
     systemdStateDirectory = lib.mkOption {
       type = lib.types.str;
 
       # Use ReadWritePaths= instead if varDir is outside of /var/lib
       default = assert lib.strings.hasPrefix "/var/lib/" cfg.dataDir;
-        lib.strings.removePrefix "/var/lib/" cfg.dataDir;
+      lib.strings.removePrefix "/var/lib/" cfg.dataDir;
 
       description = ''
-      Adjusted Peertube data directory for systemd
+        Adjusted Peertube data directory for systemd
       '';
 
       readOnly = true;
@@ -70,6 +88,8 @@ in
         description = "Peertube user";
         home = cfg.dataDir;
         useDefaultShell = true;
+        # todo: fix this. needed for postgres authentication
+        password = "peertube";
       };
     };
     users.groups = lib.optionalAttrs (cfg.group == name) {
@@ -78,17 +98,46 @@ in
       };
     };
 
+    services.redis = {
+      enable = true;
+    };
+
+    services.postgresql = {
+      enable = true;
+      package = pkgs.postgresql_12;
+      # requires sudo -u postgres createdb -O peertube -E UTF8 -T template0 ${cfg.database}
+      # so this may not suffice
+      # ensureDatabases = [ "${cfg.database}" ];
+      ensureUsers = [
+        {
+          name = "${cfg.user}";
+          # we create database with `peertube` as owner in `preStart`
+          # ensurePermissions = {
+            #   "DATABASE ${cfg.database}" = "ALL PRIVILEGES";
+            # };
+        }
+      ];
+      authentication = ''
+        host ${cfg.database} ${cfg.user} 127.0.0.1/32 trust
+        host ${cfg.database} ${cfg.user} 127.0.0.1/32 md5
+      '';
+
+    };
+
+    systemd.tmpfiles.rules = [
+      "d \"${cfg.dataDir}\" - ${cfg.user} ${cfg.group} - -"
+    ];
+
     systemd.services.peertube = {
       description = "Peertube";
       wantedBy = [ "multi-user.target" ];
-      after = [ "network.target" "postgresql.service" ];
-      wants = [ "postgresql.service" ];
+      after = [ "network.target" "postgresql.service" "redis.service" ];
+      wants = [ "postgresql.service" "redis.service" ];
 
       environment.NODE_CONFIG_DIR = "${cfg.dataDir}/config";
       environment.NODE_ENV = "production";
       environment.HOME = cfg.package;
 
-      path = [ pkgs.nodejs pkgs.bashInteractive pkgs.ffmpeg pkgs.openssl ];
+      path = [ pkgs.nodejs pkgs.bashInteractive pkgs.ffmpeg pkgs.openssl pkgs.sudo ];
 
       script = ''
         install -m 0750 -d ${cfg.dataDir}/config
@@ -108,6 +157,26 @@ in
         Restart = "always";
         Type = "simple";
         TimeoutSec = 60;
+        ExecStartPre = let script = pkgs.writeScript "peertube-pre-start.sh" ''
+          #!/bin/sh
+          set -e
+
+          if ! [ -e "${cfg.dataDir}/.first_run" ]; then
+          set -v
+          if [ -e "${cfg.dataDir}/.first_run_partial" ]; then
+          echo "Warn: first run was interrupted"
+          fi
+          touch "${cfg.dataDir}/.first_run_partial"
+
+          sudo -u postgres "${config.services.postgresql.package}/bin/createdb" -O ${cfg.user} -E UTF8 -T template0 ${cfg.database}
+          sudo -u postgres "${config.services.postgresql.package}/bin/psql" -c "CREATE EXTENSION pg_trgm;" ${cfg.database}
+          sudo -u postgres "${config.services.postgresql.package}/bin/psql" -c "CREATE EXTENSION unaccent;" ${cfg.database}
+
+          touch "${cfg.dataDir}/.first_run"
+          rm "${cfg.dataDir}/.first_run_partial"
+          fi
+        '';
+        in "+${script}";
       };
 
       unitConfig.RequiresMountsFor = cfg.dataDir;
diff --git a/pkgs/servers/peertube/default.nix b/pkgs/servers/peertube/default.nix
index 52ddfb44dac..9ce5183d8b1 100644
--- a/pkgs/servers/peertube/default.nix
+++ b/pkgs/servers/peertube/default.nix
@@ -4,16 +4,20 @@
 let
   nodeHeaders = fetchurl {
     url = "https://nodejs.org/download/release/v${nodejs.version}/node-v${nodejs.version}-headers.tar.gz";
-    sha256 = "15hkcbs328d3rc1s14rmky8lh8d3rr86l8k0bia0ggxzwl23lj9c";
+    sha256 = "17kf05a92r4y4n1lj78265wr6zhkpzbr1k8nbwrl8sq71npd6n5j";
+    # node 10 sha256 = "0i69flgrj59200nkkmj64d29j1jildvflc1dngbqv9dkawd47bpg";
+# 15hkcbs328d3rc1s14rmky8lh8d3rr86l8k0bia0ggxzwl23lj9c";
   };
   source = rec {
-    version = "v2.3.0";
+    # version = "v2.3.0";
+    version = "v2.1.1";
     name = "peertube-${version}";
     src = fetchFromGitHub {
       owner = "Chocobozzz";
       repo = "PeerTube";
       rev = version;
-      sha256 = "1si4adhdd7c4avgm9qvva2f77x2bmfq0gx5ibnhlxr9bsc8s4ran";
+      # sha256 = "1si4adhdd7c4avgm9qvva2f77x2bmfq0gx5ibnhlxr9bsc8s4ran";
+      sha256 = "147gm1j657fkpv2ix1bmkhl7ld5h224q7hgdj9ffj3z14mqgk8hj";
       fetchSubmodules = true;
     };
   };
@@ -44,8 +48,10 @@ let
       buildInputs = [ nodePackages.node-pre-gyp ];
       postInstall = let
         bcrypt_lib = fetchurl {
-          url = "https://github.com/kelektiv/node.bcrypt.js/releases/download/v3.0.7/bcrypt_lib-v3.0.7-node-v64-linux-x64-glibc.tar.gz";
-          sha256 = "0gbq4grhp5wl0f9yqb4y43kjfh8nivfd6y0nkv1x6gfvs2v23wb0";
+          # url = "https://github.com/kelektiv/node.bcrypt.js/releases/download/v3.0.7/bcrypt_lib-v3.0.7-node-v64-linux-x64-glibc.tar.gz";
+          # sha256 = "0gbq4grhp5wl0f9yqb4y43kjfh8nivfd6y0nkv1x6gfvs2v23wb0";
+          url = "https://github.com/kelektiv/node.bcrypt.js/releases/download/v3.0.7/bcrypt_lib-v3.0.7-node-v72-linux-x64-glibc.tar.gz";
+          sha256 = "0kpm9j0yc4lqsafldfsql3m72rr1fapljlb6ddxvy3zi13rb7ppx";
         };
       in
         ''
diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix
index 10f18ccc68a..ec017c01b58 100644
--- a/pkgs/top-level/all-packages.nix
+++ b/pkgs/top-level/all-packages.nix
@@ -22375,7 +22375,7 @@ in
   peek = callPackage ../applications/video/peek { };
 
   peertube = callPackage ../servers/peertube {
-    nodejs = pkgs.nodejs-10_x;
+    nodejs = pkgs.nodejs-12_x;
   };
 
   pflask = callPackage ../os-specific/linux/pflask {};

@matthiasbeyer
Copy link
Contributor Author

Please give me an url to pull from or send patchmails.

@samlich
Copy link
Contributor

samlich commented Sep 30, 2020

https://github.com/samlich/nixpkgs/tree/peertube
Not sure why those LDAP patches didn't show up as from an earlier commit.

And it's not really organized as I was going to work on updating to 2.4.0 and maybe add declarative plugins. If the plugins work fine imperatively though, I'll probably hold off on that part.

Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
Suggested-by: samlich <nixos@samli.ch>
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
Suggested-by: samlich <nixos@samli.ch>
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
Suggested-by: samlich <nixos@samli.ch>
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
Suggested-by: samlich <nixos@samli.ch>
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
Suggested-by: samlich <nixos@samli.ch>
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
Suggested-by: samlich <nixos@samli.ch>
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
Suggested-by: samlich <nixos@samli.ch>
@matthiasbeyer
Copy link
Contributor Author

Thanks, @samlich for the patches.
I splitted them into proper commits. I did not take the last one because the patches added were not used anywhere.

Please commit properly next time, so I can simply cherry-pick your patches 😉 !

Copy link
Contributor

@stevenroose stevenroose left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't really like that you patched PeerTube itself (with ldap etc). Wouldn't it be a better idea to release this without and PR them to PeerTube itself and wait for it to get accepted there and then update here to have support for it?

};

# Output variables
systemdStateDirectory = lib.mkOption {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is this for? I'm no Nix expert but the assert down seems to make this break if the dataDir is set to something outside of /var/lib.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this not be hardcoded to /var/run/${name}?

};

config = lib.mkIf cfg.enable {
users.users = lib.optionalAttrs (cfg.user == name) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm is this a common pattern? To only create the user if it's the same name as the package?

description = "Peertube user";
home = cfg.dataDir;
useDefaultShell = true;
# todo: fix this. needed for postgres authentication
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any idea no how to fix this?

set -e

if ! [ -e "${cfg.dataDir}/.first_run" ]; then
set -v
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you indent those lines inside the if block?

@stevenroose
Copy link
Contributor

Any updates on this? I had a simpler pkg based on yarn2nix, but it's definitely not working due to some broken yarn dependencies.

Also, I read this was for nixos 19.09 and I see it's PeerTube 2.1.1 while 2.4.0 is already out. I can try update a bit of this, but I'm totally lost in the pkg with all the node stuff. I'll try look into other packages that use mkYarnPackage.

@matthiasbeyer
Copy link
Contributor Author

Feel free to take any patches from this, but I am no longer interested in this javascript hell. Sorry.

@immae
Copy link
Contributor

immae commented Jan 20, 2021

If you’re interested in reviving this PR, I packaged the last version of peertube (3.0.1, with "live streaming").

It’s there: https://git.immae.eu/cgit/perso/Immae/Config/Nix.git/commit/?id=ded643e14096a7cb166c78dd961cf68fb4ddb0cf

Notes:

  • This packaging is probably much cleaner than my previous (beginner) work.
  • It’s a flake, it probably needs some porting to nixpkgs
  • I wrote tests to check that client and server run correctly, but I didn’t run it live yet (my instances are heavily patched, I need to port the patches before), so expect surprises when you try it first.

@matthiasbeyer matthiasbeyer deleted the add-peertube branch April 13, 2021 11:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

10 participants