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";
26 { meta.description = "transmission: apply RFC0042 and harden the service";
27 url = "https://github.com/NixOS/nixpkgs/pull/92106.diff";
28 sha256 = "0h1105qy0wrirvi9fk5d00qsjvm745196vb7wgr648d56rm17vv1";
31 localNixpkgsPatches = [
32 #nixpkgs/patches/apparmor.diff
34 # Build nixpkgs with some patches.
35 nixpkgs = originPkgs.applyPatches {
36 name = "nixpkgs-patched";
38 patches = map originPkgs.fetchpatch remoteNixpkgsPatches ++ localNixpkgsPatches;
40 patch=$(printf '%s\n' ${builtins.concatStringsSep " "
41 (map (p: p.sha256) remoteNixpkgsPatches ++ localNixpkgsPatches)} |
42 sort | sha256sum | cut -c -7)
43 echo "+patch-$patch" >.version-suffix
46 # Final pkgs with custom overlays.
47 pkgs = import nixpkgs {
48 config = {}; # Make the config pure, ignoring user's config.
49 overlays = import nixpkgs/overlays.nix;
53 nixos = pkgs.nixos {};
54 # Configuration of shell/modules/
55 # to expand shellHook and buildInputs of this shell.nix
56 configuration = {config, ...}: {
62 auto-optimise-store = true
70 gnupgHome = toString ../sec/gnupg;
73 trusted-key 0xB2450D97085B7B8C
78 opensslHome = toString ../sec/openssl;
79 certificates = import shell/x509.nix;
84 Ciphers aes256-gcm@openssh.com,aes128-gcm@openssh.com,aes256-ctr
88 ControlPath ${toString ../sec/ssh}/ssh-%h-%p-%r.socket
90 #SSAPIAuthentication no
92 StrictHostKeyChecking yes
93 UserKnownHostsFile ${toString ../sec/ssh/known_hosts}
101 # Using modules enables to separate specific configurations
102 # from reusable code in shell/modules.nix and shell/modules/
103 # which may find its way in another git repository one day.
105 (import shell/modules.nix {
107 modules = [ configuration ];
110 pwd = toString (./. + "");
111 sourcephile-shred-tmp = pkgs.writeShellScriptBin "sourcephile-shred-tmp" ''
112 # This is done when entering the nix-shell
113 # because direnv already hooks trap EXIT.
115 test ! -e sec/tmp || {
116 find sec/tmp -type f -exec shred -fu {} +
122 name = "sourcephile-nix";
124 #preferLocalBuild = true;
125 #allowSubstitutes = false;
126 buildInputs = modules.nix-shell.buildInputs ++ [
127 sourcephile-shred-tmp
128 nixos.nixos-generate-config
162 #pkgs.rxvt_unicode.terminfo
181 #enableParallelBuilding = true;
183 echo >&2 "nix: running shellHook"
186 export PASSWORD_STORE_DIR="$PWD"/../sec/pass
189 PATH=$NIX_SHELL_PATH:$PATH
190 export NIX_PATH="${lib.concatStringsSep ":" [
191 "servers=$PWD/servers.nix"
192 #"pass=$PASSWORD_STORE_DIR"
193 "nixpkgs=${toString pkgs.path}"
194 "nixpkgs-overlays=$PWD/nixpkgs/overlays.nix"
197 # Since the .envrc calls this shellHook
198 # the EXIT trap cannot be freely used
199 # because it's already used by direnv,
200 # hence shred at startup, which is not ideal.
201 sourcephile-shred-tmp
203 ${modules.nix-shell.shellHook}
206 export GPG_TTY=$(tty)
207 gpg-connect-agent updatestartuptty /bye >/dev/null