2 nixpkgs_channel = builtins.getEnv "nixpkgs_channel";
3 # Bootstraping Nixpkgs to get tools to patch it.
4 originNixpkgs = import (.config/nixpkgs-channel + ("/${nixpkgs_channel}.nix"));
5 originPkgs = import originNixpkgs {
6 config = {}; # Make the config pure, ignoring user's config.
9 remoteNixpkgsPatches = [
10 { meta.description = "Dovecot plugin for Full Text Search (FTS) with Xapian";
11 url = "https://github.com/NixOS/nixpkgs/pull/78780.diff";
12 sha256 = "1h45qhbragp5ky6xix198qhadj1j7gd3qswa135mnmw1ijfczyry";
14 { meta.description = "dstat: fix pluginpath";
15 url = "https://github.com/NixOS/nixpkgs/pull/80151.diff";
16 sha256 = "0jjw2gvp7b7v2n2m2d6yj0gw711j6p9lyjf5ywp2y9ql6905qf4b";
18 { meta.description = "syncoid: fix PATH to let it use sudo";
19 url = "https://github.com/NixOS/nixpkgs/pull/83901.diff";
20 sha256 = "0q2dicmvl3h3hb9xdd870n5hf6lac489p000c7f1r6k70sh2id4l";
22 { meta.description = "sanoid: fix sanoid.conf generation";
23 url = "https://github.com/NixOS/nixpkgs/pull/83904.diff";
24 sha256 = "0lj4krmmbz82zpmbacw0qj2ywsx895bq4d1psjn753ymh7jjqj8k";
26 { meta.description = "nixos/public-inbox: init";
27 url = "https://github.com/NixOS/nixpkgs/pull/77450.diff";
28 sha256 = "13ikg7chpbf6rrg5sngbdb95q3awhdgl4g8vci42xmqyf208hzzd";
31 localNixpkgsPatches = [
32 #patches/fts_xapian.diff
33 #patches/public-inbox.diff
35 # Build nixpkgs with some patches.
36 nixpkgs = originPkgs.applyPatches {
37 name = "nixpkgs-patched";
39 patches = map originPkgs.fetchpatch remoteNixpkgsPatches ++ localNixpkgsPatches;
41 patch=$(printf '%s\n' ${builtins.concatStringsSep " "
42 (map (p: p.sha256) remoteNixpkgsPatches ++ localNixpkgsPatches)} |
43 sort | sha256sum | cut -c -7)
44 echo "+patch-$patch" >.version-suffix
47 # Final pkgs with custom overlays.
48 pkgs = import nixpkgs {
49 config = {}; # Make the config pure, ignoring user's config.
50 overlays = import nixpkgs/overlays.nix;
54 nixos = pkgs.nixos {};
55 # Configuration of shell/modules/
56 # to expand shellHook and buildInputs of this shell.nix
57 configuration = {config, ...}: {
62 auto-optimise-store = true
70 gnupgHome = toString ../sec/gnupg;
71 keys = import shell/openpgp.nix;
74 trusted-key 0xB2450D97085B7B8C
79 opensslHome = toString ../sec/openssl;
80 certificates = import shell/x509.nix;
85 Ciphers aes256-gcm@openssh.com,aes128-gcm@openssh.com,aes256-ctr
89 ControlPath ${toString ../sec/ssh}/ssh-%h-%p-%r.socket
91 #SSAPIAuthentication no
93 StrictHostKeyChecking yes
94 UserKnownHostsFile ${toString ../sec/ssh/known_hosts}
102 # Using modules enables to separate specific configurations
103 # from reusable code in shell/modules.nix and shell/modules/
104 # which may find its way in another git repository one day.
106 (import shell/modules.nix {
108 modules = [ configuration ];
111 pwd = toString (./. + "");
112 sourcephile-shred-tmp = pkgs.writeShellScriptBin "sourcephile-shred-tmp" ''
113 # This is done when entering the nix-shell
114 # because direnv already hooks trap EXIT.
116 test ! -e sec/tmp || {
117 find sec/tmp -type f -exec shred -fu {} +
123 name = "sourcephile-nix";
125 #preferLocalBuild = true;
126 #allowSubstitutes = false;
127 buildInputs = modules.nix-shell.buildInputs ++ [
128 sourcephile-shred-tmp
129 nixos.nixos-generate-config
163 #pkgs.rxvt_unicode.terminfo
182 #enableParallelBuilding = true;
184 echo >&2 "nix: running shellHook"
187 PATH=$NIX_SHELL_PATH:$PATH
188 export NIX_PATH="servers=$PWD/servers.nix:nixpkgs=${toString pkgs.path}:nixpkgs-overlays=$PWD/nixpkgs/overlays.nix"
190 # Since the .envrc calls this shellHook
191 # the EXIT trap cannot be freely used
192 # because it's already used by direnv,
193 # hence shred at startup, which is not ideal.
194 sourcephile-shred-tmp
196 ${modules.nix-shell.shellHook}
199 export PASSWORD_STORE_DIR="$PWD"/../sec/pass
202 export GPG_TTY=$(tty)
203 gpg-connect-agent updatestartuptty /bye >/dev/null