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";
27 localNixpkgsPatches = [
28 #patches/fts_xapian.diff
30 # Build nixpkgs with some patches.
31 nixpkgs = originPkgs.applyPatches {
32 name = "nixpkgs-patched";
34 patches = map originPkgs.fetchpatch remoteNixpkgsPatches ++ localNixpkgsPatches;
36 patch=$(printf '%s\n' ${builtins.concatStringsSep " "
37 (map (p: p.sha256) remoteNixpkgsPatches ++ localNixpkgsPatches)} |
38 sort | sha256sum | cut -c -7)
39 echo "+patch-$patch" >.version-suffix
42 # Final pkgs with custom overlays.
43 pkgs = import nixpkgs {
44 config = {}; # Make the config pure, ignoring user's config.
45 overlays = import ./overlays.nix;
49 nixos = pkgs.nixos {};
50 # Configuration of shell/modules/
51 # to expand shellHook and buildInputs of this shell.nix
52 configuration = {config, ...}: {
57 auto-optimise-store = true
65 gnupgHome = toString ../sec/gnupg;
66 keys = import shell/openpgp.nix;
69 trusted-key 0xB2450D97085B7B8C
74 opensslHome = toString ../sec/openssl;
75 certificates = import shell/x509.nix;
80 Ciphers aes256-gcm@openssh.com,aes128-gcm@openssh.com,aes256-ctr
84 ControlPath ${toString ../sec/ssh}/ssh-%h-%p-%r.socket
86 #SSAPIAuthentication no
88 StrictHostKeyChecking yes
89 UserKnownHostsFile ${toString ../sec/ssh/known_hosts}
97 # Using modules enables to separate specific configurations
98 # from reusable code in shell/modules.nix and shell/modules/
99 # which may find its way in another git repository one day.
101 (import shell/modules.nix {
103 modules = [ configuration ];
106 pwd = toString (./. + "");
107 sourcephile-shred-tmp = pkgs.writeShellScriptBin "sourcephile-shred-tmp" ''
108 # This is done when entering the nix-shell
109 # because direnv already hooks trap EXIT.
111 test ! -e sec/tmp || {
112 find sec/tmp -type f -exec shred -fu {} +
118 name = "sourcephile-nix";
120 #preferLocalBuild = true;
121 #allowSubstitutes = false;
122 buildInputs = modules.nix-shell.buildInputs ++ [
123 sourcephile-shred-tmp
124 nixos.nixos-generate-config
158 #pkgs.rxvt_unicode.terminfo
177 #enableParallelBuilding = true;
179 echo >&2 "nix: running shellHook"
182 PATH=$NIX_SHELL_PATH:$PATH
183 export NIX_PATH="nixpkgs=${toString pkgs.path}:nixpkgs-overlays="$PWD"/overlays.nix"
185 # Since the .envrc calls this shellHook
186 # the EXIT trap cannot be freely used
187 # because it's already used by direnv,
188 # hence shred at startup, which is not ideal.
189 sourcephile-shred-tmp
191 ${modules.nix-shell.shellHook}
194 export PASSWORD_STORE_DIR="$PWD"/../sec/pass
197 export GPG_TTY=$(tty)
198 gpg-connect-agent updatestartuptty /bye >/dev/null