nixfiles/home-manager/modules/ezpcusr.nix
2021-09-27 16:42:21 -07:00

1068 lines
31 KiB
Nix
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

inputs:
{ config, lib, pkgs, ... }:
with lib;
let
cfg = config.ezpcusr;
elm-format-working = pkgs.elmPackages.elm-format.overrideAttrs (_: { doCheck = false; });
flameshot = pkgs.flameshot.overrideAttrs (super: {
src = builtins.fetchGit {
url = "https://github.com/flameshot-org/flameshot.git";
rev = "f24bae0a18ae59b5937ceee6d466b928d5f4c65f";
};
});
selshot = pkgs.writeScript "selshot.sh" (
if cfg.wayland then ''
#!${pkgs.zsh}/bin/zsh
${pkgs.grim}/bin/grim -g "$(${pkgs.slurp}/bin/slurp)" $1
'' else ''
#!${pkgs.zsh}/bin/zsh
${flameshot}/bin/flameshot gui -r > $1
''
);
selvid = pkgs.writeScript "selvid.sh" ''
#!${pkgs.zsh}/bin/zsh
${pkgs.wf-recorder}/bin/wf-recorder -g "$(${pkgs.slurp}/bin/slurp)" -f $1
'';
getscrloc = pkgs.writeScript "getscrloc.sh" ''
#!${pkgs.zsh}/bin/zsh
mkdir -p "$HOME/Pictures/Screenshots"
echo "$HOME/Pictures/Screenshots/$(date +%F_%T).''${1:-png}"
'';
copyBin =
if cfg.wayland then
"${pkgs.wl-clipboard}/bin/wl-copy"
else
"${pkgs.xclip}/bin/xclip -selection clipboard";
pasteBin =
if cfg.wayland then
"${pkgs.wl-clipboard}/bin/wl-paste"
else
"${pkgs.xclip}/bin/xclip -selection clipboard -o";
# rofiBin = if cfg.wayland then "${pkgs..wofi}/bin/wofi" else "${pkgs.rofi}/bin/rofi";
rofiBin = "${pkgs.rofi}/bin/rofi";
scrsaveclip = pkgs.writeScript "scr-save-clip.sh" ''
#!${pkgs.zsh}/bin/zsh
LOC=$(${getscrloc})
${selshot} $LOC
${copyBin} -t image/png < $LOC
'';
scrsaveup =
if cfg.uploadScript != null then
pkgs.writeScript "scr-save-up.sh" ''
#!${pkgs.zsh}/bin/zsh
LOC=$(${getscrloc})
${selshot} $LOC
${cfg.uploadScript} $LOC | xargs echo -n | ${copyBin}
notify-send "Screenshot Uploaded!"
''
else
null;
scrvidsaveclip = pkgs.writeScript "scr-vid-save-clip.sh" ''
#!${pkgs.zsh}/bin/zsh
LOC=$(${getscrloc} mp4)
${selvid} $LOC
${copyBin} -t video/mp4 < $LOC
'';
scrvidsaveup =
if cfg.uploadScript != null then
pkgs.writeScript "scr-vid-save-up.sh" ''
#!${pkgs.zsh}/bin/zsh
LOC=$(${getscrloc} mp4)
${selvid} $LOC
${cfg.uploadScript} $LOC | ${pkgs.findutils}/bin/xargs echo -n | ${copyBin}
notify-send "Screen Recording Uploaded!"
''
else
null;
scrvidstop = pkgs.writeScript "scr-vid-stop.sh" ''
#!${pkgs.zsh}/bin/zsh
${pkgs.procps}/bin/pkill -2 wf-recorder
'';
um = pkgs.writeScript "update-music.sh" ''
#!${pkgs.bash}/bin/bash
${pkgs.mpc_cli}/bin/mpc update --wait && ${pkgs.mpc_cli}/bin/mpc clear && ${pkgs.mpc_cli}/bin/mpc ls | ${pkgs.mpc_cli}/bin/mpc add
'';
ezDrv =
pkgs.runCommand "ez-commands"
{ }
(
''
mkdir -p $out/bin
ln -s ${selshot} $out/bin/selshot
ln -s ${selvid} $out/bin/selvid
ln -s ${getscrloc} $out/bin/getscrloc
ln -s ${scrsaveclip} $out/bin/scrsaveclip
ln -s ${scrvidsaveclip} $out/bin/scrvidsaveclip
ln -s ${scrvidstop} $out/bin/scrvidstop
ln -s ${um} $out/bin/um
'' + (
if cfg.uploadScript != null then ''
ln -s ${cfg.uploadScript} $out/bin/upload_file
ln -s ${scrsaveup} $out/bin/scrsaveup
ln -s ${scrvidsaveup} $out/bin/scrvidsaveup
'' else
""
)
);
rofiMenu =
if cfg.wayland then
"${rofiBin} -show drun -show-icons -run-command 'swaymsg exec -- {cmd}'"
else
"${rofiBin} -show drun -show-icons";
swayConfig = {
enable = true;
config = {
terminal = "kitty";
modifier = "Mod4";
keybindings =
let
musicRofi = pkgs.writeScript "music-rofi" ''
#!${pkgs.fish}/bin/fish
${pkgs.mpc_cli}/bin/mpc -f "%position% - %artist% - %album% - %title%" playlist | ${rofiBin} -dmenu -i | ${pkgs.coreutils}/bin/cut -d " " -f 1 | ${pkgs.findutils}/bin/xargs ${pkgs.mpc_cli}/bin/mpc play
'';
# ugly stupid way of doing things but im lazy
bwRofi = pkgs.writeScript "bw-rofi" ''
#!${pkgs.bash}/bin/bash
export BW_SESSION="${cfg.bitwardenSession}"
LIST=$(${pkgs.bitwarden-cli}/bin/bw list items)
USERLIST=$(echo "$LIST" | ${pkgs.jq}/bin/jq -r '.[] | "\(.name) - \(.login.username)"')
CHOSEN=$(echo "$USERLIST" | ${rofiBin} -dmenu -i)
NUMBER=$(echo "$USERLIST" | grep -n "^$CHOSEN$" | cut -d':' -f1)
NTH=$(expr $NUMBER - 1)
echo "$LIST" | ${pkgs.jq}/bin/jq -j -r ".[$NTH].login.password" | ${copyBin}
'';
# very ugly stupid way of doing things but im still lazy
bwRofiOtp = pkgs.writeScript "bw-rofi-otp" ''
#!${pkgs.bash}/bin/bash
export BW_SESSION="${cfg.bitwardenSession}"
LIST=$(${pkgs.bitwarden-cli}/bin/bw list items)
USERLIST=$(echo "$LIST" | ${pkgs.jq}/bin/jq -r '.[] | "\(.name) - \(.login.username)"')
CHOSEN=$(echo "$USERLIST" | ${rofiBin} -dmenu -i)
NUMBER=$(echo "$USERLIST" | grep -n "^$CHOSEN$" | cut -d':' -f1)
NTH=$(expr $NUMBER - 1)
ID=$(echo "$LIST" | ${pkgs.jq}/bin/jq -j -r ".[$NTH].id")
${pkgs.bitwarden-cli}/bin/bw get totp $ID | ${copyBin}
'';
# reeeeeeeeeeee ugly
emojiRofi =
let
# emojiTxt = builtins.toFile "emojis.txt" (builtins.readFile ../data/emojis.txt);
emojiTxt = toString ../data/emojis.txt;
in
pkgs.writeScript "rofi-emoji" ''
line=$(${pkgs.coreutils}/bin/cat ${emojiTxt} | ${rofiBin} -dmenu -i)
${pkgs.coreutils}/bin/echo ''${line::1} | ${copyBin}
'';
configPlace =
if cfg.wayland then
config.wayland.windowManager.sway
else
config.xsession.windowManager.i3;
alphabet = [
"${if cfg.wayland then "Ctrl" else "Control"}"
"${if cfg.wayland then "Alt" else "Mod1"}"
"${if cfg.wayland then "Ctrl" else "Control"}+${if cfg.wayland then "Alt" else "Mod1"}"
];
char = n: builtins.elemAt alphabet ((n - 1) / 10);
in
lib.mkOptionDefault (
cfg.keybindings // lib.listToAttrs (
map
(
n: {
name = "${configPlace.config.modifier}+${char (n - 10)}+${
toString (lib.mod n 10)
}";
value = "workspace ${toString n}";
}
)
(lib.lists.range 11 (10 * (builtins.length alphabet) + 10))
)
// lib.listToAttrs (
map
(
n: {
name = "${configPlace.config.modifier}+Shift+${char (n - 10)}+${
toString (lib.mod n 10)
}";
value = "move container to workspace ${toString n}";
}
)
(lib.lists.range 11 (10 * (builtins.length alphabet) + 10))
) // (
let
volumeUp = "exec ${pkgs.pulseaudio}/bin/pactl set-sink-volume @DEFAULT_SINK@ +5%";
volumeDown = "exec ${pkgs.pulseaudio}/bin/pactl set-sink-volume @DEFAULT_SINK@ -5%";
in
{
"Print" = "exec ${scrsaveclip}";
"Shift+Print" =
if cfg.uploadScript != null then "exec ${scrsaveup}" else "nop";
"${if cfg.wayland then "Ctrl" else "Control"}+Print" =
"exec ${scrvidsaveclip}";
"${if cfg.wayland then "Ctrl" else "Control"}+${if cfg.wayland then "Alt" else "Mod1"
}+Print" = "exec ${scrvidstop}";
"${configPlace.config.modifier}+minus" = volumeDown;
"${configPlace.config.modifier}+equal" = volumeUp;
"XF86AudioRaiseVolume" = volumeUp;
"XF86AudioLowerVolume" = volumeDown;
"XF86AudioMute" =
"exec ${pkgs.pulseaudio}/bin/pactl set-sink-mute @DEFAULT_SINK@ toggle";
"XF86AudioMicMute" =
"exec ${pkgs.pulseaudio}/bin/pactl set-source-mute @DEFAULT_SOURCE@ toggle";
"XF86MonBrightnessDown" = "exec ${pkgs.light}/bin/light -U 10";
"XF86MonBrightnessUp" = "exec ${pkgs.light}/bin/light -A 10";
"${configPlace.config.modifier}+semicolon" =
"exec ${pkgs.light}/bin/light -U 10";
"${configPlace.config.modifier}+apostrophe" =
"exec ${pkgs.light}/bin/light -A 10";
# Previous/next but change the shuffle/random state before action (and change back afterwards)
"${configPlace.config.modifier}+Shift+bracketright" =
"exec ${pkgs.mpc_cli}/bin/mpc random && ${pkgs.mpc_cli}/bin/mpc next && ${pkgs.mpc_cli}/bin/mpc random";
"${configPlace.config.modifier}+Shift+bracketleft" =
"exec ${pkgs.mpc_cli}/bin/mpc random && ${pkgs.mpc_cli}/bin/mpc prev && ${pkgs.mpc_cli}/bin/mpc random";
"Shift+XF86AudioNext" =
"exec ${pkgs.mpc_cli}/bin/mpc random && ${pkgs.mpc_cli}/bin/mpc next && ${pkgs.mpc_cli}/bin/mpc random";
# Previous/next
"${configPlace.config.modifier}+bracketright" =
"exec ${pkgs.mpc_cli}/bin/mpc next";
"${configPlace.config.modifier}+bracketleft" =
"exec ${pkgs.mpc_cli}/bin/mpc prev";
"XF86AudioNext" = "exec ${pkgs.mpc_cli}/bin/mpc next";
"XF86AudioPrev" = "exec ${pkgs.mpc_cli}/bin/mpc prev";
# Toggle play/pause
"XF86AudioPlay" = "exec ${pkgs.mpc_cli}/bin/mpc toggle";
"XF86AudioPause" = "exec ${pkgs.mpc_cli}/bin/mpc toggle";
"${configPlace.config.modifier}+backslash" =
"exec ${pkgs.mpc_cli}/bin/mpc toggle";
"${configPlace.config.modifier}+m" = "exec ${musicRofi}";
# "${configPlace.config.modifier}+Shift+m" = "exec ${magicMudl}";
"${configPlace.config.modifier}+p" = "exec ${bwRofi}";
"${configPlace.config.modifier}+t" = "exec ${bwRofiOtp}";
"${configPlace.config.modifier}+o" = "exec ${emojiRofi}";
"${configPlace.config.modifier}+0" = "workspace 10";
"${configPlace.config.modifier}+Shift+0" =
"move container to workspace 10";
"${if cfg.wayland then "Ctrl" else "Control"}+${if cfg.wayland then "Alt" else "Mod1"
}+l" =
let
lockBin =
if cfg.wayland then
"${pkgs.swaylock}/bin/swaylock"
else
"${pkgs.i3lock}/bin/i3lock";
in
"exec ${lockBin} ${cfg.swaylockArgs}";
}
)
);
menu = rofiMenu;
bars = lib.optional (cfg.babybar || cfg.wayland != true) {
position = "top";
colors = config.colors.i3BarColors;
};
gaps = {
smartGaps = true;
smartBorders = "on";
inner = 5;
outer = 5;
};
};
};
mainConfig = {
programs.direnv = {
enable = true;
nix-direnv = {
enable = true;
enableFlakes = true;
};
stdlib = ''
: ''${XDG_CACHE_HOME:=$HOME/.cache}
declare -A direnv_layout_dirs
direnv_layout_dir() {
echo "''${direnv_layout_dirs[$PWD]:=$(
echo -n "$XDG_CACHE_HOME"/direnv/layouts/
echo -n "$PWD" | shasum | cut -d ' ' -f 1
)}"
}
'';
};
services.keynav.enable = true;
services.clipmenu.enable = true;
colors.enable = true;
fonts.enable = true;
programs.chromium = {
enable = true;
package = pkgs.ungoogled-chromium.override {
commandLineArgs = "--enable-features=UseOzonePlatform --ozone-platform=wayland";
};
};
services.lorri.enable = true;
services.blueman-applet = {
enable = cfg.bluetooth;
};
systemd.user.services.mpris-proxy = mkIf cfg.bluetooth {
Unit.Description = "Mpris proxy";
Unit.After = [ "network.target" "sound.target" ];
Service.ExecStart = "${pkgs.bluez}/bin/mpris-proxy";
Install.WantedBy = [ "default.target" ];
};
home.sessionVariables = { BW_SESSION = cfg.bitwardenSession; };
services.mpd = {
enable = true;
musicDirectory = "${config.home.homeDirectory}/Music";
};
gtk = {
enable = true;
iconTheme = {
package = cfg.favIcons.package;
name = cfg.favIcons.name;
};
};
qt = {
enable = true;
platformTheme = "gtk";
};
programs.kitty = {
enable = true;
settings = {
background_opacity = "0.70";
dynamic_background_opacity = true;
};
};
xdg.configFile."neofetch/config.conf".text =
let
image = builtins.path {
name = "nixos_circlejerk.png";
path = ../data/nixos_circlejerk.png;
};
in
''
image_source="${image}"
image_backend="kitty"
'';
programs.mpv.config = {
enable = true;
profile = "gpu-hq";
ytdl-format = "bestvideo+bestaudio";
cache-default = 4000000;
};
fonts.fontconfig.enable = true;
home.packages = with pkgs;
let
steam = pkgs.steam.override { withJava = true; };
steam-run = steam.run;
newwine = (pkgs.wineFull.override { wineBuild = "wineWow"; wineRelease = "staging"; });
newwinetricks = pkgs.winetricks.override { wine = newwine; };
oldwine = pkgs.wineWowPackages.full;
oldwinetricks = pkgs.winetricks.override { wine = oldwine; };
in
[
xlibs.xf86inputjoystick
oldwine
oldwinetricks
flameshot
jq
ezDrv
inputs.mudl.defaultPackage.${pkgs.system}
bitwarden-cli
kitty
pavucontrol
mpv
yt-dlp
xorg.xkill
maim
slop
ark
notify-osd
libnotify
ffmpeg
id3v2
imagemagick
mpc_cli
nix-index
] ++ (lib.optionals cfg.developer [
openvpn
gitAndTools.hub
nmap
nixpkgs-fmt
]) ++ (lib.optionals cfg.gaming [
xlibs.xf86inputjoystick
oldwine
oldwinetricks
]) ++ (lib.optionals (cfg.gaming && !cfg.flatSteam) [
steam
steam-run
(writeScriptBin "steam-run-native" ''
#!${pkgs.stdenv.shell}
${(steam.override { nativeOnly = true; }).run}/bin/steam-run $@
'')
]) ++ (lib.optionals (cfg.gaming && cfg.newWine) [
(
pkgs.runCommand "new-wine-stuff"
{ } ''
mkdir -p $out/bin
ln -s ${newwine}/bin/wine $out/bin/new-wine
ln -s ${newwine}/bin/winecfg $out/bin/new-winecfg
ln -s ${newwinetricks}/bin/winetricks $out/bin/new-winetricks
''
)
]);
programs.rofi = {
enable = true;
terminal = "kitty";
borderWidth = 0;
lines = 30;
};
};
waylandConfig = {
home.sessionVariables = {
QT_QPA_PLATFORM = "wayland-egl;xcb";
MOZ_ENABLE_WAYLAND = "1";
QT_WAYLAND_DISABLE_WINDOWDECORATION = "1";
ECORE_EVAS_ENGINE = "wayland_egl";
ELM_ENGINE = "wayland_egl";
_JAVA_AWT_WM_NONREPARENTING = "1";
};
programs.waybar = {
enable = cfg.babybar != true;
systemd.enable = true;
settings = [
({
position = "left";
height = null;
modules-left = [ "sway/workspaces" "custom/right-arrow-dark" "custom/right-arrow-light" "custom/weather-temp" "custom/weather-precip" "custom/weather-wind" "custom/right-arrow-dark" ];
modules-center = [ "custom/left-arrow-dark" "clock#1" "clock#2" "custom/left-arrow-light" "custom/left-arrow-dark" "mpd" "custom/right-arrow-dark" "custom/right-arrow-light" "clock#3" "custom/right-arrow-dark" ];
modules-right = [ "custom/left-arrow-dark" "pulseaudio" "custom/left-arrow-light" "custom/left-arrow-dark" "memory" "custom/left-arrow-light" "custom/left-arrow-dark" "cpu" "custom/left-arrow-light" "custom/left-arrow-dark" ] ++ lib.optionals cfg.battery [ "battery" "custom/left-arrow-light" "custom/left-arrow-dark" ] ++ [ "tray" ];
modules = {
"custom/left-arrow-dark" = {
format = "";
tooltip = false;
rotate = 270;
};
"custom/left-arrow-light" = {
format = "";
tooltip = false;
rotate = 270;
};
"custom/right-arrow-dark" = {
format = "";
tooltip = false;
rotate = 270;
};
"custom/right-arrow-light" = {
format = "";
tooltip = false;
rotate = 270;
};
"custom/weather-temp" = {
exec = "${pkgs.curl}/bin/curl 'wttr.in/${cfg.location}?format=%c+%t'";
on-click = "${pkgs.xdg-utils}/bin/xdg-open 'https://weather.com/weather/today/l/85625'";
on-click-right = "${pkgs.xdg-utils}/bin/xdg-open 'https://wttr.in/${cfg.location}'";
interval = 3600;
};
"custom/weather-precip" = {
exec = "${pkgs.curl}/bin/curl 'wttr.in/${cfg.location}?format=🌧+%p'";
on-click = "${pkgs.xdg-utils}/bin/xdg-open 'https://www.lightningmaps.org/'";
on-click-right = "${pkgs.xdg-utils}/bin/xdg-open 'https://wttr.in/${cfg.location}'";
interval = 3600;
};
"custom/weather-wind" = {
exec = "${pkgs.curl}/bin/curl 'wttr.in/${cfg.location}?format=🌬+%w'";
on-click = "${pkgs.xdg-utils}/bin/xdg-open 'https://www.ventusky.com/";
on-click-right = "${pkgs.xdg-utils}/bin/xdg-open 'https://wttr.in/${cfg.location}'";
interval = 3600;
};
mpd = {
rotate = 90;
max-length = 60;
format = "{stateIcon} {artist} - {title}";
format-stopped = " STOPPED";
state-icons = {
paused = "";
playing = "";
};
};
"sway/workspaces" = {
disable-scroll = true;
};
"clock#1" = {
tooltip = false;
format = "{:%a}";
};
"clock#2" = {
tooltip = false;
format = "{:%m-%d}";
};
"clock#3" = {
tooltip = false;
format = "{:%I:%M %p}";
};
pulseaudio = {
format = "{icon} {volume}%";
format-bluetooth = "{icon} {volume}%";
format-muted = "MUTE";
format-icons = {
headphone = "";
default = "";
};
on-click = "${pkgs.pulseaudio}/bin/pactl set-source-mute @DEFAULT_SOURCE@ toggle";
on-click-right = "${pkgs.pavucontrol}/bin/pavucontrol";
};
memory = {
interval = 10;
format = " {}%";
};
cpu = {
interval = 10;
format = " {usage}%";
};
battery = {
states = {
good = 90;
warning = 25;
critical = 10;
};
format = "{icon} {capacity}%";
format-icons = [ "" "" "" "" "" ];
};
tray = {
icon-size = 18;
spacing = 5;
};
};
} // cfg.waybarConfig)
];
style = ''
window#waybar {
background: #${config.colors.base16.base01};
color: #${config.colors.base16.base06};
}
#custom-right-arrow-dark,
#custom-left-arrow-dark {
color: #${config.colors.base16.base00};
font-size: 15px;
}
#custom-right-arrow-light,
#custom-left-arrow-light {
color: #${config.colors.base16.base01};
background: #${config.colors.base16.base00};
font-size: 15px;
}
#workspaces,
#clock.1,
#clock.2,
#clock.3,
#pulseaudio,
#memory,
#cpu,
#battery,
#disk,
#tray,
#mode,
#custom-weather-temp,
#custom-weather-precip,
#custom-weather-wind,
#mpd {
background: #${config.colors.base16.base00};
padding: 5px 0;
}
#workspaces { padding: 0 0 5px 0; }
#clock.1 { padding: 5px 0 0 0; }
#clock.2 { padding: 0 0 5px 0; }
#custom-weather-temp { padding: 5px 0 0 0; }
#custom-weather-precip { padding: 5px 0; }
#custom-weather-wind { padding: 0 0 5px 0; }
#mpd.playing {
color: #${config.colors.base16.base0A};
}
#workspaces button.focused {
color: #${config.colors.base16.base0A};
}
#workspaces button:hover {
background: #${config.colors.base16.base02};
}
#pulseaudio {
color: #${config.colors.base16.base0B};
}
#memory {
color: #${config.colors.base16.base0C};
}
#cpu {
color: #${config.colors.base16.base0D};
}
#battery {
color: #${config.colors.base16.base0E};
}
* {
font-family: "${config.fonts.favFont.name}";
font-size: ${toString (config.fonts.favFont.size + 1)}px;
border-radius: 0;
border: none;
}
'';
};
programs.mako.enable = true;
systemd.user.services.swayidle = mkIf cfg.screensaver.enable {
Unit = {
Description = "Idle manager for Wayland";
PartOf = "sway-session.target";
};
Service.ExecStart = ''
${pkgs.swayidle}/bin/swayidle -w \
timeout ${
toString cfg.screensaver.lockTime
} 'swaylock -f ${cfg.swaylockArgs}' \
timeout ${
toString cfg.screensaver.offTime
} 'swaymsg "output * dpms off"' \
resume 'swaymsg "output * dpms on"' \
before-sleep 'swaylock -f ${cfg.swaylockArgs}'
'';
Install = { WantedBy = [ "sway-session.target" ]; };
};
wayland.windowManager.sway = mkMerge [
swayConfig
{
config = { output = cfg.outputOptions; };
extraConfig =
let
oguri-swaybg = pkgs.writeScript "oguri-swaybg" ''
#!/bin/sh
set -e
set -o pipefail
outputs=""
images=""
while getopts o:i:m:c: OPTION; do
case $OPTION in
o)
outputs="''${outputs}[output $OPTARG]\n"
;;
i)
outputs="''${outputs}image=$OPTARG\n"
;;
m)
outputs="''${outputs}scaling-mode=$OPTARG\n"
;;
c) ;; # No color support.
esac
done
printf "''${outputs}\n" | ${pkgs.oguri}/bin/oguri -c /dev/stdin
'';
in
''
swaybg_command ${oguri-swaybg}
'';
systemdIntegration = true;
wrapperFeatures.gtk = true;
}
];
home.packages = with pkgs; [
waybar
wl-clipboard # important actually, for vim and other things
swaylock
pkgs.swayidle
xwayland
rxvt_unicode
libappindicator-gtk3
];
};
xConfig =
let
allOutputs =
builtins.attrValues
cfg.outputOptions;
mainOutput =
if
builtins.length
allOutputs >= 1 then
builtins.elemAt
(allOutputs)
0 else null;
mainWallpaper =
if mainOutput != null &&
builtins.hasAttr
"bg"
mainOutput then mainOutput.bg else null;
mainWallpaperSplit =
if mainWallpaper != null then
lib.splitString
" "
mainWallpaper else null;
mainWallpaperImgRaw =
if mainWallpaperSplit != null then
builtins.elemAt
mainWallpaperSplit
0 else null;
mainWallpaperImg =
if mainWallpaperImgRaw != null then
lib.replaceStrings
[ "$HOME" ]
[ "%h" ]
mainWallpaperImgRaw else null;
mainWallpaperDisplayMaybe =
if mainWallpaperSplit != null then
builtins.elemAt
mainWallpaperSplit
1 else null;
mainWallpaperDisplay = if mainWallpaperDisplayMaybe != null then mainWallpaperDisplayMaybe else "fill";
in
{
xdg.configFile."flameshot/flameshot.ini".text = ''
[General]
buttons=@Variant(\0\0\0\x7f\0\0\0\vQList<int>\0\0\0\0\n\0\0\0\0\0\0\0\x2\0\0\0\x3\0\0\0\x5\0\0\0\x6\0\0\0\x12\0\0\0\xf\0\0\0\x13\0\0\0\b\0\0\0\n)
contrastOpacity=142
contrastUiColor=#0ee900
disabledTrayIcon=false
drawColor=#ff0000
drawThickness=9
savePath=/dev/null
uiColor=#6a00a3
'';
systemd.user.services =
if mainWallpaperImg != null then {
background = {
Unit = {
Description = "Set the wallpaper";
After = [ "graphical-session-pre.target" ];
PartOf = [ "graphical-session.target" ];
};
Service = {
Type = "oneshot";
ExecStart = "${pkgs.feh}/bin/feh --bg-${mainWallpaperDisplay} ${mainWallpaperImg}";
IOSchedulingClass = "idle";
};
Install = { WantedBy = [ "graphical-session.target" ]; };
};
} else { } // {
flameshot = {
Unit = {
Description = "Flameshot screenshot tool";
After = [
"graphical-session-pre.target"
"polybar.service"
"stalonetray.service"
"taffybar.service"
];
PartOf = [ "graphical-session.target" ];
};
Install = { WantedBy = [ "graphical-session.target" ]; };
Service = {
Environment = "PATH=${config.home.profileDirectory}/bin";
ExecStart = "${flameshot}/bin/flameshot";
Restart = "on-abort";
};
};
};
services.picom = {
enable = true;
vSync = true;
#refreshRate = 144;
blur = true;
package = pkgs.picom;
experimentalBackends = true;
blurExclude = [
"window_type = 'dock'"
"window_type = 'desktop'"
"_GTK_FRAME_EXTENTS@:c"
"class_g = 'slop'"
];
extraOptions = ''
blur:
{
method = "kawase";
strength = 4;
kern = "3x3box";
deviation = 5.0;
};
'';
};
xsession = {
enable = true;
windowManager.i3 = swayConfig;
};
services.dunst = {
enable = true;
settings = {
global = {
geometry = "300x5-30+50";
padding = 8;
horizontal_padding = 8;
transparency = 10;
};
};
};
};
in
{
options.ezpcusr = {
enable = mkEnableOption "Enable simple PC user config";
newWine = mkOption {
type = types.bool;
default = false;
description = "If you want to include wine-staging as new-wine";
};
flatSteam = mkOption {
type = types.bool;
default = false;
description = "If you use the flatpak Steam instead of NixOS";
};
wayland = mkOption {
default = true;
description = "Enable wayland config (disabling this is experimental)";
};
babybar = mkOption {
default = false;
description = ''Switch to using the "baby" swaybar rather than waybar'';
};
keybindings = mkOption {
description = "Keyboard shortcuts";
default = { };
type = types.attrsOf (types.nullOr types.str);
};
uploadScript = mkOption {
type = types.nullOr types.package;
default = null;
description =
"A path to a script that takes a path to a file and returns a URL";
};
bitwardenSession = mkOption {
description = "Session key for bitwarden";
default = "";
type = types.str;
};
outputOptions = mkOption {
description = "Additional output options";
default = { };
type = types.attrsOf (types.attrsOf types.str);
};
waybarConfig = mkOption {
description = "Waybar config";
default = { };
};
makoArgs = mkOption {
description = "Args for mako notification displayer";
default = "";
type = types.str;
};
swaylockArgs = mkOption {
description = "Args for swaylock lock screen";
default = "";
type = types.str;
};
screensaver = mkOption {
description = "ezpcusr screensaver";
default = { };
type = types.submodule {
options = {
enable = mkOption {
type = types.bool;
default = true;
description = "Enable ezpcusr's screensaver";
};
lockTime = mkOption {
type = types.int;
default = 300;
description = "Time until your screen locks";
};
offTime = mkOption {
type = types.int;
default = 600;
description = "Time until your screen turns off";
};
};
};
};
favIcons = mkOption {
description = "Your favourite icons pack";
default = { };
type = types.submodule {
options = {
name = mkOption {
type = types.str;
default = "Papirus-Dark";
description = "Name of your icon pack";
};
package = mkOption {
type = types.package;
default = pkgs.papirus-icon-theme;
description = "Package for your icon pack";
};
};
};
};
developer = mkOption {
type = types.bool;
default = true;
description = "Enable developer tools";
};
gaming = mkOption {
type = types.bool;
default = false;
description = "If this PC is used for gaming";
};
bluetooth = mkOption {
type = types.bool;
default = false;
description = "If this PC has bluetooth support";
};
battery = mkOption {
type = types.bool;
default = false;
description = "If this PC has a battery";
};
location = mkOption {
description = "Your location (used for weather)";
example = "US-12345";
default = "";
type = types.str;
};
};
config = mkIf cfg.enable (
mkMerge [
mainConfig
(mkIf cfg.wayland waylandConfig)
(mkIf (cfg.wayland != true) xConfig)
]
);
}