]> git.immae.eu Git - perso/Immae/Config/Nix/NUR.git/blame - pkgs/webapps/diaspora/default.nix
Use fetchgit rather than builtins
[perso/Immae/Config/Nix/NUR.git] / pkgs / webapps / diaspora / default.nix
CommitLineData
24fd1fe6
IB
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 }:
4let
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";
24fd1fe6
IB
18 gemfile = "${diaspora_src}/Gemfile";
19 lockfile = "${diaspora_src}/Gemfile.lock";
20 gemset = if ldap then ./gemset_ldap.nix else ./gemset.nix;
21 groups = [ "postgresql" "default" "production" ];
22 gemConfig = defaultGemConfig // {
23 kostya-sigar = attrs: {
24 buildInputs = [ perl ];
25 };
26 };
27 };
28 build_config = writeText "diaspora.yml" ''
29 configuration:
30 environment:
31 certificate_authorities: '${cacert}/etc/ssl/certs/ca-bundle.crt'
32 ${if podmin_email != null then ''
33 # dummy comment for indentation
34 admins:
35 podmin_email: '${podmin_email}'
36 '' else ""}
37 production:
38 environment:
39 '';
40 dummy_token = writeText "secret_token.rb" ''
41 Diaspora::Application.config.secret_key_base = 'dummy'
42 '';
43in
44stdenv.mkDerivation {
45 name = "diaspora";
46 inherit diaspora_src;
47 builder = writeText "build_diaspora" ''
48 source $stdenv/setup
49 cp -a $diaspora_src $out
50 cd $out
51 chmod -R u+rwX .
52 tar -czf public/source.tar.gz ./{app,db,lib,script,Gemfile,Gemfile.lock,Rakefile,config.ru}
53 ln -s database.yml.example config/database.yml
54 ln -s ${build_config} config/diaspora.yml
55 ln -s ${dummy_token} config/initializers/secret_token.rb
56 ln -sf ${varDir}/schedule.yml config/schedule.yml
57 ln -sf ${varDir}/oidc_key.pem config/oidc_key.pem
58 ln -sf ${varDir}/uploads public/uploads
59 RAILS_ENV=production ${gems}/bin/rake assets:precompile
60 ln -sf ${config_dir}/database.yml config/database.yml
61 ln -sf ${config_dir}/diaspora.yml config/diaspora.yml
62 ln -sf ${config_dir}/secret_token.rb config/initializers/secret_token.rb
63 rm -rf tmp log
64 ln -sf ${varDir}/tmp tmp
65 ln -sf ${varDir}/log log
66 '';
67 propagatedBuildInputs = [ gems nodejs which git ];
68 passthru = { inherit gems varDir; };
69}