From e08ffc472c136c36308f14b67b442f35f6516583 Mon Sep 17 00:00:00 2001 From: Augustin Borsu Date: Wed, 21 Oct 2015 05:29:33 +0200 Subject: [PATCH 1/4] owncloud httpd-service: add urlPrefix option This option allows user to specify a url prefix for owncloud. By default it is set to "" and the document root will be set to owncloud's dir. If a prefix is set, e.g. urlPrefix = "/owncloud" an alias will be created using that prefix to point to owncloud's dir and owncloud will be available at http://localhost/owncloud --- .../web-servers/apache-httpd/owncloud.nix | 21 ++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/nixos/modules/services/web-servers/apache-httpd/owncloud.nix b/nixos/modules/services/web-servers/apache-httpd/owncloud.nix index a5e539bc9ba..b3f47cddecc 100644 --- a/nixos/modules/services/web-servers/apache-httpd/owncloud.nix +++ b/nixos/modules/services/web-servers/apache-httpd/owncloud.nix @@ -345,13 +345,12 @@ rec { extraConfig = '' - ServerName ${config.siteName} - ServerAdmin ${config.adminAddr} - DocumentRoot ${documentRoot} + ${if config.urlPrefix != "" then "Alias ${config.urlPrefix} ${pkgs.owncloud}" else '' - RewriteEngine On - RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} !-f - RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} !-d + RewriteEngine On + RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} !-f + RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} !-d + ''} ${builtins.readFile "${pkgs.owncloud}/.htaccess"} @@ -362,12 +361,20 @@ rec { { name = "OC_CONFIG_PATH"; value = "${config.dataDir}/config/"; } ]; - documentRoot = pkgs.owncloud; + documentRoot = if config.urlPrefix == "" then pkgs.owncloud else null; enablePHP = true; options = { + urlPrefix = mkOption { + default = ""; + example = "/owncloud"; + description = '' + The URL prefix under which the owncloud service appears. + ''; + }; + id = mkOption { default = "main"; description = '' From 16fd6c1cf0d9386363c26246c2100c88fd3f2fdf Mon Sep 17 00:00:00 2001 From: Augustin Borsu Date: Wed, 4 Nov 2015 16:04:02 +0000 Subject: [PATCH 2/4] owncloud: 7.0.5 -> 7.0.10 + Commit changes default version to 7.0.10, 7.0.5 version is kept for people reluctant to update. Needed info has also been added for versions 8.0, 8.1 and 8.2 only the latest minor version of each major version is included. --- .../web-servers/apache-httpd/owncloud.nix | 6 +- pkgs/servers/owncloud/default.nix | 67 ++++++++++++++----- pkgs/top-level/all-packages.nix | 9 ++- 3 files changed, 62 insertions(+), 20 deletions(-) diff --git a/nixos/modules/services/web-servers/apache-httpd/owncloud.nix b/nixos/modules/services/web-servers/apache-httpd/owncloud.nix index b3f47cddecc..f69e2141805 100644 --- a/nixos/modules/services/web-servers/apache-httpd/owncloud.nix +++ b/nixos/modules/services/web-servers/apache-httpd/owncloud.nix @@ -573,7 +573,11 @@ rec { ${pkgs.sudo}/bin/sudo -u postgres ${pkgs.postgresql}/bin/psql -h "/tmp" -U postgres -d ${config.dbName} -Atw -c "$QUERY" || true fi - ${php}/bin/php ${pkgs.owncloud}/occ upgrade || true + if [ -e ${pkgs.owncloud}/config/ca-bundle.crt ]; then + cp -f ${pkgs.owncloud}/config/ca-bundle.crt ${config.dataDir}/config/ + fi + + ${php}/bin/php ${pkgs.owncloud}/occ upgrade >> ${config.dataDir}/upgrade.log || true chown wwwrun:wwwrun ${config.dataDir}/owncloud.log || true diff --git a/pkgs/servers/owncloud/default.nix b/pkgs/servers/owncloud/default.nix index 449eee556c1..4122e940c76 100644 --- a/pkgs/servers/owncloud/default.nix +++ b/pkgs/servers/owncloud/default.nix @@ -1,28 +1,59 @@ { stdenv, fetchurl }: -stdenv.mkDerivation rec { - name= "owncloud-${version}"; - version = "7.0.5"; +let + common = { versiona, sha256 } @ args: stdenv.mkDerivation (rec { - src = fetchurl { - url = "https://download.owncloud.org/community/${name}.tar.bz2"; + name= "owncloud-${version}"; + version= versiona; + + src = fetchurl { + url = "https://download.owncloud.org/community/${name}.tar.bz2"; + inherit sha256; + }; + + installPhase = + '' + mkdir -p $out + find . -maxdepth 1 -execdir cp -r '{}' $out \; + + substituteInPlace $out/lib/base.php \ + --replace 'OC_Config::$object = new \OC\Config(self::$configDir);' \ + 'self::$configDir = getenv("OC_CONFIG_PATH"); OC_Config::$object = new \OC\Config(self::$configDir);' + ''; + + meta = { + description = "An enterprise file sharing solution for online collaboration and storage"; + homepage = https://owncloud.org; + maintainers = with stdenv.lib.maintainers; [ matejc ]; + license = stdenv.lib.licenses.agpl3Plus; + }; + + }); + +in { + + owncloud705 = common { + versiona = "7.0.5"; sha256 = "1j21b7ljvbhni9l0b1cpzlhsjy36scyas1l1j222mqdg2srfsi9y"; }; - installPhase = - '' - mkdir -p $out - find . -maxdepth 1 -execdir cp -r '{}' $out \; + owncloud70 = common { + versiona = "7.0.10"; + sha256 = "7e77f27137f37a721a8827b0436a9e71c100406d9745c4251c37c14bcaf31d0b"; + }; - substituteInPlace $out/lib/base.php \ - --replace 'OC_Config::$object = new \OC\Config(self::$configDir);' \ - 'self::$configDir = getenv("OC_CONFIG_PATH"); OC_Config::$object = new \OC\Config(self::$configDir);' - ''; + owncloud80 = common { + versiona = "8.0.9"; + sha256 = "0c1f915f4123dbe07d564cf0172930568690ab5257d2fca4fec4ec515858bef1"; + }; - meta = { - description = "An enterprise file sharing solution for online collaboration and storage"; - homepage = https://owncloud.org; - maintainers = with stdenv.lib.maintainers; [ matejc ]; - license = stdenv.lib.licenses.agpl3Plus; + owncloud81 = common { + versiona = "8.1.4"; + sha256 = "e0f4bf0c85821fc1b6e7f6268080ad3ca3e98c41baa68a9d616809d74a77312d"; + }; + + owncloud82 = common { + versiona = "8.2.0"; + sha256 = "fcfe99cf1c3aa06ff369e5b1a602147c08dd977af11800fe06c6a661fa5f770c"; }; } diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 14041573472..b9e07a590ab 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -2573,7 +2573,14 @@ let otpw = callPackage ../os-specific/linux/otpw { }; - owncloud = callPackage ../servers/owncloud { }; + owncloud = owncloud70; + + inherit (callPackages ../servers/owncloud { }) + owncloud705 + owncloud70 + owncloud80 + owncloud81 + owncloud82; owncloudclient = callPackage ../applications/networking/owncloud-client { }; From 9d5bf282c7fe5fe9ee88bd4f31953a42fa708046 Mon Sep 17 00:00:00 2001 From: Augustin Borsu Date: Thu, 26 Nov 2015 15:26:58 +0100 Subject: [PATCH 3/4] owncloud httpd-service: fix trusted_domain when unset When an empty string was given as trusted_domain, the trusted domain was set to be empty string instead of not beeing set. --- nixos/modules/services/web-servers/apache-httpd/owncloud.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nixos/modules/services/web-servers/apache-httpd/owncloud.nix b/nixos/modules/services/web-servers/apache-httpd/owncloud.nix index f69e2141805..1484f175035 100644 --- a/nixos/modules/services/web-servers/apache-httpd/owncloud.nix +++ b/nixos/modules/services/web-servers/apache-httpd/owncloud.nix @@ -70,7 +70,7 @@ let "proxyuserpwd" => "", /* List of trusted domains, to prevent host header poisoning ownCloud is only using these Host headers */ - 'trusted_domains' => array('${config.trustedDomain}'), + ${if config.trustedDomain != "" then "'trusted_domains' => array('${config.trustedDomain}')," else ""} /* Theme to use for ownCloud */ "theme" => "", From c17a60b636a22e526a8953d0d36d45b4a47c60e8 Mon Sep 17 00:00:00 2001 From: Augustin Borsu Date: Thu, 26 Nov 2015 15:53:34 +0100 Subject: [PATCH 4/4] owncloud httpd-service: add package option Owncloud package used can now be set in configuration.nix using package option. --- .../web-servers/apache-httpd/owncloud.nix | 27 ++++++++++++------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/nixos/modules/services/web-servers/apache-httpd/owncloud.nix b/nixos/modules/services/web-servers/apache-httpd/owncloud.nix index 1484f175035..9994de0f9b4 100644 --- a/nixos/modules/services/web-servers/apache-httpd/owncloud.nix +++ b/nixos/modules/services/web-servers/apache-httpd/owncloud.nix @@ -331,7 +331,7 @@ let */ 'share_folder' => '/', - 'version' => '${pkgs.owncloud.version}', + 'version' => '${config.package.version}', 'openssl' => '${pkgs.openssl}/bin/openssl' @@ -345,15 +345,15 @@ rec { extraConfig = '' - ${if config.urlPrefix != "" then "Alias ${config.urlPrefix} ${pkgs.owncloud}" else '' + ${if config.urlPrefix != "" then "Alias ${config.urlPrefix} ${config.package}" else '' RewriteEngine On RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} !-f RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} !-d ''} - - ${builtins.readFile "${pkgs.owncloud}/.htaccess"} + + ${builtins.readFile "${config.package}/.htaccess"} ''; @@ -361,12 +361,21 @@ rec { { name = "OC_CONFIG_PATH"; value = "${config.dataDir}/config/"; } ]; - documentRoot = if config.urlPrefix == "" then pkgs.owncloud else null; + documentRoot = if config.urlPrefix == "" then config.package else null; enablePHP = true; options = { + package = mkOption { + type = types.package; + default = pkgs.owncloud70; + example = literalExample "pkgs.owncloud70"; + description = '' + PostgreSQL package to use. + ''; + }; + urlPrefix = mkOption { default = ""; example = "/owncloud"; @@ -559,7 +568,7 @@ rec { cp ${owncloudConfig} ${config.dataDir}/config/config.php mkdir -p ${config.dataDir}/storage mkdir -p ${config.dataDir}/apps - cp -r ${pkgs.owncloud}/apps/* ${config.dataDir}/apps/ + cp -r ${config.package}/apps/* ${config.dataDir}/apps/ chmod -R ug+rw ${config.dataDir} chmod -R o-rwx ${config.dataDir} chown -R wwwrun:wwwrun ${config.dataDir} @@ -573,11 +582,11 @@ rec { ${pkgs.sudo}/bin/sudo -u postgres ${pkgs.postgresql}/bin/psql -h "/tmp" -U postgres -d ${config.dbName} -Atw -c "$QUERY" || true fi - if [ -e ${pkgs.owncloud}/config/ca-bundle.crt ]; then - cp -f ${pkgs.owncloud}/config/ca-bundle.crt ${config.dataDir}/config/ + if [ -e ${config.package}/config/ca-bundle.crt ]; then + cp -f ${config.package}/config/ca-bundle.crt ${config.dataDir}/config/ fi - ${php}/bin/php ${pkgs.owncloud}/occ upgrade >> ${config.dataDir}/upgrade.log || true + ${php}/bin/php ${config.package}/occ upgrade >> ${config.dataDir}/upgrade.log || true chown wwwrun:wwwrun ${config.dataDir}/owncloud.log || true