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 = "dstat: fix pluginpath";
11 url = "https://github.com/NixOS/nixpkgs/pull/80151.diff";
12 sha256 = "0jjw2gvp7b7v2n2m2d6yj0gw711j6p9lyjf5ywp2y9ql6905qf4b";
14 { meta.description = "syncoid: fix PATH to let it use sudo";
15 url = "https://github.com/NixOS/nixpkgs/pull/83901.diff";
16 sha256 = "0q2dicmvl3h3hb9xdd870n5hf6lac489p000c7f1r6k70sh2id4l";
18 { meta.description = "sanoid: fix sanoid.conf generation";
19 url = "https://github.com/NixOS/nixpkgs/pull/83904.diff";
20 sha256 = "0lj4krmmbz82zpmbacw0qj2ywsx895bq4d1psjn753ymh7jjqj8k";
22 { meta.description = "nixos/public-inbox: init";
23 url = "https://github.com/NixOS/nixpkgs/pull/77450.diff";
24 sha256 = "13ikg7chpbf6rrg5sngbdb95q3awhdgl4g8vci42xmqyf208hzzd";
27 localNixpkgsPatches = [
29 # Build nixpkgs with some patches.
30 nixpkgs = originPkgs.applyPatches {
31 name = "nixpkgs-patched";
33 patches = map originPkgs.fetchpatch remoteNixpkgsPatches ++ localNixpkgsPatches;
35 patch=$(printf '%s\n' ${builtins.concatStringsSep " "
36 (map (p: p.sha256) remoteNixpkgsPatches ++ localNixpkgsPatches)} |
37 sort | sha256sum | cut -c -7)
38 echo "+patch-$patch" >.version-suffix
41 # Final pkgs with custom overlays.
42 pkgs = import nixpkgs {
43 config = {}; # Make the config pure, ignoring user's config.
44 overlays = import nixpkgs/overlays.nix;
48 nixos = pkgs.nixos {};
49 # Configuration of shell/modules/
50 # to expand shellHook and buildInputs of this shell.nix
51 configuration = {config, ...}: {
57 auto-optimise-store = true
65 gnupgHome = toString ../sec/gnupg;
68 trusted-key 0xB2450D97085B7B8C
73 opensslHome = toString ../sec/openssl;
74 certificates = import shell/x509.nix;
79 Ciphers aes256-gcm@openssh.com,aes128-gcm@openssh.com,aes256-ctr
83 ControlPath ${toString ../sec/ssh}/ssh-%h-%p-%r.socket
85 #SSAPIAuthentication no
87 StrictHostKeyChecking yes
88 UserKnownHostsFile ${toString ../sec/ssh/known_hosts}
96 # Using modules enables to separate specific configurations
97 # from reusable code in shell/modules.nix and shell/modules/
98 # which may find its way in another git repository one day.
100 (import shell/modules.nix {
102 modules = [ configuration ];
105 pwd = toString (./. + "");
106 sourcephile-shred-tmp = pkgs.writeShellScriptBin "sourcephile-shred-tmp" ''
107 # This is done when entering the nix-shell
108 # because direnv already hooks trap EXIT.
110 test ! -e sec/tmp || {
111 find sec/tmp -type f -exec shred -fu {} +
117 name = "sourcephile-nix";
119 #preferLocalBuild = true;
120 #allowSubstitutes = false;
121 buildInputs = modules.nix-shell.buildInputs ++ [
122 sourcephile-shred-tmp
123 nixos.nixos-generate-config
157 #pkgs.rxvt_unicode.terminfo
176 #enableParallelBuilding = true;
178 echo >&2 "nix: running shellHook"
181 export PASSWORD_STORE_DIR="$PWD"/../sec/pass
184 PATH=$NIX_SHELL_PATH:$PATH
185 export NIX_PATH="${lib.concatStringsSep ":" [
186 "servers=$PWD/servers.nix"
187 #"pass=$PASSWORD_STORE_DIR"
188 "nixpkgs=${toString pkgs.path}"
189 "nixpkgs-overlays=$PWD/nixpkgs/overlays.nix"
192 # Since the .envrc calls this shellHook
193 # the EXIT trap cannot be freely used
194 # because it's already used by direnv,
195 # hence shred at startup, which is not ideal.
196 sourcephile-shred-tmp
198 ${modules.nix-shell.shellHook}
201 export GPG_TTY=$(tty)
202 gpg-connect-agent updatestartuptty /bye >/dev/null