From 68e623d2eb8bf812c34b5752f99dd2a53adedf6d Mon Sep 17 00:00:00 2001 From: Luke Granger-Brown Date: Tue, 21 Dec 2021 19:39:11 +0000 Subject: [PATCH] nix/pkgs/baserow: make it configurably OSS-only --- nix/pkgs/baserow/default.nix | 41 +++++++++++++++++++++++------------- 1 file changed, 26 insertions(+), 15 deletions(-) diff --git a/nix/pkgs/baserow/default.nix b/nix/pkgs/baserow/default.nix index 4898206a1c..f95ee30244 100644 --- a/nix/pkgs/baserow/default.nix +++ b/nix/pkgs/baserow/default.nix @@ -1,19 +1,30 @@ { fetchFromGitLab , pkgs +, lib , stdenv , makeWrapper , python3 , nodejs-12_x +, ossOnly ? true }: let version = "1.7.1"; - src = fetchFromGitLab { + suffix = lib.optionalString ossOnly "-oss"; + src' = fetchFromGitLab { owner = "bramw"; repo = "baserow"; rev = version; sha256 = "0jcisfhksrins33whwq46zg4r1101xvs2r0kcf1552x39r911gdg"; }; + src = if ossOnly then pkgs.runCommand "${src'.name}${suffix}" {} '' + cp -R ${src'} $out + chmod -R u+w $out + rm -rf $out/premium + + sed -i '/baserow_premium/d' $out/backend/src/baserow/config/settings/base.py + sed -i '/premium/d' $out/web-frontend/config/nuxt.config.base.js + '' else src'; web-frontend-deps = import ./web-frontend { inherit pkgs nodejs; inherit (pkgs) system; @@ -30,29 +41,27 @@ let let oss = import ./backend/pynixify/overlay.nix self super; premium = import ./premium-backend/pynixify/overlay.nix self super; + baserow-premium-backend = premium.baserow-premium-backend.overridePythonAttrs (_: { + src = "${src}/premium/backend"; + }); in - oss // premium // (rec { + oss // (if !ossOnly then premium else {}) // { baserow-backend = oss.baserow-backend.overridePythonAttrs (oldAttrs: { src = "${src}/backend"; prePatch = '' # Yeet. Just assume everything is installed in the environment already. > requirements/base.txt ''; - propagatedBuildInputs = oldAttrs.propagatedBuildInputs ++ [ - baserow-premium-backend - ]; + propagatedBuildInputs = oldAttrs.propagatedBuildInputs ++ lib.optional (!ossOnly) baserow-premium-backend; }); - baserow-premium-backend = premium.baserow-premium-backend.overridePythonAttrs (_: { - src = "${src}/premium/backend"; - }); - }); + } // (if !ossOnly then { inherit baserow-premium-backend; } else {}); }; in { inherit src web-frontend-deps mjml-tcpserver-deps; web-frontend = stdenv.mkDerivation { - name = "baserow-web-frontend"; + name = "baserow${suffix}-web-frontend"; inherit src version; buildInputs = [ nodejs ]; nativeBuildInputs = [ makeWrapper ]; @@ -61,9 +70,13 @@ in runHook preBuild outpath="$out/share/baserow" - mkdir -p $outpath $outpath/premium + mkdir -p $outpath cp -R web-frontend $outpath/web-frontend - cp -R premium/web-frontend $outpath/premium/web-frontend + + ${lib.optionalString (!ossOnly) '' + mkdir -p $outpath/premium + cp -R premium/web-frontend $outpath/premium/web-frontend + ''} # Disable prompts export MINIMAL=true @@ -109,9 +122,7 @@ in install -m 0755 ${./backend/gunicorn.py} $out/bin/baserow-gunicorn install -m 0755 ${./backend/celery.py} $out/bin/baserow-celery ''; - propagatedBuildInputs = oldAttrs.propagatedBuildInputs ++ (with python.pkgs; [ - baserow-premium-backend - ]); + propagatedBuildInputs = oldAttrs.propagatedBuildInputs ++ (with python.pkgs; lib.optional (!ossOnly) baserow-premium-backend); }); mjml-tcpserver = stdenv.mkDerivation {