From 7325ad9ab735424257b05a81e0c8197e4651e68f Mon Sep 17 00:00:00 2001 From: Guillaume Maudoux Date: Wed, 1 Nov 2017 01:09:39 +0100 Subject: [PATCH] graphite: override django and django_tagging instead of depending on specific versions in the django_tagging_0_4_3 and graphite_web derivations. This should fix: https://github.com/NixOS/nixpkgs/pull/30277#discussion_r145393088 This was joint work of @basvandijk and @layus at NixCon 2017. --- .../modules/services/monitoring/graphite.nix | 22 +++++++++++++------ pkgs/top-level/python-packages.nix | 15 +++++++++---- 2 files changed, 26 insertions(+), 11 deletions(-) diff --git a/nixos/modules/services/monitoring/graphite.nix b/nixos/modules/services/monitoring/graphite.nix index 645dfeab0193..4b1ad34b3a4e 100644 --- a/nixos/modules/services/monitoring/graphite.nix +++ b/nixos/modules/services/monitoring/graphite.nix @@ -467,7 +467,15 @@ in { ]; }) - (mkIf cfg.web.enable { + (mkIf cfg.web.enable (let + python27' = pkgs.python27.override { + packageOverrides = self: super: { + django = self.django_1_8; + django_tagging = self.django_tagging_0_4_3; + }; + }; + pythonPackages = python27'.pkgs; + in { systemd.services.graphiteWeb = { description = "Graphite Web Interface"; wantedBy = [ "multi-user.target" ]; @@ -477,8 +485,8 @@ in { PYTHONPATH = let penv = pkgs.python.buildEnv.override { extraLibs = [ - pkgs.python27Packages.graphite_web - pkgs.python27Packages.pysqlite + pythonPackages.graphite_web + pythonPackages.pysqlite ]; }; penvPack = "${penv}/${pkgs.python.sitePackages}"; @@ -516,17 +524,17 @@ in { fi # Only collect static files when graphite_web changes. - if ! [ "${dataDir}/current_graphite_web" -ef "${pkgs.python27Packages.graphite_web}" ]; then + if ! [ "${dataDir}/current_graphite_web" -ef "${pythonPackages.graphite_web}" ]; then mkdir -p ${staticDir} ${pkgs.pythonPackages.django_1_8}/bin/django-admin.py collectstatic --noinput --clear chown -R graphite:graphite ${staticDir} - ln -sfT "${pkgs.python27Packages.graphite_web}" "${dataDir}/current_graphite_web" + ln -sfT "${pythonPackages.graphite_web}" "${dataDir}/current_graphite_web" fi ''; }; - environment.systemPackages = [ pkgs.python27Packages.graphite_web ]; - }) + environment.systemPackages = [ pythonPackages.graphite_web ]; + })) (mkIf cfg.api.enable { systemd.services.graphiteApi = { diff --git a/pkgs/top-level/python-packages.nix b/pkgs/top-level/python-packages.nix index 0be1ff17ee01..7013b980865a 100644 --- a/pkgs/top-level/python-packages.nix +++ b/pkgs/top-level/python-packages.nix @@ -8093,14 +8093,17 @@ in { django_tagging = callPackage ../development/python-modules/django_tagging { }; - django_tagging_0_4_3 = self.django_tagging.overrideAttrs (attrs: rec { + django_tagging_0_4_3 = if + self.django != self.django_1_8 + then throw "django_tagging_0_4_3 should be build with django_1_8" + else (callPackage ../development/python-modules/django_tagging {}).overrideAttrs (attrs: rec { name = "django-tagging-0.4.3"; src = pkgs.fetchurl { url = "mirror://pypi/d/django-tagging/${name}.tar.gz"; sha256 = "0617azpmp6jpg3d88v2ir97qrc9aqcs2s9gyvv9bgf2cp55khxhs"; }; - propagatedBuildInputs = with self; [ django_1_8 ]; + propagatedBuildInputs = with self; [ django ]; }); django_classytags = buildPythonPackage rec { @@ -22835,7 +22838,11 @@ EOF }; }; - graphite_web = buildPythonPackage rec { + graphite_web = if + self.django != self.django_1_8 + || self.django_tagging != self.django_tagging_0_4_3 + then throw "graphite_web should be build with django_1_8 and django_tagging_0_4_3" + else buildPythonPackage rec { name = "graphite-web-${version}"; disabled = isPy3k; version = graphiteVersion; @@ -22846,7 +22853,7 @@ EOF }; propagatedBuildInputs = with self; [ - django_1_8 django_tagging_0_4_3 whisper pycairo cairocffi + django django_tagging whisper pycairo cairocffi ldap memcached pytz urllib3 scandir ];