From 653e45f1926c09c9242dfb3582f3d8f86604c66d Mon Sep 17 00:00:00 2001 From: Quentin Dufour Date: Fri, 6 May 2022 10:32:41 +0200 Subject: [PATCH] Packaging try on Cryptpad --- .gitmodules | 3 -- app/cryptpad/build/common.nix | 10 ++++++ app/cryptpad/build/default.nix | 58 ++++++++++++++++++++++++++++++++-- 3 files changed, 65 insertions(+), 6 deletions(-) diff --git a/.gitmodules b/.gitmodules index 19d4187..db0508d 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,6 +1,3 @@ [submodule "docker/static/goStatic"] path = app/build/static/goStatic url = https://github.com/PierreZ/goStatic -[submodule "app/cryptpad/build/cryptpad"] - path = app/cryptpad/build/cryptpad - url = https://github.com/xwiki-labs/cryptpad.git diff --git a/app/cryptpad/build/common.nix b/app/cryptpad/build/common.nix index 61d02fa..7ed1d55 100644 --- a/app/cryptpad/build/common.nix +++ b/app/cryptpad/build/common.nix @@ -5,5 +5,15 @@ url ="https://github.com/NixOS/nixpkgs/archive/2f06b87f64bc06229e05045853e0876666e1b023.tar.gz"; sha256 = "sha256:1d7zg96xw4qsqh7c89pgha9wkq3rbi9as3k3d88jlxy2z0ns0cy2"; }; + cryptpadSrc = builtins.fetchGit { + url = "https://github.com/xwiki-labs/cryptpad"; + ref = "refs/tags/4.14.1"; + rev = "5979aafdee90aab232658374b11aca8331fd0421"; + }; + bower2nixSrc = builtins.fetchGit { + url = ""; + ref = ""; + rev = ""; + } nodejs = "nodejs-slim-16_x"; } diff --git a/app/cryptpad/build/default.nix b/app/cryptpad/build/default.nix index 2069a58..96795bc 100644 --- a/app/cryptpad/build/default.nix +++ b/app/cryptpad/build/default.nix @@ -2,20 +2,72 @@ let common = import ./common.nix; pkgs = import common.pkgsSrc {}; nodejs = pkgs.${common.nodejs}; + + bower2nix = + bowerNix = pkgs.stdenv.mkDerivation { + name = "cryptpad-bower-ifd"; + src = common.cryptpadSrc; + + buildPhase = '' + ${pkgs.nodePackages.bower2nix}/bin/bower2nix bower.json bower.nix + ''; + + installPhase = '' + cp bower.nix $out + ''; + + dontFixup = true; + }; + bower = pkgs.buildBowerComponents { + name = "cryptpad-bower"; + generated = bowerNix; + src = common.cryptpadSrc; + }; + + npmNix = pkgs.stdenv.mkDerivation { + name = "cryptpad-npm-ifd"; + src = common.cryptpadSrc; + + buildPhase = '' + ${pkgs.nodePackages.node2nix}/bin/node2nix -l package-lock.json + ''; + + installPhase = '' + mkdir -p $out/ + cp *.nix $out/ + ''; + + dontFixup = true; + }; + npm = (import npmNix { + inherit pkgs nodejs; + }).nodeDependencies; + in pkgs.stdenv.mkDerivation { name = "cryptpad"; - src = ./cryptpad; + src = common.cryptpadSrc; installPhase = '' mkdir -p $out/{bin,opt} - cp -r config customize.dist lib node_modules package.json package-lock.json server.js www $out/opt/ + # copy the source code + cp -r customize.dist lib server.js www $out/opt/ + + # mount node_modules + ln -s ${npm}/lib/node_modules $out/opt/node_modules + + # mount bower, based on the .bowerrc file at the git repo root + ln -s ${bower} $out/opt/www/bower_components + + # cryptpad is bugged with absolute path, this is a workaround to use absolute path as relative path ln -s / $out/opt/root + # start script cat > $out/bin/cryptpad <