]> Git — Sourcephile - sourcephile-nix.git/blob - shell.nix
nix: shell: add ldns
[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.ldns
90 #pkgs.ldns.examples
91 #pkgs.mailutils
92 pkgs.man
93 pkgs.mdadm
94 pkgs.gptfdisk
95 pkgs.ncdu
96 pkgs.ncurses
97 pkgs.nixops
98 #pkgs.openssl
99 pkgs.pass
100 pkgs.procps
101 pkgs.rsync
102 #pkgs.rxvt_unicode.terminfo
103 #pkgs.sqlite
104 pkgs.sqlite
105 #pkgs.sudo
106 pkgs.tig
107 pkgs.time
108 #pkgs.tmux
109 pkgs.tree
110 pkgs.utillinux
111 pkgs.vim
112 #pkgs.virtualbox
113 pkgs.which
114 pkgs.xdg_utils
115 pkgs.zfs
116 pkgs.fio
117 pkgs.strace
118 pkgs.utillinux
119 #pkgs.zfstools
120 ];
121 #enableParallelBuilding = true;
122 shellHook = ''
123 echo >&2 "nix: running shellHook"
124
125 # Cleanup "../sec/tmp/"
126 # This is done when exiting the nix-shell
127 # (or when… entering the directory with direnv
128 # which spawns a nix-shell just to get the env).
129 trap "cd '$PWD' && find ../sec/tmp -type f -exec shred -fu {} +" EXIT
130
131 ${modules.nix-shell.shellHook}
132
133 # nix
134 export NIX_PATH="nixpkgs=${nixpkgs}"
135 NIX_PATH+=":nixpkgs-overlays="$PWD"/overlays"
136 #NIX_PATH+=""
137
138 # executables
139 PATH_NIX="$(dirname "$(PATH="${builtins.getEnv "PATH"}"; which nix)")"
140 PATH_NIXOS=/run/wrappers/bin
141 export PATH="$PATH_NIXOS:$PATH:$PATH_NIX:/usr/sbin:/usr/bin:/bin"
142
143 # NOTE: sudo needs to be own by root with the setuid bit,
144 # but this won't be the case for the sudo provided by Nix outside NixOS,
145 # hence the addition of $PATH_FHS in shellHook
146 # to provide the host system's sudo.
147 # WARNING: beware that sudo may reset the environment,
148 # and especially PATH, to some system's default.
149
150 # locales
151 export LANG=fr_FR.UTF-8
152 export LC_CTYPE=fr_FR.UTF-8
153
154 # password-store
155 export PASSWORD_STORE_DIR="$PWD"/../sec/pass
156
157 # gpg
158 export GPG_TTY=$(tty)
159 gpg-connect-agent updatestartuptty /bye >/dev/null
160
161 # git
162 gitdir="$PWD"/.git
163 test ! -f "$gitdir" || while IFS=" :" read -r hdr gitdir; do [ "$hdr" != gitdir ] || break; done <"$gitdir"
164 ln -fnsr \
165 "$PWD"/.lib/git/hooks/prepare-commit-msg--longuest-common-prefix \
166 "$gitdir"/hooks/prepare-commit-msg
167
168 # nixops
169 #export NIXOPS_DEPLOYMENT="staging"
170 export NIXOPS_STATE="$PWD"/../sec/nixops/state.nixops
171 NIXOPS_OPTS+=" --show-trace"
172 export NIXOPS_OPTS
173
174 # disnix
175 #export DISNIXOS_USE_NIXOPS=1
176 #export DISNIX_CLIENT_INTERFACE=disnix-nixops-client
177 #export DISNIX_PROFILE=default
178 #export DISNIX_TARGET_PROPERTY=hostname
179 #export DYSNOMIA_STATEDIR="$PWD"/../sec/dysnomia
180 '';
181 }