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";
30 { meta.description = "stig: update to 0.11.0a";
31 url = "https://github.com/NixOS/nixpkgs/pull/89557.diff";
32 sha256 = "1gjx3kd2fh2l1pz1r0v2wgdyi7vfi0404aq80y2v89k6zinb7kpy";
35 localNixpkgsPatches = [
37 # Build nixpkgs with some patches.
38 nixpkgs = originPkgs.applyPatches {
39 name = "nixpkgs-patched";
41 patches = map originPkgs.fetchpatch remoteNixpkgsPatches ++ localNixpkgsPatches;
43 patch=$(printf '%s\n' ${builtins.concatStringsSep " "
44 (map (p: p.sha256) remoteNixpkgsPatches ++ localNixpkgsPatches)} |
45 sort | sha256sum | cut -c -7)
46 echo "+patch-$patch" >.version-suffix
49 # Final pkgs with custom overlays.
50 pkgs = import nixpkgs {
51 config = {}; # Make the config pure, ignoring user's config.
52 overlays = import nixpkgs/overlays.nix;
56 nixos = pkgs.nixos {};
57 # Configuration of shell/modules/
58 # to expand shellHook and buildInputs of this shell.nix
59 configuration = {config, ...}: {
65 auto-optimise-store = true
73 gnupgHome = toString ../sec/gnupg;
76 trusted-key 0xB2450D97085B7B8C
81 opensslHome = toString ../sec/openssl;
82 certificates = import shell/x509.nix;
87 Ciphers aes256-gcm@openssh.com,aes128-gcm@openssh.com,aes256-ctr
91 ControlPath ${toString ../sec/ssh}/ssh-%h-%p-%r.socket
93 #SSAPIAuthentication no
95 StrictHostKeyChecking yes
96 UserKnownHostsFile ${toString ../sec/ssh/known_hosts}
104 # Using modules enables to separate specific configurations
105 # from reusable code in shell/modules.nix and shell/modules/
106 # which may find its way in another git repository one day.
108 (import shell/modules.nix {
110 modules = [ configuration ];
113 pwd = toString (./. + "");
114 sourcephile-shred-tmp = pkgs.writeShellScriptBin "sourcephile-shred-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 ++ [
130 sourcephile-shred-tmp
131 nixos.nixos-generate-config
165 #pkgs.rxvt_unicode.terminfo
184 #enableParallelBuilding = true;
186 echo >&2 "nix: running shellHook"
189 export PASSWORD_STORE_DIR="$PWD"/../sec/pass
192 PATH=$NIX_SHELL_PATH:$PATH
193 export NIX_PATH="${lib.concatStringsSep ":" [
194 "servers=$PWD/servers.nix"
195 #"pass=$PASSWORD_STORE_DIR"
196 "nixpkgs=${toString pkgs.path}"
197 "nixpkgs-overlays=$PWD/nixpkgs/overlays.nix"
200 # Since the .envrc calls this shellHook
201 # the EXIT trap cannot be freely used
202 # because it's already used by direnv,
203 # hence shred at startup, which is not ideal.
204 sourcephile-shred-tmp
206 ${modules.nix-shell.shellHook}
209 export GPG_TTY=$(tty)
210 gpg-connect-agent updatestartuptty /bye >/dev/null