]> Git — Sourcephile - sourcephile-nix.git/blob - shell.nix
nginx: use forceSSL
[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 nixpkgsPatches = [
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 { meta.description = "shorewall: fix warnings due to types.loaOf being deprecated";
40 url = "https://github.com/NixOS/nixpkgs/pull/80154.diff";
41 sha256 = "0b216m1rib3jl6s3r5cbkd5h1bfhppikg4cz9ayr1fspsflr3bci";
42 }
43 { meta.description = "shorewall: fix RestartTriggers";
44 url = "https://github.com/NixOS/nixpkgs/pull/81774.diff";
45 sha256 = "14drpym2mq9gq505psjzqq23gv0wkbwrrvh438h5jirzcym3467a";
46 }
47 ];
48 localNixpkgsPatches = [
49 patches/direnv.diff
50 ];
51 nixpkgs = originPkgs.stdenv.mkDerivation {
52 name = "nixpkgs-patched";
53 src = originNixpkgs;
54 phases = [ "unpackPhase" "patchPhase" ];
55 patches = map originPkgs.fetchpatch nixpkgsPatches ++ localNixpkgsPatches;
56 postPatch = ''
57 patch=$(printf '%s\n' ${builtins.concatStringsSep " " (map (p: p.sha256) nixpkgsPatches)} |
58 sort | sha256sum | cut -c -7)
59 mv $PWD $out
60 echo "+patch-$patch" >$out/.version-suffix
61 '';
62 };
63 pkgs = import nixpkgs {
64 config = {}; # Make the config pure, ignoring user's config.
65 overlays = import ./overlays.nix;
66 };
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 trusted-key 0xB2450D97085B7B8C
89 '';
90 };
91 openssl = {
92 enable = true;
93 opensslHome = toString ../sec/openssl;
94 certificates = import shell/x509.nix;
95 };
96 openssh = {
97 # WARNING: nixops uses its own ssh, not this one.
98 enable = true;
99 sshConf = ''
100 Ciphers aes256-gcm@openssh.com,aes128-gcm@openssh.com,aes256-ctr
101 Compression no
102 #CompressionLevel 4
103 ControlMaster auto
104 ControlPath ${builtins.toString ../sec/ssh}/ssh-%h-%p-%r.socket
105 HashKnownHosts no
106 #SSAPIAuthentication no
107 SendEnv LANG LC_*
108 StrictHostKeyChecking yes
109 UserKnownHostsFile ${builtins.toString ../sec/ssh/known_hosts}
110 '';
111 };
112 virtualbox = {
113 enable = true;
114 };
115 };
116
117 # Using modules enables to separate specific configurations
118 # from reusable code in shell/modules.nix and shell/modules/
119 # which may find its way in another git repository one day.
120 modules =
121 (import shell/modules.nix {
122 inherit pkgs lib;
123 modules = [ configuration ];
124 }).config;
125 in
126 pkgs.mkShell {
127 name = "sourcephile-nix";
128 src = null;
129 #preferLocalBuild = true;
130 #allowSubstitutes = false;
131 buildInputs = modules.nix-shell.buildInputs ++ [
132 nixos.nixos-generate-config
133 nixos.nixos-install
134 nixos.nixos-enter
135 #pkgs.binutils
136 pkgs.coreutils
137 pkgs.cryptsetup
138 pkgs.curl
139 #pkgs.direnv
140 pkgs.dnsutils
141 #pkgs.dropbear
142 pkgs.e2fsprogs
143 pkgs.git
144 pkgs.glibcLocales
145 pkgs.gnumake
146 pkgs.gnupg
147 pkgs.htop
148 #pkgs.inetutils
149 pkgs.ipcalc
150 #pkgs.iputils
151 pkgs.less
152 pkgs.libfaketime
153 pkgs.ldns
154 #pkgs.ldns.examples
155 #pkgs.mailutils
156 pkgs.man
157 pkgs.mdadm
158 pkgs.gptfdisk
159 pkgs.ncdu
160 pkgs.ncurses
161 pkgs.nixops
162 #pkgs.openssl
163 pkgs.pass
164 pkgs.procps
165 pkgs.rsync
166 #pkgs.rxvt_unicode.terminfo
167 #pkgs.sqlite
168 pkgs.sqlite
169 #pkgs.sudo
170 pkgs.tig
171 pkgs.time
172 #pkgs.tmux
173 pkgs.tree
174 pkgs.utillinux
175 #pkgs.vim
176 #pkgs.virtualbox
177 pkgs.which
178 pkgs.xdg_utils
179 pkgs.zfs
180 pkgs.fio
181 pkgs.strace
182 pkgs.utillinux
183 #pkgs.zfstools
184 ];
185 #enableParallelBuilding = true;
186 shellHook = ''
187 echo >&2 "nix: running shellHook"
188
189 # Nix
190 PATH=$NIX_SHELL_PATH:$PATH
191 export NIX_PATH="nixpkgs=${toString pkgs.path}:nixpkgs-overlays="$PWD"/overlays"
192 export nixpkgs_channel=${nixpkgs_channel}
193
194 # Cleanup "../sec/tmp/"
195 # This is done when entering the nix-shell
196 # because direnv already hooks trap EXIT.
197 (cd "$PWD" && find ../sec/tmp -type f -exec shred -fu {} +)
198
199 ${modules.nix-shell.shellHook}
200
201 # locales
202 export LANG=fr_FR.UTF-8
203 export LC_CTYPE=fr_FR.UTF-8
204
205 # password-store
206 export PASSWORD_STORE_DIR="$PWD"/../sec/pass
207
208 # gpg
209 export GPG_TTY=$(tty)
210 gpg-connect-agent updatestartuptty /bye >/dev/null
211
212 # nixops
213 #export NIXOPS_DEPLOYMENT="staging"
214 export NIXOPS_STATE="$PWD"/../sec/nixops/state.nixops
215 NIXOPS_OPTS+=" --show-trace"
216 export NIXOPS_OPTS
217
218 # disnix
219 #export DISNIXOS_USE_NIXOPS=1
220 #export DISNIX_CLIENT_INTERFACE=disnix-nixops-client
221 #export DISNIX_PROFILE=default
222 #export DISNIX_TARGET_PROPERTY=hostname
223 #export DYSNOMIA_STATEDIR="$PWD"/../sec/dysnomia
224 '';
225 }