2 nixpkgs_channel = builtins.getEnv "nixpkgs_channel";
3 originNixpkgs = import (.config/nixpkgs-channel + ("/" + nixpkgs_channel + ".nix"));
4 originPkgs = import originNixpkgs {
5 config = {}; # Make the config pure, ignoring user's config.
8 remoteNixpkgsPatches = [
9 { meta.description = "Dovecot plugin for Full Text Search (FTS) with Xapian";
10 url = "https://github.com/NixOS/nixpkgs/pull/78780.diff";
11 sha256 = "15ix8kwisjcgf4n7x7vlh223rb3206lcd5b13wbcvld07rzinjkc";
13 { meta.description = "dstat: fix pluginpath";
14 url = "https://github.com/NixOS/nixpkgs/pull/80151.diff";
15 sha256 = "0jjw2gvp7b7v2n2m2d6yj0gw711j6p9lyjf5ywp2y9ql6905qf4b";
17 { meta.description = "syncoid: fix PATH to let it use sudo";
18 url = "https://github.com/NixOS/nixpkgs/pull/83901.diff";
19 sha256 = "0q2dicmvl3h3hb9xdd870n5hf6lac489p000c7f1r6k70sh2id4l";
21 { meta.description = "sanoid: fix sanoid.conf generation";
22 url = "https://github.com/NixOS/nixpkgs/pull/83904.diff";
23 sha256 = "0lj4krmmbz82zpmbacw0qj2ywsx895bq4d1psjn753ymh7jjqj8k";
26 localNixpkgsPatches = [
29 nixpkgs = originPkgs.applyPatches {
30 name = "nixpkgs-patched";
32 patches = map originPkgs.fetchpatch remoteNixpkgsPatches ++ localNixpkgsPatches;
34 patch=$(printf '%s\n' ${builtins.concatStringsSep " "
35 (map (p: p.sha256) remoteNixpkgsPatches ++ localNixpkgsPatches)} |
36 sort | sha256sum | cut -c -7)
37 echo "+patch-$patch" >.version-suffix
40 pkgs = import nixpkgs {
41 config = {}; # Make the config pure, ignoring user's config.
42 overlays = import ./overlays.nix;
46 nixos = pkgs.nixos {};
47 # Configuration of shell/modules/
48 configuration = {config, ...}: {
53 auto-optimise-store = true
61 gnupgHome = toString ../sec/gnupg;
62 keys = import shell/openpgp.nix;
65 trusted-key 0xB2450D97085B7B8C
70 opensslHome = toString ../sec/openssl;
71 certificates = import shell/x509.nix;
74 # WARNING: nixops uses its own ssh, not this one.
77 Ciphers aes256-gcm@openssh.com,aes128-gcm@openssh.com,aes256-ctr
81 ControlPath ${builtins.toString ../sec/ssh}/ssh-%h-%p-%r.socket
83 #SSAPIAuthentication no
85 StrictHostKeyChecking yes
86 UserKnownHostsFile ${builtins.toString ../sec/ssh/known_hosts}
94 # Using modules enables to separate specific configurations
95 # from reusable code in shell/modules.nix and shell/modules/
96 # which may find its way in another git repository one day.
98 (import shell/modules.nix {
100 modules = [ configuration ];
103 # Utility to query the Nix files like nixops show-option
104 # but without requiring a nixops database, and not limited to config entries.
105 pwd = toString (./. + "");
106 sourcephile-nix-get = pkgs.writeShellScriptBin "sourcephile-nix-get" ''
107 nix-instantiate --read-write-mode \
108 --arg networkExprs "[${pwd}/servers.nix ${pwd}/servers/production.nix]" \
109 --arg args '{}' --argstr "uuid" whatever \
110 --argstr deploymentName production "<nixops/eval-machine-info.nix>" \
111 --eval-only --strict --arg checkConfigurationOptions false -A "$@"
113 sourcephile-shred-tmp = pkgs.writeShellScriptBin "sourcephile-shred-tmp" ''
114 # Cleanup "../sec/tmp/"
115 # This is done when entering the nix-shell
116 # because direnv already hooks trap EXIT.
118 test ! -e sec/tmp || {
119 find sec/tmp -type f -exec shred -fu {} +
125 name = "sourcephile-nix";
127 #preferLocalBuild = true;
128 #allowSubstitutes = false;
129 buildInputs = modules.nix-shell.buildInputs ++ [
131 sourcephile-shred-tmp
132 nixos.nixos-generate-config
166 #pkgs.rxvt_unicode.terminfo
185 #enableParallelBuilding = true;
187 echo >&2 "nix: running shellHook"
190 PATH=$NIX_SHELL_PATH:$PATH
191 export NIX_PATH="nixpkgs=${toString pkgs.path}:nixpkgs-overlays="$PWD"/overlays:nixops=${toString pkgs.nixops}/share/nix/nixops"
193 # Since the .envrc calls this shellHook
194 # the EXIT trap cannot be freely used
195 # because it's already used by direnv,
196 # hence shred at startup, which is not ideal.
197 sourcephile-shred-tmp
199 ${modules.nix-shell.shellHook}
202 export PASSWORD_STORE_DIR="$PWD"/../sec/pass
205 export GPG_TTY=$(tty)
206 gpg-connect-agent updatestartuptty /bye >/dev/null
209 #export NIXOPS_DEPLOYMENT="staging"
210 export MERMET_DEPLOYMENT=production
211 export LOSURDO_DEPLOYMENT=production
212 export NIXOPS_STATE="$PWD"/../sec/nixops/state.nixops
213 NIXOPS_OPTS+=" --show-trace"
217 #export DISNIXOS_USE_NIXOPS=1
218 #export DISNIX_CLIENT_INTERFACE=disnix-nixops-client
219 #export DISNIX_PROFILE=default
220 #export DISNIX_TARGET_PROPERTY=hostname
221 #export DYSNOMIA_STATEDIR="$PWD"/../sec/dysnomia