infra/nix/home-manager/home.nix
2026-01-05 23:09:19 +01:00

597 lines
15 KiB
Nix

{
config,
lib,
pkgs,
username,
hostName,
...
}: let
#dotfiles = builtins.fetchGit {
# # allRefs = true;
# url = "https://git.dotya.ml/wanderer/dotfiles";
# ref = "master";
# allRefs = true;
# rev = "817b220cddeb12725a658111af3f0c7ad39597a9";
# # rev = "ac2cc918f89e56537cdb384ba3fe1c4c71e0c825";
#};
# rev = "817b220cddeb12725a658111af3f0c7ad39597a9";
# rev = "9623ced23d5d7ca465a15be8f415f774a60035bb";
# rev = "e83a79d12b104b24a65b87d1327e6cab237ad175";
#rev = "1370e15be841bffc108db8b9fb58cb4aa85f08b2";
rev = "52119018c87d74dca268fd6e5a85bd5960dd717c";
dotfiles = builtins.fetchTarball {
url = "https://git.dotya.ml/wanderer/dotfiles.git/archive/${rev}.tar.gz";
# sha256 = "";
sha256 = "sha256-K0ahMidM7Oqrf2/JdBZsjaMXnMEkGVDpbmNwZ0puyyo=";
};
swayTgt = "sway-session.target";
start-waybar = pkgs.writeShellScriptBin "start-waybar" ''
export SWAYSOCK=/run/user/$(id -u)/sway-ipc.$(id -u).$(pgrep -f 'sway$').sock
${pkgs.waybar}/bin/waybar
'';
start-autotiling = pkgs.writeShellScriptBin "start-autotiling" ''
export SWAYSOCK=/run/user/$(id -u)/sway-ipc.$(id -u).$(pgrep -f 'sway$').sock
${pkgs.autotiling}/bin/autotiling
'';
in {
imports = [
# ./modules/desktop/waybar.nix
# ./modules/desktop/hypr.nix
# ./modules/desktop/wayland.nix
./modules/desktop/sway.nix
];
sops = {
defaultSopsFile = ../hosts/${hostName}/secrets.yaml;
# age.keyFile = "/run/secrets-rendered/sopsFile";
age.keyFile = "/run/secrets/rendered/sopsFile";
secrets = {
gitUsername.path = "%r/secrets/gitUsername";
gitConf.path = "${config.home.homeDirectory}/.config/git/config.${hostName}";
};
};
home = {
# username = lib.mkForce "${username}";
# homeDirectory = lib.mkForce "/home/${username}";
# enableNixpkgsReleaseCheck = false;
packages = with pkgs; [
actionlint
asciinema
asciiquarium
bat
bc
black
sqlite
bun
caddy
cliphist
cowsay
curlie
dig
dive
dogdns
doggo
entr
# eza
exif
exiftool
fd
feh
ffmpeg
figlet
file
git-lfs
# firefox-wayland
chromium
qutebrowser
fx
gcc
glow
gnumake
# go_1_23
go_1_25
gofumpt
golangci-lint
golangci-lint-langserver
gopls
goreleaser
gotools
graph-easy
hadolint
hugo
ipcalc
jq
killall
libnotify
libtelnet
lolcat
lsof
mpv-unwrapped
neofetch
netcat
networkmanagerapplet
# nixfmt
nixfmt-classic
nmap
nodePackages.prettier
nodePackages.typescript
nodePackages.typescript-language-server
nodePackages.yaml-language-server
nodejs
pciutils
pgcli
pulsemixer
pamixer
pavucontrol
pylint
ruff
python3
python3Packages.pipx
pre-commit
ripgrep
slsa-verifier
himalaya
# rnix-lsp
rsync
shellcheck
shfmt
signal-desktop
# slack
statix
p7zip
unzip
nautilus
# gnome.nautilus
# gnome.seahorse
seahorse
# gnome.eog
eog
gnome-tweaks
# gnome.gnome-tweaks
gnome-calculator
# gnome.gnome-calculator
tailscale-systray
yaru-theme
junction
usbutils
v4l-utils
wev
whois
xdg-utils
#youtube-dl
yt-dlp
yq-go
zathura
zip
azure-cli
azure-functions-core-tools
kdePackages.fcitx5-with-addons
];
# stateVersion = lib.mkForce "24.05";
# stateVersion = lib.mkForce "23.11";
};
dconf.enable = true;
dconf.settings = {
"org/gnome/desktop/interface" = {
color-scheme = "prefer-dark";
};
};
#gtk = {
# enable = true;
# iconTheme = {
# name = "Papirus-Dark";
# package = pkgs.papirus-icon-theme;
# };
# theme = {
# name = "palenight";
# package = pkgs.palenight-theme;
# };
# cursorTheme = {
# name = "Numix-Cursor";
# package = pkgs.numix-cursor-theme;
# };
# gtk3.extraConfig = {
# Settings = ''
# gtk-application-prefer-dark-theme=1
# '';
# };
# gtk4.extraConfig = {
# Settings = ''
# gtk-application-prefer-dark-theme=1
# '';
# };
#};
home.sessionVariables.GTK_THEME = "Dracula";
editorconfig.settings = {
"*" = {
charset = "utf-8";
end_of_line = "lf";
trim_trailing_whitespace = true;
insert_final_newline = true;
max_line_width = 78;
indent_style = "space";
indent_size = 4;
};
};
services = {
blueman-applet.enable = true;
network-manager-applet.enable = true;
avizo.enable = true;
batsignal = {
enable = true;
extraArgs = ["-w 25" "-c 15" "-d 10"];
};
};
systemd.user.services.avizo.Service = {
RestartSec = "5s";
Restart = "always";
};
programs = {
fzf = {
enable = true;
enableZshIntegration = true;
};
gh = {enable = true;};
home-manager = {enable = true;};
obs-studio = {
enable = true;
plugins = with pkgs.obs-studio-plugins; [wlrobs obs-pipewire-audio-capture obs-gstreamer];
};
vscode = {
enable = true;
package = pkgs.vscodium;
#extensions = with pkgs.vscode-extensions; [
# dracula-theme.theme-dracula
# vscodevim.vim
# yzhang.markdown-all-in-one
#];
};
};
# better eval time
manual = {
html.enable = false;
manpages.enable = true;
json.enable = false;
};
# https://rycee.gitlab.io/home-manager/options.html#opt-programs.ssh.matchBlocks
home.file = {
".config/kitty/kitty.conf" = {
source = "${dotfiles}/.config/kitty/kitty.conf";
};
".vimrc" = {
source = "${dotfiles}/.vim/vimrc";
};
".vim/deoplete.vimrc.vim" = {
source = "${dotfiles}/.vim/deoplete.vimrc.vim";
};
".vim/gotags.vimrc.vim" = {
source = "${dotfiles}/.vim/gotags.vimrc.vim";
};
".vim/python.vimrc.vim" = {
source = "${dotfiles}/.vim/python.vimrc.vim";
};
".config/nvim/init.vim" = {
source = "${dotfiles}/.config/nvim/init.vim";
};
".config/systemd/user.conf" = {
text = ''
[Manager]
DefaultTimeoutStarSec=15s
DefaultTimeoutStopSec=15s
'';
};
".config/sway/config.d/dracula.sway" = {
source = "${dotfiles}/.config/sway/config.d/dracula.sway";
};
".config/waybar/config" = {
source = "${dotfiles}/.config/waybar/config";
};
".config/waybar/style.css" = {
source = "${dotfiles}/.config/waybar/style.css";
};
".config/waybar/modules/storage.sh" = {
source = "${dotfiles}/.config/waybar/modules/storage.sh";
};
".config/kanshi/config" = let cfg = builtins.readFile "${dotfiles}/.config/kanshi/config"; in {
# source = "${dotfiles}/.config/kanshi/config";
text = ''
profile lg-v {
output "LG Electronics LG ULTRAFINE 401NTZNBX045" mode 2560x2160
output eDP-1 disable
}
profile lg-vAlt {
output "LG Electronics LG ULTRAFINE 401NTZNBX045" mode 2560x2160
output "eDP-1 BOE 0x07DB Unknown" disable
}
'' + cfg;
};
".config/mako/config" = {
source = "${dotfiles}/.config/mako/config";
};
".config/swaylock/config" = {
source = "${dotfiles}/.config/swaylock/config";
};
#".config/albert.conf" = {
# source = "${dotfiles}/.config/albert/albert.conf";
#};
".config/direnv/direnv.toml" = {
source = "${dotfiles}/.config/direnv/direnv.toml";
};
".config/git/config-common" = {
source = "${dotfiles}/.config/git/config";
};
# host-specific gitconfig.
# ".config/git/config.${hostName}" = {
#text = ''
# [user]
# name = ${hostName}
# email = wanderer@dotya.ml
# signingkey = ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIDAqwhsHHLKG7k7kDa7Tauy2V+rXqQFxiuMCdVltz0n1
#'';
# }
# source = config.sops.secrets.gitConf;
# text = ''
# [user]
# name = ${hostName}
# email = ${config.sops.secrets.gitUsername}
# signingkey = ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIDAqwhsHHLKG7k7kDa7Tauy2V+rXqQFxiuMCdVltz0n1
# '';
# };
".config/git/config" = {
text = ''
[include]
path = ~/.config/git/config-common
[include]
path = ~/.config/git/config.${hostName}
[alias]
fuckem = merge -s ours
'';
};
".config/git/allowed_signers" = {
source = "${dotfiles}/.config/git/allowed_signers";
};
".cargo/config.toml" = {
# source = "${dotfiles}/.cargo/config.toml";
text = ''
[build]
jobs = 4 # number of parallel jobs, defaults to # of CPUs
# rustc = ".cargo/bin/rustc" # the rust compiler tool
rustc-wrapper = "sccache" # enable sccache
[future-incompat-report]
frequency = 'always' # when to display a notification about a future incompat report
[http]
debug = false # HTTP debugging
ssl-version = "tlsv1.3" # TLS version to use
timeout = 30 # timeout for each HTTP request, in seconds
low-speed-limit = 10 # network timeout threshold (bytes/sec)
check-revoke = true # check for SSL certificate revocation
multiplexing = true # HTTP/2 multiplexing
[target.x86_64-unknown-linux-gnu]
rustflags = ["-C", "target-cpu=native"]
'';
};
".npmrc" = {
text = ''
prefix=''${HOME}/.npm-packages
audit=false
fund=false
'';
};
".config/tridactyl/tridactylrc" = {
source = "${dotfiles}/.config/tridactyl/tridactylrc";
};
".config/bat/config" = {
source = "${dotfiles}/.config/bat/config";
};
".ncpamixer.conf" = {
source = "${dotfiles}/.config/ncpamixer.conf";
};
".gdbinit" = {
text = ''
set auto-load safe-path /nix/store
set history save on
set history size 10000
set history remove-duplicates 100
set history filename ~/.gdb_history
'';
};
#".local/bin/winprint.sh" = {
# source = "${dotfiles}/bin/winprint.sh";
# executable = true;
#};
};
systemd.user.services = {
waybar = {
Unit = {
Description = "Highly customizable Wayland bar for Sway and Wlroots based compositors.";
Documentation = "https://github.com/Alexays/Waybar/wiki/";
PartOf = swayTgt;
After = swayTgt;
};
Service = {
Environment = "PATH=/run/current-system/sw/sbin:/run/current-system/sw/bin";
# ExecStart = "${start-waybar}/bin/start-waybar";
ExecStart = "${pkgs.waybar}/bin/waybar";
ExecReload = "kill -SIGUSR2 $MAINPID";
Restart = "on-failure";
RestartSec = "3s";
LockPersonality = true;
PrivateTmp = "yes";
DevicePolicy = "closed";
};
Install = {WantedBy = [swayTgt];};
};
autotiling = {
Unit = {
Description = "Script for sway and i3 to automatically switch the horizontal / vertical window split orientation";
Documentation = "https://github.com/nwg-piotr/autotiling";
BindsTo = swayTgt;
};
Service = {
Type = "simple";
# ExecStart = "${start-autotiling}/bin/start-autotiling";
ExecStart = "${pkgs.autotiling}/bin/autotiling";
Restart = "always";
RestartSec = "5s";
LockPersonality = true;
PrivateTmp = "yes";
DevicePolicy = "closed";
};
Install = {WantedBy = [swayTgt];};
};
# albert = {
# Unit = {
# Description = "A C++/Qt based desktop agnostic keyboard launcher that helps you to accomplish your workflows in a breeze";
# Documentation = "https://albertlauncher.github.io/";
# BindsTo = swayTgt;
# };
# Service = {
# Type = "simple";
# # after hm stateVersion bump to 23.05, albert doesn't seem to support explicit wayland.
# Environment = "QT_QPA_PLATFORM=xcb";
# ExecStart = "${pkgs.albert}/bin/albert";
# Restart = "always";
# RestartSec = "3s";
# LockPersonality = true;
# PrivateTmp = "yes";
# DevicePolicy = "closed";
# };
# Install = {WantedBy = [swayTgt];};
# };
kanshi = {
Unit = {
Description = "Dynamic output configuration for Wayland compositors";
# Documentation = "man:kanshi(1)";
Documentation = "https://sr.ht/~emersion/kanshi";
# BindsTo = config.services.kanshi.systemdTarget;
BindsTo = [swayTgt];
};
# Install = {WantedBy = [config.services.kanshi.systemdTarget];};
Install = {WantedBy = [swayTgt];};
Service = {
Type = "simple";
# ExecStart = "/usr/sbin/kanshi";
ExecStart = "${config.services.kanshi.package}/bin/kanshi";
Restart = "always";
RestartSec = "5s";
LockPersonality = true;
PrivateTmp = "yes";
DevicePolicy = "closed";
};
};
mako = {
Unit = {
Description = "Mako notification daemon";
BindsTo = [swayTgt];
};
Install = {
WantedBy = [swayTgt];
};
Service = {
Type = "dbus";
BusName = "org.freedesktop.Notifications";
ExecStart = "${pkgs.mako}/bin/mako";
RestartSec = 5;
Restart = "always";
};
};
## gopls = {
## Unit = {
## Description = "Go language server";
## };
## Service = let
## sock = "/tmp/.gopls-daemon.sock";
## c = pkgs.coreutils;
## script = "${c}/bin/rm -v -f ${sock} || ${c}/bin/true";
## in {
## Type = "simple";
## # Environment = "PATH=/run/current-system/sw/bin";
## # ExecStartPre = "${pkgs.bash}/bin/bash -c \"${script}\"";
## ExecStartPre = script;
## ExecStart = "%h/go/bin/gopls -listen=\"unix;${sock}\"";
## # ExecStartPost = "${pkgs.bash}/bin/bash -c \"${script}\"";
## ExecStartPost = script;
## Restart = "on-failure";
## RestartSec = "1m";
## TimeoutStopFailureMode = "abort";
## SystemCallFilter = "~@reboot @obsolete";
## ProtectProc = "invisible";
## ProcSubset = "pid";
## ProtectHome = "tmpfs";
## BindPaths = ["%h/.cache" "%h/go" "${sock}"];
## PrivateTmp = "no";
## RestrictNamespaces = true;
## NoNewPrivileges = "yes";
## ProtectSystem = "strict";
## DevicePolicy = "closed";
## LockPersonality = true;
## MemoryDenyWriteExecute = true;
## #RestrictAddressFamilies="AF_UNIX AF_INET AF_INET6";
## RestrictAddressFamilies = "AF_UNIX";
## RestrictRealtime = true;
## RestrictSUIDSGID = true;
## SystemCallArchitectures = "native";
## };
## Install = {WantedBy = ["default.target"];};
## };
};
#xdg = (import "${dotfiles}/nix/xdg.nix") {inherit pkgs config hostName;} // {configFile."aerc/aerc.conf"= {content = "";};};
xdg = (import "${dotfiles}/nix/xdg.nix") {inherit pkgs config hostName;};
}