summaryrefslogtreecommitdiffstats
path: root/spejstore/default.nix
blob: c02da73f5d943a693460773f3c40e35f26882123 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
{ stdenv, fetchurl, fetchgit, python3, python3Packages, makeWrapper, lib }:

let
  django_1_11 = pyPkgs: pyPkgs.django_1_11;
  python = python3.override {
    packageOverrides = self: super: {
      django = django_1_11 super;
      # we use some dependencies that are outside of nixpkgs
      django-flat-responsive = self.callPackage ./python-modules/django-flat-responsive.nix { };
      django-hstore = self.callPackage ./python-modules/django-hstore.nix { };
      django-markdown2 = self.callPackage ./python-modules/django-markdown2.nix { };
      django-select2 = self.callPackage ./python-modules/django-select2.nix { };
      django-tree = self.callPackage ./python-modules/django-tree.nix { };
      django-restframework-hstore = self.callPackage ./python-modules/django-restframework-hstore.nix { };
      social-auth-app-django = self.callPackage ./python-modules/social-auth-app-django.nix { };
      social-auth-core = self.callPackage ./python-modules/social-auth-core.nix { };
    };
  };
in
stdenv.mkDerivation rec {
  name = "spejstore";

  src = fetchgit {
    url = "http://code.hackerspace.pl/ar/spejstore/";
    rev = "6b5c97b6384c48d5b7adbe551683105d73ceb7b2";
    sha256 = "1wgcj4fdqbrmvb2g09a1q6jriq00avxpc5cly75kxjhzc1bxxxfs";
  };

  nativeBuildInputs = [ makeWrapper ];

  runtimePackages = with python.pkgs; [
    certifi chardet django djangorestframework pillow psycopg2 requests urllib3 django_appconf setuptools
    django-tree django-flat-responsive django-hstore django-select2 social-auth-app-django django-markdown2 django-restframework-hstore
  ];

  pythonEnv = python.withPackages (_: runtimePackages);
  passthru = {
    inherit python runtimePackages;
  };

  unpackPhase = ''
    srcDir=$out/share/spejstore
    mkdir -p $srcDir
    cp -r --no-preserve=mode -t $srcDir $src/{manage.py,auth,spejstore,storage,static,templates}
  '';

  installPhase = ''
    ${python.interpreter} -m compileall $srcDir
    makeWrapper $pythonEnv/bin/python $out/bin/spejstore \
      --add-flags $out/share/spejstore/manage.py

    $out/bin/spejstore collectstatic
  '';
}