Files
flake-nixinator/home/christoph/default.nix
T

606 lines
20 KiB
Nix

# This is your home-manager configuration file
# Use this to configure your home environment (it replaces ~/.config/nixpkgs/home.nix)
# The nixosConfig allows to access the toplevel system configuration from within home manager
# https://github.com/nix-community/home-manager/blob/586ac1fd58d2de10b926ce3d544b3179891e58cb/nixos/default.nix#L19
{
inputs,
hostname,
username,
publicKeys,
lib,
mylib,
nixosConfig,
config,
pkgs,
headless,
...
}: let
inherit (config.homemodules) color;
in
# This is a HM module.
# Because no imports/options/config is defined explicitly, everything is treated as config:
# { inputs, lib, ... }: { ... } gets turned into { inputs, lib, ... }: { config = { ... }; } implicitly.
{
# Every module is a nix expression, specifically a function { inputs, lib, ... }: { ... }.
# Every module (/function) is called with the same arguments as this module.
# Arguments with matching names are "plugged in" into the right slots,
# the case of different arity is handled by always providing ellipses (...) in module definitions.
# Enable and configure my custom HM modules.
paths = rec {
nixflake = "${config.home.homeDirectory}/NixFlake";
dotfiles = "${nixflake}/config";
};
homemodules = {
beets.enable = !headless;
cava.enable = !headless;
chromium = {
enable = !headless;
google = false;
};
color = {
installPackages = !headless;
extraPackages = with pkgs; [
papirus-icon-theme
bibata-cursors
# Lol
# inputs.waifu-cursors.packages.${pkgs.stdenv.hostPlatform.system}.all
];
cursor = "Bibata-Modern-Classic";
cursorSize = 24;
cursorPackage = pkgs.bibata-cursors;
iconTheme = "Papirus-Dark";
iconPackage = pkgs.papirus-icon-theme;
scheme = "catppuccin-mocha";
accent = "mauve";
accentHl = "pink";
accentDim = "lavender";
accentText = "base";
wallpaper = "Windows";
font = builtins.head nixosConfig.fonts.fontconfig.defaultFonts.monospace;
};
docs.enable = !headless;
firefox = {
enable = !headless;
wayland = true;
vaapi = true;
textfox = true;
disableTabBar = true;
};
hyprland = {
enable = nixosConfig.programs.hyprland.enable;
bars.enable = false;
hyprpanel.enable = false;
keybindings = {
main-mod = "SUPER";
bindings = let
sessionMenu = mylib.rofi.mkMenu {
prompt = "Session2";
layers = [
{
"󰤂 Poweroff" = "poweroff";
"󰜉 Reboot" = "reboot";
"󰌾 Lock" = "loginctl lock-session";
# " Reload Hyprpanel" = "systemctl --user restart hyprpanel.service";
" Reload Hyprland" = "hyprctl reload";
" Exit Hyprland" = "hyprctl dispatch exit";
# " Exit Niri" = "niri msg action quit";
}
];
prompts = ["Select Session Action"];
rofiCmd = "walker -d";
};
in
lib.mergeAttrsList [
{
"$mainMod SHIFT, a" = ["exec, walker -m providerlist"];
"$mainMod, a" = ["exec, walker -m desktopapplications"];
"$mainMod, c" = ["exec, walker -m clipboard"];
"$mainMod, Escape" = ["exec, ${sessionMenu}/bin/rofi-menu-Session2"];
"$mainMod CTRL, w" = ["exec, waypaper"];
}
{
# Applications
"$mainMod, t" = ["exec, kitty"];
"$mainMod, e" = ["exec, kitty --title=Yazi yazi"];
"$mainMod, n" = ["exec, neovide"];
# "$mainMod, r" = ["exec, kitty --title=Rmpc rmpc"];
"$mainMod CTRL, n" = ["exec, kitty --title=Navi navi"];
"$mainMod SHIFT, n" = ["exec, neovide ${config.paths.dotfiles}/navi/christoph.cheat"];
"$mainMod SHIFT, f" = ["exec, neovide ${config.paths.dotfiles}/flake.nix"];
# "ALT, tab" = ["exec, rofi -show window"];
# Screenshots
"$mainMod, p" = ["exec, hyprpicker --autocopy --format=hex"];
"$mainMod, s" = ["exec, grim -g \"$(slurp)\""];
"$mainMod SHIFT, s" = ["exec, grim -g \"$(slurp)\" - | wl-copy"];
# Audio
", XF86AudioRaiseVolume" = ["exec, wpctl set-volume -l 1.5 @DEFAULT_AUDIO_SINK@ 5%+"];
", XF86AudioLowerVolume" = ["exec, wpctl set-volume -l 1.5 @DEFAULT_AUDIO_SINK@ 5%-"];
", XF86AudioPlay" = ["exec, playerctl play-pause"];
", XF86AudioPrev" = ["exec, playerctl previous"];
", XF86AudioNext" = ["exec, playerctl next"];
# Brightness
", XF86MonBrightnessDown" = ["exec, hyprctl hyprsunset gamma -10"];
", XF86MonBrightnessUp" = ["exec, hyprctl hyprsunset gamma +10"];
"$mainMod, XF86MonBrightnessDown" = ["exec, hyprctl hyprsunset temperature 5750"];
"$mainMod, XF86MonBrightnessUp" = ["exec, hyprctl hyprsunset identity"];
"CTRL ALT, f" = let
hyprctl = "${config.wayland.windowManager.hyprland.package}/bin/hyprctl";
grep = "${pkgs.gnugrep}/bin/grep";
awk = "${pkgs.gawk}/bin/gawk";
notify = "${pkgs.libnotify}/bin/notify-send";
toggleMouseFocus = pkgs.writeScriptBin "hypr-toggle-mouse-focus" ''
CURRENT=$(${hyprctl} getoption input:follow_mouse | ${grep} int | ${awk} -F' ' '{print $2}')
if [[ "$CURRENT" == "1" ]]; then
${hyprctl} keyword input:follow_mouse 0
${notify} "Disabled Mouse Focus!"
else
${hyprctl} keyword input:follow_mouse 1
${notify} "Enabled Mouse Focus!"
fi
'';
in ["exec, ${toggleMouseFocus}/bin/hypr-toggle-mouse-focus"];
# "CTRL ALT, t" = ["exec, bash -c 'systemctl --user restart hyprpanel.service'"];
}
];
ws-bindings = {
# "<Workspace>" = "<Key>";
"1" = "1";
"2" = "2";
"3" = "3";
"4" = "4";
"5" = "5";
"6" = "6";
"7" = "7";
"8" = "8";
"9" = "9";
"10" = "0";
};
# special-ws-bindings = {
# "ferdium" = "x";
# "msty" = "z";
# "btop" = "b";
# "rmpc" = "r";
# };
};
autostart = {
immediate = [
"kitty --hold fastfetch"
# "zeal"
# "protonvpn-app"
# "kdeconnect-indicator" # started by services.kdeconnect.indicator
];
delayed = [
# "keepassxc" # The tray doesn't work when started too early
"nextcloud --background"
];
special-silent = {
# "ferdium" = ["ferdium"];
# "msty" = ["msty"];
# "btop" = ["kitty --title=Btop btop"];
# "rmpc" = ["kitty --title=Rmpc rmpc"];
};
};
windowrules = [
# Fix jetbrains tooltip flicker
"match:class ^(jetbrains-.*)$, match:title ^(win[0-9]+)$, float 1"
"match:class ^(jetbrains-.*)$, match:title ^(win[0-9]+)$, no_initial_focus 1"
];
workspacerules = {
"1" = [];
"2" = ["neovide" "code-url-handler" "dev.zed.Zed" "code" "jetbrains-(.+)"];
"3" = ["obsidian" "Zotero"];
"4" = ["firefox" "Google-chrome" "chromium-browser" "org.qutebrowser.qutebrowser"];
"5" = ["steam"];
"6" = ["steam_app_(.+)" "factorio"];
"7" = ["signal"];
"8" = [];
"9" = ["discord"];
"10" = [];
};
floating = [
{class = "org.kde.polkit-kde-authentication-agent-1";}
{
class = "thunar";
title = "File Operation Progress";
}
{class = "ffplay";}
{class = "Unity";}
{class = "code-url-handler";}
];
transparent-opacity = "0.85";
transparent = [
"kitty"
"Alacritty"
"discord"
"signal"
"vesktop"
"Spotify"
"tidal-hifi"
"obsidian"
"firefox"
"org.qutebrowser.qutebrowser"
"jetbrains-clion"
"jetbrains-idea"
"jetbrains-pycharm"
"jetbrains-rustrover"
"jetbrains-rider"
"jetbrains-webstorm"
"code-url-handler"
"neovide"
"steam"
"ferdium"
"Msty"
];
};
mpd.enable = !headless;
niri.enable = nixosConfig.programs.niri.enable;
nnn.enable = false; # Use yazi
packages.enable = true;
qutebrowser.enable = !headless;
rmpc.enable = !headless;
rofi.enable = false;
terminal.enable = true;
waybar.enable = !headless;
zathura.enable = !headless;
};
manual = {
manpages.enable = nixosConfig.documentation.enable;
html.enable = false;
};
# Make fonts installed through user packages available to applications.
# Also updates the font-cache.
fonts.fontconfig.enable = !headless;
# This only works when HM is installed as a system module,
# as nixosConfig won't be available otherwise.
xdg = {
enable = true; # This only does xdg path management
mime.enable = nixosConfig.systemmodules.mime.enable;
mimeApps = {
enable = nixosConfig.systemmodules.mime.enable;
associations.added = nixosConfig.xdg.mime.addedAssociations;
associations.removed = nixosConfig.xdg.mime.removedAssociations;
defaultApplications = nixosConfig.xdg.mime.defaultApplications;
};
portal = {
inherit (nixosConfig.xdg.portal) enable xdgOpenUsePortal config extraPortals;
};
};
home = {
inherit username; # Inherited from flake.nix
homeDirectory = "/home/${config.home.username}";
enableNixpkgsReleaseCheck = true;
# Environment variables
sessionVariables = lib.mkMerge [
{
LANG = "en_US.UTF-8";
MANPAGER = "nvim +Man!";
}
(lib.mkIf (!headless) {
# TERMINAL = "alacritty -o font.size=12";
TERMINAL = "kitty";
BROWSER = "firefox";
# Enable wayland
XDG_SESSION_TYPE = "wayland";
# QT_QPA_PLATFORM = "wayland;xcb";
QT_QPA_PLATFORM = "wayland";
NIXOS_OZONE_WL = "1";
# ELECTRON_OZONE_PLATFORM_HINT = "auto";
SDL_VIDEODRIVER = "wayland"; # Leave unset as gamescope uses xwayland
# Run SSH_ASKPASS as GUI, not TTY for Obsidian git
SSH_ASKPASS_REQUIRE = "prefer";
# GTK_IM_MODULE, QT_IM_MODULE, XMODIFIERS are set by HomeManager fcitx5 module
})
];
# Files to generate in the home directory are specified here.
file = lib.mkMerge [
{
# Because we can't access the absolute path /run/secrets/... we have to symlink.
# This will create a chain of links leading to /run/secrets/... without /nix/store
# containing the secret contents.
".ssh/id_ed25519".source =
config.lib.file.mkOutOfStoreSymlink
nixosConfig.sops.secrets.ssh-private-key.path;
".ssh/id_ed25519.pub".text = "${publicKeys.${username}.ssh}";
".secrets/age/age.pub".text = "${publicKeys.${username}.age}";
# The sops config specifies what happens when we call sops edit
".sops.yaml".text = ''
keys:
- &${username} ${publicKeys.${username}.age}
creation_rules:
- path_regex: secrets.yaml$
key_groups:
- age:
- *${username}
'';
".config/nix/nix.conf".source =
config.lib.file.mkOutOfStoreSymlink
nixosConfig.sops.templates."nix.conf".path;
}
(lib.mkIf nixosConfig.systemmodules.desktopportal.termfilechooser.enable {
".config/xdg-desktop-portal-termfilechooser/config".text = ''
[filechooser]
cmd=${pkgs.xdg-desktop-portal-termfilechooser}/share/xdg-desktop-portal-termfilechooser/yazi-wrapper.sh
default_dir=$HOME
env=TERMCMD=kitty --class=file_chooser
open_mode = suggested
save_mode = last
'';
})
(lib.mkIf config.homemodules.git.enable {
".ssh/allowed_signers".text = "* ${publicKeys.${username}.ssh}";
})
(lib.mkIf config.programs.navi.enable {
".local/share/navi/cheats/christoph.cheat".source = config.lib.file.mkOutOfStoreSymlink "${config.paths.dotfiles}/navi/christoph.cheat";
})
(lib.mkIf (!headless) {
# killswitch: 0, 1, 2 (off, on, advanced - still on after reboot)
# netshield: 0, 1, 2 (off, malware, ads+malware+trackers)
".config/Proton/VPN/settings.json".text = ''
{
"protocol": "wireguard",
"killswitch": 1,
"custom_dns": {
"enabled": false,
"ip_list": []
},
"ipv6": true,
"anonymous_crash_reports": false,
"features": {
"netshield": 1,
"moderate_nat": true,
"vpn_accelerator": true,
"port_forwarding": false
}
}
'';
".config/Proton/VPN/app-config.json".text = ''
{
"tray_pinned_servers": [
"DE",
"CH",
"AU"
],
"connect_at_app_startup": null,
"start_app_minimized": true
}
'';
# KeePassXC
".config/QtProject.conf".text = ''
[FileDialog]
history=@Invalid()
lastVisited=file:///home/christoph/Documents/KeePass
qtVersion=5.15.18
viewMode=Detail
'';
})
];
# Here, custom scripts can be run when activating a HM generation.
# If those scripts contain side-effects, like creating files,
# they must be placed after the "writeBoundary" node in the execution graph.
activation = {
# Example with side-effects:
# linkObsidianLatexSnippets =
# lib.hm.dag.entryAfter ["writeBoundary"]
# (mylib.modules.mkLink "~/NixFlake/config/obsidian/latex_snippets.json" "~/Notes/Obsidian/Chriphost/latex_snippets.json");
};
# Add stuff for your user as you see fit:
# packages = with pkgs; []; # Configured in homemodules/packages
};
# home.file.".options-doc".source = "${pkgs.modules-options-doc}";
# Packages with extra options managed by HomeManager natively
programs = {
imv = {
enable = !headless;
settings = {
options = {
background = "${color.hex.base}";
overlay = true;
overlay_font = "${color.font}:12";
overlay_background_color = "${color.hex.accent}";
overlay_text_color = "${color.hex.accentText}";
};
};
};
keychain = {
enable = true;
enableFishIntegration = config.homemodules.fish.enable;
enableXsessionIntegration = !headless;
keys = ["id_ed25519"];
};
mpv = {
enable = !headless;
config = {
gpu-context = "wayland";
};
};
nix-index = {
enable = true;
enableFishIntegration = config.homemodules.fish.enable;
};
nushell.enable = false;
# spicetify = let
# spicePkgs = inputs.spicetify-nix.legacyPackages.${pkgs.stdenv.hostPlatform.system};
# in {
# enable = true;
#
# # https://github.com/catppuccin/spicetify
# theme = spicePkgs.themes.catppuccin;
# colorScheme = "mocha";
#
# wayland = true;
#
# enabledExtensions = with spicePkgs.extensions; [
# adblock
# hidePodcasts
# oneko # cat
# ];
# # enabledCustomApps = with spicePkgs.apps; [];
# enabledSnippets = with spicePkgs.snippets; [
# rotatingCoverart
# pointer
# ];
# };
};
services = {
kdeconnect = {
enable = nixosConfig.programs.kdeconnect.enable; # Only the system package sets up the firewall
indicator = nixosConfig.programs.kdeconnect.enable;
};
flatpak = lib.mkIf nixosConfig.services.flatpak.enable {
# FlatHub stable is only added by default if no custom remotes are specified
remotes = lib.mkOptionDefault [
{
name = "flathub";
location = "https://flathub.org/repo/flathub.flatpakrepo";
}
{
name = "flathub-beta";
location = "https://flathub.org/beta-repo/flathub-beta.flatpakrepo";
}
];
packages = lib.mkMerge [
[]
(lib.mkIf (!headless) [
"com.github.tchx84.Flatseal"
# "com.spotify.Client" # Don't need this when spicetify is enabled
"com.discordapp.Discord"
# "com.discordapp.DiscordCanary"
# "com.google.Chrome"
# "md.obsidian.Obsidian"
# "io.anytype.anytype"
])
];
uninstallUnmanaged = true;
uninstallUnused = true;
update.auto = {
enable = true;
onCalendar = "daily"; # Default value: weekly
};
overrides = {
global = {
# Force Wayland by default
# Context.sockets = ["wayland" "!x11" "!fallback-x11"]; # NOTE: Makes discord + steam crash
Context.filesystems = [
"/nix/store:ro"
"${config.home.homeDirectory}/.themes:ro"
"${config.home.homeDirectory}/.config/gtk-4.0:ro"
];
Environment = {
# Fix un-themed cursor in some Wayland apps
XCURSOR_PATH = "/run/host/user-share/icons:/run/host/share/icons";
# Force correct theme for some GTK apps
GTK_THEME = config.gtk.theme.name;
};
};
"io.anytype.anytype".Context = {
filesystems = [
"${config.home.homeDirectory}"
];
};
"com.discordapp.Discord".Context = {
filesystems = [
"${config.home.homeDirectory}"
];
};
};
};
};
systemd = {
user = {
# TODO: This has been deprecated and replaced with a bad alternative in a stupid HM update
# tmpfiles.rules = lib.mkMerge [
# []
# (lib.mkIf (mylib.modules.contains
# config.services.flatpak.packages
# "com.discordapp.Discord") [
# # Fix Discord rich presence for Flatpak
# "L %t/discord-ipc-0 - - - - app/com.discordapp.Discord/discord-ipc-0"
# ])
# (lib.mkIf (mylib.modules.contains
# config.services.flatpak.packages
# "com.discordapp.DiscordCanary") [
# # Fix Discord rich presence for Flatpak
# "L %t/discord-ipc-0 - - - - app/com.discordapp.DiscordCanary/discord-ipc-0"
# ])
# ];
# Nicely reload system units when changing configs
startServices = "sd-switch";
};
};
}