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;
7 # Using modules enables to separate specific configurations in shell/configuration.nix
8 # from reusable code in shell/modules.nix
9 # which may find its way in another git repository one day.
11 (import shell/modules.nix {
14 modules = [ ( import shell/configuration.nix ) ];
17 sourcephile-nix-build =
18 pkgs.stdenv.mkDerivation {
19 name = "sourcephile-nix-build";
20 preferLocalBuild = true;
21 allowSubstitutes = false;
22 inherit (pkgs) coreutils;
23 builder = pkgs.writeText "builder.sh" modules.init.builder;
26 sourcephile-nix-build =
28 name = "sourcephile-nix-build";
29 pathsToLink = [ "/bin" ];
30 paths = with modules; [
32 #gnupg.gpg-fingerprint
33 #nix-plugins.nix-with-extra-builtins
36 nixos = pkgs.nixos {};
37 nixos-generate-config = nixos.nixos-generate-config;
38 nixos-install = nixos.nixos-install;
39 nixos-enter = nixos.nixos-enter;
41 pkgs.stdenv.mkDerivation {
42 name = "sourcephile-nix";
44 #preferLocalBuild = true;
45 #allowSubstitutes = false;
78 #pkgs.rxvt_unicode.terminfo
96 #enableParallelBuilding = true;
98 echo >&2 "nix: running shellHook"
101 export NIX_PATH="nixpkgs=${nixpkgs}:nixpkgs-sourcephile=$PWD/.lib/nixpkgs-sourcephile"
102 NIX_PATH+=":nixpkgs-overlays="$PWD"/overlays"
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 ln -sfn ${sourcephile-nix-build}/bin "$PWD"/.bin
114 export NIX_CONF_DIR="$PWD"/.config/nix
115 install -D /dev/stdin "$PWD"/.config/nix/nix.conf <<-EOF
116 auto-optimise-store = true
117 plugin-files = ${pkgs.nix-plugins}/lib/nix/plugins/libnix-extra-builtins.so
118 extra-builtins-file = ${modules.nix-plugins.extra-builtins}
121 # NOTE: sudo needs to be own by root with the setuid bit,
122 # but this won't be the case for the sudo provided by Nix outside NixOS,
123 # hence the addition of $PATH_FHS in shellHook
124 # to provide the host system's sudo.
125 # WARNING: beware that sudo may reset the environment,
126 # and especially PATH, to some system's default.
129 export LANG=fr_FR.UTF-8
130 export LC_CTYPE=fr_FR.UTF-8
133 export GNUPGHOME="$PWD"/../sec/gnupg
134 install -dm700 "$GNUPGHOME"
135 export GPG_TTY=$(tty)
136 gpgconf --launch gpg-agent
137 export SSH_AUTH_SOCK=$(gpgconf --list-dirs agent-ssh-socket)
140 export PASSWORD_STORE_DIR="$PWD"/../sec/pass
143 export NIX_SSL_CERT_FILE="${pkgs.cacert}/etc/ssl/certs/ca-bundle.crt"
144 export SSL_CERT_FILE="${pkgs.cacert}/etc/ssl/certs/ca-bundle.crt"
148 test ! -f "$gitdir" || while IFS=" :" read -r hdr gitdir; do [ "$hdr" != gitdir ] || break; done <"$gitdir"
150 "$PWD"/.lib/git/hooks/prepare-commit-msg--longuest-common-prefix \
151 "$gitdir"/hooks/prepare-commit-msg
154 #export NIXOPS_DEPLOYMENT="staging"
155 export NIXOPS_STATE="$PWD"/.sec/nixops/state.nixops
156 # Extend the Nix interpreter
157 # to enable builtins.extraBuiltins,
158 # which provides an unsafe exec useful to get secrets
159 # from the local password-store.
160 NIXOPS_OPTS+=" --show-trace"
161 NIXOPS_OPTS+=" --option plugin-files ${pkgs.nix-plugins}/lib/nix/plugins/libnix-extra-builtins.so"
162 NIXOPS_OPTS+=" --option extra-builtins-file ${modules.nix-plugins.extra-builtins}"
166 #export DISNIXOS_USE_NIXOPS=1
167 #export DISNIX_CLIENT_INTERFACE=disnix-nixops-client
168 #export DISNIX_PROFILE=default
169 #export DISNIX_TARGET_PROPERTY=hostname
170 #export DYSNOMIA_STATEDIR="$PWD"/.sec/dysnomia