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