From 2438a882f49cb5f71439715a1011627b0d755702 Mon Sep 17 00:00:00 2001 From: Martin Larsson Date: Sun, 11 May 2025 13:27:31 +0200 Subject: [PATCH 01/12] Add spacing before icon in battery --- confutils/get-battery.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/confutils/get-battery.sh b/confutils/get-battery.sh index ec7017e..9723474 100755 --- a/confutils/get-battery.sh +++ b/confutils/get-battery.sh @@ -28,7 +28,7 @@ get_battery_info_mac() { capacity=$(pmset -g batt | grep -o "\d\+%" | head -n1 | tr -d '%') if [[ -n "$capacity" ]]; then # Just show generic icon + capacity on mac - echo "$MAC_BATTERY_ICON $capacity%" + echo "$MAC_BATTERY_ICON $capacity%" return 0 fi @@ -104,9 +104,9 @@ get_battery_info_linux() { # Build the final string if [[ -n "$power_consumption_watts" ]]; then - echo "$battery_icon $capacity% (${power_consumption_watts} W)" + echo "$battery_icon $capacity% (${power_consumption_watts} W)" else - echo "$battery_icon $capacity%" + echo "$battery_icon $capacity%" fi return 0 fi From ba613b2a59dee8d8d598887bd0bb8af458ade268 Mon Sep 17 00:00:00 2001 From: Martin Larsson Date: Sun, 11 May 2025 13:28:20 +0200 Subject: [PATCH 02/12] Setup legcord, spotify-qt, librespot and blueman --- nix/pkgs/linux.nix | 70 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) diff --git a/nix/pkgs/linux.nix b/nix/pkgs/linux.nix index f495153..cb3fadd 100644 --- a/nix/pkgs/linux.nix +++ b/nix/pkgs/linux.nix @@ -1,6 +1,7 @@ { pkgs, config, + lib, nur, ... }: @@ -75,6 +76,57 @@ let rev = "21b79cca716af87b8a2b9e420c0e1d3d08b67414"; sha256 = "sha256-2xP9tHCmOM35fxFMbABUhHHnefv2sSCwhnYpjbHM/V0="; }; + + # User-specific librespot settings + librespot_device_name = "asahi-nixos-librespot"; + librespot_username = "martymeister98"; + librespot_bitrate = "320"; + + # Construct librespot arguments + librespot_args = '' + --name ${librespot_device_name} + --username ${librespot_username} + --bitrate ${librespot_bitrate} + --disable-audio-cache + --initial-volume 50 + ''; + + spotify_qt_initial_config = { + General = { + check_for_updates = false; + close_to_tray = false; + fallback_icons = false; + native_window = false; + notify_track_change = false; + relative_added = true; + show_changelog = false; + style = "Fusion"; + style_palette = 2; + track_list_resize_mode = 0; + track_numbers = 1; + tray_album_art = false; + tray_icon = false; + tray_light_icon = false; + }; + Qt = { + album_shape = 1; + album_size = 1; + library_layout = 1; + mirror_title_bar = false; + system_title_bar = true; + toolbar_position = 1; + }; + Spotify = { + path = "${pkgs.librespot}/bin/librespot"; + client_arguments = librespot_args; + always_start = true; + bitrate = 320; + disable_discovery = true; + start_client = true; + }; + }; + + spotify_qt_initial_json = builtins.toJSON spotify_qt_initial_config; in { wayland.windowManager.sway = { @@ -141,6 +193,10 @@ in grim slurp pavucontrol + legcord + spotify-qt + librespot + blueman ]; file = { @@ -151,6 +207,20 @@ in recursive = true; }; }; + + activation.conditionally_create_spotify-qt_config = lib.hm.dag.entryAfter [ "linkGeneration" ] '' + configFile="${config.home.homeDirectory}/.config/kraxarn/spotify-qt.json" + configDir="$(dirname "$configFile")" + if [ ! -f "$configFile" ]; then + echo "Initial spotify-qt.json not found. Creating with declarative defaults." + + mkdir -p "$configDir" + printf '%s' '${spotify_qt_initial_json}' > "$configFile" + echo "Initial spotify-qt.json created at $configFile." + else + echo "spotify-qt.json already exists at $configFile. Skipping initial creation." + fi + ''; }; programs = { From 3f03230f17b64316c770f880f27478bb9d76babd Mon Sep 17 00:00:00 2001 From: Martin Larsson Date: Sun, 11 May 2025 15:14:25 +0200 Subject: [PATCH 03/12] Remove border radius from sway --- sway/config | 2 -- 1 file changed, 2 deletions(-) diff --git a/sway/config b/sway/config index 897d6ae..6ed7ed6 100644 --- a/sway/config +++ b/sway/config @@ -212,8 +212,6 @@ gaps inner 6 gaps outer 6 smart_gaps on -corner_radius 10 - titlebar_separator disable blur enable From 8ad94f53e30c2e7dccf7a62e04087530e441beeb Mon Sep 17 00:00:00 2001 From: Martin Larsson Date: Sun, 11 May 2025 15:15:28 +0200 Subject: [PATCH 04/12] Move shared linux system config to a generic linux module --- nix/system/linux.nix | 53 ++++++++++++++++++++++++++++++++++---- nix/system/linux_aarch.nix | 46 +++++---------------------------- nix/system/linux_x86.nix | 38 +-------------------------- 3 files changed, 55 insertions(+), 82 deletions(-) diff --git a/nix/system/linux.nix b/nix/system/linux.nix index d905ff6..7335e87 100644 --- a/nix/system/linux.nix +++ b/nix/system/linux.nix @@ -4,6 +4,23 @@ zsh.enable = true; }; + boot = { + consoleLogLevel = 0; + }; + + hardware = { + graphics.enable = true; + + bluetooth.enable = true; + bluetooth.powerOnBoot = true; + bluetooth.settings = { + General = { + Enable = "Source,Sink,Media,Socket"; + Experimental = true; + }; + }; + }; + networking = { firewall = { enable = true; @@ -34,6 +51,7 @@ }; timesyncd.enable = true; mullvad-vpn.enable = true; + xserver.enable = true; }; time = { @@ -54,9 +72,34 @@ ]; }; - environment.systemPackages = with pkgs; [ - vim - home-manager - swaylock-effects - ]; + environment = { + systemPackages = with pkgs; [ + home-manager + swaylock-effects + ]; + + variables = { + NIXOS_OZONE_WL = "1"; + }; + }; + + networking = { + wireless.iwd = { + enable = true; + settings.General.EnableNetworkConfiguration = true; + }; + networkmanager = { + enable = true; + wifi.backend = "iwd"; + wifi.powersave = true; + }; + }; + + users.users.larssonmartin = { + isNormalUser = true; + home = "/home/larssonmartin"; + extraGroups = [ "wheel" ]; + packages = [ ]; + shell = pkgs.zsh; + }; } diff --git a/nix/system/linux_aarch.nix b/nix/system/linux_aarch.nix index 6565667..ed45825 100644 --- a/nix/system/linux_aarch.nix +++ b/nix/system/linux_aarch.nix @@ -13,54 +13,20 @@ }; boot = { - consoleLogLevel = 0; - kernelParams = [ "apple_dcp.show_notch=1" ]; + kernelParams = [ "apple_dcp.show_notch=0" ]; loader.efi.canTouchEfiVariables = false; }; - hardware = { - asahi = { - peripheralFirmwareDirectory = ./firmware; - useExperimentalGPUDriver = true; - setupAsahiSound = true; - withRust = true; - }; - - graphics.enable = true; - - bluetooth.enable = true; - bluetooth.powerOnBoot = true; - bluetooth.settings = { - General = { - Enable = "Source,Sink,Media,Socket"; - Experimental = true; - }; - }; + hardware.asahi = { + peripheralFirmwareDirectory = ./firmware; + useExperimentalGPUDriver = true; + setupAsahiSound = true; + withRust = true; }; networking.hostName = "asahi-nixos"; - networking = { - wireless.iwd = { - enable = true; - settings.General.EnableNetworkConfiguration = true; - }; - networkmanager = { - enable = true; - wifi.backend = "iwd"; - wifi.powersave = true; - }; - }; - services = { tlp.enable = true; }; - - users.users.larssonmartin = { - isNormalUser = true; - home = "/home/larssonmartin"; - extraGroups = [ "wheel" ]; - packages = [ ]; - shell = pkgs.zsh; - }; } diff --git a/nix/system/linux_x86.nix b/nix/system/linux_x86.nix index e7dcfe0..732c224 100644 --- a/nix/system/linux_x86.nix +++ b/nix/system/linux_x86.nix @@ -5,7 +5,6 @@ ]; boot = { - consoleLogLevel = 0; loader = { systemd-boot.enable = true; efi.canTouchEfiVariables = true; @@ -33,34 +32,11 @@ finegrained = false; }; nvidiaPersistenced = true; - - }; - graphics.enable = true; - - bluetooth.enable = true; - bluetooth.powerOnBoot = true; - bluetooth.settings = { - General = { - Enable = "Source,Sink,Media,Socket"; - Experimental = true; - }; }; }; networking.hostName = "walnut-nixos"; - networking = { - wireless.iwd = { - enable = true; - settings.General.EnableNetworkConfiguration = true; - }; - networkmanager = { - enable = true; - wifi.backend = "iwd"; - wifi.powersave = true; - }; - }; - programs = { xwayland.enable = true; sway = { @@ -75,23 +51,11 @@ environment.variables = { GBM_BACKEND = "nvidia-drm"; __GLX_VENDOR_LIBRARY_NAME = "nvidia"; - NIXOS_OZONE_WL = "1"; WLR_NO_HARDWARE_CURSORS = "1"; WLR_RENDERER = "vulkan"; }; services = { - xserver = { - enable = true; - videoDrivers = [ "nvidia" ]; - }; - }; - - users.users.larssonmartin = { - isNormalUser = true; - home = "/home/larssonmartin"; - extraGroups = [ "wheel" ]; - packages = [ ]; - shell = pkgs.zsh; + xserver.videoDrivers = [ "nvidia" ]; }; } From d32ba1b498592088f85592e8de5b0c45e6441e38 Mon Sep 17 00:00:00 2001 From: Martin Larsson Date: Sun, 11 May 2025 15:17:18 +0200 Subject: [PATCH 05/12] Rename pkgs dir to home dir, add x86 and aarch specific linux home modules --- nix/home.nix | 62 -------------------------- nix/{pkgs => home}/darwin.nix | 0 nix/{pkgs => home}/darwin_personal.nix | 0 nix/{pkgs => home}/darwin_work.nix | 0 nix/{pkgs => home}/home.nix | 1 + nix/{pkgs => home}/linux.nix | 0 nix/home/linux_aarch.nix | 13 ++++++ nix/home/linux_x86.nix | 12 +++++ nix/{local_home.nix => home/local.nix} | 0 nix/{pkgs => home}/wsl.nix | 0 nix/local_system.nix | 10 ----- 11 files changed, 26 insertions(+), 72 deletions(-) delete mode 100644 nix/home.nix rename nix/{pkgs => home}/darwin.nix (100%) rename nix/{pkgs => home}/darwin_personal.nix (100%) rename nix/{pkgs => home}/darwin_work.nix (100%) rename nix/{pkgs => home}/home.nix (99%) rename nix/{pkgs => home}/linux.nix (100%) create mode 100644 nix/home/linux_aarch.nix create mode 100644 nix/home/linux_x86.nix rename nix/{local_home.nix => home/local.nix} (100%) rename nix/{pkgs => home}/wsl.nix (100%) delete mode 100644 nix/local_system.nix diff --git a/nix/home.nix b/nix/home.nix deleted file mode 100644 index 31adef5..0000000 --- a/nix/home.nix +++ /dev/null @@ -1,62 +0,0 @@ -{ pkgs, neovim-flake, ... }: -{ - programs = { - zsh = { - enable = true; - }; - }; - - home = { - stateVersion = "24.05"; - packages = with pkgs; [ - neovim-flake.packages.${system}.neovim - fzf - bat - git - yazi - tmux - eza - curl - wget - ripgrep - fd - jq - starship - fastfetch - nixfmt-rfc-style - luajit - zoxide - rustup - zig - zls - nil - lldb - gopls - delve - golangci-lint - cmake - cmake-language-server - cmake-format - cmake-lint - python313Packages.debugpy - pyright - lua-language-server - gnumake - ninja - nodejs - bitwarden-cli - ]; - file = { - ".zshrc".source = ../zsh/.zshrc; - ".config/nvim".source = ../nvim; - ".config/yazi".source = ../yazi; - ".config/starship.toml".source = ../starship/starship.toml; - ".tmux.conf".source = ../tmux/.tmux.conf; - ".config/tmux".source = ../tmux; - ".config/bat".source = ../bat; - ".config/ghostty".source = ../ghostty; - ".config/confutils".source = ../confutils; - ".config/wallpapers".source = ../wallpapers; - }; - }; -} diff --git a/nix/pkgs/darwin.nix b/nix/home/darwin.nix similarity index 100% rename from nix/pkgs/darwin.nix rename to nix/home/darwin.nix diff --git a/nix/pkgs/darwin_personal.nix b/nix/home/darwin_personal.nix similarity index 100% rename from nix/pkgs/darwin_personal.nix rename to nix/home/darwin_personal.nix diff --git a/nix/pkgs/darwin_work.nix b/nix/home/darwin_work.nix similarity index 100% rename from nix/pkgs/darwin_work.nix rename to nix/home/darwin_work.nix diff --git a/nix/pkgs/home.nix b/nix/home/home.nix similarity index 99% rename from nix/pkgs/home.nix rename to nix/home/home.nix index 0a94fa5..fed4ae1 100644 --- a/nix/pkgs/home.nix +++ b/nix/home/home.nix @@ -120,6 +120,7 @@ in bc cmatrix svelte-language-server + bitwarden-cli ]; file = symlinkFiles; diff --git a/nix/pkgs/linux.nix b/nix/home/linux.nix similarity index 100% rename from nix/pkgs/linux.nix rename to nix/home/linux.nix diff --git a/nix/home/linux_aarch.nix b/nix/home/linux_aarch.nix new file mode 100644 index 0000000..b3c666f --- /dev/null +++ b/nix/home/linux_aarch.nix @@ -0,0 +1,13 @@ +{ + pkgs, + ... +}: +{ + home = { + packages = with pkgs; [ + legcord + librespot + spotify-qt + ]; + }; +} diff --git a/nix/home/linux_x86.nix b/nix/home/linux_x86.nix new file mode 100644 index 0000000..d8fc703 --- /dev/null +++ b/nix/home/linux_x86.nix @@ -0,0 +1,12 @@ +{ + pkgs, + ... +}: +{ + home = { + packages = with pkgs; [ + discord + spotify + ]; + }; +} diff --git a/nix/local_home.nix b/nix/home/local.nix similarity index 100% rename from nix/local_home.nix rename to nix/home/local.nix diff --git a/nix/pkgs/wsl.nix b/nix/home/wsl.nix similarity index 100% rename from nix/pkgs/wsl.nix rename to nix/home/wsl.nix diff --git a/nix/local_system.nix b/nix/local_system.nix deleted file mode 100644 index e916e9c..0000000 --- a/nix/local_system.nix +++ /dev/null @@ -1,10 +0,0 @@ -{ - ... -}: -{ - system = { - stateVersion = 5; - }; - - nix-homebrew.user = "martin.larsson"; -} From 8db7fef98b40fa18f798e3f219da214ccc5a838e Mon Sep 17 00:00:00 2001 From: Martin Larsson Date: Sun, 11 May 2025 15:18:05 +0200 Subject: [PATCH 06/12] Format flake.nix, rename local files, fix some paths --- flake.nix | 54 +++++++++++++++++++++++++++----------------- nix/system/local.nix | 10 ++++++++ 2 files changed, 43 insertions(+), 21 deletions(-) create mode 100644 nix/system/local.nix diff --git a/flake.nix b/flake.nix index c5bcf07..3f46f7c 100644 --- a/flake.nix +++ b/flake.nix @@ -61,12 +61,15 @@ }: let lib = nixpkgs.lib; - get_pkgs = { system }: import nixpkgs { - inherit system; - config = { - allowUnfree = true; + + get_pkgs = + { system }: + import nixpkgs { + inherit system; + config = { + allowUnfree = true; + }; }; - }; makeSystemConfig = { @@ -78,7 +81,8 @@ }: let pkgs = get_pkgs { inherit system; }; - in builder { + in + builder { inherit system; pkgs = pkgs; modules = [ @@ -86,9 +90,9 @@ nix.settings.experimental-features = "nix-command flakes"; environment.systemPackages = with pkgs; [ vim - ]; + ]; } - ./nix/local_system.nix + ./nix/system/local.nix ] ++ extraModules; specialArgs = specialArgs; @@ -99,13 +103,15 @@ name, system, extraModules ? [ ], - }: let + }: + let pkgs = get_pkgs { inherit system; }; - in home-manager.lib.homeManagerConfiguration { + in + home-manager.lib.homeManagerConfiguration { pkgs = pkgs; modules = [ - ./nix/pkgs/home.nix - ./nix/local_home.nix + ./nix/home/home.nix + ./nix/home/local.nix ] ++ extraModules; extraSpecialArgs = { @@ -130,10 +136,10 @@ name = "linux-x86"; system = "x86_64-linux"; builder = lib.nixosSystem; - extraModules = [ + extraModules = [ ./nix/system/linux.nix ./nix/system/linux_x86.nix - ]; + ]; }; "linux-aarch" = makeSystemConfig { @@ -206,27 +212,33 @@ "wsl" = makeHomeConfig { name = "wsl"; system = "x86_64-linux"; - extraModules = [ ./nix/pkgs/wsl.nix ]; + extraModules = [ ./nix/home/wsl.nix ]; }; "linux-x86" = makeHomeConfig { name = "linux-x86"; system = "x86_64-linux"; - extraModules = [ ./nix/pkgs/linux.nix ]; + extraModules = [ + ./nix/home/linux.nix + ./nix/home/linux_x86.nix + ]; }; "linux-aarch" = makeHomeConfig { name = "linux-aarch"; system = "aarch64-linux"; - extraModules = [ ./nix/pkgs/linux.nix ]; + extraModules = [ + ./nix/home/linux.nix + ./nix/home/linux_aarch.nix + ]; }; "darwin" = makeHomeConfig { name = "darwin"; system = "aarch64-darwin"; extraModules = [ - ./nix/pkgs/darwin.nix - ./nix/pkgs/darwin_personal.nix + ./nix/home/darwin.nix + ./nix/home/darwin_personal.nix ]; }; @@ -234,8 +246,8 @@ name = "work"; system = "aarch64-darwin"; extraModules = [ - ./nix/pkgs/darwin.nix - ./nix/pkgs/darwin_work.nix + ./nix/home/darwin.nix + ./nix/home/darwin_work.nix ]; }; }; diff --git a/nix/system/local.nix b/nix/system/local.nix new file mode 100644 index 0000000..e916e9c --- /dev/null +++ b/nix/system/local.nix @@ -0,0 +1,10 @@ +{ + ... +}: +{ + system = { + stateVersion = 5; + }; + + nix-homebrew.user = "martin.larsson"; +} From bfcc1e97204a19a3e6443903e056aa80b54b5ac8 Mon Sep 17 00:00:00 2001 From: Martin Larsson Date: Sun, 11 May 2025 16:26:15 +0200 Subject: [PATCH 07/12] Bring back old diagnostics, disable virtual line --- nvim/lua/diagnostics.lua | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/nvim/lua/diagnostics.lua b/nvim/lua/diagnostics.lua index 4ae79e7..afb9016 100644 --- a/nvim/lua/diagnostics.lua +++ b/nvim/lua/diagnostics.lua @@ -29,11 +29,11 @@ local sev = vim.diagnostic.severity vim.diagnostic.config({ underline = true, -- This enables the diagnostics at end of line - -- virtual_text = { - -- prefix = "●", - -- }, + virtual_text = { + prefix = "●", + }, -- This enables the separate buffer diagnostics - virtual_lines = true, + -- virtual_lines = true, update_in_insert = true, signs = { text = { From 7fe1eb68fa80d0c865e5b8d9990ebe73f443a564 Mon Sep 17 00:00:00 2001 From: Martin Larsson Date: Sun, 11 May 2025 16:26:36 +0200 Subject: [PATCH 08/12] Small keybind changes to sway --- sway/config | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/sway/config b/sway/config index 6ed7ed6..295b562 100644 --- a/sway/config +++ b/sway/config @@ -161,14 +161,15 @@ set $update_status_bar /run/current-system/sw/bin/kill -s 42 $(cat $status_pid_f # bindsym $mod+Shift+s splitv # Switch the current container between different layout styles - # bindsym $mod+Shift+t layout tabbed - # bindsym $mod+Shift+s layout toggle split + bindsym $mod+Shift+t layout tabbed + # s keybind would make sense, but its in use. g for grid instead + bindsym $mod+Shift+g layout toggle split # Make the current focus fullscreen bindsym $mod+Shift+f fullscreen # Move focus to the parent container - # bindsym $mod+Shift+a focus parent + bindsym $mod+Shift+a focus parent # Resizing containers: # mode "resize" { From d5735692d23b6dc11bb9326b8b05a880bc34b2ab Mon Sep 17 00:00:00 2001 From: Martin Larsson Date: Sun, 11 May 2025 16:26:50 +0200 Subject: [PATCH 09/12] Small keybind changes to tmux --- tmux/.tmux.conf | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tmux/.tmux.conf b/tmux/.tmux.conf index da44145..1a63f5e 100644 --- a/tmux/.tmux.conf +++ b/tmux/.tmux.conf @@ -35,9 +35,9 @@ bind-key -n M-d run-shell "~/.config/tmux/tmux-fuzzy-find-session.sh" # Split window, change keybindings to match vim concept of splits bind-key -n M-V split-window -h -c "#{pane_current_path}" -bind-key -n M-H split-window -v -c "#{pane_current_path}" +bind-key -n M-S split-window -v -c "#{pane_current_path}" bind-key -n M-q kill-pane -bind-key -n M-f resize-pane -Z +bind-key -n M-F resize-pane -Z bind-key -n M-s command-prompt -p "New session: " "run-shell '~/.config/tmux/tmux-create-session.sh '%%''" bind-key -n M-w new-window -c "#{pane_current_path}" bind-key -n M-r command-prompt -p "Rename window:" "rename-window '%%'" From c4d7f5d082782aed8cb765c047de48a5c032c018 Mon Sep 17 00:00:00 2001 From: Martin Larsson Date: Sun, 11 May 2025 18:19:19 +0200 Subject: [PATCH 10/12] Major refactor to flake, abstract non-trivial packages into their own files (such as firefox/spotify-qt+librespot), create utils for reusable function library --- nix/home/common/firefox.nix | 96 +++++++++++ nix/home/common/spotify_arm.nix | 80 +++++++++ nix/home/common/theming.nix | 119 +++++++++++++ nix/home/home.nix | 13 +- nix/home/linux.nix | 297 ++------------------------------ nix/home/linux_aarch.nix | 6 +- nix/system/common/nvidia.nix | 40 +++++ nix/system/linux.nix | 4 + nix/system/linux_aarch.nix | 1 - nix/system/linux_x86.nix | 38 +--- nix/utils.nix | 16 ++ 11 files changed, 379 insertions(+), 331 deletions(-) create mode 100644 nix/home/common/firefox.nix create mode 100644 nix/home/common/spotify_arm.nix create mode 100644 nix/home/common/theming.nix create mode 100644 nix/system/common/nvidia.nix create mode 100644 nix/utils.nix diff --git a/nix/home/common/firefox.nix b/nix/home/common/firefox.nix new file mode 100644 index 0000000..fa702f9 --- /dev/null +++ b/nix/home/common/firefox.nix @@ -0,0 +1,96 @@ +{ + pkgs, + nur, + ... +}: +{ + programs = { + firefox = { + enable = true; + package = pkgs.firefox-wayland; + + policies = { + "DisableFirefoxStudies" = true; + "DisableTelemetry" = true; + }; + + profiles = { + default = { + isDefault = true; + name = "DefaultProfile"; + userChrome = '' + @import "theme/nordic-theme.css"; + @import "theme/hide-single-tab.css"; + @import "theme/matching-autocomplete-width.css"; + @import "theme/system-icons.css"; + @import "theme/symbolic-tab-icons.css"; + + @import "customChrome.css"; + ''; + + extensions = { + packages = with nur.repos.rycee.firefox-addons; [ + ublock-origin + bitwarden + vimium + privacy-badger + clearurls + darkreader + ]; + }; + + settings = { + "browser.startup.homepage" = "https://search.nixos.org"; + "browser.shell.checkDefaultBrowser" = false; + "privacy.resistFingerprinting" = false; + "dom.security.https_only_mode" = true; + "browser.tabs.warnOnClose" = false; + "extensions.pocket.enabled" = false; + "browser.search.defaultenginename" = "ddg"; + "gfx.webrender.all" = true; + "toolkit.legacyUserProfileCustomizations.stylesheets" = true; + "browser.tabs.allow_transparent_browser" = true; + }; + + search = { + force = true; + default = "ddg"; + order = [ + "ddg" + "google" + ]; + engines = { + "ddg".metaData = { + alias = "@d"; + hidden = false; + }; + "google".metaData = { + alias = "@g"; + hidden = false; + }; + "Nix Packages" = { + urls = [ + { + template = "https://search.nixos.org/packages"; + params = [ + { + name = "type"; + value = "packages"; + } + { + name = "query"; + value = "{searchTerms}"; + } + ]; + } + ]; + icon = "${pkgs.nixos-icons}/share/icons/hicolor/scalable/apps/nix-snowflake.svg"; + definedAliases = [ "@np" ]; + }; + }; + }; + }; + }; + }; + }; +} diff --git a/nix/home/common/spotify_arm.nix b/nix/home/common/spotify_arm.nix new file mode 100644 index 0000000..f642a20 --- /dev/null +++ b/nix/home/common/spotify_arm.nix @@ -0,0 +1,80 @@ +{ + pkgs, + config, + lib, + ... +}: +let + # User-specific librespot settings + librespot_device_name = "asahi-nixos-librespot"; + librespot_username = "martymeister98"; + librespot_bitrate = "320"; + + # Construct librespot arguments + librespot_args = '' + --name ${librespot_device_name} + --username ${librespot_username} + --bitrate ${librespot_bitrate} + --disable-audio-cache + --initial-volume 50 + ''; + + spotify_qt_initial_config = { + General = { + check_for_updates = false; + close_to_tray = false; + fallback_icons = false; + native_window = false; + notify_track_change = false; + relative_added = true; + show_changelog = false; + style = "Fusion"; + style_palette = 2; + track_list_resize_mode = 0; + track_numbers = 1; + tray_album_art = false; + tray_icon = false; + tray_light_icon = false; + }; + Qt = { + album_shape = 1; + album_size = 1; + library_layout = 1; + mirror_title_bar = false; + system_title_bar = true; + toolbar_position = 1; + }; + Spotify = { + path = "${pkgs.librespot}/bin/librespot"; + client_arguments = librespot_args; + always_start = true; + bitrate = 320; + disable_discovery = true; + start_client = true; + }; + }; + + spotify_qt_initial_json = builtins.toJSON spotify_qt_initial_config; +in +{ + home = { + packages = with pkgs; [ + librespot + spotify-qt + ]; + + activation.conditionally_create_spotify-qt_config = lib.hm.dag.entryAfter [ "linkGeneration" ] '' + configFile="${config.home.homeDirectory}/.config/kraxarn/spotify-qt.json" + configDir="$(dirname "$configFile")" + if [ ! -f "$configFile" ]; then + echo "Initial spotify-qt.json not found. Creating with declarative defaults." + + mkdir -p "$configDir" + printf '%s' '${spotify_qt_initial_json}' > "$configFile" + echo "Initial spotify-qt.json created at $configFile." + else + echo "spotify-qt.json already exists at $configFile. Skipping initial creation." + fi + ''; + }; +} diff --git a/nix/home/common/theming.nix b/nix/home/common/theming.nix new file mode 100644 index 0000000..d9328b3 --- /dev/null +++ b/nix/home/common/theming.nix @@ -0,0 +1,119 @@ +{ + pkgs, + ... +}: + +let + cursor_name = "Banana-Blue"; + cursor_base_size = 32; + + bananaCursorBlueTarball = pkgs.fetchurl { + url = "https://github.com/ful1e5/banana-cursor/releases/download/v2.0.0/Banana-Blue.tar.xz"; + sha256 = "sha256-mpTrvgYiMfamMebtytY0bLouSbaP3qEqP8pgCFl+xPQ="; + }; + + banana_cursor_blue = pkgs.stdenv.mkDerivation { + pname = "banana-cursor-blue"; + version = "2.0.0"; + src = bananaCursorBlueTarball; + nativeBuildInputs = [ pkgs.xz ]; + + dontBuild = true; + + installPhase = '' + runHook preInstall + # Define shell variable using Nix interpolation for $out and the outer Nix var cursorName + local themeInstallDir="$out/share/icons/${cursor_name}" + mkdir -p "$themeInstallDir" + # Use the outer Nix var cursorName and the builder's $version shell variable + echo "Unpacking and installing pre-built theme ${cursor_name} (v$version) to $themeInstallDir" + + if tar -xJf $src --strip-components=1 -C "$themeInstallDir"; then + echo "Unpacked successfully with --strip-components=1." + else + echo "-----------------------------------------------------" + echo "WARNING: Unpacking with --strip-components=1 failed (archive might not have a single top-level dir)." + echo "Listing archive contents:" + tar -tf $src || echo "Failed to list archive contents." + echo "Attempting unpack without --strip-components=1..." + rm -rf "$themeInstallDir"; mkdir -p "$themeInstallDir" # Clean and recreate before retry + if tar -xJf $src -C "$themeInstallDir"; then + echo "Unpacked successfully without --strip-components=1." + else + echo "ERROR: Failed to unpack archive even without --strip-components=1." + exit 1 + fi + echo "-----------------------------------------------------" + fi + runHook postInstall + ''; + + meta = with pkgs.lib; { + description = "Banana Cursor Theme (Pre-built Blue variant v2.0.0)"; + homepage = "https://github.com/ful1e5/banana-cursor"; + license = licenses.gpl3Only; + maintainers = with maintainers; [ eelco ]; + platforms = platforms.linux; + }; + }; + + cursor_package = banana_cursor_blue; + + effective_cursor_size_str = toString cursor_base_size; +in +{ + wayland.windowManager.sway = { + config = { + seat = { + "*" = { + # Sway uses this for its own cursor and for XWayland applications. + # It takes the theme name and base size. Sway should scale this based on output settings. + xcursor_theme = "${cursor_name} ${effective_cursor_size_str}"; + }; + }; + }; + }; + + # Home Manager Pointer Configuration + # This makes the theme available and sets X11/GTK defaults via Home Manager mechanisms. + home = { + pointerCursor = { + name = cursor_name; + size = cursor_base_size; + package = cursor_package; + x11.enable = true; + gtk.enable = true; + x11.defaultCursor = "left_ptr"; + }; + packages = with pkgs; [ + (cursor_package) + ]; + }; + + qt = { + enable = true; + platformTheme.name = "gtk"; + style.name = "Nordic"; + }; + + gtk = { + enable = true; + cursorTheme = { + name = cursor_name; + size = cursor_base_size; # GTK applications will use this base size. + package = cursor_package; + }; + theme = { + package = pkgs.nordic; + name = "Nordic"; + }; + }; + + xresources.properties = { + "Xcursor.theme" = cursor_name; + }; + + home.sessionVariables = { + XCURSOR_THEME = cursor_name; + }; +} diff --git a/nix/home/home.nix b/nix/home/home.nix index fed4ae1..8589f13 100644 --- a/nix/home/home.nix +++ b/nix/home/home.nix @@ -6,6 +6,7 @@ ... }: let + utils = import ../utils.nix; dotfiles = [ [ ".zshrc" @@ -54,16 +55,6 @@ let cp ${pkgs.vscode-extensions.vadimcn.vscode-lldb}/share/vscode/extensions/vadimcn.vscode-lldb/adapter/codelldb $out/bin/codelldb chmod +x $out/bin/codelldb ''; - - symlinkFiles = builtins.listToAttrs ( - map (file: { - name = builtins.elemAt file 0; - value = { - source = config.lib.file.mkOutOfStoreSymlink "${config.home.homeDirectory}/dev/git/.dotfiles/${builtins.elemAt file 1}"; - }; - - }) dotfiles - ); in { programs = { @@ -123,7 +114,7 @@ in bitwarden-cli ]; - file = symlinkFiles; + file = utils.mk_symlinks { inherit config dotfiles; }; activation.batCache = lib.hm.dag.entryAfter [ "writeBoundary" ] '' run ${pkgs.bat}/bin/bat cache --build ''; diff --git a/nix/home/linux.nix b/nix/home/linux.nix index 817c4a4..dad2a2e 100644 --- a/nix/home/linux.nix +++ b/nix/home/linux.nix @@ -1,186 +1,35 @@ { pkgs, config, - lib, - nur, ... }: let + utils = import ../utils.nix; + dotfiles = [ + [ + ".config/sway" + "sway" + ] + [ + ".config/wofi" + "wofi" + ] + ]; + pythonEnv = pkgs.python3.withPackages ( ps: with ps; [ i3ipc ] ); - - cursorName = "Banana-Blue"; - cursorBaseSize = 32; - - bananaCursorBlueTarball = pkgs.fetchurl { - url = "https://github.com/ful1e5/banana-cursor/releases/download/v2.0.0/Banana-Blue.tar.xz"; - sha256 = "sha256-mpTrvgYiMfamMebtytY0bLouSbaP3qEqP8pgCFl+xPQ="; - }; - - bananaCursorBlue = pkgs.stdenv.mkDerivation { - pname = "banana-cursor-blue"; - version = "2.0.0"; - src = bananaCursorBlueTarball; - nativeBuildInputs = [ pkgs.xz ]; - - dontBuild = true; - - installPhase = '' - runHook preInstall - # Define shell variable using Nix interpolation for $out and the outer Nix var cursorName - local themeInstallDir="$out/share/icons/${cursorName}" - mkdir -p "$themeInstallDir" - # Use the outer Nix var cursorName and the builder's $version shell variable - echo "Unpacking and installing pre-built theme ${cursorName} (v$version) to $themeInstallDir" - - if tar -xJf $src --strip-components=1 -C "$themeInstallDir"; then - echo "Unpacked successfully with --strip-components=1." - else - echo "-----------------------------------------------------" - echo "WARNING: Unpacking with --strip-components=1 failed (archive might not have a single top-level dir)." - echo "Listing archive contents:" - tar -tf $src || echo "Failed to list archive contents." - echo "Attempting unpack without --strip-components=1..." - rm -rf "$themeInstallDir"; mkdir -p "$themeInstallDir" # Clean and recreate before retry - if tar -xJf $src -C "$themeInstallDir"; then - echo "Unpacked successfully without --strip-components=1." - else - echo "ERROR: Failed to unpack archive even without --strip-components=1." - exit 1 - fi - echo "-----------------------------------------------------" - fi - runHook postInstall - ''; - - meta = with pkgs.lib; { - description = "Banana Cursor Theme (Pre-built Blue variant v2.0.0)"; - homepage = "https://github.com/ful1e5/banana-cursor"; - license = licenses.gpl3Only; - maintainers = with maintainers; [ eelco ]; # Original nixpkgs maintainer - platforms = platforms.linux; - }; - }; - - cursorPackage = bananaCursorBlue; - - effectiveCursorSizeStr = toString cursorBaseSize; - - firefox-nordic-theme-src = pkgs.fetchFromGitHub { - owner = "EliverLara"; - repo = "firefox-nordic-theme"; - rev = "21b79cca716af87b8a2b9e420c0e1d3d08b67414"; - sha256 = "sha256-2xP9tHCmOM35fxFMbABUhHHnefv2sSCwhnYpjbHM/V0="; - }; - - # User-specific librespot settings - librespot_device_name = "asahi-nixos-librespot"; - librespot_username = "martymeister98"; - librespot_bitrate = "320"; - - # Construct librespot arguments - librespot_args = '' - --name ${librespot_device_name} - --username ${librespot_username} - --bitrate ${librespot_bitrate} - --disable-audio-cache - --initial-volume 50 - ''; - - spotify_qt_initial_config = { - General = { - check_for_updates = false; - close_to_tray = false; - fallback_icons = false; - native_window = false; - notify_track_change = false; - relative_added = true; - show_changelog = false; - style = "Fusion"; - style_palette = 2; - track_list_resize_mode = 0; - track_numbers = 1; - tray_album_art = false; - tray_icon = false; - tray_light_icon = false; - }; - Qt = { - album_shape = 1; - album_size = 1; - library_layout = 1; - mirror_title_bar = false; - system_title_bar = true; - toolbar_position = 1; - }; - Spotify = { - path = "${pkgs.librespot}/bin/librespot"; - client_arguments = librespot_args; - always_start = true; - bitrate = 320; - disable_discovery = true; - start_client = true; - }; - }; - - spotify_qt_initial_json = builtins.toJSON spotify_qt_initial_config; in { - wayland.windowManager.sway = { - config = { - seat = { - "*" = { - # Sway uses this for its own cursor and for XWayland applications. - # It takes the theme name and base size. Sway should scale this based on output settings. - xcursor_theme = "${cursorName} ${effectiveCursorSizeStr}"; - }; - }; - }; - }; - - # Home Manager Pointer Configuration - # This makes the theme available and sets X11/GTK defaults via Home Manager mechanisms. - home.pointerCursor = { - name = cursorName; - size = cursorBaseSize; - package = cursorPackage; - x11.enable = true; - gtk.enable = true; - x11.defaultCursor = "left_ptr"; - }; - - qt = { - enable = true; - platformTheme.name = "gtk"; - style.name = "Nordic"; - }; - - gtk = { - enable = true; - cursorTheme = { - name = cursorName; - size = cursorBaseSize; # GTK applications will use this base size. - package = cursorPackage; - }; - theme = { - package = pkgs.nordic; - name = "Nordic"; - }; - }; - - xresources.properties = { - "Xcursor.theme" = cursorName; - }; + imports = [ + ./common/firefox.nix + ]; home = { - sessionVariables = { - XCURSOR_THEME = cursorName; - }; packages = with pkgs; [ - (cursorPackage) pythonEnv wl-clipboard-rs clang @@ -193,124 +42,10 @@ in grim slurp pavucontrol - legcord - spotify-qt - librespot blueman playerctl ]; - file = { - ".config/sway".source = config.lib.file.mkOutOfStoreSymlink ../../sway; - ".config/wofi".source = config.lib.file.mkOutOfStoreSymlink ../../wofi; - "${config.home.homeDirectory}/.mozilla/firefox/hm-profile-default/chrome/firefox-nordic-theme" = { - source = firefox-nordic-theme-src; - recursive = true; - }; - }; - - activation.conditionally_create_spotify-qt_config = lib.hm.dag.entryAfter [ "linkGeneration" ] '' - configFile="${config.home.homeDirectory}/.config/kraxarn/spotify-qt.json" - configDir="$(dirname "$configFile")" - if [ ! -f "$configFile" ]; then - echo "Initial spotify-qt.json not found. Creating with declarative defaults." - - mkdir -p "$configDir" - printf '%s' '${spotify_qt_initial_json}' > "$configFile" - echo "Initial spotify-qt.json created at $configFile." - else - echo "spotify-qt.json already exists at $configFile. Skipping initial creation." - fi - ''; - }; - - programs = { - firefox = { - enable = true; - package = pkgs.firefox-wayland; - - policies = { - "DisableFirefoxStudies" = true; - "DisableTelemetry" = true; - }; - - profiles = { - default = { - isDefault = true; - name = "DefaultProfile"; - userChrome = '' - @import "theme/nordic-theme.css"; - @import "theme/hide-single-tab.css"; - @import "theme/matching-autocomplete-width.css"; - @import "theme/system-icons.css"; - @import "theme/symbolic-tab-icons.css"; - - @import "customChrome.css"; - ''; - - extensions = { - packages = with nur.repos.rycee.firefox-addons; [ - ublock-origin - bitwarden - vimium - privacy-badger - clearurls - darkreader - ]; - }; - - settings = { - "browser.startup.homepage" = "https://search.nixos.org"; - "browser.shell.checkDefaultBrowser" = false; - "privacy.resistFingerprinting" = false; - "dom.security.https_only_mode" = true; - "browser.tabs.warnOnClose" = false; - "extensions.pocket.enabled" = false; - "browser.search.defaultenginename" = "ddg"; - "gfx.webrender.all" = true; - "toolkit.legacyUserProfileCustomizations.stylesheets" = true; - "browser.tabs.allow_transparent_browser" = true; - }; - - search = { - force = true; - default = "ddg"; - order = [ - "ddg" - "google" - ]; - engines = { - "ddg".metaData = { - alias = "@d"; - hidden = false; - }; - "google".metaData = { - alias = "@g"; - hidden = false; - }; - "Nix Packages" = { - urls = [ - { - template = "https://search.nixos.org/packages"; - params = [ - { - name = "type"; - value = "packages"; - } - { - name = "query"; - value = "{searchTerms}"; - } - ]; - } - ]; - icon = "${pkgs.nixos-icons}/share/icons/hicolor/scalable/apps/nix-snowflake.svg"; - definedAliases = [ "@np" ]; - }; - }; - }; - }; - }; - }; + file = utils.mk_symlinks { inherit config dotfiles; }; }; } diff --git a/nix/home/linux_aarch.nix b/nix/home/linux_aarch.nix index b3c666f..ac5f019 100644 --- a/nix/home/linux_aarch.nix +++ b/nix/home/linux_aarch.nix @@ -3,11 +3,13 @@ ... }: { + imports = [ + ./common/spotify_arm.nix + ]; + home = { packages = with pkgs; [ legcord - librespot - spotify-qt ]; }; } diff --git a/nix/system/common/nvidia.nix b/nix/system/common/nvidia.nix new file mode 100644 index 0000000..e2591ac --- /dev/null +++ b/nix/system/common/nvidia.nix @@ -0,0 +1,40 @@ +{ config, ... }: +{ + boot = { + kernelModules = [ + "nvidia" + "nvidia_modeset" + "nvidia_uvm" + "nvidia_drm" + ]; + blacklistedKernelModules = [ "nouveau" ]; + kernelParams = [ + "nvidia-drm.modeset=1" + "nvidia-drm.fbdev=1" + ]; + }; + + hardware = { + nvidia = { + modesetting.enable = true; + package = config.boot.kernelPackages.nvidiaPackages.stable; + open = true; + powerManagement = { + enable = true; + finegrained = false; + }; + nvidiaPersistenced = true; + }; + }; + + environment.variables = { + GBM_BACKEND = "nvidia-drm"; + __GLX_VENDOR_LIBRARY_NAME = "nvidia"; + WLR_NO_HARDWARE_CURSORS = "1"; + WLR_RENDERER = "vulkan"; + }; + + services = { + xserver.videoDrivers = [ "nvidia" ]; + }; +} diff --git a/nix/system/linux.nix b/nix/system/linux.nix index 7335e87..e8a2218 100644 --- a/nix/system/linux.nix +++ b/nix/system/linux.nix @@ -1,5 +1,9 @@ { pkgs, ... }: { + imports = [ + ./hardware-configuration.nix + ]; + programs = { zsh.enable = true; }; diff --git a/nix/system/linux_aarch.nix b/nix/system/linux_aarch.nix index ed45825..710e2ac 100644 --- a/nix/system/linux_aarch.nix +++ b/nix/system/linux_aarch.nix @@ -1,7 +1,6 @@ { apple-silicon-support, pkgs, ... }: { imports = [ - ./hardware-configuration.nix apple-silicon-support.nixosModules.apple-silicon-support ]; diff --git a/nix/system/linux_x86.nix b/nix/system/linux_x86.nix index 732c224..38b82e1 100644 --- a/nix/system/linux_x86.nix +++ b/nix/system/linux_x86.nix @@ -1,7 +1,8 @@ -{ pkgs, config, ... }: +{ pkgs, ... }: { imports = [ ./hardware-configuration.nix + ./common/nvidia.nix ]; boot = { @@ -9,30 +10,6 @@ systemd-boot.enable = true; efi.canTouchEfiVariables = true; }; - kernelModules = [ - "nvidia" - "nvidia_modeset" - "nvidia_uvm" - "nvidia_drm" - ]; - blacklistedKernelModules = [ "nouveau" ]; - kernelParams = [ - "nvidia-drm.modeset=1" - "nvidia-drm.fbdev=1" - ]; - }; - - hardware = { - nvidia = { - modesetting.enable = true; - package = config.boot.kernelPackages.nvidiaPackages.stable; - open = true; - powerManagement = { - enable = true; - finegrained = false; - }; - nvidiaPersistenced = true; - }; }; networking.hostName = "walnut-nixos"; @@ -47,15 +24,4 @@ ]; }; }; - - environment.variables = { - GBM_BACKEND = "nvidia-drm"; - __GLX_VENDOR_LIBRARY_NAME = "nvidia"; - WLR_NO_HARDWARE_CURSORS = "1"; - WLR_RENDERER = "vulkan"; - }; - - services = { - xserver.videoDrivers = [ "nvidia" ]; - }; } diff --git a/nix/utils.nix b/nix/utils.nix new file mode 100644 index 0000000..a70c4a9 --- /dev/null +++ b/nix/utils.nix @@ -0,0 +1,16 @@ +{ + mk_symlinks = + { + config, + basePath ? "${config.home.homeDirectory}/dev/git/.dotfiles", + dotfiles ? [ ], + }: + builtins.listToAttrs ( + map (file: { + name = builtins.elemAt file 0; + value = { + source = config.lib.file.mkOutOfStoreSymlink "${basePath}/${builtins.elemAt file 1}"; + }; + }) dotfiles + ); +} From 571c1027cb24451992227ca4117e30ee06fe9e4d Mon Sep 17 00:00:00 2001 From: Martin Larsson Date: Sun, 11 May 2025 18:29:38 +0200 Subject: [PATCH 11/12] Make sure to import theming.nix in the home/linux module --- nix/home/linux.nix | 1 + 1 file changed, 1 insertion(+) diff --git a/nix/home/linux.nix b/nix/home/linux.nix index dad2a2e..5dbc2fd 100644 --- a/nix/home/linux.nix +++ b/nix/home/linux.nix @@ -25,6 +25,7 @@ let in { imports = [ + ./common/theming.nix ./common/firefox.nix ]; From ca56564ec92103b6a8d49a130589852505badcbc Mon Sep 17 00:00:00 2001 From: Martin Larsson Date: Sun, 11 May 2025 18:32:36 +0200 Subject: [PATCH 12/12] Rename home/home.nix -> home/default.nix --- flake.nix | 2 +- nix/home/{home.nix => default.nix} | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename nix/home/{home.nix => default.nix} (100%) diff --git a/flake.nix b/flake.nix index 3f46f7c..a7be4e0 100644 --- a/flake.nix +++ b/flake.nix @@ -110,7 +110,7 @@ home-manager.lib.homeManagerConfiguration { pkgs = pkgs; modules = [ - ./nix/home/home.nix + ./nix/home/default.nix ./nix/home/local.nix ] ++ extraModules; diff --git a/nix/home/home.nix b/nix/home/default.nix similarity index 100% rename from nix/home/home.nix rename to nix/home/default.nix