diff options
Diffstat (limited to 'nixops/modules/websites/tools/diaspora/diaspora.nix')
-rw-r--r-- | nixops/modules/websites/tools/diaspora/diaspora.nix | 154 |
1 files changed, 154 insertions, 0 deletions
diff --git a/nixops/modules/websites/tools/diaspora/diaspora.nix b/nixops/modules/websites/tools/diaspora/diaspora.nix new file mode 100644 index 0000000..798ebe6 --- /dev/null +++ b/nixops/modules/websites/tools/diaspora/diaspora.nix | |||
@@ -0,0 +1,154 @@ | |||
1 | { env, fetchedGithub, stdenv, defaultGemConfig, writeText, bundlerEnv, ruby_2_4, pkgs, cacert }: | ||
2 | let | ||
3 | gems = bundlerEnv { | ||
4 | name = "diaspora-env"; | ||
5 | ruby = ruby_2_4; | ||
6 | gemdir = ./.; | ||
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"; | ||
15 | diaspora = stdenv.mkDerivation (fetchedGithub ./diaspora.json // rec { | ||
16 | buildPhase = '' | ||
17 | patch -p1 < ${./ldap.patch} | ||
18 | ''; | ||
19 | installPhase = '' | ||
20 | cp -a . $out | ||
21 | ''; | ||
22 | }); | ||
23 | secret_token = writeText "secret_token.rb" '' | ||
24 | Diaspora::Application.config.secret_key_base = '${env.secret_token}' | ||
25 | ''; | ||
26 | config = writeText "diaspora.yml" '' | ||
27 | configuration: | ||
28 | environment: | ||
29 | url: "https://diaspora.immae.eu/" | ||
30 | certificate_authorities: '${cacert}/etc/ssl/certs/ca-bundle.crt' | ||
31 | redis: '${env.redis_url}' | ||
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' | ||
72 | method: 'smtp' | ||
73 | smtp: | ||
74 | host: 'mail.immae.eu' | ||
75 | sendmail: | ||
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" | ||
91 | bind_pw: "${env.ldap.password}" | ||
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 | ''; | ||
99 | database_config = writeText "database.yml" '' | ||
100 | postgresql: &postgresql | ||
101 | adapter: postgresql | ||
102 | host: db-1.immae.eu | ||
103 | port: 5432 | ||
104 | username: "diaspora" | ||
105 | password: "${env.postgresql.password}" | ||
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 | ||
116 | database: diaspora | ||
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 | ||
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 | ||
143 | RAILS_ENV=production ${gems}/bin/rake assets:precompile | ||
144 | rm -rf tmp log | ||
145 | ln -sf ../../../../../${varDir}/tmp tmp | ||
146 | ln -sf ../../../../../${varDir}/log log | ||
147 | ''; | ||
148 | propagatedBuildInputs = [ gems pkgs.nodejs pkgs.which pkgs.git ]; | ||
149 | }; | ||
150 | in | ||
151 | { | ||
152 | inherit railsRoot varDir socketsDir gems; | ||
153 | railsSocket = "${socketsDir}/diaspora.sock"; | ||
154 | } | ||