diff --git a/flake.lock b/flake.lock index 84dc686..4f6372a 100644 --- a/flake.lock +++ b/flake.lock @@ -189,26 +189,6 @@ "type": "github" } }, - "paneru": { - "inputs": { - "nixpkgs": [ - "nixpkgs" - ] - }, - "locked": { - "lastModified": 1770939321, - "narHash": "sha256-OVF0sxT7mgZroAhOjK3QZqtnzOFcxN3wnxgghSYGgNw=", - "owner": "karinushka", - "repo": "paneru", - "rev": "c0537d166144f0776eb1bf0539942bda218716d5", - "type": "github" - }, - "original": { - "owner": "karinushka", - "repo": "paneru", - "type": "github" - } - }, "root": { "inputs": { "flake-parts": "flake-parts", @@ -219,8 +199,7 @@ "nix-darwin": "nix-darwin", "nix-homebrew": "nix-homebrew", "nixpkgs": "nixpkgs", - "nixpkgs-unstable": "nixpkgs-unstable", - "paneru": "paneru" + "nixpkgs-unstable": "nixpkgs-unstable" } } }, diff --git a/flake.nix b/flake.nix index 91ffb52..c411194 100755 --- a/flake.nix +++ b/flake.nix @@ -17,10 +17,6 @@ home-manager.url = "github:nix-community/home-manager/release-25.11"; home-manager.inputs.nixpkgs.follows = "nixpkgs"; - # Paneru - paneru.url = "github:karinushka/paneru"; - paneru.inputs.nixpkgs.follows = "nixpkgs"; - # Nix Homebrew nix-homebrew.url = "github:zhaofengli/nix-homebrew"; homebrew-core = { @@ -36,7 +32,6 @@ outputs = inputs@{ self, - paneru, nixpkgs, nix-darwin, flake-parts, @@ -85,7 +80,6 @@ "MacBook-Air-de-Laurent" = nix-darwin.lib.darwinSystem { specialArgs = { self = self; - paneru = paneru; import-tree = import-tree; home-manager = home-manager; homebrew-core = homebrew-core; diff --git a/hosts/darwin/home/alistreaza.nix b/hosts/darwin/home/alistreaza.nix index a73b198..1ba63c2 100644 --- a/hosts/darwin/home/alistreaza.nix +++ b/hosts/darwin/home/alistreaza.nix @@ -1,9 +1,9 @@ -{ import-tree, paneru, ... }: +{ import-tree, pkgs, ... }: { home-manager.users.alistreaza = { imports = [ + pkgs.paneru.homeModules.paneru (import-tree ../../../modules/home/common) - paneru.homeModules.paneru ]; home = { @@ -30,6 +30,10 @@ targets.darwin.linkApps.enable = false; targets.darwin.copyApps.enable = false; + services.paneru = { + enable = true; + }; + # The state version is required and should stay at the version you # originally installed. home.stateVersion = "25.11"; diff --git a/hosts/darwin/overlays/paneru.nix b/hosts/darwin/overlays/paneru.nix index 7ef63e7..b251fd9 100644 --- a/hosts/darwin/overlays/paneru.nix +++ b/hosts/darwin/overlays/paneru.nix @@ -1,11 +1,8 @@ -{ paneru, ... }: +{ ... }: { - nixpkgs.overlays = [ (final: prev: { - paneru = paneru.overrideAttrs (old: { - package.doCheck = false; - }); + paneru = prev.callPackage ../packages/paneru.nix { }; }) ]; } diff --git a/hosts/darwin/packages/paneru.nix b/hosts/darwin/packages/paneru.nix new file mode 100644 index 0000000..d8abbe4 --- /dev/null +++ b/hosts/darwin/packages/paneru.nix @@ -0,0 +1,125 @@ +{ + self, + fetchFromGitHub, + nixpkgs, +}: +let + pkgs = import nixpkgs { system = "aarch64-darwin"; }; + package = pkgs.rustPlatform.buildRustPackage { + pname = "paneru"; + src = fetchFromGitHub { + owner = "karinushka"; + repo = "paneru"; + sha256 = "sha256-ZPnuAjieJM+C/ebNEr04ZN3Iw+J/mquHekJXXMNHelI="; + }; + postPatch = '' + substituteInPlace build.rs --replace-fail \ + 'let sdk_dir = "/Library/Developer/CommandLineTools/SDKs";' \ + 'let sdk_dir = "${pkgs.apple-sdk}/Platforms/MacOSX.platform/Developer/SDKs";' + ''; + cargoLock.lockFile = ./Cargo.lock; + buildInputs = [ + pkgs.apple-sdk.privateFrameworksHook + ]; + }; +in +{ + packages.aarch64-darwin.default = self.packages.aarch64-darwin.paneru; + packages.aarch64-darwin.paneru = package; + homeModules.paneru = + { config, lib, ... }: + let + cfg = config.services.paneru; + tomlFormat = pkgs.formats.toml { }; + in + { + options.services.paneru = { + enable = lib.mkEnableOption '' + Install paneru and configure the launchd agent. + + The first time this is enabled, macOS will prompt you to allow this background + item in System Settings. + + You can verify the service is running correctly from your terminal. + Run: `launchctl list | grep paneru` + + In case of failure, check the logs with `cat /tmp/paneru.err.log`. + ''; + + package = lib.mkOption { + type = lib.types.package; + default = package; + description = "The paneru package to use."; + }; + + settings = lib.mkOption { + type = lib.types.nullOr lib.types.attrs; + default = null; + description = "Configuration to put in `~/.paneru.toml`."; + example = { + options = { + focus_follows_mouse = true; + preset_column_widths = [ + 0.25 + 0.33 + 0.5 + 0.66 + 0.75 + ]; + swipe_gesture_fingers = 4; + animation_speed = 4000; + }; + bindings = { + window_focus_west = "cmd - h"; + window_focus_east = "cmd - l"; + window_focus_north = "cmd - k"; + window_focus_south = "cmd - j"; + window_swap_west = "alt - h"; + window_swap_east = "alt - l"; + window_swap_first = "alt + shift - h"; + window_swap_last = "alt + shift - l"; + window_center = "alt - c"; + window_resize = "alt - r"; + window_manage = "ctrl + alt - t"; + window_stack = "alt - ]"; + window_unstack = "alt + shift - ]"; + quit = "ctrl + alt - q"; + }; + }; + }; + }; + + config = lib.mkIf cfg.enable { + assertions = [ (lib.hm.assertions.assertPlatform "services.paneru" pkgs lib.platforms.darwin) ]; + launchd.agents.paneru = { + enable = true; + config = { + KeepAlive = { + Crashed = true; + SuccessfulExit = false; + }; + Label = "Paneru"; + Nice = -20; + ProcessType = "Interactive"; + EnvironmentVariables = { + NO_COLOR = "1"; + XDG_CONFIG_HOME = + if config.xdg.enable then config.xdg.configHome else "${config.home.homeDirectory}/.config"; + }; + RunAtLoad = true; + StandardOutPath = "/tmp/paneru.log"; + StandardErrorPath = "/tmp/paneru.err.log"; + Program = cfg.package + /bin/paneru; + }; + }; + + xdg.configFile."paneru/paneru.toml" = lib.mkIf (config.xdg.enable && cfg.settings != null) { + source = tomlFormat.generate "paneru.toml" cfg.settings; + }; + + home.file.".paneru.toml" = lib.mkIf (!config.xdg.enable && cfg.settings != null) { + source = tomlFormat.generate ".paneru.toml" cfg.settings; + }; + }; + }; +}