nix-system/home.nix

522 lines
14 KiB
Nix

let user = import ./name.nix; in
{ config, pkgs, flakes-pkgs, ... }:
{
# Home Manager needs a bit of information about you and the paths it should
# manage.
home.username = user;
home.homeDirectory = "/home/${user}";
# This value determines the Home Manager release that your configuration is
# compatible with. This helps avoid breakage when a new Home Manager release
# introduces backwards incompatible changes.
#
# You should not change this value, even if you update Home Manager. If you do
# want to update the value, then make sure to first check the Home Manager
# release notes.
home.stateVersion = "23.05"; # Please read the comment before changing.
# The home.packages option allows you to install Nix packages into your
# environment.
home.packages = with pkgs; [
betterbird
python3
python3Packages.virtualenv
nodePackages.pyright
dunst
ncdu
nsxiv
wl-clipboard
pamixer
pulsemixer
bluez
bluetuith
wtype
dmenu
keepmenu
dtrx
trash-cli
rofimoji
nnn
go-mtpfs
nix-output-monitor
libnotify
qbittorrent
go
unzip
pandoc
gnumake
xdg-utils
entr
# xdg-desktop-portal-wlr
xdg-desktop-portal-hyprland
(catppuccin-gtk.override {
accents = [ "pink" ];
size = "compact";
tweaks = [ "black" ];
variant = "mocha";
})
davfs2
htop
yt-dlp
ffmpeg
wget
lua-language-server
inter
material-design-icons
(nerdfonts.override { fonts = [ "CascadiaCode" "Noto" "Hack" ]; })
devenv
];
# Home Manager is pretty good at managing dotfiles. The primary way to manage
# plain files is through 'home.file'.
home.file = {
# ".config/fontconfig/fonts.conf".source = dotfiles/fonts.conf;
".config/waybar/config.jsonc".source = dotfiles/waybar.jsonc;
".config/waybar/style.css".source = dotfiles/waybar.css;
# ".config/kitty/kitty.conf".source = dotfiles/kitty/kitty.conf;
".config/kitty/light.conf".source = dotfiles/kitty/light.conf;
".config/kitty/dark.conf".source = dotfiles/kitty/dark.conf;
".config/rofi/colors-dark.rasi".source = dotfiles/rofi/colors-dark.rasi;
".config/rofi/colors-light.rasi".source = dotfiles/rofi/colors-light.rasi;
# ".config/rofi/config.rasi".source = dotfiles/rofi/config.rasi;
".config/rofi/theme.rasi".source = dotfiles/rofi/theme.rasi;
# ".config/dunst/dunstrc".source = dotfiles/dunstrc;
".config/keepmenu/config.ini".source = dotfiles/keepmenu.ini;
".bin/runmenu".source = pkgs.writers.writeBash "runmenu" ''
${config.programs.rofi.package}/bin/rofi -matching normal -sort -show run
'';
# ".bin/wl".source = bin/wl;
".bin/window_dir".source = pkgs.writers.writeBash "window_dir" ''
PID=$(${pkgs.hyprland}/bin/hyprctl activewindow | grep pid | cut -d' ' -f 2)
PID=$(echo $(ps --ppid $PID -o pid | tail -n1))
cwd=$(readlink /proc/"$PID"/cwd)
echo "$cwd"
'';
".bin/screenshot".source = (import ./bin/screenshot.nix) pkgs;
".bin/ocrzone".source = pkgs.writers.writeBash "ocrzone" ''
${pkgs.pkgs.sway-contrib.grimshot}/bin/grimshot save area - | \
${pkgs.tesseract}/bin/tesseract -l fra - - | \
${pkgs.wl-clipboard}/bin/wl-copy
'';
".bin/wifi-toggle".source = pkgs.writers.writeBash "wifi-toggle" ''
if [[ $(nmcli radio wifi) == "enabled" ]]; then
nmcli radio wifi off
else
nmcli radio wifi on
fi
'';
".bin/rofi-udisk".source = pkgs.writers.writeBash "rofi-udisk" ''
device=$(${pkgs.udiskie}/bin/udiskie-info -a -o "{ui_label} {in_use}" -f is_filesystem | \
${pkgs.gnused}/bin/sed 's/True$/[Mounted]/' | \
${pkgs.gnused}/bin/sed 's/False$//' | \
${config.programs.rofi.package}/bin/rofi -dmenu | \
${pkgs.coreutils}/bin/cut -d':' -f1)
if [ -n "$device" ] ; then
if ${pkgs.mount}/bin/mount | ${pkgs.gnugrep}/bin/grep "$device" ; then
${pkgs.libnotify}/bin/notify-send "Unmounting $device..."
output=$(${pkgs.udisks}/bin/udisksctl unmount -b $device 2>&1)
if [ $? -eq 0 ] ; then
${pkgs.libnotify}/bin/notify-send "Device successfully unmounted."
else
${pkgs.libnotify}/bin/notify-send "Failed to unmount device" "$output"
fi
else
${pkgs.libnotify}/bin/notify-send "Mounting $device..."
output=$(${pkgs.udisks}/bin/udisksctl mount -b $device 2>&1)
if [ $? -eq 0 ] ; then
${pkgs.libnotify}/bin/notify-send "Device successfully mounted."
else
${pkgs.libnotify}/bin/notify-send "Failed to mount device" "$output"
fi
fi
fi
'';
".bin/mount-android".source = pkgs.writers.writeBash "mount-android" ''
if ${pkgs.mount}/bin/mount | ${pkgs.gnugrep}/bin/grep $(realpath ~/android); then
umount $(realpath ~/android)
${pkgs.libnotify}/bin/notify-send "Android unmounted"
elif ${pkgs.simple-mtpfs}/bin/simple-mtpfs $(realpath ~/android); then
${pkgs.libnotify}/bin/notify-send "Android mounted in ~/android"
else
${pkgs.libnotify}/bin/notify-send "Can't find Android device"
fi
'';
".bin/dark".source = (import ./bin/dark.nix) pkgs;
};
home.sessionPath = [
"$HOME/.local/bin"
"$HOME/.bin"
];
home.sessionVariables = {
NIXOS_OZONE_WL = "1";
EDITOR = "nvim";
TERMINAL = "kitty";
TERM = "kitty";
NNN_TRASH = 1;
GOPATH = "${config.home.homeDirectory}/.local/share/go";
GOMODCACHE = "${config.home.homeDirectory}/.cache/go/pkg/mod";
GDK_BACKEND = "wayland,x11";
QT_QPA_PLATFORM = "wayland;xcb";
CLUTTER_BACKEND = "wayland";
XDG_CURRENT_DESKTOP = "Hyprland";
XDG_SESSION_TYPE = "wayland";
XDG_SESSION_DESKTOP = "Hyprland";
QT_AUTO_SCREEN_SCALE_FACTOR = "1";
WLR_NO_HARDWARE_CURSORS = "1";
XCURSOR_SIZE = "24";
};
home.keyboard.options = [
"caps:escape"
];
# xsession.enable = true;
# xsession.windowManager.command = "${pkgs.fish}/bin/fish --login";
wayland.windowManager.hyprland = (import ./hyprland.nix) { pkgs = pkgs; flakes-pkgs = flakes-pkgs; };
xdg = {
enable = true;
systemDirs.data = [ "${config.home.homeDirectory}/.local/share" ];
# portal = {
# enable = true;
# configPackage = pkgs.xdg-desktop-portal-hyprland;
# xdgOpenUsePortal = true;
# };
userDirs = {
enable = true;
createDirectories = false;
download = "${config.home.homeDirectory}/downloads";
templates = "${config.home.homeDirectory}/templates";
videos = "${config.home.homeDirectory}/videos";
desktop = "${config.home.homeDirectory}";
};
mimeApps = {
enable = true;
defaultApplications = {
"text/plain" = "nvim.desktop";
};
};
};
services.syncthing.enable = true;
systemd.user.services = {
battery-notify = {
Unit = {
Description = "Send notification when battery is low";
Wants = "battery-timer.timer";
};
Service = {
Type = "oneshot";
ExecStart = "${pkgs.writers.writeBash "battery-notify" ''
# ${pkgs.libnotify}/bin/notify-send $(${pkgs.coreutils}/bin/cat /sys/class/power_supply/BAT0/capacity)
if [[ $(${pkgs.coreutils}/bin/cat /sys/class/power_supply/BAT0/capacity) -lt 10 ]]; then
${pkgs.libnotify}/bin/notify-send -u critical "Battery is low"
fi
'' }";
};
};
};
systemd.user.timers = {
battery-timer = {
Unit = {
Description = "Execute battery-notify every minute";
};
Install = {
# enable the service
# WantedBy = [ "default.target" ];
};
Timer = {
Unit = "battery-notify.service";
OnCalendar = "*-*-* *:*:00";
};
};
};
# services.darkman = {
# enable = true;
#
# lightModeScripts = {
# gtk-theme = ''
# ${pkgs.dconf}/bin/dconf write \
# /org/gnome/desktop/interface/color-scheme "'prefer-light'"
# '';
# # my-python-script = pkgs.writers.writePython3 "my-python-script" { } ''
# # print('Do something!')
# # '';
# };
#
# darkModeScripts = {
# gtk-theme = ''
# ${pkgs.dconf}/bin/dconf write \
# /org/gnome/desktop/interface/color-scheme "'prefer-dark'"
# '';
# # my-python-script = pkgs.writers.writePython3 "my-python-script" { } ''
# # print('Do something!')
# # '';
# };
#
# settings = {
# lat = 52.3;
# lng = 4.8;
# usegeoclue = true;
# };
# };
fonts.fontconfig.enable = true;
gtk = {
enable = true;
font = {
package = pkgs.inter;
name = "Inter";
};
theme = {
name = "Catppuccin-Latte-Compact-Pink-Light";
# name = "Catppuccin-Mocha-Compact-Pink-Dark";
package = pkgs.catppuccin-gtk.override {
accents = [ "pink" ];
size = "compact";
tweaks = [ ];
variant = "latte";
};
};
iconTheme = {
name = "Adwaita";
package = pkgs.gnome.adwaita-icon-theme;
};
cursorTheme = {
name = "Hackneyed";
package = pkgs.hackneyed;
};
};
qt = {
enable = true;
platformTheme.name = "kde";
};
programs.direnv = {
enable = true;
nix-direnv.enable = true;
};
programs.rofi = {
enable = true;
package = pkgs.rofi-wayland;
plugins = [ pkgs.rofi-calc pkgs.rofi-emoji ];
# extraConfig = {
# "@theme" = "\"theme.rasi\"";
# };
theme = "theme.rasi";
};
programs.pistol.enable = true;
programs.lf =
(import ./lf.nix) { config = config; pkgs = pkgs; };
programs.fish = (import ./fish.nix) pkgs;
services.dunst.enable = true;
services.dunst.settings = import ./dunstconfig.nix;
services.kdeconnect.enable = true;
# programs.chromium = {
# enable = true;
# package = pkgs.ungoogled-chromium;
# dictioaries = [
# pkgs.hunspellDictsChromium.en_US
# pkgs.hunspellDictsChromium.fr_FR
# ];
# extensions = [
# { id = "cjpalhdlnbpafiamejdnhcphjbkeiagm"; } # ublock origin
# { id = "hfjbmagddngcpeloejdejnfgbamkjaeg"; } # vimium C
# ];
# };
programs.swaylock = {
enable = true;
package = pkgs.swaylock-effects;
# --screenshots \
# --clock \
# --indicator \
# --indicator-radius 100 \
# --indicator-thickness 7 \
# --effect-blur 7x5 \
# --effect-vignette 0.5:0.5 \
# --ring-color bb00cc \
# --key-hl-color 880033 \
# --line-color 00000000 \
# --inside-color 00000088 \
# --separator-color 00000000 \
# --grace 2 \
# --fade-in 0.2
settings = {
screenshots = true;
# clock = true;
font = "Sans:bold";
disable-caps-lock-text = true;
effect-blur = "7x5";
text-color = "ffffff";
layout-text-color = "ffffff";
ring-color = "000000";
key-hl-color = "dddddd";
line-color = "00000000";
inside-color = "00000088";
separator-color = "00000000";
ring-clear-color = "00000000";
line-clear-color = "00000000";
inside-clear-color = "00000000";
text-clear-color = "00000000";
};
};
services.swayidle = {
enable = true;
events = [{
event = "before-sleep";
command = "${config.programs.swaylock.package}/bin/swaylock -defF";
}
{
event = "after-resume";
command = "${config.wayland.windowManager.hyprland.package}/bin/hyprctl dispatch dpms on";
}
{
event = "lock";
command = "${config.programs.swaylock.package}/bin/swaylock -defF";
}];
timeouts = [{
timeout = 900;
command = "${config.programs.swaylock.package}/bin/swaylock -defF";
}
{
timeout = 900;
command = "${config.wayland.windowManager.hyprland.package}/bin/hyprctl dispatch dpms off";
}];
};
# services.swayidle = {
# enable = true;
# events = [
# { event = "after-resume"; command = "${pkgs.hyprland}/bin/hyprctl dispatch dpms on"; }
# ];
# timeouts = [{
# timeout = 10;
# command =
# "${pkgs.hyprland}/bin/hyprctl dispatch dpms off & swaylock";
# }];
#
# };
programs.kitty = {
enable = true;
font.name = "monospace";
font.size = 12;
settings = {
cursor_shape = "block";
default_pointer_shape = "arrow";
pointer_shape_when_dragging = "arrow";
enable_audio_bell = false;
placement_strategy = "top-left";
remember_window_size = false;
initial_window_width = 1300;
initial_window_height = 800;
confirm_os_window_close = 0;
resize_debounce_time = "0.1 0.1";
};
keybindings = {
"ctrl+shift+equal" = "change_font_size all +0.5";
"ctrl+shift+plus" = "change_font_size all +0.5";
"ctrl+shift+kp_add" = "change_font_size all +0.5";
"ctrl+shift+minus" = "change_font_size all -0.5";
"ctrl+shift+kp_subtract" = "change_font_size all -0.5";
};
shellIntegration.enableFishIntegration = true;
shellIntegration.mode = "no-cursor";
extraConfig = ''
include colors.conf
'';
};
programs.neovim = {
enable = true;
viAlias = true;
defaultEditor = true;
extraPackages = with pkgs; [
nodejs_22
gcc
ocamlPackages.lsp
ocamlPackages.ocamlformat
# rnix-lsp
cargo
];
};
programs.mpv = {
enable = true;
config = {
keep-open = "yes";
osd-bar = "no";
};
scripts = with pkgs.mpvScripts; [
uosc
thumbfast
mpris
];
};
programs.waybar.enable = true;
programs.firefox.enable = true;
programs.zathura.enable = true;
programs.tmux = {
enable = true;
historyLimit = 600000;
escapeTime = 10;
keyMode = "vi";
mouse = true;
extraConfig = ''
unbind-key 'Space'
bind-key 'Space' copy-mode
'';
};
programs.git = {
enable = true;
userName = user;
userEmail = "${user}@domain.xyz";
};
programs.home-manager.enable = true;
}