]> Git — Sourcephile - sourcephile-nix.git/blob - shell.nix
mermet: fix the networking
[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/gnupg/keys.nix;
26 };
27 openssh = {
28 enable = true;
29 sshConf = ''
30 Ciphers aes256-gcm@openssh.com,aes128-gcm@openssh.com
31 Compression yes
32 CompressionLevel 4
33 ControlMaster auto
34 ControlPath ${builtins.toString .sec/ssh}/ssh-%h-%p-%r.socket
35 HashKnownHosts no
36 SSAPIAuthentication no
37 SendEnv LANG LC_*
38 StrictHostKeyChecking yes
39 UserKnownHostsFile ${builtins.toString .sec/ssh/known_hosts}
40 '';
41 };
42 };
43
44 # Using modules enables to separate specific configurations
45 # from reusable code in shell/modules.nix and shell/modules/
46 # which may find its way in another git repository one day.
47 modules =
48 (import shell/modules.nix {
49 inherit pkgs lib;
50 modules = [ configuration ];
51 }).config;
52 in
53 pkgs.stdenv.mkDerivation {
54 name = "sourcephile-nix";
55 src = null;
56 #preferLocalBuild = true;
57 #allowSubstitutes = false;
58 buildInputs = modules.nix-shell.buildInputs ++ [
59 nixpkgs
60 nixos.nixos-generate-config
61 nixos.nixos-install
62 nixos.nixos-enter
63 #pkgs.binutils
64 pkgs.coreutils
65 pkgs.cryptsetup
66 pkgs.curl
67 #pkgs.direnv
68 #pkgs.dnsutils
69 #pkgs.dropbear
70 pkgs.e2fsprogs
71 pkgs.git
72 pkgs.glibcLocales
73 pkgs.gnumake
74 pkgs.gnupg
75 pkgs.htop
76 #pkgs.inetutils
77 pkgs.ipcalc
78 pkgs.less
79 pkgs.libfaketime
80 #pkgs.mailutils
81 pkgs.man
82 pkgs.mdadm
83 pkgs.gptfdisk
84 pkgs.ncdu
85 pkgs.ncurses
86 pkgs.nixops
87 #pkgs.openssl
88 pkgs.pass
89 pkgs.procps
90 #pkgs.rxvt_unicode.terminfo
91 #pkgs.sqlite
92 pkgs.sqlite
93 pkgs.sudo
94 pkgs.tig
95 pkgs.time
96 #pkgs.tmux
97 pkgs.tree
98 pkgs.utillinux
99 pkgs.vim
100 #pkgs.virtualbox
101 pkgs.which
102 pkgs.xdg_utils
103 pkgs.zfs
104 pkgs.fio
105 pkgs.strace
106 pkgs.utillinux
107 #pkgs.zfstools
108 ];
109 #enableParallelBuilding = true;
110 shellHook = ''
111 echo >&2 "nix: running shellHook"
112
113 ${modules.nix-shell.shellHook}
114
115 # nix
116 export NIX_PATH="nixpkgs=${nixpkgs}"
117 NIX_PATH+=":nixpkgs-overlays="$PWD"/overlays"
118 #NIX_PATH+=""
119
120 # executables
121 PATH_NIX=$(dirname $(readlink -e ~/.nix-profile/bin/nix))
122 PATH_NIXOS=/run/wrappers/bin
123 PATH_FHS="$PWD"/.lib/nix/fhs-bin
124 PATH_FHS_VBOX="$PWD"/.lib/fhs-vbox-bin
125 export PATH="$PATH_NIXOS:$PATH_FHS_VBOX:$PATH_FHS:$PATH:$PATH_NIX"
126
127 # NOTE: sudo needs to be own by root with the setuid bit,
128 # but this won't be the case for the sudo provided by Nix outside NixOS,
129 # hence the addition of $PATH_FHS in shellHook
130 # to provide the host system's sudo.
131 # WARNING: beware that sudo may reset the environment,
132 # and especially PATH, to some system's default.
133
134 # locales
135 export LANG=fr_FR.UTF-8
136 export LC_CTYPE=fr_FR.UTF-8
137
138 # password-store
139 export PASSWORD_STORE_DIR="$PWD"/../sec/pass
140
141 # git
142 gitdir="$PWD"/.git
143 test ! -f "$gitdir" || while IFS=" :" read -r hdr gitdir; do [ "$hdr" != gitdir ] || break; done <"$gitdir"
144 ln -fnsr \
145 "$PWD"/.lib/git/hooks/prepare-commit-msg--longuest-common-prefix \
146 "$gitdir"/hooks/prepare-commit-msg
147
148 # nixops
149 #export NIXOPS_DEPLOYMENT="staging"
150 export NIXOPS_STATE="$PWD"/.sec/nixops/state.nixops
151 NIXOPS_OPTS+=" --show-trace"
152 export NIXOPS_OPTS
153
154 # disnix
155 #export DISNIXOS_USE_NIXOPS=1
156 #export DISNIX_CLIENT_INTERFACE=disnix-nixops-client
157 #export DISNIX_PROFILE=default
158 #export DISNIX_TARGET_PROPERTY=hostname
159 #export DYSNOMIA_STATEDIR="$PWD"/.sec/dysnomia
160 '';
161 }