Merge branch 'main' of github.com:LarssonMartin1998/.dotfiles

This commit is contained in:
Martin Larsson 2025-05-11 20:42:37 +02:00
commit 0ff714cd02
25 changed files with 549 additions and 237 deletions

View file

@ -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

View file

@ -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/default.nix
./nix/home/local.nix
] ++ extraModules;
extraSpecialArgs = {
@ -133,7 +139,7 @@
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
];
};
};

View file

@ -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;
};
};
}

View file

@ -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" ];
};
};
};
};
};
};
};
}

View file

@ -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
'';
};
}

119
nix/home/common/theming.nix Normal file
View file

@ -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;
};
}

View file

@ -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 = {
@ -120,9 +111,10 @@ in
bc
cmatrix
svelte-language-server
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
'';

56
nix/home/linux.nix Normal file
View file

@ -0,0 +1,56 @@
{
pkgs,
config,
...
}:
let
utils = import ../utils.nix;
dotfiles = [
[
".config/sway"
"sway"
]
[
".config/wofi"
"wofi"
]
];
pythonEnv = pkgs.python3.withPackages (
ps: with ps; [
i3ipc
]
);
in
{
imports = [
./common/theming.nix
./common/firefox.nix
];
home = {
packages = with pkgs; [
pythonEnv
wl-clipboard-rs
clang
clang-tools
gimp3
ghostty
mullvad
thunderbird
wofi
grim
slurp
pavucontrol
blueman
playerctl
mako
];
file = utils.mk_symlinks { inherit config dotfiles; };
};
services = {
mako.enable = true;
};
}

15
nix/home/linux_aarch.nix Normal file
View file

@ -0,0 +1,15 @@
{
pkgs,
...
}:
{
imports = [
./common/spotify_arm.nix
];
home = {
packages = with pkgs; [
legcord
];
};
}

18
nix/home/linux_x86.nix Normal file
View file

@ -0,0 +1,18 @@
{
pkgs,
...
}:
let
discord_wrapped = pkgs.writeShellScriptBin "discord" ''
#!${pkgs.runtimeShell}
exec "${pkgs.discord}/bin/discord" "$@" >/dev/null 2>&1
'';
in
{
home = {
packages = with pkgs; [
discord_wrapped
spotify
];
};
}

View file

@ -20,13 +20,6 @@ let
sha256 = "sha256-mpTrvgYiMfamMebtytY0bLouSbaP3qEqP8pgCFl+xPQ=";
};
discord_wrapped = pkgs.writeShellScriptBin "discord" ''
#!${pkgs.runtimeShell}
# Execute the original Discord binary, redirecting stdout and stderr to /dev/null
# "$@" passes along any arguments (like URLs for opening links in Discord)
exec "${pkgs.discord}/bin/discord" "$@" >/dev/null 2>&1
'';
bananaCursorBlue = pkgs.stdenv.mkDerivation {
pname = "banana-cursor-blue";
version = "2.0.0";
@ -164,10 +157,6 @@ in
};
};
services = {
mako.enable = true;
};
programs = {
firefox = {
enable = true;

View file

@ -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" ];
};
}

View file

@ -1,9 +1,30 @@
{ pkgs, ... }:
{
imports = [
./hardware-configuration.nix
];
programs = {
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 +55,7 @@
};
timesyncd.enable = true;
mullvad-vpn.enable = true;
xserver.enable = true;
};
time = {
@ -54,9 +76,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;
};
}

View file

@ -1,7 +1,6 @@
{ apple-silicon-support, pkgs, ... }:
{
imports = [
./hardware-configuration.nix
apple-silicon-support.nixosModules.apple-silicon-support
];
@ -13,54 +12,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;
};
}

View file

@ -1,66 +1,19 @@
{ pkgs, config, ... }:
{ pkgs, ... }:
{
imports = [
./hardware-configuration.nix
./common/nvidia.nix
];
boot = {
consoleLogLevel = 0;
loader = {
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;
};
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 = {
@ -71,27 +24,4 @@
];
};
};
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;
};
}

16
nix/utils.nix Normal file
View file

@ -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
);
}

View file

@ -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 = {

View file

@ -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" {
@ -212,8 +213,6 @@ gaps inner 6
gaps outer 6
smart_gaps on
corner_radius 10
titlebar_separator disable
blur enable

View file

@ -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 '%%'"