]> Git — Sourcephile - sourcephile-nix.git/blob - shell.nix
nix: use nixos-unstable-small
[sourcephile-nix.git] / shell.nix
1 let
2 originNixpkgs = import (.config/nixpkgs-channel + ("/" + builtins.getEnv "nixpkgs_channel" + ".nix"));
3 originPkgs = import originNixpkgs {
4 config = {}; # Make the config pure, ignoring user's config.
5 overlays = [];
6 };
7 nixpkgsPatches = [
8 /*
9 { meta.description = "nsd : use types.lines where appropriate";
10 url = "https://github.com/NixOS/nixpkgs/pull/78968.diff";
11 sha256 = "11bqq1g1ax6i7xghihyhklmqpsq3njalardp6nvzphkjgxrypb47";
12 }
13 { meta.description = "shorewall: init at 5.2.3.3";
14 url = "https://github.com/NixOS/nixpkgs/pull/46131.diff";
15 sha256 = "0mfzlcr23ni5spnwksmmls50sw10alqbr5j6hjrwp9i30z0419yx";
16 }
17 */
18 { meta.description = "Dovecot plugin for Full Text Search (FTS) with Xapian";
19 url = "https://github.com/NixOS/nixpkgs/pull/78780.diff";
20 sha256 = "053md69ryybj27cp0xdfrza48zyzpblk6wvb2m2dbs9hm0gmcwc4";
21 }
22 /* Disabled because it triggers the local build of too many reverse-dependencies
23 { meta.description = "openldap: enable sha2 and pbkdf2 modules";
24 url = "https://github.com/NixOS/nixpkgs/pull/79286.diff";
25 sha256 = "0y255x74qksqy7fm4bdwlknhm3s55vgfgbv4dd7580p4lcavya0m";
26 }
27 */
28 { meta.description = "Replace simp-le with lego and support DNS-01 challenge";
29 url = "https://github.com/NixOS/nixpkgs/pull/77578.diff";
30 sha256 = "15zs2146zh54jg1gywrcwyqxpx7izc35vlakk3cvrlqwwsvlr2rf";
31 }
32 ];
33 nixpkgs = originPkgs.stdenv.mkDerivation {
34 name = "nixpkgs-patched";
35 src = originNixpkgs;
36 phases = [ "unpackPhase" "patchPhase" ];
37 patches = map originPkgs.fetchpatch nixpkgsPatches;
38 postPatch = ''
39 patch=$(printf '%s\n' ${builtins.concatStringsSep " " (map (p: p.sha256) nixpkgsPatches)} |
40 sort | sha256sum | cut -c -7)
41 mv $PWD $out
42 echo "+patch-$patch" >$out/.version-suffix
43 '';
44 };
45 pkgs = import nixpkgs {
46 config = {}; # Make the config pure, ignoring user's config.
47 overlays = import ./overlays.nix;
48 };
49
50
51 lib = pkgs.lib;
52 nixos = pkgs.nixos {};
53 # Configuration of shell/modules/
54 configuration = {config, ...}: {
55 imports = [
56 ];
57 nix = {
58 nixConf = ''
59 auto-optimise-store = true
60 '';
61 };
62 nix-plugins = {
63 enable = true;
64 };
65 gnupg = {
66 enable = true;
67 gnupgHome = toString ../sec/gnupg;
68 keys = import shell/openpgp.nix;
69 gpgExtraConf = ''
70 trusted-key 0xB2450D97085B7B8C
71 '';
72 };
73 openssl = {
74 enable = true;
75 opensslHome = toString ../sec/openssl;
76 certificates = import shell/x509.nix;
77 };
78 openssh = {
79 # WARNING: nixops uses its own ssh, not this one.
80 enable = true;
81 sshConf = ''
82 Ciphers aes256-gcm@openssh.com,aes128-gcm@openssh.com,aes256-ctr
83 Compression no
84 #CompressionLevel 4
85 ControlMaster auto
86 ControlPath ${builtins.toString ../sec/ssh}/ssh-%h-%p-%r.socket
87 HashKnownHosts no
88 #SSAPIAuthentication no
89 SendEnv LANG LC_*
90 StrictHostKeyChecking yes
91 UserKnownHostsFile ${builtins.toString ../sec/ssh/known_hosts}
92 '';
93 };
94 virtualbox = {
95 enable = true;
96 };
97 };
98
99 # Using modules enables to separate specific configurations
100 # from reusable code in shell/modules.nix and shell/modules/
101 # which may find its way in another git repository one day.
102 modules =
103 (import shell/modules.nix {
104 inherit pkgs lib;
105 modules = [ configuration ];
106 }).config;
107 in
108 pkgs.mkShell {
109 name = "sourcephile-nix";
110 src = null;
111 #preferLocalBuild = true;
112 #allowSubstitutes = false;
113 buildInputs = modules.nix-shell.buildInputs ++ [
114 nixpkgs
115 nixos.nixos-generate-config
116 nixos.nixos-install
117 nixos.nixos-enter
118 #pkgs.binutils
119 pkgs.coreutils
120 pkgs.cryptsetup
121 pkgs.curl
122 #pkgs.direnv
123 pkgs.dnsutils
124 #pkgs.dropbear
125 pkgs.e2fsprogs
126 pkgs.git
127 pkgs.glibcLocales
128 pkgs.gnumake
129 pkgs.gnupg
130 pkgs.htop
131 #pkgs.inetutils
132 pkgs.ipcalc
133 #pkgs.iputils
134 pkgs.less
135 pkgs.libfaketime
136 pkgs.ldns
137 #pkgs.ldns.examples
138 #pkgs.mailutils
139 pkgs.man
140 pkgs.mdadm
141 pkgs.gptfdisk
142 pkgs.ncdu
143 pkgs.ncurses
144 pkgs.nixops
145 #pkgs.openssl
146 pkgs.pass
147 pkgs.procps
148 pkgs.rsync
149 #pkgs.rxvt_unicode.terminfo
150 #pkgs.sqlite
151 pkgs.sqlite
152 #pkgs.sudo
153 pkgs.tig
154 pkgs.time
155 #pkgs.tmux
156 pkgs.tree
157 pkgs.utillinux
158 #pkgs.vim
159 #pkgs.virtualbox
160 pkgs.which
161 pkgs.xdg_utils
162 pkgs.zfs
163 pkgs.fio
164 pkgs.strace
165 pkgs.utillinux
166 #pkgs.zfstools
167 ];
168 #enableParallelBuilding = true;
169 shellHook = ''
170 echo >&2 "nix: running shellHook"
171 # WARNING: beware that sudo may reset the environment,
172 # and especially PATH, to some system's default.
173
174 NIX_SHELL_PATH=$PATH
175 unset __ETC_PROFILE_SOURCED
176 unset __NIXOS_SET_ENVIRONMENT_DONE
177 test ! -e /etc/profile || . /etc/profile
178 test ! -e ~/.profile || . ~/.profile
179
180 # nix
181 test ! -e ~/.nix-profile/etc/profile.d/nix.sh ||
182 . ~/.nix-profile/etc/profile.d/nix.sh
183
184 # home-manager
185 unset __HM_SESS_VARS_SOURCED
186 test ! -e ~/.nix-profile/etc/profile.d/hm-session-vars.sh ||
187 . ~/.nix-profile/etc/profile.d/hm-session-vars.sh
188
189 PATH=$NIX_SHELL_PATH:$PATH
190 export NIX_PATH="nixpkgs=${pkgs.path}:nixpkgs-overlays="$PWD"/overlays"
191
192 # Cleanup "../sec/tmp/"
193 # This is done when exiting the nix-shell
194 # (or when… entering the directory with direnv
195 # which spawns a nix-shell just to get the env).
196 trap "cd '$PWD' && find ../sec/tmp -type f -exec shred -fu {} +" EXIT
197
198 ${modules.nix-shell.shellHook}
199
200 # locales
201 export LANG=fr_FR.UTF-8
202 export LC_CTYPE=fr_FR.UTF-8
203
204 # password-store
205 export PASSWORD_STORE_DIR="$PWD"/../sec/pass
206
207 # gpg
208 export GPG_TTY=$(tty)
209 gpg-connect-agent updatestartuptty /bye >/dev/null
210
211 # git
212 gitdir="$PWD"/.git
213 test ! -f "$gitdir" || while IFS=" :" read -r hdr gitdir; do [ "$hdr" != gitdir ] || break; done <"$gitdir"
214 ln -fnsr \
215 "$PWD"/.lib/git/hooks/prepare-commit-msg--longuest-common-prefix \
216 "$gitdir"/hooks/prepare-commit-msg
217
218 # nixops
219 #export NIXOPS_DEPLOYMENT="staging"
220 export NIXOPS_STATE="$PWD"/../sec/nixops/state.nixops
221 NIXOPS_OPTS+=" --show-trace"
222 export NIXOPS_OPTS
223
224 # disnix
225 #export DISNIXOS_USE_NIXOPS=1
226 #export DISNIX_CLIENT_INTERFACE=disnix-nixops-client
227 #export DISNIX_PROFILE=default
228 #export DISNIX_TARGET_PROPERTY=hostname
229 #export DYSNOMIA_STATEDIR="$PWD"/../sec/dysnomia
230 '';
231 }