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 { meta.description = "transmission: apply RFC0042 and harden the service";
28 url = "https://github.com/NixOS/nixpkgs/pull/92106.diff";
29 sha256 = "0h1105qy0wrirvi9fk5d00qsjvm745196vb7wgr648d56rm17vv1";
32 { meta.description = "apparmor: fix and improve the service";
33 url = "https://github.com/NixOS/nixpkgs/pull/93457.diff";
34 sha256 = "0y1kvsnm8xiplbm4w4cadmfkr452vipswkz3kwyyikknh06vj3mn";
37 localNixpkgsPatches = [
38 #nixpkgs/patches/apparmor.diff
40 # Build nixpkgs with some patches.
41 nixpkgs = originPkgs.applyPatches {
42 name = "nixpkgs-patched";
44 patches = map originPkgs.fetchpatch remoteNixpkgsPatches ++ localNixpkgsPatches;
46 patch=$(printf '%s\n' ${builtins.concatStringsSep " "
47 (map (p: p.sha256) remoteNixpkgsPatches ++ localNixpkgsPatches)} |
48 sort | sha256sum | cut -c -7)
49 echo "+patch-$patch" >.version-suffix
52 # Final pkgs with custom overlays.
53 pkgs = import nixpkgs {
54 config = {}; # Make the config pure, ignoring user's config.
55 overlays = import nixpkgs/overlays.nix;
59 nixos = pkgs.nixos {};
60 # Configuration of shell/modules/
61 # to expand shellHook and buildInputs of this shell.nix
62 configuration = {config, ...}: {
68 auto-optimise-store = true
76 gnupgHome = toString ../sec/gnupg;
79 trusted-key 0xB2450D97085B7B8C
84 opensslHome = toString ../sec/openssl;
85 certificates = import shell/x509.nix;
90 Ciphers aes256-gcm@openssh.com,aes128-gcm@openssh.com,aes256-ctr
94 ControlPath ${toString ../sec/ssh}/ssh-%h-%p-%r.socket
96 #SSAPIAuthentication no
98 StrictHostKeyChecking yes
99 UserKnownHostsFile ${toString ../sec/ssh/known_hosts}
107 # Using modules enables to separate specific configurations
108 # from reusable code in shell/modules.nix and shell/modules/
109 # which may find its way in another git repository one day.
111 (import shell/modules.nix {
113 modules = [ configuration ];
116 pwd = toString (./. + "");
117 sourcephile-shred-tmp = pkgs.writeShellScriptBin "sourcephile-shred-tmp" ''
118 # This is done when entering the nix-shell
119 # because direnv already hooks trap EXIT.
121 test ! -e sec/tmp || {
122 find sec/tmp -type f -exec shred -fu {} +
128 name = "sourcephile-nix";
130 #preferLocalBuild = true;
131 #allowSubstitutes = false;
132 buildInputs = modules.nix-shell.buildInputs ++ [
133 sourcephile-shred-tmp
134 nixos.nixos-generate-config
168 #pkgs.rxvt_unicode.terminfo
187 #enableParallelBuilding = true;
189 echo >&2 "nix: running shellHook"
192 export PASSWORD_STORE_DIR="$PWD"/../sec/pass
195 PATH=$NIX_SHELL_PATH:$PATH
196 export NIX_PATH="${lib.concatStringsSep ":" [
197 "servers=$PWD/servers.nix"
198 #"pass=$PASSWORD_STORE_DIR"
199 "nixpkgs=${toString pkgs.path}"
200 "nixpkgs-overlays=$PWD/nixpkgs/overlays.nix"
203 # Since the .envrc calls this shellHook
204 # the EXIT trap cannot be freely used
205 # because it's already used by direnv,
206 # hence shred at startup, which is not ideal.
207 sourcephile-shred-tmp
209 ${modules.nix-shell.shellHook}
212 export GPG_TTY=$(tty)
213 gpg-connect-agent updatestartuptty /bye >/dev/null