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