]>
Commit | Line | Data |
---|---|---|
3bb8a82a | 1 | { ldap ? false, varDir ? "/var/lib/diaspora", podmin_email ? null, config_dir ? "/etc/diaspora", |
bc0f9fcf | 2 | src, stdenv, bundlerEnv, writeText, |
3bb8a82a IB |
3 | cacert, defaultGemConfig, perl, ruby_2_4, nodejs, which, git }: |
4 | let | |
bc0f9fcf IB |
5 | diaspora_src = stdenv.mkDerivation { |
6 | inherit (src) version; | |
7 | pname = "diaspora"; | |
8 | inherit src; | |
3bb8a82a IB |
9 | buildPhase = '' |
10 | ${if ldap then "patch -p1 < ${./ldap.patch}" else ""} | |
11 | # FIXME: bundlerEnv below doesn't take postgresql group for some | |
12 | # reason | |
13 | echo 'gem "pg", "1.1.3"' >> Gemfile | |
14 | ''; | |
15 | installPhase = '' | |
16 | cp -a . $out | |
17 | ''; | |
bc0f9fcf | 18 | }; |
3bb8a82a IB |
19 | gems = bundlerEnv { |
20 | name = "diaspora-env"; | |
3bb8a82a IB |
21 | gemfile = "${diaspora_src}/Gemfile"; |
22 | lockfile = "${diaspora_src}/Gemfile.lock"; | |
23 | gemset = if ldap then ./gemset_ldap.nix else ./gemset.nix; | |
24 | groups = [ "postgresql" "default" "production" ]; | |
25 | gemConfig = defaultGemConfig // { | |
26 | kostya-sigar = attrs: { | |
27 | buildInputs = [ perl ]; | |
28 | }; | |
29 | }; | |
30 | }; | |
31 | build_config = writeText "diaspora.yml" '' | |
32 | configuration: | |
33 | environment: | |
34 | certificate_authorities: '${cacert}/etc/ssl/certs/ca-bundle.crt' | |
35 | ${if podmin_email != null then '' | |
36 | # dummy comment for indentation | |
37 | admins: | |
38 | podmin_email: '${podmin_email}' | |
39 | '' else ""} | |
40 | production: | |
41 | environment: | |
42 | ''; | |
43 | dummy_token = writeText "secret_token.rb" '' | |
44 | Diaspora::Application.config.secret_key_base = 'dummy' | |
45 | ''; | |
bc0f9fcf IB |
46 | diaspora = stdenv.mkDerivation { |
47 | name = "diaspora"; | |
48 | inherit diaspora_src; | |
49 | builder = writeText "build_diaspora" '' | |
50 | source $stdenv/setup | |
51 | cp -a $diaspora_src $out | |
52 | cd $out | |
53 | chmod -R u+rwX . | |
54 | tar -czf public/source.tar.gz ./{app,db,lib,script,Gemfile,Gemfile.lock,Rakefile,config.ru} | |
55 | ln -s database.yml.example config/database.yml | |
56 | ln -s ${build_config} config/diaspora.yml | |
57 | ln -s ${dummy_token} config/initializers/secret_token.rb | |
58 | ln -sf ${varDir}/schedule.yml config/schedule.yml | |
59 | ln -sf ${varDir}/oidc_key.pem config/oidc_key.pem | |
60 | ln -sf ${varDir}/uploads public/uploads | |
61 | RAILS_ENV=production ${gems}/bin/rake assets:precompile | |
62 | ln -sf ${config_dir}/database.yml config/database.yml | |
63 | ln -sf ${config_dir}/diaspora.yml config/diaspora.yml | |
64 | ln -sf ${config_dir}/secret_token.rb config/initializers/secret_token.rb | |
65 | rm -rf tmp log | |
66 | ln -sf ${varDir}/tmp tmp | |
67 | ln -sf ${varDir}/log log | |
68 | ''; | |
69 | propagatedBuildInputs = [ gems nodejs which git ]; | |
70 | passthru = { inherit gems varDir; }; | |
71 | }; | |
3bb8a82a | 72 | in |
bc0f9fcf | 73 | diaspora |