From 98d28abc3ff55caedb56e6500501bfad84cdb09d Mon Sep 17 00:00:00 2001 From: Ahmad Ansori Palembani Date: Fri, 18 Oct 2024 21:06:26 +0700 Subject: [PATCH] refactor(nix): More split Also added floorp, but not functional at the moment, it requires 24.11 --- .config/nix/flake.lock | 14 ++-- .config/nix/flake.nix | 2 +- .config/nix/modules/home-manager/floorp.nix | 80 +++++++++++++++++++++ .config/nix/users/default.nix | 17 ++++- .config/nix/users/ziro.nix | 33 --------- .config/nix/users/ziro/darwin.nix | 24 +++++++ .config/nix/users/ziro/default.nix | 9 +++ .config/nix/users/ziro/linux.nix | 5 ++ 8 files changed, 142 insertions(+), 42 deletions(-) create mode 100644 .config/nix/modules/home-manager/floorp.nix delete mode 100644 .config/nix/users/ziro.nix create mode 100644 .config/nix/users/ziro/darwin.nix create mode 100644 .config/nix/users/ziro/default.nix create mode 100644 .config/nix/users/ziro/linux.nix diff --git a/.config/nix/flake.lock b/.config/nix/flake.lock index 56cd243..2fea2e5 100644 --- a/.config/nix/flake.lock +++ b/.config/nix/flake.lock @@ -99,11 +99,11 @@ ] }, "locked": { - "lastModified": 1720042825, - "narHash": "sha256-A0vrUB6x82/jvf17qPCpxaM+ulJnD8YZwH9Ci0BsAzE=", + "lastModified": 1726989464, + "narHash": "sha256-Vl+WVTJwutXkimwGprnEtXc/s/s8sMuXzqXaspIGlwM=", "owner": "nix-community", "repo": "home-manager", - "rev": "e1391fb22e18a36f57e6999c7a9f966dc80ac073", + "rev": "2f23fa308a7c067e52dfcc30a0758f47043ec176", "type": "github" }, "original": { @@ -156,16 +156,16 @@ }, "nixpkgs": { "locked": { - "lastModified": 1720599075, - "narHash": "sha256-0pS6J6Jr7PEkjxkGolrWvilDIlgcEnMHAG9vxPuBeoE=", + "lastModified": 1729242558, + "narHash": "sha256-VgcLDu4igNT0eYua6OAl9pWCI0cYXhDbR+pWP44tte0=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "f694c70847dff1a24c29d2ff6b90966fe5619729", + "rev": "4a3f2d3195b60d07530574988df92e049372c10e", "type": "github" }, "original": { "owner": "NixOS", - "ref": "nixpkgs-24.05-darwin", + "ref": "release-24.05", "repo": "nixpkgs", "type": "github" } diff --git a/.config/nix/flake.nix b/.config/nix/flake.nix index b2ef8a7..098979c 100644 --- a/.config/nix/flake.nix +++ b/.config/nix/flake.nix @@ -31,7 +31,7 @@ }; inputs = { - nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-24.05-darwin"; + nixpkgs.url = "github:NixOS/nixpkgs/release-24.05"; nix-darwin = { url = "github:LnL7/nix-darwin"; diff --git a/.config/nix/modules/home-manager/floorp.nix b/.config/nix/modules/home-manager/floorp.nix new file mode 100644 index 0000000..f7368d0 --- /dev/null +++ b/.config/nix/modules/home-manager/floorp.nix @@ -0,0 +1,80 @@ +{ pkgs, config, vars, ... }: + +{ + programs = { + floorp = { + enable = true; + package = pkgs.emptyDirectory; # we only want the config + profiles.ziro = { + userChrome = + '' + /** + * Better Floorp vertical tabs + * + * This makes Floorp's (expanded) vertical tabs not affecting sites' width, + * which can cause lag on heavy websites like Twitch and YouTube. + * + * This also fixed vertical tabs' width breaking when some preference related + * to browser's "head" is changed + * + * Based on my changes for Pulse, but Pulse is dead. + * REF: https://github.com/null2264/pulse/commit/fce966a110c2987b08d35bcd04c5992655b24b13 + */ + :root { + /* from Floorp source code, too big for me */ + /*--default-verticaltab-width: 45px;*/ + /*--hoverd-verticaltab-width: 20em;*/ + + --default-verticaltab-width: 35px !important; + --hoverd-verticaltab-width: 18em; + } + + @charset "UTF-8"; + @-moz-document url(chrome://browser/content/browser.xhtml) { + .browserContainer { + border-inline-width: 0 !important; + } + + /* >> Fix height being inconsistent on hover */ + .tab-icon-stack, + .tab-label-container { + height: 2.7em !important; + } + + .tab-icon-stack { + align-items: center; + } + /* << Fix height being inconsistent on hover */ + + #sidebar-select-box { + width: var(--default-verticaltab-width) !important; + min-width: var(--default-verticaltab-width) !important; + max-width: var(--default-verticaltab-width) !important; + } + + #TabsToolbar { + position: relative !important; + transition: all 300ms !important; + width: calc(var(--default-verticaltab-width) + 5px) !important; + min-width: calc(var(--default-verticaltab-width) + 5px) !important; + max-width: calc(var(--default-verticaltab-width) + 5px) !important; + z-index: 1; /* Probably not needed, since Floorp already handle this */ + } + #TabsToolbar:not(:hover) { + scrollbar-width: none !important; + } + + #TabsToolbar:hover { + transition: all 300ms !important; + width: var(--hoverd-verticaltab-width) !important; + min-width: var(--hoverd-verticaltab-width) !important; + max-width: var(--hoverd-verticaltab-width) !important; + z-index: 2; /* Probably not needed, since Floorp already handle this */ + margin-right: calc((var(--hoverd-verticaltab-width) - var(--default-verticaltab-width) - 5px) * -1) !important; + } + } + ''; + }; + }; + }; +} diff --git a/.config/nix/users/default.nix b/.config/nix/users/default.nix index 801581f..d64450d 100644 --- a/.config/nix/users/default.nix +++ b/.config/nix/users/default.nix @@ -24,7 +24,22 @@ in inherit pkgs; extraSpecialArgs = { inherit inputs pkgs home-manager vars; }; modules = [ - ./ziro.nix + ./ziro + ./ziro/darwin.nix + ]; + }; + + "ziro@potato" = + let + inherit (mkSystem "x86_64-linux" nixpkgs) system pkgs; + in + home-manager.lib.homeManagerConfiguration { + inherit pkgs; + extraSpecialArgs = { inherit inputs pkgs home-manager vars; }; + modules = [ + ./ziro + ./ziro/linux.nix + #../modules/home-manager/floorp.nix # FIXME: Added on 24.11 ]; }; } diff --git a/.config/nix/users/ziro.nix b/.config/nix/users/ziro.nix deleted file mode 100644 index f53c970..0000000 --- a/.config/nix/users/ziro.nix +++ /dev/null @@ -1,33 +0,0 @@ -{ pkgs, config, vars, ... }: - -let - dirPrefix = if pkgs.stdenv.isDarwin then "/Users/" else "/home/"; -in { - home = { - username = "ziro"; - homeDirectory = dirPrefix + "ziro"; - }; - - programs = { - browserpass = { - enable = true; - browsers = [ "brave" "chrome" ]; # Arc and Chrome share the same `Application Support` dir, not sure why tbh. - }; - }; - - # Swap CapsLock with Esc for better vi-mode experience. - launchd.agents.CapsEscSwap = { - enable = true; - config = { - ProgramArguments = [ - "/usr/bin/hidutil" - "property" - "--set" - "{\"UserKeyMapping\":[{\"HIDKeyboardModifierMappingSrc\":0x700000039,\"HIDKeyboardModifierMappingDst\":0x700000029},{\"HIDKeyboardModifierMappingSrc\":0x700000029,\"HIDKeyboardModifierMappingDst\":0x700000039}]}" - ]; - RunAtLoad = true; - }; - }; - - home.stateVersion = "24.05"; -} diff --git a/.config/nix/users/ziro/darwin.nix b/.config/nix/users/ziro/darwin.nix new file mode 100644 index 0000000..90d380b --- /dev/null +++ b/.config/nix/users/ziro/darwin.nix @@ -0,0 +1,24 @@ +{ pkgs, config, vars, ... }: + +{ + home.homeDirectory = "/Users/ziro"; + + programs.browserpass = { + enable = true; + browsers = [ "brave" "chrome" ]; # Arc and Chrome share the same `Application Support` dir, not sure why tbh. + }; + + # Swap CapsLock with Esc for better vi-mode experience. + launchd.agents.CapsEscSwap = { + enable = true; + config = { + ProgramArguments = [ + "/usr/bin/hidutil" + "property" + "--set" + ''{"UserKeyMapping":[{"HIDKeyboardModifierMappingSrc":0x700000039,"HIDKeyboardModifierMappingDst":0x700000029},{"HIDKeyboardModifierMappingSrc":0x700000029,"HIDKeyboardModifierMappingDst":0x700000039}]}'' + ]; + RunAtLoad = true; + }; + }; +} diff --git a/.config/nix/users/ziro/default.nix b/.config/nix/users/ziro/default.nix new file mode 100644 index 0000000..30b55ed --- /dev/null +++ b/.config/nix/users/ziro/default.nix @@ -0,0 +1,9 @@ +{ pkgs, config, vars, ... }: + +{ + home = { + username = "ziro"; + }; + + home.stateVersion = "24.05"; +} diff --git a/.config/nix/users/ziro/linux.nix b/.config/nix/users/ziro/linux.nix new file mode 100644 index 0000000..56a5b8e --- /dev/null +++ b/.config/nix/users/ziro/linux.nix @@ -0,0 +1,5 @@ +{ pkgs, config, vars, ... }: + +{ + home.homeDirectory = "/home/ziro"; +}