ctucx.git: nixfiles

ctucx' nixfiles

commit 6bf3f7f972bd56cfec3dfc8955487d5b2b9f2041
parent ff1240875ed1f88fd9af22be1b67f94dcc88b7c8
Author: Leah (ctucx) <leah@ctu.cx>
Date: Thu, 16 Jun 2022 15:08:51 +0200

darwin-rebuild: select darwin-configuration based on system-hostname
2 files changed, 6 insertions(+), 7 deletions(-)
diff --git a/darwin-configuration.nix b/darwin-configuration.nix
@@ -1,7 +1 @@
-{ config, pkgs, ... }:
-
-{
-  imports = [
-    ./machines/blechbuechse/darwin-configuration.nix
-  ];
-}
+with (import <nixpkgs> {}).lib; import "${toString ./.}/machines/${fileContents /etc/hostname}/darwin-configuration.nix"
diff --git a/darwin-rebuild b/darwin-rebuild
@@ -1,2 +1,7 @@
 #!/usr/bin/env sh
+
+if [ ! -e /etc/hostname ] || [ "$(hostname)" != "$(cat /etc/hostname | tr -d '\n')" ]; then
+  echo "$(hostname)" | sudo tee /etc/hostname >/dev/null
+fi
+
 darwin-rebuild -I "darwin-config=/Users/leah/nixfiles/darwin-configuration.nix" -I $(nix-build /Users/leah/nixfiles/nix/sources-dir.nix --no-out-link) "$@"