From 4d51d9e408916e2d71db0f9881bb8e81e83541f0 Mon Sep 17 00:00:00 2001 From: Vincent Ambo Date: Fri, 21 Feb 2025 14:42:49 +0300 Subject: [PATCH] feat(tazjin/khamovnik): ensure private configuration is available I've managed to (several times!) lock myself out of the office network by rebuilding while the configuration was unavailable. Might as well assert that. Change-Id: Ib2685c0e8dab977a3cb576606e70f8960968b574 Reviewed-on: https://cl.tvl.fyi/c/depot/+/13168 Autosubmit: tazjin Tested-by: BuildkiteCI Reviewed-by: tazjin --- users/tazjin/nixos/khamovnik/default.nix | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/users/tazjin/nixos/khamovnik/default.nix b/users/tazjin/nixos/khamovnik/default.nix index 225bc25d7..1f37cafaa 100644 --- a/users/tazjin/nixos/khamovnik/default.nix +++ b/users/tazjin/nixos/khamovnik/default.nix @@ -7,12 +7,27 @@ config: let mod = name: depot.path.origSrc + ("/ops/modules/" + name); usermod = name: depot.path.origSrc + ("/users/tazjin/nixos/modules/" + name); - private = /arc/junk/tazjin; zdevice = device: { inherit device; fsType = "zfs"; }; + + # Determine whether private Yandex-specific configuration should be loaded, + # and fail if it is unexpectedly not available. + yandexConfigIncludes = + let + hostname = if builtins.pathExists "/etc/hostname" then builtins.readFile "/etc/hostname" else ""; + isKhamovnik = hostname == "khamovnik\n"; + private = /arc/junk/tazjin; + hasPrivate = builtins.pathExists private; + in + assert isKhamovnik -> hasPrivate; + if !isKhamovnik then [ ] else [ + (private + "/nixos/yandex.nix") + (private + "/emacs/module.nix") + ]; + in { imports = [ @@ -24,10 +39,7 @@ in (usermod "physical.nix") (usermod "systemd-unfreeze.nix") (pkgs.home-manager.src + "/nixos") - ] ++ (if (builtins.pathExists private) then [ - (private + "/nixos/yandex.nix") - (private + "/emacs/module.nix") - ] else [ ]); + ] ++ yandexConfigIncludes; # from hardware-configuration.nix boot = {