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