From d8380f6c9942b8c9d978d354982490777c0833e5 Mon Sep 17 00:00:00 2001 From: RGBCube Date: Sat, 26 Jul 2025 04:53:05 +0300 Subject: [PATCH 1/4] hammerspoon: move to xdg config dir --- modules/darwin/hammerspoon.nix | 4 +++- modules/darwin/paperwm.nix | 6 +++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/modules/darwin/hammerspoon.nix b/modules/darwin/hammerspoon.nix index 158c0bf..863ef19 100644 --- a/modules/darwin/hammerspoon.nix +++ b/modules/darwin/hammerspoon.nix @@ -1,5 +1,7 @@ { + system.defaults.CustomSystemPreferences."org.hammerspoon.Hammerspoon".MJConfigFile = "~/.config/hammerspoon/init.lua"; + home-manager.sharedModules = [{ - home.file.".hammerspoon/init.lua".text = ""; + xdg.configFile."hammerspoon/init.lua".text = ""; }]; } diff --git a/modules/darwin/paperwm.nix b/modules/darwin/paperwm.nix index 13c0272..bc0fe9c 100644 --- a/modules/darwin/paperwm.nix +++ b/modules/darwin/paperwm.nix @@ -60,7 +60,7 @@ in { }; home-manager.sharedModules = [{ - home.file.".hammerspoon/Spoons/PaperWM.spoon" = { + xdg.configFile."hammerspoon/Spoons/PaperWM.spoon" = { recursive = true; source = pkgs.fetchFromGitHub { @@ -71,7 +71,7 @@ in { }; }; - home.file.".hammerspoon/Spoons/Swipe.spoon" = { + xdg.configFile."hammerspoon/Spoons/Swipe.spoon" = { recursive = true; source = pkgs.fetchFromGitHub { @@ -82,7 +82,7 @@ in { }; }; - home.file.".hammerspoon/init.lua".text = mkAfter /* lua */ '' + xdg.configFile."hammerspoon/init.lua".text = mkAfter /* lua */ '' ---@type table _G.hs = _G.hs From 147b54eac17089561cb527f49e3bde99c6d40c38 Mon Sep 17 00:00:00 2001 From: RGBCube Date: Sat, 26 Jul 2025 05:20:16 +0300 Subject: [PATCH 2/4] rebuild: run with sudo --- rebuild.nu | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rebuild.nu b/rebuild.nu index 3ac8e08..2cd98be 100755 --- a/rebuild.nu +++ b/rebuild.nu @@ -60,8 +60,8 @@ def main --wrapped [ ] | append ($args_split | get --ignore-errors 1 | default []) if (uname | get kernel-name) == "Darwin" { - NH_BYPASS_ROOT_CHECK=true NH_NO_CHECKS=true nh darwin switch . ...$nh_flags -- ...$nix_flags + NH_BYPASS_ROOT_CHECK=true NH_NO_CHECKS=true sudo nh darwin switch . ...$nh_flags -- ...$nix_flags } else { - NH_BYPASS_ROOT_CHECK=true NH_NO_CHECKS=true nh os switch . ...$nh_flags -- ...$nix_flags + NH_BYPASS_ROOT_CHECK=true NH_NO_CHECKS=true sudo nh os switch . ...$nh_flags -- ...$nix_flags } } From c5f3572631e16ee0ec2c965be5b0a71da4f5c9f1 Mon Sep 17 00:00:00 2001 From: RGBCube Date: Sat, 26 Jul 2025 14:45:01 +0300 Subject: [PATCH 3/4] darwin.paperwm: fix gotospace --- modules/darwin/paperwm.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/darwin/paperwm.nix b/modules/darwin/paperwm.nix index bc0fe9c..f703c3a 100644 --- a/modules/darwin/paperwm.nix +++ b/modules/darwin/paperwm.nix @@ -276,7 +276,7 @@ in { local button = hs.menubar.new() button:setTitle(hs.styledtext.new(title, attributes)) button:setClickCallback(function() - gotoSpace(space) + gotoSpace(index) end) table.insert(space_buttons, button) From 86f136d9fd7cc2f3b736124a514e0a3043dad967 Mon Sep 17 00:00:00 2001 From: RGBCube Date: Sat, 26 Jul 2025 19:59:48 +0300 Subject: [PATCH 4/4] rebuild: fix nh --- modules/common/{nix.nix => nix/default.nix} | 6 ++++- modules/common/nix/nh.patch | 28 +++++++++++++++++++++ rebuild.nu | 4 +-- 3 files changed, 35 insertions(+), 3 deletions(-) rename modules/common/{nix.nix => nix/default.nix} (95%) create mode 100644 modules/common/nix/nh.patch diff --git a/modules/common/nix.nix b/modules/common/nix/default.nix similarity index 95% rename from modules/common/nix.nix rename to modules/common/nix/default.nix index d485fb3..cb288a1 100644 --- a/modules/common/nix.nix +++ b/modules/common/nix/default.nix @@ -54,7 +54,11 @@ in { nix.optimise.automatic = true; environment.systemPackages = [ - pkgs.nh + (pkgs.nh.overrideAttrs (old: { + patches = old.patches or [] ++ [ + ./nh.patch + ]; + })) pkgs.nix-index pkgs.nix-output-monitor ]; diff --git a/modules/common/nix/nh.patch b/modules/common/nix/nh.patch new file mode 100644 index 0000000..2b697bf --- /dev/null +++ b/modules/common/nix/nh.patch @@ -0,0 +1,28 @@ +diff --git i/src/darwin.rs w/src/darwin.rs +index 64cdbd5..8bd337c 100644 +--- i/src/darwin.rs ++++ w/src/darwin.rs +@@ -46,7 +46,7 @@ impl DarwinRebuildArgs { + fn rebuild(self, variant: &DarwinRebuildVariant) -> Result<()> { + use DarwinRebuildVariant::{Build, Switch}; + +- if nix::unistd::Uid::effective().is_root() { ++ if nix::unistd::Uid::effective().is_root() && !self.bypass_root_check { + bail!("Don't run nh os as root. I will call sudo internally as needed"); + } + +diff --git i/src/interface.rs w/src/interface.rs +index a7e199c..fc63b10 100644 +--- i/src/interface.rs ++++ w/src/interface.rs +@@ -595,6 +595,10 @@ pub struct DarwinRebuildArgs { + /// Extra arguments passed to nix build + #[arg(last = true)] + pub extra_args: Vec, ++ ++ /// Don't panic if calling nh as root ++ #[arg(short = 'R', long, env = "NH_BYPASS_ROOT_CHECK")] ++ pub bypass_root_check: bool, + } + + impl DarwinRebuildArgs { diff --git a/rebuild.nu b/rebuild.nu index 2cd98be..80132df 100755 --- a/rebuild.nu +++ b/rebuild.nu @@ -60,8 +60,8 @@ def main --wrapped [ ] | append ($args_split | get --ignore-errors 1 | default []) if (uname | get kernel-name) == "Darwin" { - NH_BYPASS_ROOT_CHECK=true NH_NO_CHECKS=true sudo nh darwin switch . ...$nh_flags -- ...$nix_flags + sudo NH_BYPASS_ROOT_CHECK=true NH_NO_CHECKS=true nh darwin switch . ...$nh_flags -- ...$nix_flags } else { - NH_BYPASS_ROOT_CHECK=true NH_NO_CHECKS=true sudo nh os switch . ...$nh_flags -- ...$nix_flags + NH_BYPASS_ROOT_CHECK=true NH_NO_CHECKS=true nh os switch . ...$nh_flags -- ...$nix_flags } }