]>
Commit | Line | Data |
---|---|---|
9d90e7e2 | 1 | { env, fetchedGithub, stdenv, defaultGemConfig, writeText, bundlerEnv, ruby_2_4, pkgs, cacert }: |
a7f7fdae IB |
2 | let |
3 | gems = bundlerEnv { | |
4 | name = "diaspora-env"; | |
5 | ruby = ruby_2_4; | |
6 | gemdir = ./.; | |
a7f7fdae IB |
7 | gemConfig = defaultGemConfig // { |
8 | kostya-sigar = attrs: { | |
9 | buildInputs = with pkgs; [ pkgs.perl ]; | |
10 | }; | |
11 | }; | |
12 | }; | |
13 | varDir = "/var/lib/diaspora_immae"; | |
14 | socketsDir = "/run/diaspora"; | |
a7f7fdae IB |
15 | diaspora = stdenv.mkDerivation (fetchedGithub ./diaspora.json // rec { |
16 | buildPhase = '' | |
a7f7fdae IB |
17 | patch -p1 < ${./ldap.patch} |
18 | ''; | |
19 | installPhase = '' | |
20 | cp -a . $out | |
21 | ''; | |
a7f7fdae | 22 | }); |
9d90e7e2 IB |
23 | secret_token = writeText "secret_token.rb" '' |
24 | Diaspora::Application.config.secret_key_base = '${env.secret_token}' | |
a7f7fdae | 25 | ''; |
9d90e7e2 | 26 | config = writeText "diaspora.yml" '' |
a7f7fdae IB |
27 | configuration: |
28 | environment: | |
29 | url: "https://diaspora.immae.eu/" | |
0fa86654 | 30 | certificate_authorities: '${cacert}/etc/ssl/certs/ca-bundle.crt' |
b0781dbc | 31 | redis: '${env.redis_url}' |
a7f7fdae IB |
32 | sidekiq: |
33 | s3: | |
34 | assets: | |
35 | logging: | |
36 | logrotate: | |
37 | debug: | |
38 | server: | |
39 | listen: '${socketsDir}/diaspora.sock' | |
40 | rails_environment: 'production' | |
41 | chat: | |
42 | server: | |
43 | bosh: | |
44 | log: | |
45 | map: | |
46 | mapbox: | |
47 | privacy: | |
48 | piwik: | |
49 | statistics: | |
50 | camo: | |
51 | settings: | |
52 | enable_registrations: false | |
53 | welcome_message: | |
54 | invitations: | |
55 | open: false | |
56 | paypal_donations: | |
57 | community_spotlight: | |
58 | captcha: | |
59 | enable: false | |
60 | terms: | |
61 | maintenance: | |
62 | remove_old_users: | |
63 | default_metas: | |
64 | csp: | |
65 | services: | |
66 | twitter: | |
67 | tumblr: | |
68 | wordpress: | |
69 | mail: | |
70 | enable: true | |
71 | sender_address: 'diaspora@immae.eu' | |
591ebd87 | 72 | method: 'sendmail' |
a7f7fdae | 73 | smtp: |
a7f7fdae | 74 | sendmail: |
591ebd87 | 75 | location: '/run/wrappers/bin/sendmail' |
a7f7fdae IB |
76 | admins: |
77 | account: "ismael" | |
78 | podmin_email: 'diaspora@immae.eu' | |
79 | relay: | |
80 | outbound: | |
81 | inbound: | |
82 | ldap: | |
83 | enable: true | |
84 | host: ldap.immae.eu | |
85 | port: 636 | |
86 | only_ldap: true | |
87 | mail_attribute: mail | |
88 | skip_email_confirmation: true | |
89 | use_bind_dn: true | |
90 | bind_dn: "cn=diaspora,ou=services,dc=immae,dc=eu" | |
9d90e7e2 | 91 | bind_pw: "${env.ldap.password}" |
a7f7fdae IB |
92 | search_base: "dc=immae,dc=eu" |
93 | search_filter: "(&(memberOf=cn=users,cn=diaspora,ou=services,dc=immae,dc=eu)(uid=%{username}))" | |
94 | production: | |
95 | environment: | |
96 | development: | |
97 | environment: | |
98 | ''; | |
9d90e7e2 | 99 | database_config = writeText "database.yml" '' |
a7f7fdae IB |
100 | postgresql: &postgresql |
101 | adapter: postgresql | |
7ebcaad5 IB |
102 | host: "${env.postgresql.socket}" |
103 | port: "${env.postgresql.port}" | |
104 | username: "${env.postgresql.user}" | |
9d90e7e2 | 105 | password: "${env.postgresql.password}" |
a7f7fdae IB |
106 | encoding: unicode |
107 | common: &common | |
108 | <<: *postgresql | |
109 | combined: &combined | |
110 | <<: *common | |
111 | development: | |
112 | <<: *combined | |
113 | database: diaspora_development | |
114 | production: | |
115 | <<: *combined | |
7ebcaad5 | 116 | database: ${env.postgresql.database} |
a7f7fdae IB |
117 | test: |
118 | <<: *combined | |
119 | database: "diaspora_test" | |
120 | integration1: | |
121 | <<: *combined | |
122 | database: diaspora_integration1 | |
123 | integration2: | |
124 | <<: *combined | |
125 | database: diaspora_integration2 | |
126 | ''; | |
127 | ||
128 | railsRoot = stdenv.mkDerivation { | |
129 | name = "diaspora_immae"; | |
130 | inherit diaspora; | |
131 | builder = writeText "build_diaspora_immae" '' | |
132 | source $stdenv/setup | |
133 | cp -a $diaspora $out | |
134 | cd $out | |
135 | chmod -R u+rwX . | |
136 | tar -czf public/source.tar.gz ./{app,db,lib,script,Gemfile,Gemfile.lock,Rakefile,config.ru} | |
137 | ln -s ${database_config} config/database.yml | |
138 | ln -s ${config} config/diaspora.yml | |
139 | ln -s ${secret_token} config/initializers/secret_token.rb | |
3c8d7f87 IB |
140 | ln -sf ${varDir}/schedule.yml config/schedule.yml |
141 | ln -sf ${varDir}/oidc_key.pem config/oidc_key.pem | |
142 | ln -sf ${varDir}/uploads public/uploads | |
a7f7fdae IB |
143 | RAILS_ENV=production ${gems}/bin/rake assets:precompile |
144 | rm -rf tmp log | |
3c8d7f87 IB |
145 | ln -sf ${varDir}/tmp tmp |
146 | ln -sf ${varDir}/log log | |
a7f7fdae | 147 | ''; |
159d8ff3 | 148 | propagatedBuildInputs = [ gems pkgs.nodejs pkgs.which pkgs.git ]; |
a7f7fdae IB |
149 | }; |
150 | in | |
151 | { | |
152 | inherit railsRoot varDir socketsDir gems; | |
153 | railsSocket = "${socketsDir}/diaspora.sock"; | |
154 | } |