2 nixpkgs_channel = builtins.getEnv "nixpkgs_channel";
3 originNixpkgs = import (.config/nixpkgs-channel + ("/" + nixpkgs_channel + ".nix"));
4 originPkgs = import originNixpkgs {
5 config = {}; # Make the config pure, ignoring user's config.
8 remoteNixpkgsPatches = [
10 { meta.description = "nsd : use types.lines where appropriate";
11 url = "https://github.com/NixOS/nixpkgs/pull/78968.diff";
12 sha256 = "11bqq1g1ax6i7xghihyhklmqpsq3njalardp6nvzphkjgxrypb47";
14 { meta.description = "shorewall: init at 5.2.3.3";
15 url = "https://github.com/NixOS/nixpkgs/pull/46131.diff";
16 sha256 = "0mfzlcr23ni5spnwksmmls50sw10alqbr5j6hjrwp9i30z0419yx";
19 { meta.description = "Dovecot plugin for Full Text Search (FTS) with Xapian";
20 url = "https://github.com/NixOS/nixpkgs/pull/78780.diff";
21 sha256 = "053md69ryybj27cp0xdfrza48zyzpblk6wvb2m2dbs9hm0gmcwc4";
23 /* Disabled because it triggers the local build of too many reverse-dependencies
24 { meta.description = "openldap: enable sha2 and pbkdf2 modules";
25 url = "https://github.com/NixOS/nixpkgs/pull/79286.diff";
26 sha256 = "0y255x74qksqy7fm4bdwlknhm3s55vgfgbv4dd7580p4lcavya0m";
30 { meta.description = "Replace simp-le with lego and support DNS-01 challenge";
31 url = "https://github.com/NixOS/nixpkgs/pull/77578.diff";
32 sha256 = "15zs2146zh54jg1gywrcwyqxpx7izc35vlakk3cvrlqwwsvlr2rf";
35 { meta.description = "dstat: fix pluginpath";
36 url = "https://github.com/NixOS/nixpkgs/pull/80151.diff";
37 sha256 = "0jjw2gvp7b7v2n2m2d6yj0gw711j6p9lyjf5ywp2y9ql6905qf4b";
40 { meta.description = "shorewall: fix warnings due to types.loaOf being deprecated";
41 url = "https://github.com/NixOS/nixpkgs/pull/80154.diff";
42 sha256 = "0b216m1rib3jl6s3r5cbkd5h1bfhppikg4cz9ayr1fspsflr3bci";
44 { meta.description = "shorewall: fix RestartTriggers";
45 url = "https://github.com/NixOS/nixpkgs/pull/81774.diff";
46 sha256 = "14drpym2mq9gq505psjzqq23gv0wkbwrrvh438h5jirzcym3467a";
50 localNixpkgsPatches = [
53 nixpkgs = originPkgs.stdenv.mkDerivation {
54 name = "nixpkgs-patched";
56 phases = [ "unpackPhase" "patchPhase" ];
57 patches = map originPkgs.fetchpatch remoteNixpkgsPatches ++ localNixpkgsPatches;
60 patch=$(printf '%s\n' ${builtins.concatStringsSep " "
61 (map (p: p.sha256) remoteNixpkgsPatches ++ localNixpkgsPatches)} |
62 sort | sha256sum | cut -c -7)
64 echo "+patch-$patch" >$out/.version-suffix
67 pkgs = import nixpkgs {
68 config = {}; # Make the config pure, ignoring user's config.
69 overlays = import ./overlays.nix;
73 nixos = pkgs.nixos {};
74 # Configuration of shell/modules/
75 configuration = {config, ...}: {
80 auto-optimise-store = true
88 gnupgHome = toString ../sec/gnupg;
89 keys = import shell/openpgp.nix;
92 trusted-key 0xB2450D97085B7B8C
97 opensslHome = toString ../sec/openssl;
98 certificates = import shell/x509.nix;
101 # WARNING: nixops uses its own ssh, not this one.
104 Ciphers aes256-gcm@openssh.com,aes128-gcm@openssh.com,aes256-ctr
108 ControlPath ${builtins.toString ../sec/ssh}/ssh-%h-%p-%r.socket
110 #SSAPIAuthentication no
112 StrictHostKeyChecking yes
113 UserKnownHostsFile ${builtins.toString ../sec/ssh/known_hosts}
121 # Using modules enables to separate specific configurations
122 # from reusable code in shell/modules.nix and shell/modules/
123 # which may find its way in another git repository one day.
125 (import shell/modules.nix {
127 modules = [ configuration ];
130 # Utility to query the Nix files like nixops show-option
131 # but without requiring a nixops database, and not limited to config entries.
132 pwd = toString (./. + "");
133 sourcephile-nix-get = pkgs.writeShellScriptBin "sourcephile-nix-get" ''
134 nix-instantiate --read-write-mode \
135 --arg networkExprs "[${pwd}/servers.nix ${pwd}/servers/production.nix]" \
136 --arg args '{}' --argstr "uuid" whatever \
137 --argstr deploymentName production "<nixops/eval-machine-info.nix>" \
138 --eval-only --strict --arg checkConfigurationOptions false -A "$@"
140 sourcephile-shred-tmp = pkgs.writeShellScriptBin "sourcephile-shred-tmp" ''
141 # Cleanup "../sec/tmp/"
142 # This is done when entering the nix-shell
143 # because direnv already hooks trap EXIT.
145 test ! -e sec/tmp || {
146 find sec/tmp -type f -exec shred -fu {} +
152 name = "sourcephile-nix";
154 #preferLocalBuild = true;
155 #allowSubstitutes = false;
156 buildInputs = modules.nix-shell.buildInputs ++ [
158 sourcephile-shred-tmp
159 nixos.nixos-generate-config
193 #pkgs.rxvt_unicode.terminfo
212 #enableParallelBuilding = true;
214 echo >&2 "nix: running shellHook"
217 PATH=$NIX_SHELL_PATH:$PATH
218 export NIX_PATH="nixpkgs=${toString pkgs.path}:nixpkgs-overlays="$PWD"/overlays:nixops=${toString pkgs.nixops}/share/nix/nixops"
220 # Since the .envrc calls this shellHook
221 # the EXIT trap cannot be freely used
222 # because it's already used by direnv,
223 # hence shred at startup, which is not ideal.
224 sourcephile-shred-tmp
226 ${modules.nix-shell.shellHook}
229 export PASSWORD_STORE_DIR="$PWD"/../sec/pass
232 export GPG_TTY=$(tty)
233 gpg-connect-agent updatestartuptty /bye >/dev/null
236 #export NIXOPS_DEPLOYMENT="staging"
237 export MERMET_DEPLOYMENT=production
238 export LOSURDO_DEPLOYMENT=production
239 export NIXOPS_STATE="$PWD"/../sec/nixops/state.nixops
240 NIXOPS_OPTS+=" --show-trace"
244 #export DISNIXOS_USE_NIXOPS=1
245 #export DISNIX_CLIENT_INTERFACE=disnix-nixops-client
246 #export DISNIX_PROFILE=default
247 #export DISNIX_TARGET_PROPERTY=hostname
248 #export DYSNOMIA_STATEDIR="$PWD"/../sec/dysnomia