From fe3f7716f0494fd0170f307e1a8a5e00fa3e6d2f Mon Sep 17 00:00:00 2001 From: Strahinja Popovic Date: Thu, 17 Jul 2014 12:51:17 +0200 Subject: [PATCH] Enabled access to binaries of needed tools, and worker daemons can be enabled for phabricator #3306 --- nixos/modules/module-list.nix | 1 + nixos/modules/services/misc/phd.nix | 52 ++++++++++++++++ .../web-servers/apache-httpd/phabricator.nix | 61 +++++++++++-------- nixos/tests/phabricator.nix | 7 +++ pkgs/misc/phabricator/default.nix | 28 +++++++++ pkgs/top-level/all-packages.nix | 2 + 6 files changed, 125 insertions(+), 26 deletions(-) create mode 100644 nixos/modules/services/misc/phd.nix create mode 100644 pkgs/misc/phabricator/default.nix diff --git a/nixos/modules/module-list.nix b/nixos/modules/module-list.nix index 1135534263c6..2d977e38a12f 100755 --- a/nixos/modules/module-list.nix +++ b/nixos/modules/module-list.nix @@ -165,6 +165,7 @@ ./services/misc/nix-gc.nix ./services/misc/nixos-manual.nix ./services/misc/nix-ssh-serve.nix + ./services/misc/phd.nix ./services/misc/rippled.nix ./services/misc/rogue.nix ./services/misc/siproxd.nix diff --git a/nixos/modules/services/misc/phd.nix b/nixos/modules/services/misc/phd.nix new file mode 100644 index 000000000000..888247275ac6 --- /dev/null +++ b/nixos/modules/services/misc/phd.nix @@ -0,0 +1,52 @@ +{ config, lib, pkgs, ... }: + +with lib; + +let + + cfg = config.services.phd; + +in + +{ + + ###### interface + + options = { + + services.phd = { + + enable = mkOption { + default = false; + description = " + Enable daemons for phabricator. + "; + }; + + }; + + }; + + ###### implementation + + config = mkIf cfg.enable { + + systemd.services.phd = { + path = [ pkgs.phabricator pkgs.php pkgs.mercurial pkgs.git pkgs.subversion ]; + + after = [ "httpd.service" ]; + wantedBy = [ "multi-user.target" ]; + + serviceConfig = { + ExecStart = "${pkgs.phabricator}/phabricator/bin/phd start"; + ExecStop = "${pkgs.phabricator}/phabricator/bin/phd start"; + User = "wwwrun"; + RestartSec = "30s"; + Restart = "always"; + StartLimitInterval = "1m"; + }; + }; + + }; + +} diff --git a/nixos/modules/services/web-servers/apache-httpd/phabricator.nix b/nixos/modules/services/web-servers/apache-httpd/phabricator.nix index c7a9bdf68c56..e4e3aac8d411 100644 --- a/nixos/modules/services/web-servers/apache-httpd/phabricator.nix +++ b/nixos/modules/services/web-servers/apache-httpd/phabricator.nix @@ -1,35 +1,30 @@ { config, lib, pkgs, ... }: + +with lib; + let - phabricatorRoot = pkgs.stdenv.mkDerivation rec { - version = "2014-05-12"; - name = "phabricator-${version}"; - srcLibphutil = pkgs.fetchgit { - url = git://github.com/facebook/libphutil.git; - rev = "2f3b5a1cf6ea464a0250d4b1c653a795a90d2716"; - sha256 = "9598cec400984dc149162f1e648814a54ea0cd34fcd529973dc83f5486fdd9fd"; - }; - srcArcanist = pkgs.fetchgit { - url = git://github.com/facebook/arcanist.git; - rev = "54c377448db8dbc40f0ca86d43c837d30e493485"; - sha256 = "086db3c0d1154fbad23e7c6def31fd913384ee20247b329515838b669c3028e0"; - }; - srcPhabricator = pkgs.fetchgit { - url = git://github.com/facebook/phabricator.git; - rev = "1644ef185ecf1e9fca3eb6b16351ef46b19d110f"; - sha256 = "e1135e4ba76d53f48aad4161563035414ed7e878f39a8a34a875a01b41b2a084"; - }; - - buildCommand = '' - mkdir -p $out - cp -R ${srcLibphutil} $out/libphutil - cp -R ${srcArcanist} $out/arcanist - cp -R ${srcPhabricator} $out/phabricator - ''; - }; + phabricatorRoot = pkgs.phabricator; in { + enablePHP = true; extraApacheModules = [ "mod_rewrite" ]; DocumentRoot = "${phabricatorRoot}/phabricator/webroot"; + + options = { + git = mkOption { + default = true; + description = "Enable git repositories."; + }; + mercurial = mkOption { + default = true; + description = "Enable mercurial repositories."; + }; + subversion = mkOption { + default = true; + description = "Enable subversion repositories."; + }; + }; + extraConfig = '' DocumentRoot ${phabricatorRoot}/phabricator/webroot @@ -38,4 +33,18 @@ in { RewriteRule ^/favicon.ico - [L,QSA] RewriteRule ^(.*)$ /index.php?__path__=$1 [B,L,QSA] ''; + + extraServerPath = [ + "${pkgs.which}" + "${pkgs.diffutils}" + ] ++ + (if config.mercurial then ["${pkgs.mercurial}"] else []) ++ + (if config.subversion then ["${pkgs.subversion}"] else []) ++ + (if config.git then ["${pkgs.git}"] else []); + + startupScript = pkgs.writeScript "activatePhabricator" '' + mkdir -p /var/repo + chown wwwrun /var/repo + ''; + } diff --git a/nixos/tests/phabricator.nix b/nixos/tests/phabricator.nix index 53038474c91a..0fe31f66502d 100644 --- a/nixos/tests/phabricator.nix +++ b/nixos/tests/phabricator.nix @@ -32,9 +32,16 @@ import ./make-test.nix ({ pkgs, ... }: { }]; }; + phd = { + enable = true; + }; + mysql = { enable = true; package = pkgs.mysql; + extraOptions = '' + sql_mode=STRICT_ALL_TABLES + ''; }; }; diff --git a/pkgs/misc/phabricator/default.nix b/pkgs/misc/phabricator/default.nix new file mode 100644 index 000000000000..3162dd0079d0 --- /dev/null +++ b/pkgs/misc/phabricator/default.nix @@ -0,0 +1,28 @@ +{ stdenv, fetchgit, pkgs, ... }: + +stdenv.mkDerivation rec { + version = "2014-07-16"; + name = "phabricator-${version}"; + srcLibphutil = pkgs.fetchgit { + url = git://github.com/facebook/libphutil.git; + rev = "48a04395363d6c1dd9f66057bd11fd70d4665ba9"; + sha256 = "d570d2c1e68471c2eda35b8722d8083bcc13163fbd5c944529464f2c7b55a2e5"; + }; + srcArcanist = pkgs.fetchgit { + url = git://github.com/facebook/arcanist.git; + rev = "97501da16416fbfdc6e84bd60abcbf5ad9506225"; + sha256 = "9031c4ae228bdc986131e0c93c98fb73290bb0e297be1ec32f22ab09cdacafa3"; + }; + srcPhabricator = pkgs.fetchgit { + url = git://github.com/phacility/phabricator.git; + rev = "7ac5abb97934f7399b67762aa98f59f667711bf3"; + sha256 = "6a1d449597ae4432e40a3e6cdb14e3a5a8a40e019f3930493064c35911f2adcc"; + }; + + buildCommand = '' + mkdir -p $out + cp -R ${srcLibphutil} $out/libphutil + cp -R ${srcArcanist} $out/arcanist + cp -R ${srcPhabricator} $out/phabricator + ''; +} diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index fb7edbfd3892..69ce2d19e586 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -11421,6 +11421,8 @@ let pgfplots = callPackage ../tools/typesetting/tex/pgfplots { }; + phabricator = callPackage ../misc/phabricator { }; + pjsip = callPackage ../applications/networking/pjsip { }; polytable = callPackage ../tools/typesetting/tex/polytable { };