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