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