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