]> Git — Sourcephile - sourcephile-nix.git/blob - shell.nix
nsd: lower sourcephile.fr TTL
[sourcephile-nix.git] / shell.nix
1 let
2 nixpkgs = import .config/nixpkgs-channel/nixos-19.09-small.nix;
3 pkgs = import nixpkgs {
4 config = {}; # Make the config pure, ignoring user's config.
5 overlays = import ./overlays.nix;
6 };
7 lib = pkgs.lib;
8 nixos = pkgs.nixos {};
9 # Configuration of shell/modules/
10 configuration = {config, ...}: {
11 imports = [
12 ];
13 nix = {
14 nixConf = ''
15 auto-optimise-store = true
16 '';
17 };
18 nix-plugins = {
19 enable = true;
20 };
21 gnupg = {
22 enable = true;
23 gnupgHome = toString ../sec/gnupg;
24 keys = import shell/openpgp.nix;
25 };
26 openssl = {
27 enable = true;
28 opensslHome = toString ../sec/openssl;
29 certificates = import shell/x509.nix;
30 };
31 openssh = {
32 # WARNING: nixops uses its own ssh, not this one.
33 enable = true;
34 sshConf = ''
35 Ciphers aes256-gcm@openssh.com,aes128-gcm@openssh.com,aes256-ctr
36 Compression no
37 #CompressionLevel 4
38 ControlMaster auto
39 ControlPath ${builtins.toString ../sec/ssh}/ssh-%h-%p-%r.socket
40 HashKnownHosts no
41 #SSAPIAuthentication no
42 SendEnv LANG LC_*
43 StrictHostKeyChecking yes
44 UserKnownHostsFile ${builtins.toString ../sec/ssh/known_hosts}
45 '';
46 };
47 virtualbox = {
48 enable = true;
49 };
50 };
51
52 # Using modules enables to separate specific configurations
53 # from reusable code in shell/modules.nix and shell/modules/
54 # which may find its way in another git repository one day.
55 modules =
56 (import shell/modules.nix {
57 inherit pkgs lib;
58 modules = [ configuration ];
59 }).config;
60 in
61 pkgs.stdenv.mkDerivation {
62 name = "sourcephile-nix";
63 src = null;
64 #preferLocalBuild = true;
65 #allowSubstitutes = false;
66 buildInputs = modules.nix-shell.buildInputs ++ [
67 nixpkgs
68 nixos.nixos-generate-config
69 nixos.nixos-install
70 nixos.nixos-enter
71 #pkgs.binutils
72 pkgs.coreutils
73 pkgs.cryptsetup
74 pkgs.curl
75 #pkgs.direnv
76 pkgs.dnsutils
77 #pkgs.dropbear
78 pkgs.e2fsprogs
79 pkgs.git
80 pkgs.glibcLocales
81 pkgs.gnumake
82 pkgs.gnupg
83 pkgs.htop
84 #pkgs.inetutils
85 pkgs.ipcalc
86 #pkgs.iputils
87 pkgs.less
88 pkgs.libfaketime
89 #pkgs.mailutils
90 pkgs.man
91 pkgs.mdadm
92 pkgs.gptfdisk
93 pkgs.ncdu
94 pkgs.ncurses
95 pkgs.nixops
96 #pkgs.openssl
97 pkgs.pass
98 pkgs.procps
99 pkgs.rsync
100 #pkgs.rxvt_unicode.terminfo
101 #pkgs.sqlite
102 pkgs.sqlite
103 #pkgs.sudo
104 pkgs.tig
105 pkgs.time
106 #pkgs.tmux
107 pkgs.tree
108 pkgs.utillinux
109 pkgs.vim
110 #pkgs.virtualbox
111 pkgs.which
112 pkgs.xdg_utils
113 pkgs.zfs
114 pkgs.fio
115 pkgs.strace
116 pkgs.utillinux
117 #pkgs.zfstools
118 ];
119 #enableParallelBuilding = true;
120 shellHook = ''
121 echo >&2 "nix: running shellHook"
122
123 # Cleanup "../sec/tmp/"
124 # This is done when exiting the nix-shell
125 # (or when… entering the directory with direnv
126 # which spawns a nix-shell just to get the env).
127 trap "cd '$PWD' && find ../sec/tmp -type f -exec shred -fu {} +" EXIT
128
129 ${modules.nix-shell.shellHook}
130
131 # nix
132 export NIX_PATH="nixpkgs=${nixpkgs}"
133 NIX_PATH+=":nixpkgs-overlays="$PWD"/overlays"
134 #NIX_PATH+=""
135
136 # executables
137 PATH_NIX="$(dirname "$(PATH="${builtins.getEnv "PATH"}"; which nix)")"
138 PATH_NIXOS=/run/wrappers/bin
139 export PATH="$PATH_NIXOS:$PATH:$PATH_NIX:/usr/sbin:/usr/bin:/bin"
140
141 # NOTE: sudo needs to be own by root with the setuid bit,
142 # but this won't be the case for the sudo provided by Nix outside NixOS,
143 # hence the addition of $PATH_FHS in shellHook
144 # to provide the host system's sudo.
145 # WARNING: beware that sudo may reset the environment,
146 # and especially PATH, to some system's default.
147
148 # locales
149 export LANG=fr_FR.UTF-8
150 export LC_CTYPE=fr_FR.UTF-8
151
152 # password-store
153 export PASSWORD_STORE_DIR="$PWD"/../sec/pass
154
155 # gpg
156 export GPG_TTY=$(tty)
157 gpg-connect-agent updatestartuptty /bye >/dev/null
158
159 # git
160 gitdir="$PWD"/.git
161 test ! -f "$gitdir" || while IFS=" :" read -r hdr gitdir; do [ "$hdr" != gitdir ] || break; done <"$gitdir"
162 ln -fnsr \
163 "$PWD"/.lib/git/hooks/prepare-commit-msg--longuest-common-prefix \
164 "$gitdir"/hooks/prepare-commit-msg
165
166 # nixops
167 #export NIXOPS_DEPLOYMENT="staging"
168 export NIXOPS_STATE="$PWD"/../sec/nixops/state.nixops
169 NIXOPS_OPTS+=" --show-trace"
170 export NIXOPS_OPTS
171
172 # disnix
173 #export DISNIXOS_USE_NIXOPS=1
174 #export DISNIX_CLIENT_INTERFACE=disnix-nixops-client
175 #export DISNIX_PROFILE=default
176 #export DISNIX_TARGET_PROPERTY=hostname
177 #export DYSNOMIA_STATEDIR="$PWD"/../sec/dysnomia
178 '';
179 }