From ca9a4e5820b896438fdf152ecf3e3beee99c0f08 Mon Sep 17 00:00:00 2001 From: Emmet Date: Thu, 24 Aug 2023 16:30:38 -0500 Subject: [PATCH] Maybe my system will stop freezing during rebuilds --- user/bin/phoenix.nix | 8 ++++---- user/shell/sh.nix | 2 ++ 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/user/bin/phoenix.nix b/user/bin/phoenix.nix index a47ecbe..a63b0ae 100644 --- a/user/bin/phoenix.nix +++ b/user/bin/phoenix.nix @@ -46,14 +46,14 @@ let pushd ''+dotfilesDir+'' &> /dev/null; if [ "$1" = "verbose" ]; then echo "Syncing system configuration (stack traces will be shown):" - sudo nixos-rebuild switch --flake .#system --show-trace; + sudo systemd-run --no-ask-password --uid=0 --system --scope -p MemoryLimit=16000M -p CPUQuota=60% nixos-rebuild switch --flake .#system --show-trace; else sudo bash -c ' RED="\033[0;31m"; GREEN="\033[0;32m"; NC="\033[0m" FRAMES="/ | \\ -"; - nixos-rebuild switch --flake .#system &> /dev/null & + systemd-run --no-ask-password --uid=0 --system --scope -p MemoryLimit=16000M -p CPUQuota=60% nixos-rebuild switch --flake .#system &> /dev/null & pid=$!; while ps -p $pid > /dev/null; do @@ -85,13 +85,13 @@ let if [ "$1" = "verbose" ]; then echo "Syncing user configuration (stack traces will be shown):" echo "Running home-manager switch --flake .#user --show-trace" - home-manager switch --flake .#user --show-trace; + systemd-run --no-ask-password --uid=1000 --user --scope -p MemoryLimit=16000M -p CPUQuota=60% home-manager switch --flake .#user --show-trace; which xmobar &> /dev/null && echo "Killing old xmobar instances" && echo "Running killall xmobar" && killall xmobar &> /dev/null; which xmonad &> /dev/null && echo "Recompiling xmonad" && echo "Running xmonad --recompile && xmonad --restart" && xmonad --recompile && xmonad --restart; which emacsclient &> /dev/null && echo "Reloading emacs stylix theme" && echo "Running emacsclient --no-wait --eval \"(load-theme 'doom-stylix t nil)\"" && emacsclient --no-wait --eval "(load-theme 'doom-stylix t nil)"; [ -f ~/.fehbg-stylix ] &> /dev/null && echo "Reapplying background from stylix via feh" && echo "Running ~/.fehbg-stylix" && ~/.fehbg-stylix; else - home-manager switch --flake .#user &> /dev/null & + systemd-run --no-ask-password --uid=1000 --user --scope -p MemoryLimit=16000M -p CPUQuota=60% home-manager switch --flake .#user &> /dev/null & animate_msg "Syncing user configuration..." which xmobar &> /dev/null && killall xmobar &> /dev/null & which xmonad &> /dev/null && xmonad --recompile &> /dev/null & diff --git a/user/shell/sh.nix b/user/shell/sh.nix index dda8001..415faae 100644 --- a/user/shell/sh.nix +++ b/user/shell/sh.nix @@ -8,6 +8,8 @@ let htop = "btm"; fd = "fd -Lu"; w3m = "w3m -no-cookie -v"; + nixos-rebuild = "systemd-run --no-ask-password --uid=0 --system --scope -p MemoryLimit=16000M -p CPUQuota=60% nixos-rebuild"; + home-manager = "systemd-run --no-ask-password --uid=1000 --user --scope -p MemoryLimit=16000M -p CPUQuota=60% home-manager"; }; in {