From e1fdc111b39a0273a7b89f37b61e9299058ebe5e Mon Sep 17 00:00:00 2001 From: notgne2 Date: Tue, 28 Sep 2021 13:16:34 -0700 Subject: [PATCH] clean up ezpcusr and defaults --- home-manager/modules/colors.nix | 13 - home-manager/modules/ezpcusr.nix | 1143 +++++++++++------------------- modules/workstation.nix | 28 +- 3 files changed, 426 insertions(+), 758 deletions(-) diff --git a/home-manager/modules/colors.nix b/home-manager/modules/colors.nix index 9ae0f60..a4a0cfb 100644 --- a/home-manager/modules/colors.nix +++ b/home-manager/modules/colors.nix @@ -68,11 +68,6 @@ in default = { }; }; - waybarCss = mkOption { - description = "Exported CSS for waybar"; - default = ""; - }; - base16Rgb = mkOption { readOnly = true; type = types.attrsOf (types.attrsOf types.int); @@ -260,14 +255,6 @@ in }; }; - # Waybar - colors.waybarCss = - "\n" + ( - (import ../data/waybar-base16.nix) - cfg.favColors.name - cfg.base16 - ); - # Dunst services.dunst = { settings = { diff --git a/home-manager/modules/ezpcusr.nix b/home-manager/modules/ezpcusr.nix index 4a4f0d0..3232015 100644 --- a/home-manager/modules/ezpcusr.nix +++ b/home-manager/modules/ezpcusr.nix @@ -4,24 +4,12 @@ with lib; let cfg = config.ezpcusr; - elm-format-working = pkgs.elmPackages.elm-format.overrideAttrs (_: { doCheck = false; }); + lockCommand = "${pkgs.swaylock-effects}/bin/swaylock --clock --indicator --screenshots --effect-scale 0.5 --effect-blur 5x2 --effect-vignette 0.2:0.5 --fade-in 1 --datestr %Y-%m-%e"; - 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 - '' - ); + selshot = pkgs.writeScript "selshot.sh" '' + #!${pkgs.zsh}/bin/zsh + ${pkgs.grim}/bin/grim -g "$(${pkgs.slurp}/bin/slurp)" $1 + ''; selvid = pkgs.writeScript "selvid.sh" '' #!${pkgs.zsh}/bin/zsh @@ -34,25 +22,11 @@ let 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 + ${pkgs.wl-clipboard}/bin/wl-copy -t image/png < $LOC ''; scrsaveup = @@ -61,7 +35,7 @@ let #!${pkgs.zsh}/bin/zsh LOC=$(${getscrloc}) ${selshot} $LOC - ${cfg.uploadScript} $LOC | xargs echo -n | ${copyBin} + ${cfg.uploadScript} $LOC | xargs echo -n | ${pkgs.wl-clipboard}/bin/wl-copy notify-send "Screenshot Uploaded!" '' else @@ -71,7 +45,7 @@ let #!${pkgs.zsh}/bin/zsh LOC=$(${getscrloc} mp4) ${selvid} $LOC - ${copyBin} -t video/mp4 < $LOC + ${pkgs.wl-clipboard}/bin/wl-copy -t video/mp4 < $LOC ''; scrvidsaveup = @@ -80,7 +54,7 @@ let #!${pkgs.zsh}/bin/zsh LOC=$(${getscrloc} mp4) ${selvid} $LOC - ${cfg.uploadScript} $LOC | ${pkgs.findutils}/bin/xargs echo -n | ${copyBin} + ${cfg.uploadScript} $LOC | ${pkgs.findutils}/bin/xargs echo -n | ${pkgs.wl-clipboard}/bin/wl-copy notify-send "Screen Recording Uploaded!" '' else @@ -96,402 +70,304 @@ let ${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 + 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 ${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 - "" - ) - ); + ln -s ${scrsaveup} $out/bin/scrsaveup + ln -s ${scrvidsaveup} $out/bin/scrvidsaveup + '' else "" + ) + ); +in +{ + options.ezpcusr = { + enable = mkEnableOption "Enable simple PC user config"; - rofiMenu = - if cfg.wayland then - "${rofiBin} -show drun -show-icons -run-command 'swaymsg exec -- {cmd}'" - else - "${rofiBin} -show drun -show-icons"; + newWine = mkOption { + type = types.bool; + default = false; + description = "If you want to include wine-staging as new-wine"; + }; - swayConfig = { - enable = true; + flatSteam = mkOption { + type = types.bool; + default = false; + description = "If you use the flatpak Steam instead of NixOS"; + }; - config = { - terminal = "kitty"; + babybar = mkOption { + default = false; + description = ''Switch to using the "baby" swaybar rather than waybar''; + }; - modifier = "Mod4"; + 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"; + }; - 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 - ''; + bitwardenSession = mkOption { + description = "Session key for bitwarden"; + default = ""; + type = types.str; + }; - # ugly stupid way of doing things but im lazy - bwRofi = pkgs.writeScript "bw-rofi" '' - #!${pkgs.bash}/bin/bash - export BW_SESSION="${cfg.bitwardenSession}" + outputOptions = mkOption { + description = "Additional output options"; + default = { }; + type = types.attrsOf (types.attrsOf types.str); + }; - LIST=$(${pkgs.bitwarden-cli}/bin/bw list items) - USERLIST=$(echo "$LIST" | ${pkgs.jq}/bin/jq -r '.[] | "\(.name) - \(.login.username)"') + waybarConfig = mkOption { + description = "Waybar config"; + default = { }; + }; - CHOSEN=$(echo "$USERLIST" | ${rofiBin} -dmenu -i) - NUMBER=$(echo "$USERLIST" | grep -n "^$CHOSEN$" | cut -d':' -f1) - NTH=$(expr $NUMBER - 1) + makoArgs = mkOption { + description = "Args for mako notification displayer"; + default = ""; + type = types.str; + }; - echo "$LIST" | ${pkgs.jq}/bin/jq -j -r ".[$NTH].login.password" | ${copyBin} - ''; + 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"; + }; + }; + }; + }; - # 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}" + 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"; + }; + }; + }; + }; - LIST=$(${pkgs.bitwarden-cli}/bin/bw list items) - USERLIST=$(echo "$LIST" | ${pkgs.jq}/bin/jq -r '.[] | "\(.name) - \(.login.username)"') + gaming = mkOption { + type = types.bool; + default = false; + description = "If this PC is used for gaming"; + }; - CHOSEN=$(echo "$USERLIST" | ${rofiBin} -dmenu -i) - NUMBER=$(echo "$USERLIST" | grep -n "^$CHOSEN$" | cut -d':' -f1) - NTH=$(expr $NUMBER - 1) + bluetooth = mkOption { + type = types.bool; + default = false; + description = "If this PC has bluetooth support"; + }; - ID=$(echo "$LIST" | ${pkgs.jq}/bin/jq -j -r ".[$NTH].id") + battery = mkOption { + type = types.bool; + default = false; + description = "If this PC has a battery"; + }; - ${pkgs.bitwarden-cli}/bin/bw get totp $ID | ${copyBin} - ''; + location = mkOption { + description = "Your location (used for weather)"; + example = "US-12345"; + default = ""; + type = types.str; + }; + }; - # 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) + config = lib.mkIf cfg.enable { + wayland.windowManager.sway = { + enable = lib.mkDefault true; - ${pkgs.coreutils}/bin/echo ''${line::1} | ${copyBin} + systemdIntegration = lib.mkDefault true; + wrapperFeatures.gtk = lib.mkDefault true; + + extraConfig = '' + exec swayidle -w \ + timeout ${toString cfg.screensaver.lockTime} '${lockCommand}' \ + timeout ${toString cfg.screensaver.offTime} '${pkgs.sway}/bin/swaymsg "output * dpms off"' \ + resume '${pkgs.sway}/bin/swaymsg "output * dpms on"' \ + before-sleep '${lockCommand}' + ''; + + config = { + terminal = lib.mkDefault "kitty"; + + modifier = lib.mkDefault "Mod4"; + + keybindings = + let + musicRofi = pkgs.writeScript "music-rofi" '' + #!${pkgs.fish}/bin/fish + ${pkgs.mpc_cli}/bin/mpc -f "%position% - %artist% - %album% - %title%" playlist | ${pkgs.rofi}/bin/rofi -dmenu -i | ${pkgs.coreutils}/bin/cut -d " " -f 1 | ${pkgs.findutils}/bin/xargs ${pkgs.mpc_cli}/bin/mpc play ''; - configPlace = - if cfg.wayland then - config.wayland.windowManager.sway - else - config.xsession.windowManager.i3; + # ugly stupid way of doing things but im lazy + bwRofi = pkgs.writeScript "bw-rofi" '' + #!${pkgs.bash}/bin/bash + export BW_SESSION="${cfg.bitwardenSession}" - 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"; + LIST=$(${pkgs.bitwarden-cli}/bin/bw list items) + USERLIST=$(echo "$LIST" | ${pkgs.jq}/bin/jq -r '.[] | "\(.name) - \(.login.username)"') - "${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}"; + CHOSEN=$(echo "$USERLIST" | ${pkgs.rofi}/bin/rofi -dmenu -i) + NUMBER=$(echo "$USERLIST" | grep -n "^$CHOSEN$" | cut -d':' -f1) + NTH=$(expr $NUMBER - 1) - "${configPlace.config.modifier}+minus" = volumeDown; - "${configPlace.config.modifier}+equal" = volumeUp; + echo "$LIST" | ${pkgs.jq}/bin/jq -j -r ".[$NTH].login.password" | ${pkgs.wl-clipboard}/bin/wl-copy + ''; - "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"; + # 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}" - "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"; + LIST=$(${pkgs.bitwarden-cli}/bin/bw list items) + USERLIST=$(echo "$LIST" | ${pkgs.jq}/bin/jq -r '.[] | "\(.name) - \(.login.username)"') - # 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"; + CHOSEN=$(echo "$USERLIST" | ${pkgs.rofi}/bin/rofi -dmenu -i) + NUMBER=$(echo "$USERLIST" | grep -n "^$CHOSEN$" | cut -d':' -f1) + NTH=$(expr $NUMBER - 1) - # 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"; + ID=$(echo "$LIST" | ${pkgs.jq}/bin/jq -j -r ".[$NTH].id") - # 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"; + ${pkgs.bitwarden-cli}/bin/bw get totp $ID | ${pkgs.wl-clipboard}/bin/wl-copy + ''; - "${configPlace.config.modifier}+m" = "exec ${musicRofi}"; - # "${configPlace.config.modifier}+Shift+m" = "exec ${magicMudl}"; + emojiRofi = pkgs.writeScript "rofi-emoji" '' + line=$(${pkgs.coreutils}/bin/cat ${toString ../data/emojis.txt} | ${pkgs.rofi}/bin/rofi -dmenu -i) + ${pkgs.coreutils}/bin/echo ''${line::1} | ${pkgs.wl-clipboard}/bin/wl-copy + ''; - "${configPlace.config.modifier}+p" = "exec ${bwRofi}"; - "${configPlace.config.modifier}+t" = "exec ${bwRofiOtp}"; + modifier = config.wayland.windowManager.sway.config.modifier; - "${configPlace.config.modifier}+o" = "exec ${emojiRofi}"; + alphabet = [ "Ctrl" "Alt" "Ctrl+Alt" ]; + genKeyAttrs = move: lib.listToAttrs ( + map + ( + n: { + name = "${modifier}${if move then "+Shift" else ""}+${builtins.elemAt alphabet ((n - 11) / 10)}+${ + toString (lib.mod n 10) + }"; + value = "${if move then "move container to " else ""}workspace ${toString n}"; + } + ) + (lib.lists.range 11 (10 * (builtins.length alphabet) + 10)) + ); + in + lib.mkOptionDefault ( + genKeyAttrs true // genKeyAttrs false // ( + 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"; - "${configPlace.config.modifier}+0" = "workspace 10"; - "${configPlace.config.modifier}+Shift+0" = - "move container to workspace 10"; + "Ctrl+Print" = "exec ${scrvidsaveclip}"; + "Ctrl+Alt+Print" = "exec ${scrvidstop}"; - "${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}"; - } - ) - ); + "${modifier}+minus" = volumeDown; + "${modifier}+equal" = volumeUp; - menu = rofiMenu; + "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"; - bars = lib.optional (cfg.babybar || cfg.wayland != true) { - position = "top"; - colors = config.colors.i3BarColors; - }; + "XF86MonBrightnessDown" = "exec ${pkgs.light}/bin/light -U 10"; + "XF86MonBrightnessUp" = "exec ${pkgs.light}/bin/light -A 10"; + "${modifier}+semicolon" = "exec ${pkgs.light}/bin/light -U 10"; + "${modifier}+apostrophe" = "exec ${pkgs.light}/bin/light -A 10"; - gaps = { - smartGaps = true; - smartBorders = "on"; - inner = 5; - outer = 5; - }; - }; - }; + # Previous/next but change the shuffle/random state before action (and change back afterwards) + "${modifier}+Shift+bracketright" = + "exec ${pkgs.mpc_cli}/bin/mpc random && ${pkgs.mpc_cli}/bin/mpc next && ${pkgs.mpc_cli}/bin/mpc random"; + "${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"; - 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 - )}" - } - ''; - }; + # Previous/next + "${modifier}+bracketright" = "exec ${pkgs.mpc_cli}/bin/mpc next"; + "${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"; - services.keynav.enable = true; - services.clipmenu.enable = true; + # Toggle play/pause + "XF86AudioPlay" = "exec ${pkgs.mpc_cli}/bin/mpc toggle"; + "XF86AudioPause" = "exec ${pkgs.mpc_cli}/bin/mpc toggle"; + "${modifier}+backslash" = "exec ${pkgs.mpc_cli}/bin/mpc toggle"; - colors.enable = true; - fonts.enable = true; + "${modifier}+m" = "exec ${musicRofi}"; - programs.chromium = { - enable = true; - package = pkgs.ungoogled-chromium.override { - commandLineArgs = "--enable-features=UseOzonePlatform --ozone-platform=wayland"; - }; - }; + "${modifier}+p" = "exec ${bwRofi}"; + "${modifier}+t" = "exec ${bwRofiOtp}"; - services.lorri.enable = true; + "${modifier}+o" = "exec ${emojiRofi}"; - services.blueman-applet = { - enable = cfg.bluetooth; - }; + "${modifier}+0" = "workspace 10"; + "${modifier}+Shift+0" = "move container to workspace 10"; - 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" ]; - }; + "Ctrl+Alt+l" = "exec ${lockCommand}"; + } + ) + ); - home.sessionVariables = { BW_SESSION = cfg.bitwardenSession; }; + menu = "${pkgs.rofi}/bin/rofi -show drun -show-icons -run-command '${pkgs.sway}/bin/swaymsg exec -- {cmd}'"; - 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; + bars = lib.optional cfg.babybar { + position = "top"; + colors = config.colors.i3BarColors; }; - in - '' - image_source="${image}" - image_backend="kitty" - ''; - programs.mpv.config = { - enable = true; - profile = "gpu-hq"; - ytdl-format = "bestvideo+bestaudio"; - cache-default = 4000000; + gaps = { + smartGaps = lib.mkDefault true; + smartBorders = lib.mkDefault "on"; + inner = lib.mkDefault 10; + outer = lib.mkDefault 0; + }; + }; }; - 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"; @@ -502,8 +378,8 @@ let }; programs.waybar = { - enable = cfg.babybar != true; - systemd.enable = true; + enable = lib.mkDefault (cfg.babybar != true); + systemd.enable = lib.mkDefault true; settings = [ ({ @@ -703,365 +579,170 @@ let ''; }; - programs.mako.enable = true; + programs.mako.enable = lib.mkDefault true; - systemd.user.services.swayidle = mkIf cfg.screensaver.enable { - Unit = { - Description = "Idle manager for Wayland"; - PartOf = "sway-session.target"; + programs.direnv = { + enable = lib.mkDefault true; + nix-direnv = { + enable = lib.mkDefault true; + enableFlakes = lib.mkDefault true; }; - - 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}' + 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 + )}" + } ''; - - Install = { WantedBy = [ "sway-session.target" ]; }; }; - wayland.windowManager.sway = mkMerge [ - swayConfig + services.clipmenu.enable = lib.mkDefault true; - { - config = { output = cfg.outputOptions; }; + colors.enable = lib.mkDefault true; + fonts.enable = lib.mkDefault true; - extraConfig = - let - oguri-swaybg = pkgs.writeScript "oguri-swaybg" '' - #!/bin/sh - set -e - set -o pipefail + programs.chromium = { + enable = lib.mkDefault true; + package = lib.mkDefault (pkgs.ungoogled-chromium.override { + commandLineArgs = "--enable-features=UseOzonePlatform --ozone-platform=wayland"; + }); + }; - outputs="" - images="" + services.lorri.enable = lib.mkDefault true; - 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 + services.blueman-applet = { + enable = lib.mkDefault cfg.bluetooth; + }; - printf "''${outputs}\n" | ${pkgs.oguri}/bin/oguri -c /dev/stdin - ''; - in + services.mpris-proxy.enable = true; + + home.sessionVariables = { BW_SESSION = cfg.bitwardenSession; }; + + services.mpd = { + enable = lib.mkDefault true; + musicDirectory = lib.mkDefault "${config.home.homeDirectory}/Music"; + }; + + gtk = { + enable = lib.mkDefault true; + iconTheme = { + package = lib.mkDefault cfg.favIcons.package; + name = lib.mkDefault cfg.favIcons.name; + }; + }; + + qt = { + enable = lib.mkDefault true; + platformTheme = lib.mkDefault "gtk"; + }; + + programs.kitty = { + enable = lib.mkDefault true; + settings = { + background_opacity = lib.mkDefault "0.80"; + dynamic_background_opacity = lib.mkDefault 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 = lib.mkDefault true; + profile = lib.mkDefault "gpu-hq"; + ytdl-format = lib.mkDefault "bestvideo+bestaudio"; + cache-default = lib.mkDefault 4000000; + }; + + fonts.fontconfig.enable = lib.mkDefault 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 + [ + waybar + wl-clipboard # important actually, for vim and other things + xwayland + libappindicator-gtk3 + + oldwine + oldwinetricks + + jq + + ezDrv + inputs.mudl.defaultPackage.${pkgs.system} + + bitwarden-cli + kitty + pavucontrol + mpv + yt-dlp + maim + slop + + ark + notify-osd + libnotify + ffmpeg + id3v2 + imagemagick + + mpc_cli + nix-index + + 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 '' - 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\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; + programs.rofi = { + enable = lib.mkDefault true; + terminal = lib.mkDefault "kitty"; + borderWidth = lib.mkDefault 0; + lines = lib.mkDefault 30; }; }; - - config = mkIf cfg.enable ( - mkMerge [ - mainConfig - (mkIf cfg.wayland waylandConfig) - (mkIf (cfg.wayland != true) xConfig) - ] - ); } diff --git a/modules/workstation.nix b/modules/workstation.nix index 42995bf..759abd0 100644 --- a/modules/workstation.nix +++ b/modules/workstation.nix @@ -21,8 +21,8 @@ in config = mkIf cfg.enable { services.avahi = { - enable = true; - nssmdns = true; + enable = lib.mkDefault true; + nssmdns = lib.mkDefault true; }; services.ezpw.enable = lib.mkDefault true; @@ -39,20 +39,20 @@ in # Don't kill the battery services.upower = { - enable = true; - percentageLow = 15; - percentageCritical = 10; - percentageAction = 5; + enable = lib.mkDefault true; + percentageLow = lib.mkDefault 15; + percentageCritical = lib.mkDefault 10; + percentageAction = lib.mkDefault 5; }; # Make battery usage sane services.tlp = { enable = lib.mkDefault cfg.battery; settings = { - DISK_IOSCHED = "bfq bfq"; + DISK_IOSCHED = lib.mkDefault "mq-deadline deadline"; - PCIE_ASPM_ON_BAT = "powersupersave"; - PCIE_ASPM_ON_AC = "default"; + PCIE_ASPM_ON_BAT = lib.mkDefault "powersupersave"; + PCIE_ASPM_ON_AC = lib.mkDefault "default"; PLATFORM_PROFILE_ON_BAT = lib.mkDefault "low-power"; PLATFORM_PROFILE_ON_AC = lib.mkDefault "performance"; @@ -81,9 +81,9 @@ in # Video support hardware.opengl = { - enable = true; + enable = lib.mkDefault true; # Fix steam - driSupport32Bit = true; + driSupport32Bit = lib.mkDefault true; # Other drivers extraPackages = with pkgs; [ intel-media-driver @@ -144,7 +144,7 @@ in # this helps with some compatibility hardware.pulseaudio.daemon.config = { - "default-sample-rate" = "48000"; + "default-sample-rate" = lib.mkDefault "48000"; }; # networking.networkmanager.ethernet.macAddress = "random"; @@ -179,7 +179,7 @@ in # Pulseaudio is off by defaultm but if you want it, make it work right hardware.pulseaudio.support32Bit = lib.mkDefault true; hardware.pulseaudio.zeroconf.discovery.enable = lib.mkDefault true; - hardware.pulseaudio.package = pkgs.pulseaudioFull; + hardware.pulseaudio.package = lib.mkDefault pkgs.pulseaudioFull; hardware.pulseaudio.extraModules = [ pkgs.pulseaudio-modules-bt ]; hardware.pulseaudio.extraConfig = '' load-module module-dbus-protocol @@ -188,6 +188,6 @@ in # bluetooth services.blueman.enable = lib.mkDefault true; hardware.bluetooth.enable = lib.mkDefault true; - hardware.bluetooth.settings.General.Enable = "Source,Sink,Media,Socket"; + hardware.bluetooth.settings.General.Enable = lib.mkDefault "Source,Sink,Media,Socket"; }; }