{ flake, flakeInputs, userName, pkgs, customUtils, lib, config, sources, ... }@inputs:
with lib;
let
cfg = config.home-manager.users.${userName};
deHaskell = flakeInputs.nixpkgs-stable.legacyPackages.x86_64-linux.haskell.packages.ghc92.override (oldAttrs: {
overrides = pkgs.lib.composeExtensions (oldAttrs.overrides or (_: _: {}))
(hself: hsuper: {
dbus = pkgs.haskell.lib.doJailbreak hsuper.dbus;
});
});
xmonad = import ./xmonad deHaskell;
emacsScratch = pkgs.stdenv.mkDerivation (sources.emacs-scratch_el // rec {
phases = [ "installPhase" ];
installPhase = ''
mkdir -p $out/share/emacs/site-lisp
cp $src/scratch.el $out/share/emacs/site-lisp/default.el
'';
});
muteScript = pkgs.stdenv.mkDerivation {
name = "mute";
src = ./scripts/mute.zsh;
buildInputs = with pkgs; [ makeWrapper ];
phases = [ "installPhase" ];
installPhase = ''
mkdir -p $out/bin
install -m 0755 $src $out/bin/mute
wrapProgram $out/bin/mute \
--prefix PATH : ${pkgs.zsh}/bin \
--prefix PATH : ${pkgs.findutils}/bin \
--prefix PATH : ${pkgs.util-linux}/bin \
--prefix PATH : ${pkgs.coreutils}/bin \
--prefix PATH : ${pkgs.pulseaudio}/bin
'';
};
wrapElectron = { package, bin ? package.meta.mainProgram or package.pname or (pkgs.lib.strings.nameFromURL package.name "-"), outBin ? bin, sandbox ? true }: pkgs.runCommand "${package.name}-wrapped" { buildInputs = with pkgs; [ makeWrapper ]; } ''
mkdir -p "$out/bin"
makeWrapper ${package}/bin/${bin} $out/bin/${outBin} \
${optionalString (!sandbox) "--add-flags '--no-sandbox'"}
'';
wrappedChrome = wrapElectron { package = pkgs.google-chrome; outBin = "google-chrome"; };
wrappedZulip = wrapElectron { package = pkgs.zulip; bin = "zulip"; outBin = "zulip"; };
wrappedElementDesktop = wrapElectron { package = pkgs.element-desktop; bin = "element-desktop"; outBin = "element"; };
wrappedRocketChatDesktop = wrapElectron { package = pkgs.rocketchat-desktop; bin = "rocketchat-desktop"; outBin = "rocketchat"; };
wrappedYTMDesktop = wrapElectron { package = pkgs.ytmdesktop; sandbox = false; };
wrappedKeepassxc = pkgs.symlinkJoin {
inherit (pkgs.keepassxc) name;
paths = with pkgs; [
keepassxc
(pkgs.writeTextFile {
name = "org.keepassxc.KeePassXC";
destination = "/share/dbus-1/services/org.keepassxc.KeePassXC.MainWindow.service";
text = ''
[D-BUS Service]
Name=org.keepassxc.KeePassXC.MainWindow
Exec=${pkgs.coreutils}/bin/false
SystemdService=keepassxc.service
'';
})
(pkgs.writeTextFile {
name = "org.freedesktop.secrets";
destination = "/share/dbus-1/services/org.freedesktop.secrets.service";
text = ''
[D-BUS Service]
Name=org.freedesktop.secrets
Exec=${pkgs.coreutils}/bin/false
SystemdService=keepassxc.service
'';
})
];
};
nvidiaOffloadScript = pkgs.writeShellScriptBin "nvidia-offload" ''
export __NV_PRIME_RENDER_OFFLOAD=1
export __NV_PRIME_RENDER_OFFLOAD_PROVIDER=NVIDIA-G0
export __GLX_VENDOR_LIBRARY_NAME=nvidia
export __VK_LAYER_NV_optimus=NVIDIA_only
exec -a "$1" "$@"
'';
in {
imports = with flake.nixosModules.userProfiles.${userName}; [
mpv yt-dlp (args: import ./xcompose.nix (inputs // args))
];
config = {
services.displayManager.defaultSession = "none+xmonad";
services.xserver = {
windowManager.session = [{
name = "xmonad";
start = ''
${pkgs.systemd}/bin/systemd-cat -t xmonad -- ${pkgs.coreutils}/bin/env -u SHLVL -- ${xmonad}/bin/xmonad &
waitPID=$!
'';
}];
};
home-manager.users.${userName} = {
imports = [
flakeInputs.nix-index-database.hmModules.nix-index
flakeInputs.impermanence.nixosModules.home-manager.impermanence
];
home.stateVersion = "20.09";
nixpkgs.config = {
allowUnfree = true;
zathura.useMupdf = false;
};
nix.registry = {
"flk" = {
from = {
type = "indirect";
id = "flk";
};
to = {
type = "git";
url = "file:///home/gkleen/config/nixos-flakes";
};
};
};
programs = {
ssh = {
matchBlocks = import ./ssh-hosts.nix { inherit pkgs; }; # customUtils.nixImport { dir = ./ssh-hosts; };
extraConfig = ''
Match host uniworx3.ifi.lmu.de,uniworx4.ifi.lmu.de,uniworx5.ifi.lmu.de,uni2workgw.ifi.lmu.de,blackbeard.tcs.ifi.lmu.de,gitlab2.rz.ifi.lmu.de,oregon.tcs.ifi.lmu.de !exec "nc -z -w 1 %h %p &>/dev/null"
ProxyJump remote.cip.ifi.lmu.de
Match host *.mathinst.loc,*.cipmath.loc,*.math.lmu.de
IdentityFile ~/.ssh/gkleen@mathinst.loc
HostKeyAlgorithms +ssh-rsa
PubkeyAcceptedAlgorithms +ssh-rsa
ConnectTimeout 30
PasswordAuthentication yes
KbdInteractiveAuthentication yes
UpdateHostKeys yes
GlobalKnownHostsFile ${pkgs.writeText "ssh_known_hosts" ''
@cert-authority *.mathinst.loc,*.math.lmu.de,*.cipmath.loc ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIBUTFpVCdETCXiDSDl7YGbR1J4BLTsoBzjDtflHJGO/z ssh-pki@mgmt01
''}
Match host *.mathinst.loc,*.math.lmu.de !host ssh.math.lmu.de !exec "nc -z -w 1 %h %p &>/dev/null"
# ProxyCommand ${pkgs.socat}/bin/socat - SOCKS4A:127.0.0.1:%h:%p,socksport=8118
ProxyJump ssh.math.lmu.de
Match host *.cipmath.loc !host cip04.cipmath.loc,mgmt-cls01.cipmath.loc !exec "nc -z -w 1 %h %p &>/dev/null"
ProxyJump cip04
Match host *.ifi.lmu.de,*.math.lmu.de
AddressFamily inet
Match host *.mgmt.yggdrasil
ProxyJump vidhar
Host *
'';
};
emacs = {
enable = true;
package = pkgs.emacs29-pgtk;
extraPackages = epkgs: with epkgs; [
evil evil-dvorak undo-tree magit haskell-mode nix-mode
yaml-mode json-mode shakespeare-mode smart-mode-line
highlight-parentheses highlight-symbol ag sass-mode lua-mode
fira-code-mode use-package wanderlust # notmuch
use-package-ensure-system-package git-gutter emacsScratch
edit-server mediawiki editorconfig typescript-mode
markdown-mode nftables-mode rustic lsp-mode lsp-ui
direnv company projectile tomorrow-night-paradise-theme
];
overrides = self: super: {
tomorrow-night-paradise-theme = super.trivialBuild {
inherit (sources.tomorrow-night-paradise-theme) pname version src;
};
};
};
firefox = {
enable = true;
profiles.default = {
settings = {
# "layout.css.devPixelsPerPx" = "0.5833";
"browser.tabs.drawInTitlebar" = false;
"toolkit.legacyUserProfileCustomizations.stylesheets" = true;
"dom.security.https_only_mode" = true;
};
};
};
alacritty = {
enable = true;
settings = import ./alacritty.nix;
};
zathura.enable = true;
mpv.config = {
demuxer-max-bytes = 1073741824;
demuxer-max-back-bytes = 268435456;
# gpu-api = "vulkan";
};
autorandr = {
enable = true;
hooks = {
preswitch = {
"stop-tray" = ''
${pkgs.systemd}/bin/systemctl --user try-restart tray.target
'';
};
postswitch = {
# "restart-compton" = "${pkgs.systemd}/bin/systemctl --user try-restart picom";
"restart-tray" = ''
${pkgs.systemd}/bin/systemctl --user try-restart tray.target
'';
};
};
profiles = customUtils.nixImport rec { dir = ./autorandr-profiles; _import = name: _base: import "${toString dir}/${name}" inputs; };
};
zsh.initExtra = "source ${./zshrc}";
zsh.dirHashes = let
flakeHashes = mapAttrs' (n: v: nameValuePair (inputNames.${n} or n) (toString v)) flakeInputs;
inputNames = {
"nixpkgs" = "nixos";
};
in flakeHashes // {
u2w = "$HOME/projects/uni2work";
docs = "$HOME/documents";
dl = "$HOME/Downloads";
scrot = "$HOME/screenshots";
flk = "$HOME/projects/machines";
rz = "$HOME/projects/rz";
pro = "$HOME/projects/pro";
};
obs-studio = {
enable = true;
plugins = with pkgs; [];
};
gh = {
enable = true;
settings = {
editor = "${config.home-manager.users.${userName}.programs.emacs.package}/bin/emacsclient";
gitProtocol = "ssh";
};
};
kitty = {
enable = true;
font = {
package = pkgs.fira;
name = "FiraMono Nerd Font";
size = 10;
};
settings = {
enable_audio_bell = false;
update_check_interval = 0;
strip_trailing_spaces = "smart";
focus_follows_mouse = true;
visual_bell_duration = "0.1";
visual_bell_color = "#26240d";
tab_bar_style = "powerline";
tab_powerline_style = "slanted";
notify_on_cmd_finish = "invisible 300.0";
};
};
wofi = {
enable = true;
settings = {
location = "top";
run-always_parse_args = true;
run-show_all = false;
};
};
waybar = {
enable = true;
systemd = {
enable = true;
target = "hyprland-session.target";
};
settings = let
windowRewrites = {
"(.*) — Mozilla Firefox" = "$1";
"(.*) - Mozilla Thunderbird" = "$1";
"(.*) - mpv" = "$1";
};
iconSize = 14;
in [
{
layer = "top";
position = "top";
height = 14;
output = "eDP-1";
modules-left = [ "hyprland/workspaces" ];
modules-center = [ "hyprland/window" ];
modules-right = [ "privacy" "clock" "tray" "battery" ];
"hyprland/workspaces" = {
all-outputs = true;
};
"hyprland/window" = {
separate-outputs = true;
icon = true;
icon-size = iconSize;
rewrite = windowRewrites;
};
clock = {
interval = 1;
timezone = "Europe/Berlin";
format = "W{:%V-%u %F %H:%M:%S%Ez}";
tooltip-format = "{calendar}";
calendar = {
mode = "year";
mode-mon-col = 3;
weeks-pos = "left";
on-scroll = 1;
format = {
months = "{}";
days = "{}";
weeks = "{}";
weekdays = "{}";
today = "{}";
};
};
};
battery = {
format = "{icon}";
format-icons = ["" "" "" "" ""];
tooltip-format = "{capacity}% {timeTo}";
};
tray = {
icon-size = iconSize;
# show-passive-items = true;
spacing = 2;
};
privacy = {
icon-spacing = 2;
icon-size = iconSize;
modules = [ { type = "screenshare"; } { type = "audio-in"; } ];
};
}
{
layer = "top";
position = "top";
height = 14;
output = "!eDP-1";
modules-left = [ "hyprland/workspaces" ];
modules-center = [ "hyprland/window" ];
modules-right = [ "clock" ];
"hyprland/workspaces" = {
all-outputs = false;
};
"hyprland/window" = {
separate-outputs = true;
icon = true;
icon-size = iconSize;
rewrite = windowRewrites;
};
clock = {
interval = 1;
timezone = "Europe/Berlin";
format = "{:%H:%M}";
tooltip-format = "W{:%V-%u %F %H:%M:%S%Ez}";
};
}
];
style = ''
@define-color white #dddddd;
@define-color blue #1a8fff;
@define-color green #23fd00;
@define-color red #f2201f;
* {
border: none;
font-family: "Fira Sans";
font-size: 10pt;
min-height: 0;
}
window#waybar {
background-color: rgba(0, 0, 0, 0.5);
color: @white;
}
label.module {
margin: 0 5px;
}
#workspaces button.visible {
color: @blue;
}
#workspaces button.active {
color: @green;
}
#workspaces button.urgent {
color: @red;
}
#workspaces button.empty {
opacity: 0.5;
}
'';
};
wpaperd = {
enable = true;
settings.default = {
path = "~/.wallpapers";
duration = "8h";
mode = "center";
};
};
hyprlock = {
enable = false;
settings = {
general = {
disable_loading_bar = false;
grace = 60;
hide_cursor = true;
no_fade_in = false;
};
background = [
{
path = "screenshot";
blur_passes = 3;
blur_size = 8;
}
];
input-field = [
{
size = "200, 50";
position = "0, -80";
monitor = "";
dots_center = true;
fade_on_empty = false;
font_color = "rgb(202, 211, 245)";
inner_color = "rgb(91, 96, 120)";
outer_color = "rgb(24, 25, 38)";
outline_thickness = 5;
placeholder_text = "'Password...'";
shadow_passes = 2;
}
];
};
};
};
services = {
dunst = {
settings = import ./dunst-settings.nix inputs;
iconTheme = cfg.gtk.iconTheme;
enable = true;
};
emacs = {
enable = true;
socketActivation.enable = true;
client = {
enable = true;
arguments = mkForce ["-a" "\"\""];
};
};
gpg-agent = {
enable = true;
enableSshSupport = true;
extraConfig = ''
pinentry-program ${pkgs.pinentry-gtk2}/bin/pinentry
grab
'';
};
taffybar = {
enable = false;
package = import ./taffybar { haskellPackages = deHaskell; };
};
# status-notifier-watcher.enable = true;
xembed-sni-proxy.enable = true;
pasystray.enable = true;
udiskie = {
enable = true;
automount = false;
settings = {
program_options = {
file_manager = "";
};
notification_actions = {
device_mounted = [];
};
};
};
unclutter = {
enable = false;
timeout = 5;
};
network-manager-applet.enable = true;
blueman-applet.enable = true;
sxhkd = {
enable = true;
keybindings = {
"button8" = "${muteScript}/bin/mute unmute";
"@button8" = "${muteScript}/bin/mute mute";
"button9" = "${pkgs.pulseaudio}/bin/pacmd set-sink-mute @DEFAULT_SINK@ 1";
"@button9" = "${pkgs.pulseaudio}/bin/pacmd set-sink-mute @DEFAULT_SINK@ 0";
};
};
unison = {
enable = true;
pairs = {
documents = {
roots = ["${cfg.home.homeDirectory}/documents" "ssh://unison.vidhar/documents"];
stateDirectory = "${cfg.xdg.dataHome}/documents.unison";
commandOptions = {
auto = "true";
batch = "true";
log = "false";
repeat = "watch";
sshcmd = "${pkgs.openssh}/bin/ssh";
ui = "text";
};
};
};
};
easyeffects = {
enable = true;
preset = "LoudnessEqualizer";
};
screen-locker = {
enable = false;
lockCmd = toString (pkgs.writeShellScript "lock" ''
${pkgs.playerctl}/bin/playerctl -a status | ${pkgs.gnugrep}/bin/grep -q "Playing" && exit 0
cleanup() {
${cfg.services.dunst.package}/bin/dunstctl set-paused false
}
trap cleanup EXIT INT TERM
# ${pkgs.playerctl}/bin/playerctl -a pause
${cfg.services.dunst.package}/bin/dunstctl set-paused true
${pkgs.xsecurelock}/bin/xsecurelock
'');
xss-lock.extraOptions = ["--transfer-sleep-lock"];
};
etesync-dav = {
enable = true;
serverUrl = "https://etesync.yggdrasil.li";
};
hypridle = {
enable = false;
settings = {
general = {
after_sleep_cmd = "hyprctl dispatch dpms on";
before_sleep_cmd = "hyprlock";
ignore_dbus_inhibit = false;
ignore_systemd_inhibit = false;
lock_cmd = "hyprlock";
};
listener = [
{
timeout = 300;
on-timeout = "hyprlock";
}
{
timeout = 600;
on-timeout = "hyprctl dispatch dpms off";
on-resume = "hyprctl dispatch dpms on";
}
];
};
};
swayidle = {
enable = true;
events = [
{ event = "before-sleep"; command = "${lib.getExe pkgs.gtklock} -d"; }
{ event = "after-resume"; command = "${cfg.wayland.windowManager.hyprland.package}/bin/hyprctl dispatch dpms on"; }
{ event = "lock"; command = "${lib.getExe pkgs.gtklock} -d"; }
];
timeouts = [
{ timeout = 300;
command = "${cfg.wayland.windowManager.hyprland.package}/bin/hyprctl dispatch dpms off";
resumeCommand = "${cfg.wayland.windowManager.hyprland.package}/bin/hyprctl dispatch dpms on";
}
{ timeout = 330; command = "${lib.getExe pkgs.gtklock} -d"; }
];
};
};
home.pointerCursor = {
package = pkgs.vanilla-dmz;
name = "Vanilla-DMZ-AA";
size = 32;
x11 = {
enable = true;
defaultCursor = "left_ptr";
};
gtk.enable = true;
};
gtk = {
enable = true;
font = {
package = pkgs.fira;
name = "Fira Sans";
size = 10;
};
theme = {
package = pkgs.equilux-theme;
name = "Equilux-compact";
};
iconTheme = {
package = pkgs.paper-icon-theme;
name = "Paper";
};
};
xsession = {
enable = true;
initExtra = ''
${pkgs.xorg.xinput}/bin/xinput disable 'Synaptics TM3512-010'
${pkgs.xorg.xmodmap}/bin/xmodmap -e 'keysym Caps_Lock = Multi_key'
'';
preferStatusNotifierItems = true;
};
xresources.properties = import ./xresources.nix;
home = {
packages = with pkgs; [
fira fira-code powerline-fonts nerdfonts pavucontrol
wrappedKeepassxc sxiv xclip mumble pulseaudio-ctl pamixer
libnotify synergy xorg.xbacklight screen-message
wrappedYTMDesktop qt5ct playerctl evince thunderbird
wrappedZulip zoom-us steam steam-run wireshark virt-manager
rclone cached-nix-shell xournal xmonad worktime
fira-code-symbols libreoffice xournalpp wrappedChrome
nixos-shell virt-viewer freerdp gnome-icon-theme
paper-icon-theme sshpassSecret weechat wrappedElementDesktop
matrix-synapse-tools.synadm wrappedRocketChatDesktop
flakeInputs.deploy-rs.packages.${config.nixpkgs.system}.deploy-rs
sieve-connect gimp inkscape udiskie glab scrot nitrokey-app
pynitrokey gtklock wlrctl nvidiaOffloadScript
];
file = {
".emacs".source = ./emacs.el;
".backup-munin".source = ./backup-patterns;
".mozilla/firefox/default/chrome/userChrome.css".source = ./firefox-chrome.css;
".mozilla/firefox/default/chrome/userContent.css".source = ./firefox-content.css;
".local/share/etesync-dav/CACHEDIR.TAG".text = ''
Signature: 8a477f597d28d172789f06886806bc55
'';
".cups/client.conf".text = ''
ServerName cups.mathinst.loc
'';
};
sessionVariables = {
# GDK_SCALE = 96.0 / 282.0;
# QT_AUTO_SCREEN_SCALE_FACTOR = 1;
QT_QPA_PLATFORMTHEME = "qt5ct";
LIBVIRT_DEFAULT_URI = "qemu:///system";
STACK_XDG = 1;
};
extraProfileCommands = ''
export XDG_DATA_DIRS="${pkgs.gsettings-desktop-schemas}/share/gsettings-schemas/${pkgs.gsettings-desktop-schemas.name}:${pkgs.gtk3}/share/gsettings-schemas/${pkgs.gtk3.name}''${XDG_DATA_DIRS:+:''${XDG_DATA_DIRS}}"
'';
};
xdg.configFile = {
"dunst/dunstrc.d" = {
source = ./dunstrc.d;
recursive = true;
onChange = ''
${pkgs.systemd}/bin/systemctl --user try-restart dunst
'';
};
"wireplumber" = {
source = ./wireplumber;
recursive = true;
onChange = ''
${pkgs.systemd}/bin/systemctl --user try-restart wireplumber
'';
};
"stack/config.yaml" = {
source = (pkgs.formats.yaml {}).generate "config.yaml" {
recommend-stack-upgrade = false;
};
};
"gtklock/config.ini" = {
source = (pkgs.formats.ini {}).generate "config.ini" {
};
};
};
xdg.dataFile = {
"pandoc/abbreviations" = {
source = pkgs.runCommand "pandoc-abbreviations" {
buildInputs = [ pkgs.pandoc pkgs.coreutils ];
} (let
germanAbbrevs = pkgs.fetchFromGitHub {
owner = "jfilter";
repo = "german-abbreviations";
rev = "8eb9dae93b6f05d7c53374cd217ab2dc89558e0c";
sha256 = "SaD3tSqzen6Y3SPICe6/9vhe4iMHlArZ3kFQaEk7Hps=";
};
in ''
cat \
<(pandoc --print-default-data-file=abbreviations) \
<(grep -E '^[^ ]+\.$' ${germanAbbrevs}/german_abbreviations.txt) \
${pkgs.writeText "abbrevs.txt" ''
i.A.
d.h.
D.h.
gdw.
''} \
| sort | uniq >$out
'');
};
"dbus-1/services/org.keepassxc.KeePassXC.service".source = "${wrappedKeepassxc}/share/dbus-1/services/org.keepassxc.KeePassXC.service";
"dbus-1/services/org.freedesktop.secrets.service.service".source = "${wrappedKeepassxc}/share/dbus-1/services/org.freedesktop.secrets.service.service";
};
xdg.mimeApps = {
enable = true;
defaultApplications = let
filters = {
};
doFilter = n: v: (filters.${n} or id) (filter (d: d != "emacs.desktop") v);
in mapAttrs doFilter (cfg.lib.xdg.mimeAssociations [
cfg.programs.zathura.package
pkgs.sxiv
cfg.programs.emacs.package
cfg.programs.firefox.package
]) // {
"x-scheme-handler/mailto" = "thunderbird.desktop";
};
};
fonts = {
fontconfig.enable = true;
lmu-hausschrift.enable = true;
};
systemd.user = import ./systemd.nix inputs;
dconf.settings = {
"org/gnome/desktop/interface" = {
color-scheme = "prefer-dark";
};
};
wayland.windowManager.hyprland = {
enable = true;
settings = import ./hyprland.nix inputs;
};
};
};
}