]> Git — Sourcephile - sourcephile-nix.git/blob - shell.nix
postfix: disable reject_unverified_recipient which fails upon greylisting
[sourcephile-nix.git] / shell.nix
1 let
2 nixpkgs_channel = builtins.getEnv "nixpkgs_channel";
3 originNixpkgs = import (.config/nixpkgs-channel + ("/" + nixpkgs_channel + ".nix"));
4 originPkgs = import originNixpkgs {
5 config = {}; # Make the config pure, ignoring user's config.
6 overlays = [];
7 };
8 remoteNixpkgsPatches = [
9 /*
10 { meta.description = "nsd : use types.lines where appropriate";
11 url = "https://github.com/NixOS/nixpkgs/pull/78968.diff";
12 sha256 = "11bqq1g1ax6i7xghihyhklmqpsq3njalardp6nvzphkjgxrypb47";
13 }
14 { meta.description = "shorewall: init at 5.2.3.3";
15 url = "https://github.com/NixOS/nixpkgs/pull/46131.diff";
16 sha256 = "0mfzlcr23ni5spnwksmmls50sw10alqbr5j6hjrwp9i30z0419yx";
17 }
18 */
19 { meta.description = "Dovecot plugin for Full Text Search (FTS) with Xapian";
20 url = "https://github.com/NixOS/nixpkgs/pull/78780.diff";
21 sha256 = "053md69ryybj27cp0xdfrza48zyzpblk6wvb2m2dbs9hm0gmcwc4";
22 }
23 /* Disabled because it triggers the local build of too many reverse-dependencies
24 { meta.description = "openldap: enable sha2 and pbkdf2 modules";
25 url = "https://github.com/NixOS/nixpkgs/pull/79286.diff";
26 sha256 = "0y255x74qksqy7fm4bdwlknhm3s55vgfgbv4dd7580p4lcavya0m";
27 }
28 */
29 /*
30 { meta.description = "Replace simp-le with lego and support DNS-01 challenge";
31 url = "https://github.com/NixOS/nixpkgs/pull/77578.diff";
32 sha256 = "15zs2146zh54jg1gywrcwyqxpx7izc35vlakk3cvrlqwwsvlr2rf";
33 }
34 */
35 { meta.description = "dstat: fix pluginpath";
36 url = "https://github.com/NixOS/nixpkgs/pull/80151.diff";
37 sha256 = "0jjw2gvp7b7v2n2m2d6yj0gw711j6p9lyjf5ywp2y9ql6905qf4b";
38 }
39 /*
40 { meta.description = "shorewall: fix warnings due to types.loaOf being deprecated";
41 url = "https://github.com/NixOS/nixpkgs/pull/80154.diff";
42 sha256 = "0b216m1rib3jl6s3r5cbkd5h1bfhppikg4cz9ayr1fspsflr3bci";
43 }
44 { meta.description = "shorewall: fix RestartTriggers";
45 url = "https://github.com/NixOS/nixpkgs/pull/81774.diff";
46 sha256 = "14drpym2mq9gq505psjzqq23gv0wkbwrrvh438h5jirzcym3467a";
47 }
48 */
49 ];
50 localNixpkgsPatches = [
51 patches/direnv.diff
52 ];
53 nixpkgs = originPkgs.applyPatches {
54 name = "nixpkgs-patched";
55 src = originNixpkgs;
56 patches = map originPkgs.fetchpatch remoteNixpkgsPatches ++ localNixpkgsPatches;
57 postPatch = ''
58 patch=$(printf '%s\n' ${builtins.concatStringsSep " "
59 (map (p: p.sha256) remoteNixpkgsPatches ++ localNixpkgsPatches)} |
60 sort | sha256sum | cut -c -7)
61 echo "+patch-$patch" >.version-suffix
62 '';
63 };
64 pkgs = import nixpkgs {
65 config = {}; # Make the config pure, ignoring user's config.
66 overlays = import ./overlays.nix;
67 };
68
69 lib = pkgs.lib;
70 nixos = pkgs.nixos {};
71 # Configuration of shell/modules/
72 configuration = {config, ...}: {
73 imports = [
74 ];
75 nix = {
76 nixConf = ''
77 auto-optimise-store = true
78 '';
79 };
80 nix-plugins = {
81 enable = true;
82 };
83 gnupg = {
84 enable = true;
85 gnupgHome = toString ../sec/gnupg;
86 keys = import shell/openpgp.nix;
87 gpgExtraConf = ''
88 # julm@sourcephile.fr
89 trusted-key 0xB2450D97085B7B8C
90 '';
91 };
92 openssl = {
93 enable = true;
94 opensslHome = toString ../sec/openssl;
95 certificates = import shell/x509.nix;
96 };
97 openssh = {
98 # WARNING: nixops uses its own ssh, not this one.
99 enable = true;
100 sshConf = ''
101 Ciphers aes256-gcm@openssh.com,aes128-gcm@openssh.com,aes256-ctr
102 Compression no
103 #CompressionLevel 4
104 ControlMaster auto
105 ControlPath ${builtins.toString ../sec/ssh}/ssh-%h-%p-%r.socket
106 HashKnownHosts no
107 #SSAPIAuthentication no
108 SendEnv LANG LC_*
109 StrictHostKeyChecking yes
110 UserKnownHostsFile ${builtins.toString ../sec/ssh/known_hosts}
111 '';
112 };
113 virtualbox = {
114 enable = true;
115 };
116 };
117
118 # Using modules enables to separate specific configurations
119 # from reusable code in shell/modules.nix and shell/modules/
120 # which may find its way in another git repository one day.
121 modules =
122 (import shell/modules.nix {
123 inherit pkgs lib;
124 modules = [ configuration ];
125 }).config;
126
127 # Utility to query the Nix files like nixops show-option
128 # but without requiring a nixops database, and not limited to config entries.
129 pwd = toString (./. + "");
130 sourcephile-nix-get = pkgs.writeShellScriptBin "sourcephile-nix-get" ''
131 nix-instantiate --read-write-mode \
132 --arg networkExprs "[${pwd}/servers.nix ${pwd}/servers/production.nix]" \
133 --arg args '{}' --argstr "uuid" whatever \
134 --argstr deploymentName production "<nixops/eval-machine-info.nix>" \
135 --eval-only --strict --arg checkConfigurationOptions false -A "$@"
136 '';
137 sourcephile-shred-tmp = pkgs.writeShellScriptBin "sourcephile-shred-tmp" ''
138 # Cleanup "../sec/tmp/"
139 # This is done when entering the nix-shell
140 # because direnv already hooks trap EXIT.
141 cd "${pwd}"
142 test ! -e sec/tmp || {
143 find sec/tmp -type f -exec shred -fu {} +
144 rm -rf sec/tmp
145 }
146 '';
147 in
148 pkgs.mkShell {
149 name = "sourcephile-nix";
150 src = null;
151 #preferLocalBuild = true;
152 #allowSubstitutes = false;
153 buildInputs = modules.nix-shell.buildInputs ++ [
154 sourcephile-nix-get
155 sourcephile-shred-tmp
156 nixos.nixos-generate-config
157 nixos.nixos-install
158 nixos.nixos-enter
159 #pkgs.binutils
160 pkgs.coreutils
161 pkgs.cryptsetup
162 pkgs.curl
163 #pkgs.direnv
164 pkgs.dnsutils
165 #pkgs.dropbear
166 pkgs.e2fsprogs
167 pkgs.git
168 pkgs.glibcLocales
169 pkgs.gnumake
170 pkgs.gnupg
171 pkgs.htop
172 #pkgs.inetutils
173 pkgs.ipcalc
174 #pkgs.iputils
175 pkgs.less
176 pkgs.libfaketime
177 pkgs.ldns
178 #pkgs.ldns.examples
179 #pkgs.mailutils
180 pkgs.man
181 pkgs.mdadm
182 pkgs.gptfdisk
183 pkgs.ncdu
184 pkgs.ncurses
185 pkgs.nixops
186 #pkgs.openssl
187 pkgs.pass
188 pkgs.procps
189 pkgs.rsync
190 #pkgs.rxvt_unicode.terminfo
191 #pkgs.sqlite
192 pkgs.sqlite
193 #pkgs.sudo
194 pkgs.tig
195 pkgs.time
196 #pkgs.tmux
197 pkgs.tree
198 pkgs.utillinux
199 #pkgs.vim
200 #pkgs.virtualbox
201 pkgs.which
202 pkgs.xdg_utils
203 pkgs.zfs
204 pkgs.fio
205 pkgs.strace
206 pkgs.utillinux
207 #pkgs.zfstools
208 ];
209 #enableParallelBuilding = true;
210 shellHook = ''
211 echo >&2 "nix: running shellHook"
212
213 # Nix
214 PATH=$NIX_SHELL_PATH:$PATH
215 export NIX_PATH="nixpkgs=${toString pkgs.path}:nixpkgs-overlays="$PWD"/overlays:nixops=${toString pkgs.nixops}/share/nix/nixops"
216
217 # Since the .envrc calls this shellHook
218 # the EXIT trap cannot be freely used
219 # because it's already used by direnv,
220 # hence shred at startup, which is not ideal.
221 sourcephile-shred-tmp
222
223 ${modules.nix-shell.shellHook}
224
225 # password-store
226 export PASSWORD_STORE_DIR="$PWD"/../sec/pass
227
228 # gpg
229 export GPG_TTY=$(tty)
230 gpg-connect-agent updatestartuptty /bye >/dev/null
231
232 # nixops
233 #export NIXOPS_DEPLOYMENT="staging"
234 export MERMET_DEPLOYMENT=production
235 export LOSURDO_DEPLOYMENT=production
236 export NIXOPS_STATE="$PWD"/../sec/nixops/state.nixops
237 NIXOPS_OPTS+=" --show-trace"
238 export NIXOPS_OPTS
239
240 # disnix
241 #export DISNIXOS_USE_NIXOPS=1
242 #export DISNIX_CLIENT_INTERFACE=disnix-nixops-client
243 #export DISNIX_PROFILE=default
244 #export DISNIX_TARGET_PROPERTY=hostname
245 #export DYSNOMIA_STATEDIR="$PWD"/../sec/dysnomia
246 '';
247 }