This commit is contained in:
John Lancaster
2026-03-27 19:16:07 -05:00
parent 8298443438
commit fa787740e9
+17 -18
View File
@@ -3,7 +3,19 @@
flake.modules.homeManager.rebuild = flake.modules.homeManager.rebuild =
{ pkgs, lib, config, ... }: { pkgs, lib, config, ... }:
let let
flakeDir = config.homeManagerFlakeDir;
echoCmd = lib.getExe' pkgs.coreutils "echo";
hostnameCmd = "$(${lib.getExe pkgs.hostname} -s)"; hostnameCmd = "$(${lib.getExe pkgs.hostname} -s)";
nhms = (pkgs.writeShellScriptBin "nhms" ''
HOSTNAME=${hostnameCmd}
${echoCmd} "Switching to the $HOSTNAME home-manager profile"
${lib.getExe pkgs.home-manager} switch --impure --flake ${flakeDir}#$HOSTNAME
'');
nfs = (pkgs.writeShellScriptBin "nfs" ''
HOSTNAME=${hostnameCmd}
${echoCmd} "Switching to the $HOSTNAME nixos profile"
sudo ${lib.getExe pkgs.nixos-rebuild} switch --impure --flake ${flakeDir}#$HOSTNAME
'');
in in
{ {
options = { options = {
@@ -21,11 +33,10 @@
config = let config = let
nixBin = lib.getExe pkgs.nix; nixBin = lib.getExe pkgs.nix;
flakeDir = config.homeManagerFlakeDir;
in in
{ {
home.activation.printFlakeDir = lib.hm.dag.entryAfter ["writeBoundary"] '' home.activation.printFlakeDir = lib.hm.dag.entryAfter ["writeBoundary"] ''
run echo "Home Manager flake directory: ${flakeDir}" run ${echoCmd} "Home Manager flake directory: ${flakeDir}"
''; '';
home.packages = with pkgs; [ home.packages = with pkgs; [
@@ -34,9 +45,6 @@
# #
# Flake-Parts checks # Flake-Parts checks
# #
(writeShellScriptBin "flake-parts-test" ''
echo "Test ${flakeDir}"
'')
(writeShellScriptBin "flake-parts-check" '' (writeShellScriptBin "flake-parts-check" ''
cd ${flakeDir} cd ${flakeDir}
${nixBin} run "${flakeDir}#write-flake" ${nixBin} run "${flakeDir}#write-flake"
@@ -46,29 +54,20 @@
# #
# Home-Manager rebuilds # Home-Manager rebuilds
# #
(writeShellScriptBin "nhms" '' nhms
HOSTNAME=${hostnameCmd}
echo "Switching to the $HOSTNAME home-manager profile"
${lib.getExe home-manager} switch --impure --flake ${flakeDir}#$HOSTNAME
'')
(writeShellScriptBin "nhmu" '' (writeShellScriptBin "nhmu" ''
${nixBin} flake update --flake ${flakeDir} ${nixBin} flake update --flake ${flakeDir}
nhms ${lib.getExe nhms}
'') '')
# #
# NixOS rebuilds # NixOS rebuilds
# #
(writeShellScriptBin "nfs" '' nfs
HOSTNAME=${hostnameCmd}
echo "Switching to the $HOSTNAME nixos profile"
sudo ${lib.getExe nixos-rebuild} switch --impure --flake ${flakeDir}#$HOSTNAME
'')
(writeShellScriptBin "nfsu" '' (writeShellScriptBin "nfsu" ''
HOSTNAME=${hostnameCmd}
${nixBin} flake update --impure --flake ${flakeDir} ${nixBin} flake update --impure --flake ${flakeDir}
${lib.getExe git} -C ${flakeDir} add ${flakeDir}/flake.lock > /dev/null 2>&1 ${lib.getExe git} -C ${flakeDir} add ${flakeDir}/flake.lock > /dev/null 2>&1
sudo ${lib.getExe nixos-rebuild} switch --impure --flake ${flakeDir}#$HOSTNAME ${lib.getExe nfs}
'') '')
]; ];
}; };