initial commit
All checks were successful
Deploy docs / build-and-deploy (push) Successful in 3s

This commit is contained in:
sid 2026-02-23 20:34:35 +01:00
commit 95a533c876
451 changed files with 18255 additions and 0 deletions

View file

@ -0,0 +1,21 @@
{ lib, ... }:
let
inherit (lib) mkDefault;
in
{
programs.bemenu = {
settings = {
border = mkDefault 2;
border-radius = mkDefault 10;
center = mkDefault true;
ignorecase = mkDefault true;
list = mkDefault "20 down";
margin = mkDefault 5;
prompt = mkDefault "";
scrollbar = mkDefault "none";
width-factor = mkDefault 0.3;
wrap = mkDefault true;
};
};
}

View file

@ -0,0 +1,32 @@
{
inputs,
config,
lib,
pkgs,
...
}:
let
cfg = config.programs.bitwarden;
inherit (lib) mkEnableOption mkIf;
in
{
options.programs.bitwarden = {
enable = mkEnableOption "Bitwarden password manager integration";
};
config = mkIf cfg.enable {
home.packages = [
pkgs.bitwarden-menu
pkgs.bitwarden-cli
];
programs.librewolf = mkIf config.programs.librewolf.enable {
profiles.default.extensions.packages =
with inputs.nur.legacyPackages."${pkgs.stdenv.hostPlatform.system}".repos.rycee.firefox-addons; [
bitwarden
];
};
};
}

View file

@ -0,0 +1,77 @@
# change directory with fzf
# Usage: cdf [optional_relative_path]
# - If no argument, searches from $HOME.
# - If a relative path (e.g., "projects/my_app") is provided, searches only within that path relative to $HOME.
# - If an absolute path (e.g., "/mnt/data") is provided, searches only within that path.
function cdf() {
local exclude_names=(
".cache"
".cargo"
".git"
".npm"
".rustup"
".venv"
"Library"
"__pycache__"
"build"
"cache"
"dist"
"neorv32"
"nixpkgs"
"node_modules"
"octave"
"snap"
"target"
"venv"
)
local dir="$HOME"
if [[ -n "$1" ]]; then
if [[ "$1" == /* ]]; then
dir="$1"
else
dir="$HOME/$1"
fi
if [[ ! -d "$dir" ]]; then
echo "Error: '$dir' does not exist or is not a directory."
return 1
fi
fi
local find_args=("$dir")
find_args+=(-path "$dir/.*" -prune -o)
local prune_exprs=()
local has_prunes=false
for name in "${exclude_names[@]}"; do
if $has_prunes; then
prune_exprs+=(-o)
fi
prune_exprs+=(-name "$name")
has_prunes=true
done
if $has_prunes; then
find_args+=(\( "${prune_exprs[@]}" \) -prune -o)
fi
find_args+=(-type d -print)
local fzf_args=(
"-i"
"--height=40%"
"--reverse"
"--prompt=Select directory: "
"--preview=tree -C {} | head -50"
"--preview-window=right:50%:wrap"
)
local selected=$(find "${find_args[@]}" 2>/dev/null | fzf "${fzf_args[@]}")
if [[ -n "$selected" ]]; then
cd "$selected" || echo "Failed to cd into '$selected'"
pwd
ls -lAh
fi
}

View file

@ -0,0 +1,30 @@
{
config,
lib,
...
}:
let
inherit (lib) mkDefault;
in
{
imports = [
./packages.nix
./shellAliases.nix
./zsh.nix
../../shared/common
];
programs.home-manager.enable = true;
home.homeDirectory = mkDefault "/home/${config.home.username}";
# Nicely reload system units when changing configs
systemd.user.startServices = "sd-switch";
# JSON formatted list of Home Manager options
manual.json.enable = true;
news.display = "silent";
}

View file

@ -0,0 +1,11 @@
{ pkgs, ... }:
{
home.packages = with pkgs; [
hydra-check
nix-init
tldr
(callPackage ../../../apps/rebuild { })
];
}

View file

@ -0,0 +1,33 @@
{
home.shellAliases = {
l = "ls -lh";
ll = "ls -lAh";
ports = "ss -tulpn";
publicip = "curl ifconfig.me/all";
sudo = "sudo "; # make aliases work with `sudo`
# systemd
userctl = "systemctl --user";
enable = "systemctl --user enable";
disable = "systemctl --user disable";
start = "systemctl --user start";
stop = "systemctl --user stop";
journal = "journalctl --user";
# git
ga = "git add";
gb = "git branch";
gc = "git commit";
gcl = "git clone";
gco = "git checkout";
gcp = "git cherry-pick -x";
gd = "git diff";
gf = "git fetch --all";
gl = "git log";
gm = "git merge";
gp = "git push";
gpl = "git pull";
gr = "git remote";
gs = "git status";
};
}

View file

@ -0,0 +1,17 @@
{ config, lib, ... }:
let
inherit (lib) mkDefault;
in
{
programs.zsh = {
enable = mkDefault true;
dotDir = "${config.xdg.configHome}/zsh";
defaultKeymap = mkDefault "emacs";
initContent = ''
PROMPT='%F{green}%n%f@%F{blue}%m%f %B%1~%b > '
RPROMPT='[%F{yellow}%?%f]'
''
+ builtins.readFile ./cdf.sh;
};
}

17
modules/home/default.nix Normal file
View file

@ -0,0 +1,17 @@
{
bemenu = import ./bemenu;
common = import ./common;
gpg = import ./gpg;
hyprland = import ./hyprland;
kitty = import ./kitty;
lf = import ./lf;
librewolf = import ./librewolf;
networkmanager-dmenu = import ./networkmanager-dmenu;
nixvim = import ./nixvim;
passwordManager = import ./password-manager;
rofi-rbw = import ./rofi-rbw;
sops = import ./sops;
stylix = import ./stylix;
virtualisation = import ./virtualisation;
waybar = import ./waybar;
}

View file

@ -0,0 +1,31 @@
{
config,
lib,
pkgs,
...
}:
let
cfg = config.programs.gpg;
inherit (lib) mkDefault mkIf;
in
{
programs.gpg = {
enable = mkDefault true;
};
services.gpg-agent = mkIf cfg.enable {
defaultCacheTtl = mkDefault 600;
defaultCacheTtlSsh = mkDefault 600;
enable = mkDefault true;
enableScDaemon = mkDefault false;
enableSshSupport = mkDefault true;
maxCacheTtl = mkDefault 7200;
maxCacheTtlSsh = mkDefault 7200;
pinentry.package = mkDefault pkgs.pinentry-qt;
verbose = mkDefault true;
};
programs.ssh = {
enable = mkDefault true;
};
}

View file

@ -0,0 +1,21 @@
{
config,
lib,
...
}:
let
cfg = config.wayland.windowManager.hyprland;
app = cfg.applications.applauncher.default;
inherit (lib) mkIf;
in
{
imports = [ ../../../bemenu ];
config = mkIf (cfg.enable && app == "bemenu") {
programs.bemenu = {
enable = true;
};
};
}

View file

@ -0,0 +1,202 @@
{
config,
lib,
pkgs,
...
}:
let
cfg = config.wayland.windowManager.hyprland;
apps = cfg.applications;
# dynamically create a set of default app assignments
defaultApps = mapAttrs (name: app: app.default) apps;
# function to generate the attribute set for each application
mkAppAttrs =
{
default,
bind ? [ "" ],
windowrule ? [ "" ],
}:
{
default = mkOption {
type = types.str;
default = default;
description = "The default application to use for the ${default}.";
};
bind = mkOption {
type = types.listOf types.str;
default = bind;
description = "The keybinding to use for the ${default}.";
};
windowrule = mkOption {
type = types.listOf types.str;
default = windowrule;
description = "The window rule to use for the ${default}.";
};
};
# generate lists of all binds and window rules and remove empty strings
binds = filter (s: s != "") (
builtins.concatLists (map (app: app.bind or [ "" ]) (attrValues apps))
);
windowrules = filter (s: s != "") (
builtins.concatLists (map (app: app.windowrule or [ "" ]) (attrValues apps))
);
inherit (lib)
attrValues
filter
getExe
mapAttrs
mkOption
types
;
in
{
imports = [
./bemenu
./dmenu-bluetooth
./element-desktop
./feh
./kitty
./libreoffice
./librewolf
./mpv
./ncmpcpp
./networkmanager_dmenu
./newsboat
./passwordmanager
./powermenu-bemenu
./presentation-mode-bemenu
./qbittorrent
./screenshot
./thunderbird
./yazi
./zathura
# add your application directories here
];
options.wayland.windowManager.hyprland.applications = with defaultApps; {
applauncher = mkAppAttrs {
default = "bemenu";
bind = [ "$mod, d, exec, ${applauncher}-run" ];
};
audiomixer = mkAppAttrs {
default = "pulsemixer";
bind = [ "$mod, a, exec, ${terminal} -T ${audiomixer} -e ${pkgs.pulsemixer}/bin/pulsemixer" ];
windowrule = [
"float, title:^${audiomixer}$"
"size 50% 50%, title:^${audiomixer}$"
];
};
bluetoothsettings = mkAppAttrs {
default = "dmenu-bluetooth";
bind = [ "$mod SHIFT, b, exec, ${bluetoothsettings}" ];
};
browser = mkAppAttrs {
default = "librewolf";
bind = [ "$mod, b, exec, ${browser}" ];
};
calculator = mkAppAttrs {
default = "octave";
bind = [
", XF86Calculator, exec, ${terminal} -T ${calculator} -e ${pkgs.octave}/bin/octave"
];
};
emailclient = mkAppAttrs {
default = "thunderbird";
bind = [ "$mod, m, exec, ${emailclient}" ];
};
equalizer = mkAppAttrs {
default = "easyeffects";
bind = [ "$mod CTRL, e, exec, ${getExe pkgs.easyeffects}" ];
};
filemanager = mkAppAttrs {
default = "yazi";
bind = [ "$mod, e, exec, ${terminal} -T ${filemanager} -e ${filemanager}" ];
};
matrix-client = mkAppAttrs {
default = "element-desktop";
bind = [ "$mod SHIFT, e, exec, ${matrix-client}" ];
};
musicplayer = mkAppAttrs {
default = "ncmpcpp";
bind = [ "$mod SHIFT, m, exec, ${terminal} -T ${musicplayer} -e ${musicplayer}" ];
};
networksettings = mkAppAttrs {
default = "networkmanager_dmenu";
bind = [ "$mod SHIFT, n, exec, ${networksettings}" ];
};
notes = mkAppAttrs {
default = "quicknote";
bind = [ "$mod CTRL, n, exec, ${terminal} -T ${notes} -e ${getExe pkgs.synix.quicknote}" ];
};
office = mkAppAttrs {
default = "libreoffice";
bind = [ "$mod SHIFT, o, exec, ${office}" ];
};
password-manager = mkAppAttrs {
default = "passmenu-bemenu";
bind = [ "$mod, p, exec, ${password-manager}" ];
};
imageviewer = mkAppAttrs { default = "feh"; };
pdfviewer = mkAppAttrs { default = "zathura"; };
powermenu = mkAppAttrs {
default = "powermenu-bemenu";
bind = [ "$mod SHIFT, q, exec, ${powermenu}" ];
};
presentation-mode = mkAppAttrs {
default = "presentation-mode-bemenu";
bind = [ "$mod SHIFT, p, exec, ${presentation-mode}" ];
};
rssreader = mkAppAttrs {
default = "newsboat";
bind = [ "$mod, n, exec, ${terminal} -T ${rssreader} -e ${rssreader}" ];
};
screenshotter = mkAppAttrs {
default = "screenshot";
bind = [
"$mod, Print, exec, ${screenshotter} output" # select monitor
"$mod SHIFT, Print, exec, ${screenshotter} region" # select region
"$mod CTRL, Print, exec, ${screenshotter} window" # select window
];
};
terminal = mkAppAttrs {
default = "kitty";
bind = [ "$mod, Return, exec, ${terminal}" ];
};
torrent-client = mkAppAttrs { default = "qbittorrent"; };
videoplayer = mkAppAttrs { default = "mpv"; };
};
config = {
wayland.windowManager.hyprland.settings = {
bind = binds;
windowrule = windowrules;
};
};
}

View file

@ -0,0 +1,22 @@
{
config,
lib,
pkgs,
...
}:
let
cfg = config.wayland.windowManager.hyprland;
app = cfg.applications.bluetoothsettings.default;
inherit (lib) mkIf;
in
{
config = mkIf (cfg.enable && app == "dmenu-bluetooth") {
home.packages = with pkgs; [ dmenu-bluetooth ];
home.sessionVariables = {
DMENU_BLUETOOTH_LAUNCHER = cfg.applications.applauncher.default or "bemenu";
};
};
}

View file

@ -0,0 +1,25 @@
{
config,
lib,
pkgs,
...
}:
let
cfg = config.wayland.windowManager.hyprland;
app = cfg.applications.matrix-client.default;
inherit (lib) mkDefault mkIf;
in
{
config = mkIf (cfg.enable && app == "element-desktop") {
# FIXME: screen sharing does not work
programs.element-desktop = {
enable = true;
settings = {
# Use Chromium for screen sharing
default_theme = mkDefault "dark";
};
};
};
}

View file

@ -0,0 +1,45 @@
{ config, lib, ... }:
let
cfg = config.wayland.windowManager.hyprland;
app = cfg.applications.imageviewer.default;
desktop = "feh.desktop";
mimeTypes = [
"image/gif"
"image/heic"
"image/jpeg"
"image/jpg"
"image/pjpeg"
"image/png"
"image/tiff"
"image/webp"
"image/x-bmp"
"image/x-pcx"
"image/x-png"
"image/x-portable-anymap"
"image/x-portable-bitmap"
"image/x-portable-graymap"
"image/x-portable-pixmap"
"image/x-tga"
"image/x-xbitmap"
];
associations =
let
genMimeAssociations = import ../genMimeAssociations.nix;
in
genMimeAssociations desktop mimeTypes;
inherit (lib) mkIf;
in
{
config = mkIf (cfg.enable && app == "feh") {
programs.feh = {
enable = true;
};
xdg.mimeApps = {
defaultApplications = associations;
associations.added = associations;
};
};
}

View file

@ -0,0 +1,8 @@
# Generate a list of mime associations for a desktop file
desktop: mimeTypes:
builtins.listToAttrs (
map (mimeType: {
name = mimeType;
value = desktop;
}) mimeTypes
)

View file

@ -0,0 +1,21 @@
{
config,
lib,
...
}:
let
cfg = config.wayland.windowManager.hyprland;
app = cfg.applications.terminal.default;
inherit (lib) mkIf;
in
{
imports = [ ../../../kitty ];
config = mkIf (cfg.enable && app == "kitty") {
programs.kitty = {
enable = true;
};
};
}

View file

@ -0,0 +1,20 @@
{
config,
lib,
pkgs,
...
}:
let
cfg = config.wayland.windowManager.hyprland;
app = cfg.applications.office.default;
inherit (lib) mkIf;
in
{
config = mkIf (cfg.enable && app == "libreoffice") {
home.packages = [ pkgs.libreoffice ];
# TODO: set Tools > Options > Application Colors > Automatic = Dark
};
}

View file

@ -0,0 +1,41 @@
{
config,
lib,
...
}:
let
cfg = config.wayland.windowManager.hyprland;
app = cfg.applications.browser.default;
desktop = "librewolf.desktop";
mimeTypes = [
"text/html"
"text/xml"
"application/xhtml+xml"
"application/vnd.mozilla.xul+xml"
"x-scheme-handler/http"
"x-scheme-handler/https"
];
associations =
let
genMimeAssociations = import ../genMimeAssociations.nix;
in
genMimeAssociations desktop mimeTypes;
inherit (lib) mkIf;
in
{
imports = [ ../../../librewolf ];
config = mkIf (cfg.enable && app == "librewolf") {
programs.librewolf = {
enable = true;
};
xdg.mimeApps = {
associations.added = associations;
defaultApplications = associations;
};
};
}

View file

@ -0,0 +1,15 @@
{ config, lib, ... }:
let
cfg = config.wayland.windowManager.hyprland;
app = cfg.applications.videoplayer.default;
inherit (lib) mkIf;
in
{
config = mkIf (cfg.enable && app == "mpv") {
programs.mpv = {
enable = true;
};
};
}

View file

@ -0,0 +1,22 @@
{ config, lib, ... }:
let
cfg = config.wayland.windowManager.hyprland;
app = cfg.applications.musicplayer.default;
inherit (lib) mkIf;
in
{
config = mkIf (cfg.enable && app == "ncmpcpp") {
programs = {
ncmpcpp = {
enable = true;
};
};
services = {
mpd = {
enable = true;
};
};
};
}

View file

@ -0,0 +1,22 @@
{
config,
lib,
...
}:
let
cfg = config.wayland.windowManager.hyprland;
app = cfg.applications.networksettings.default;
inherit (lib) mkIf;
in
{
imports = [ ../../../networkmanager-dmenu ];
config = mkIf (cfg.enable && app == "networkmanager_dmenu") {
programs.networkmanager-dmenu = {
enable = true;
config.dmenu.dmenu_command = "bemenu";
};
};
}

View file

@ -0,0 +1,47 @@
{
config,
lib,
pkgs,
...
}:
let
cfg = config.wayland.windowManager.hyprland;
app = cfg.applications.rssreader.default;
reloadTime = "${toString config.programs.newsboat.reloadTime}";
newsboat-reload = (import ./newsboat-reload.nix { inherit config pkgs; });
inherit (lib) mkIf;
in
{
config = mkIf (cfg.enable && app == "newsboat") {
programs.newsboat = {
enable = true;
extraConfig = builtins.readFile ./extra-config;
};
home.packages = [ newsboat-reload ]; # newsboat's waybar module executes newsboat-reload on click
# Automatically reload newsboat on timer
systemd.user = {
timers.newsboat-reload = {
Unit.Description = "Reload newsboat every ${reloadTime} minutes";
Timer.OnBootSec = "10sec";
Timer.OnUnitActiveSec = "${reloadTime}min";
Timer.Unit = "newsboat-reload.service";
Install.WantedBy = [ "timers.target" ];
};
services.newsboat-reload = {
Unit.Description = "Reload newsboat";
Service.Type = "oneshot";
Service.ExecStart = "${newsboat-reload}/bin/newsboat-reload";
Install.WantedBy = [ "multi-user.target" ];
};
};
};
}

View file

@ -0,0 +1,35 @@
# Format
feedlist-title-format "Your feeds (%u unread, %t total)%?T? - tag %T&?"
articlelist-title-format "Articles in feed %T (%u unread, %t total) - %U"
searchresult-title-format "Search result (%u unread, %t total)"
filebrowser-title-format "%?O?Open File&Save File? - %f"
help-title-format "Help"
selecttag-title-format "Select Tag"
selectfilter-title-format "Select Filter"
itemview-title-format "%T (%u unread, %t total) "
urlview-title-format "URLs"
dialogs-title-format "Dialogs"
feedlist-format "%4i %n %11u %t"
articlelist-format "%4i %f %D %?T?|%-17T| ?%t"
notify-format "%d new articles (%n unread articles, %f unread feeds)"
# Colors
color background white default
color listnormal white default
color listfocus white black bold
color listnormal_unread magenta default
color listfocus_unread magenta black bold
color info blue black bold
color article white default
# Highlight
highlight article "(^Feed:.*|^Title:.*|^Author:.*)" blue default bold
highlight article "(^Link:.*|^Date:.*)" default default
highlight article "https?://[^ ]+" green default
highlight article "^(Title):.*$" blue default
highlight article "\\[[0-9][0-9]*\\]" magenta default bold
highlight article "\\[image\\ [0-9]+\\]" green default bold
highlight article "\\[embedded flash: [0-9][0-9]*\\]" green default bold
highlight article ":.*\\(link\\)$" cyan default
highlight article ":.*\\(image\\)$" blue default
highlight article ":.*\\(embedded flash\\)$" magenta default

View file

@ -0,0 +1,10 @@
{ config, pkgs, ... }:
let
newsboat = "${pkgs.newsboat}/bin/newsboat";
notify = "${pkgs.libnotify}/bin/notify-send";
signal = "${toString config.programs.waybar.settings.mainBar."custom/newsboat".signal}";
in
(pkgs.writeShellScriptBin "newsboat-reload" ''
${notify} -u low 'Newsboat' 'Reloading RSS feeds...' && ${newsboat} -x reload && ${notify} -u low 'Newsboat' 'RSS feeds reloaded.' && pkill -RTMIN+${signal} waybar
'')

View file

@ -0,0 +1,22 @@
{
config,
lib,
...
}:
let
cfg = config.wayland.windowManager.hyprland;
app = cfg.applications.password-manager.default;
inherit (lib) mkIf;
in
{
imports = [ ../../../password-manager ];
config = mkIf (cfg.enable && app == "passmenu-bemenu") {
programs.passwordManager = {
enable = true;
wayland = true;
};
};
}

View file

@ -0,0 +1,18 @@
{
config,
lib,
pkgs,
...
}:
let
cfg = config.wayland.windowManager.hyprland;
app = cfg.applications.powermenu.default;
inherit (lib) mkIf;
in
{
config = mkIf (cfg.enable && app == "powermenu-bemenu") {
home.packages = [ (import ./powermenu-bemenu.nix { inherit config pkgs; }) ];
};
}

View file

@ -0,0 +1,10 @@
{ config, pkgs, ... }:
(pkgs.writeShellScriptBin "powermenu-bemenu" ''
case $(echo -e "shutdown\nreboot\nlock\nkill" | bemenu -p "") in
shutdown) systemctl poweroff ;;
reboot) systemctl reboot ;;
lock) "${config.programs.hyprlock.package}/bin/hyprlock" ;;
kill) hyprctl dispatch exit ;;
esac
'')

View file

@ -0,0 +1,22 @@
{
config,
lib,
pkgs,
...
}:
let
cfg = config.wayland.windowManager.hyprland;
app = cfg.applications.presentation-mode.default;
inherit (lib) mkIf;
in
{
config = mkIf (cfg.enable && app == "presentation-mode-bemenu") {
home.packages = [
(pkgs.writeShellScriptBin "presentation-mode-bemenu" (
builtins.readFile ./presentation-mode-bemenu.sh
))
];
};
}

View file

@ -0,0 +1,32 @@
# Variables
DISPLAYS=( $(hyprctl monitors | grep -E '^Monitor' | awk '{print $2}') )
EXTEND_RIGHT="Extend to right of main"
EXTEND_LEFT="Extend to left of main"
MIRROR="Mirror main"
DISABLE="Disable main"
# Exit if only one display is available
[[ "${#DISPLAYS[@]}" -eq 1 ]] && echo "Only one display available." && exit 0
MAIN_DISPLAY=${DISPLAYS[0]}
SECOND_DISPLAY=${DISPLAYS[1]} # TODO: Add support for more than two displays
# Select action
ACTIONS="$EXTEND_RIGHT\n$EXTEND_LEFT\n$MIRROR\n$DISABLE"
ACTIONS_CHOICE=$(echo -e "$ACTIONS" | bemenu -p "Select action")
# Handle actions that do not need a mode
case "$ACTIONS_CHOICE" in
"$MIRROR") hyprctl keyword monitor "$SECOND_DISPLAY", preferred, auto, 1, mirror, "$MAIN_DISPLAY" && exit 0;;
"$DISABLE") hyprctl keyword monitor "$MAIN_DISPLAY", disable && exit 0;;
esac
# Select mode
MODES=$( hyprctl monitors | awk '/^Monitor/{flag=1; next} /^$/{flag=0} flag' | awk -F "availableModes: " '{print $2}' | sed 's/ /\\n/g' | awk NF )
MODES_CHOICE=$(echo -e "$MODES" | bemenu -p "Select mode")
# Handle actions that need a mode
case "$ACTIONS_CHOICE" in
"$EXTEND_RIGHT") hyprctl keyword monitor "$SECOND_DISPLAY", "$MODES_CHOICE", auto-right, 1 ;;
"$EXTEND_LEFT") hyprctl keyword monitor "$SECOND_DISPLAY", "$MODES_CHOICE", auto-left, 1 ;;
esac

View file

@ -0,0 +1,34 @@
{
config,
lib,
pkgs,
...
}:
let
cfg = config.wayland.windowManager.hyprland;
app = cfg.applications.torrent-client.default;
desktop = "org.qbittorrent.qBittorrent.desktop";
mimeTypes = [
"application/x-bittorrent"
"x-scheme-handler/magnet"
];
associations =
let
genMimeAssociations = import ../genMimeAssociations.nix;
in
genMimeAssociations desktop mimeTypes;
inherit (lib) mkIf;
in
{
config = mkIf (cfg.enable && app == "qbittorrent") {
home.packages = [ pkgs.qbittorrent ];
# TODO: automatically apply dark theme
xdg.mimeApps = {
defaultApplications = associations;
associations.added = associations;
};
};
}

View file

@ -0,0 +1,18 @@
{
config,
lib,
pkgs,
...
}:
let
cfg = config.wayland.windowManager.hyprland;
app = cfg.applications.screenshotter.default;
inherit (lib) mkIf;
in
{
config = mkIf (cfg.enable && app == "screenshot") {
home.packages = [ (import ./screenshot.nix { inherit config pkgs; }) ];
};
}

View file

@ -0,0 +1,11 @@
{ config, pkgs, ... }:
# pass the mode (output, window, region) as a command line argument
let
screenshotDir = "${config.xdg.userDirs.pictures}/screenshots";
in
(pkgs.writeShellScriptBin "screenshot" ''
mkdir -p ${screenshotDir}
${pkgs.hyprshot}/bin/hyprshot --mode $1 --output-folder ${screenshotDir} --filename screenshot_$(date +"%Y-%m-%d_%H-%M-%S").png
'')

View file

@ -0,0 +1,43 @@
{
config,
lib,
pkgs,
...
}:
let
cfg = config.wayland.windowManager.hyprland;
app = cfg.applications.emailclient.default;
desktop = "thunderbird.desktop";
mimeTypes = [
"message/rfc822"
"x-scheme-handler/mailto"
"text/calendar"
"text/x-vcard"
];
associations =
let
genMimeAssociations = import ../genMimeAssociations.nix;
in
genMimeAssociations desktop mimeTypes;
inherit (lib) mkIf;
in
{
config = mkIf (cfg.enable && app == "thunderbird") {
home.packages = [ pkgs.thunderbird ];
# programs.thunderbird = {
# enable = true;
# profiles.default = {
# isDefault = mkDefault true;
# withExternalGnupg = mkDefault true;
# };
# };
xdg.mimeApps = {
defaultApplications = associations;
associations.added = associations;
};
};
}

View file

@ -0,0 +1,20 @@
{
config,
lib,
...
}:
let
cfg = config.wayland.windowManager.hyprland;
app = cfg.applications.filemanager.default;
inherit (lib) mkIf;
in
{
config = mkIf (cfg.enable && app == "yazi") {
programs.yazi = {
enable = true;
enableZshIntegration = config.programs.zsh.enable;
};
};
}

View file

@ -0,0 +1,33 @@
{ config, lib, ... }:
let
cfg = config.wayland.windowManager.hyprland;
app = cfg.applications.pdfviewer.default;
desktop = "org.pwmt.zathura.desktop";
mimeTypes = [
"application/pdf"
];
associations =
let
genMimeAssociations = import ../genMimeAssociations.nix;
in
genMimeAssociations desktop mimeTypes;
inherit (lib) mkIf;
in
{
config = mkIf (cfg.enable && app == "zathura") {
programs.zathura = {
enable = true;
options = {
guiptions = "none";
selection-clipboard = "clipboard";
};
};
xdg.mimeApps = {
defaultApplications = associations;
associations.added = associations;
};
};
}

View file

@ -0,0 +1,34 @@
{
config,
lib,
pkgs,
...
}:
let
cfg = config.wayland.windowManager.hyprland;
hyprland = import ./hyprland.nix;
mediakeys = import ./mediakeys.nix { inherit pkgs; };
windows = import ./windows.nix;
workspaces = import ./workspaces.nix;
binds = builtins.concatLists [
hyprland
mediakeys
windows
workspaces
];
inherit (lib) mkIf;
in
{
config = mkIf cfg.enable {
wayland.windowManager.hyprland = {
settings = {
bind = binds;
bindm = (import ./mouse.nix);
};
};
};
}

View file

@ -0,0 +1,3 @@
[
# "$mod CTRL, b, exec, killall -SIGUSR1 waybar" # toggle bar # FIXME: waybar: no process found
]

View file

@ -0,0 +1,22 @@
{ pkgs, ... }:
let
brightness = "${pkgs.brightnessctl}/bin/brightnessctl";
player = "${pkgs.playerctl}/bin/playerctl";
volume = "${pkgs.pulseaudio}/bin/pactl";
in
[
", XF86MonBrightnessUp, exec, ${brightness} s +5%" # increase screen brightness
", XF86MonBrightnessDown, exec, ${brightness} s 5%-" # decrease screen brightness
", XF86AudioRaiseVolume, exec, ${volume} set-sink-volume 0 +5%" # raise speaker volume
", XF86AudioLowerVolume, exec, ${volume} set-sink-volume 0 -5%" # lower speaker volume
"SHIFT, XF86AudioRaiseVolume, exec, ${volume} set-source-volume 0 +1%" # raise mic volume
"SHIFT, XF86AudioLowerVolume, exec, ${volume} set-source-volume 0 -1%" # lower mic volume
", XF86AudioMute, exec, ${volume} set-sink-mute 0 toggle" # mute/unmute speaker
"SHIFT, XF86AudioMute, exec, ${volume} set-source-mute 0 toggle" # mute/unmute mic
", XF86AudioMicMute, exec, ${volume} set-source-mute 0 toggle" # mute/unmute mic
", XF86AudioPlay, exec, ${player} play-pause" # toggle between play and pause music
", XF86AudioStop, exec, ${player} stop" # stop music
", XF86AudioPrev, exec, ${player} previous" # play previous
", XF86AudioNext, exec, ${player} next" # play next
]

View file

@ -0,0 +1,4 @@
[
"$mod, mouse:272, movewindow" # left mouse button
"$mod, mouse:273, resizewindow" # right mouse button
]

View file

@ -0,0 +1,27 @@
[
"$mod SHIFT, c, killactive" # kill active window
"$mod SHIFT, Return, layoutmsg, swapwithmaster master" # make active window master
"$mod CTRL, Return, layoutmsg, focusmaster" # focus master
"$mod, j, layoutmsg, cyclenext" # focus next window
"$mod, k, layoutmsg, cycleprev" # focus previous window
"$mod SHIFT, j, layoutmsg, swapnext" # swaps window with next
"$mod SHIFT, k, layoutmsg, swapprev" # swaps window with previous
"$mod, h, splitratio, -0.05" # decrease horizontal space of master stack
"$mod, l, splitratio, +0.05" # increase horizontal space of master stack
"$mod SHIFT, h, resizeactive, 0 -40" # shrink active window vertically
"$mod SHIFT, l, resizeactive, 0 40" # expand active window vertically
"$mod, i, layoutmsg, addmaster" # add active window to master stack
"$mod SHIFT, i, layoutmsg, removemaster" # remove active window from master stack
"$mod, o, layoutmsg, orientationcycle left top" # toggle between left and top orientation
"$mod, left, movefocus, l" # focus window to the left
"$mod, right, movefocus, r" # focus window to the right
"$mod, up, movefocus, u" # focus upper window
"$mod, down, movefocus, d" # focus lower window
"$mod SHIFT, left, swapwindow, l" # swap active window with window to the left
"$mod SHIFT, right, swapwindow, r" # swap active window with window to the right
"$mod SHIFT, up, swapwindow, u" # swap active window with upper window
"$mod SHIFT, down, swapwindow, d" # swap active window with lower window
"$mod, f, togglefloating" # toggle floating for active window
"$mod CTRL, f, workspaceopt, allfloat" # toggle floating for all windows on workspace
"$mod SHIFT, f, fullscreen" # toggle fullscreen for active window
]

View file

@ -0,0 +1,38 @@
[
"$mod, 1, workspace, 1" # go to workspace 1
"$mod, 2, workspace, 2" # ...
"$mod, 3, workspace, 3"
"$mod, 4, workspace, 4"
"$mod, 5, workspace, 5"
"$mod, 6, workspace, 6"
"$mod, 7, workspace, 7"
"$mod, 8, workspace, 8"
"$mod, 9, workspace, 9"
"$mod, 0, workspace, 10"
"$mod SHIFT, 1, movetoworkspacesilent, 1" # move active window to workspace 1
"$mod SHIFT, 2, movetoworkspacesilent, 2" # ...
"$mod SHIFT, 3, movetoworkspacesilent, 3"
"$mod SHIFT, 4, movetoworkspacesilent, 4"
"$mod SHIFT, 5, movetoworkspacesilent, 5"
"$mod SHIFT, 6, movetoworkspacesilent, 6"
"$mod SHIFT, 7, movetoworkspacesilent, 7"
"$mod SHIFT, 8, movetoworkspacesilent, 8"
"$mod SHIFT, 9, movetoworkspacesilent, 9"
"$mod SHIFT, 0, movetoworkspacesilent, 10"
"$mod CTRL, 1, focusworkspaceoncurrentmonitor, 1" # focus workspace 1 on current monitor
"$mod CTRL, 2, focusworkspaceoncurrentmonitor, 2" # ...
"$mod CTRL, 3, focusworkspaceoncurrentmonitor, 3"
"$mod CTRL, 4, focusworkspaceoncurrentmonitor, 4"
"$mod CTRL, 5, focusworkspaceoncurrentmonitor, 5"
"$mod CTRL, 6, focusworkspaceoncurrentmonitor, 6"
"$mod CTRL, 7, focusworkspaceoncurrentmonitor, 7"
"$mod CTRL, 8, focusworkspaceoncurrentmonitor, 8"
"$mod CTRL, 9, focusworkspaceoncurrentmonitor, 9"
"$mod CTRL, 0, focusworkspaceoncurrentmonitor, 10"
"$mod, Tab, workspace, previous_per_monitor" # go to previous workspace
"$mod SHIFT, Tab, movetoworkspace, previous_per_monitor" # move active window to previous workspace
"$mod, comma, focusmonitor, l" # go to left monitor
"$mod, period, focusmonitor, r" # go to right monitor
"$mod SHIFT, comma, movecurrentworkspacetomonitor, l" # move current workspace to left monitor
"$mod SHIFT, period, movecurrentworkspacetomonitor, r" # move current workspace to right monitor
]

View file

@ -0,0 +1,46 @@
{
config,
lib,
pkgs,
...
}:
let
cfg = config.wayland.windowManager.hyprland;
desktop = "chromium-browser.desktop";
inherit (lib)
mkDefault
mkIf
;
in
{
config = mkIf cfg.enable {
programs.chromium = {
enable = mkDefault true;
package = mkDefault pkgs.ungoogled-chromium;
};
# Never open chromium by default
xdg.mimeApps.associations.removed = mkIf config.programs.chromium.enable {
"application/pdf" = desktop;
"application/rdf+xml" = desktop;
"application/rss+xml" = desktop;
"application/xhtml+xml" = desktop;
"application/xhtml_xml" = desktop;
"application/xml" = desktop;
"image/gif" = desktop;
"image/jpeg" = desktop;
"image/png" = desktop;
"image/webp" = desktop;
"text/html" = desktop;
"text/xml" = desktop;
"x-scheme-handler/http" = desktop;
"x-scheme-handler/https" = desktop;
"x-scheme-handler/webcal" = desktop;
"x-scheme-handler/mailto" = desktop;
"x-scheme-handler/about" = desktop;
"x-scheme-handler/unknown" = desktop;
};
};
}

View file

@ -0,0 +1,26 @@
{
config,
lib,
pkgs,
...
}:
let
inherit (lib) mkForce;
in
{
home.pointerCursor = {
name = mkForce "Bibata-Original-Ice";
size = mkForce 24;
package = mkForce pkgs.bibata-cursors;
};
home.packages = [ pkgs.hyprcursor ];
home.sessionVariables = {
HYPRCURSOR_THEME = config.home.pointerCursor.name;
HYPRCURSOR_SIZE = toString config.home.pointerCursor.size;
};
# wayland.windowManager.hyprland.cursor.no_hardware_cursors = true;
}

View file

@ -0,0 +1,104 @@
{
config,
lib,
pkgs,
...
}:
let
cfg = config.wayland.windowManager.hyprland;
inherit (lib)
mkDefault
mkOption
mkIf
types
;
in
{
imports = [
../waybar
./applications
./binds
./chromium.nix
./cursor.nix
./hyprlock.nix
./xdg
];
options.wayland.windowManager.hyprland = {
autostart = mkOption {
type = types.bool;
default = false;
description = "Whether to automatically start Hyprland after login. Only supported for ZSH.";
};
modifier = mkOption {
type = types.str;
default = "SUPER";
description = "The modifier key to use.";
};
};
config = {
wayland.windowManager.hyprland = {
systemd = {
enable = mkDefault true;
enableXdgAutostart = mkDefault false;
variables = mkDefault [ "--all" ];
# extraCommands = [ # fix for dunst
# "${pkgs.dbus}/bin/dbus-update-activation-environment WAYLAND_DISPLAY"
# "systemctl --user restart dunst.service"
# ];
};
xwayland.enable = mkDefault true;
settings = import ./settings.nix { inherit config lib pkgs; };
};
# Set some environment variables that hopefully fix some Wayland stuff
home.sessionVariables = {
CLUTTER_BACKEND = mkDefault "wayland";
GDK_BACKEND = mkDefault "wayland";
MOZ_ENABLE_WAYLAND = mkDefault 1;
NIXOS_OZONE_WL = mkDefault 1;
QT_AUTO_SCREEN_SCALE_FACTOR = mkDefault 1;
QT_QPA_PLATFORM = mkDefault "wayland";
QT_WAYLAND_DISABLE_WINDOWDECORATION = mkDefault 1;
WAYLAND_DISPLAY = mkDefault "wayland-1";
XDG_CURRENT_DESKTOP = mkDefault "Hyprland";
XDG_SESSION_DESKTOP = mkDefault "Hyprland";
XDG_SESSION_TYPE = mkDefault "wayland";
# WLR_RENDERER_ALLOW_SOFTWARE = mkDefault 1; # TODO: For VMs only?
};
# waybar
programs.waybar.enable = mkIf cfg.enable (mkDefault true);
# auto discover fonts in `home.packages`
fonts.fontconfig.enable = true;
# notifications
services.dunst = {
enable = mkDefault true;
waylandDisplay = config.home.sessionVariables.WAYLAND_DISPLAY;
};
# install some applications
home.packages = import ./packages.nix { inherit pkgs; }; # use programs.PACKAGE or services.SERVICE when possible
# autostart
programs.zsh.loginExtra = mkIf cfg.autostart ''
if [ -z "$DISPLAY" ] && [ "$TTY" = "/dev/tty1" ]; then
exec Hyprland
fi
'';
services.udiskie = {
enable = mkDefault true;
tray = mkDefault "never";
};
services.network-manager-applet.enable = mkDefault true;
};
}

View file

@ -0,0 +1,38 @@
{ config, lib, ... }:
let
cfg = config.wayland.windowManager.hyprland;
inherit (lib) mkIf;
in
{
programs.hyprlock = mkIf cfg.enable {
enable = true;
settings = {
general = {
disable_loading_bar = true;
grace = 0;
hide_cursor = true;
no_fade_in = true;
};
animations.enabled = false;
label = {
text = "$TIME";
font_size = 100;
position = "0, 50";
halign = "center";
valign = "center";
};
input-field = {
size = "200, 50";
position = "0, -80";
dots_center = true;
fade_on_empty = false;
outline_thickness = 3;
};
};
};
}

View file

@ -0,0 +1,16 @@
{ pkgs, ... }:
# use `config.programs` or `config.services` when available
with pkgs;
[
file
grim
helvum
libnotify
slurp
udiskie
udisks
wev
wl-clipboard
]

View file

@ -0,0 +1,56 @@
{ config, lib, ... }:
let
cfg = config.wayland.windowManager.hyprland;
inherit (builtins) toString;
inherit (lib) mkDefault;
in
{
# Do not add binds here. Use `./binds/default.nix` instead.
"$mod" = cfg.modifier;
windowrule = [
"center, floating:1, not class:^(Gimp)$, not class:^(steam)$"
"float, title:^(Open|Save) Files?$"
"noborder, onworkspace:w[t1]"
"bordersize ${toString cfg.settings.general.border_size}, floating:1"
# https://wiki.hyprland.org/Useful-Utilities/Screen-Sharing/#xwayland
"opacity 0.0 override, class:^(xwaylandvideobridge)$"
"noanim, class:^(xwaylandvideobridge)$"
"noinitialfocus, class:^(xwaylandvideobridge)$"
"maxsize 1 1, class:^(xwaylandvideobridge)$"
"noblur, class:^(xwaylandvideobridge)$"
];
# Layouts
general.layout = mkDefault "master";
master = {
mfact = mkDefault 0.5;
new_status = mkDefault "master";
new_on_top = mkDefault true;
};
input.kb_layout = mkDefault "de";
xwayland = {
force_zero_scaling = mkDefault true;
};
misc = {
disable_hyprland_logo = mkDefault true;
force_default_wallpaper = mkDefault 0;
};
# Styling
animations.enabled = mkDefault false;
decoration = {
blur.enabled = mkDefault false;
shadow.enabled = mkDefault false;
};
general = {
resize_on_border = mkDefault true;
border_size = mkDefault 2;
};
}

View file

@ -0,0 +1,27 @@
{
config,
lib,
pkgs,
...
}:
let
cfg = config.wayland.windowManager.hyprland;
portal = pkgs.xdg-desktop-portal-hyprland;
inherit (lib) mkDefault mkIf;
in
{
config.xdg = mkIf cfg.enable {
enable = mkDefault true;
mime.enable = mkDefault true;
mimeApps.enable = mkDefault true;
userDirs = {
enable = mkDefault true;
createDirectories = mkDefault true;
};
portal.enable = mkDefault true;
portal.extraPortals = [ portal ];
portal.configPackages = [ portal ];
};
}

View file

@ -0,0 +1,22 @@
{ lib, ... }:
let
inherit (lib) mkDefault;
in
{
programs.kitty = {
settings = {
confirm_os_window_close = mkDefault 0;
enable_audio_bell = mkDefault "no";
window_margin_width = mkDefault 5;
};
};
home.sessionVariables = {
TERMINAL = "kitty";
};
home.shellAliases = {
s = "kitten ssh"; # copy terminfo
};
}

View file

@ -0,0 +1,51 @@
{
inputs,
config,
lib,
pkgs,
...
}:
let
cfg = config.programs.librewolf;
inherit (lib) mkDefault mkIf;
in
{
imports = [ ./search ];
config = {
programs.librewolf = {
policies.Homepage.StartPage = mkDefault "previous-session";
profiles.default = {
extensions.packages = import ./extensions.nix { inherit inputs pkgs; };
settings = import ./settings.nix;
search = {
force = true;
default = "Startpage";
privateDefault = "Startpage";
order = [ "Startpage" ];
engines = {
Startpage = {
urls = [ { template = "https://www.startpage.com/do/dsearch?q={searchTerms}"; } ];
icon = "https://www.startpage.com/sp/cdn/favicons/favicon--default.ico";
updateInterval = 24 * 60 * 60 * 1000; # every day
};
# engines below are disabled
bing.metaData.hidden = true;
ddg.metaData.hidden = true;
google.metaData.hidden = true;
};
};
};
};
home.sessionVariables = mkIf cfg.enable (
with cfg;
{
DEFAULT_BROWSER = "${package}/bin/librewolf";
BROWSER = "${package}/bin/librewolf";
}
);
};
}

View file

@ -0,0 +1,9 @@
{ inputs, pkgs, ... }:
with inputs.nur.legacyPackages."${pkgs.stdenv.hostPlatform.system}".repos.rycee.firefox-addons;
[
darkreader
floccus
ublock-origin
]

View file

@ -0,0 +1,88 @@
{
config,
lib,
pkgs,
...
}:
let
cfg = config.programs.librewolf;
engines = import ./engines.nix pkgs;
urlRegex = "^(http|https|ftp)://";
isUrl = s: (match urlRegex s) != null;
transformEngine =
engine:
let
every_day = 24 * 60 * 60 * 1000;
in
{
urls = [ { template = engine.url; } ];
icon = engine.icon;
updateInterval = if (isUrl engine.icon) then every_day else null;
definedAliases = optional (engine ? alias) engine.alias;
};
transformedEngines = mapAttrs' (name: engine: {
name = name;
value = transformEngine engine;
}) engines;
inherit (lib)
listToAttrs
mapAttrs
mapAttrs'
mkOption
optional
types
;
inherit (lib.strings) match;
in
{
options.programs.librewolf = {
searchEngines = mkOption {
type = types.listOf types.str;
default = [
"github"
"home-manager-options"
"nixos-options"
"nixos-wiki"
"nixpkgs"
"nixpkgs-issues"
"noogle"
"nuschtos"
"wikiless"
"youtube"
];
example = [
"github"
"home-manager-options"
"howlongtobeat"
"keyforsteam"
"nixos-options"
"nixos-wiki"
"nixpkgs"
"nixpkgs-issues"
"noogle"
"nuschtos"
"protondb"
"steamdb"
"wikiless"
"youtube"
];
description = "Additional search engines for LibreWolf.";
};
};
config.programs.librewolf = {
profiles.default.search.engines = mapAttrs (_: name: transformedEngines.${name}) (
listToAttrs (
map (name: {
name = name;
value = name;
}) cfg.searchEngines
)
);
};
}

View file

@ -0,0 +1,87 @@
pkgs:
{
github = {
url = "https://github.com/search?q={searchTerms}";
icon = "https://github.com/favicon.ico";
alias = "@gh";
};
home-manager-options = {
url = "https://home-manager-options.extranix.com/?query={searchTerms}&release=release-25.11";
icon = "${pkgs.nixos-icons}/share/icons/hicolor/scalable/apps/nix-snowflake.svg";
alias = "@hm";
};
nixpkgs = {
url = "https://search.nixos.org/packages?channel=25.11&query={searchTerms}";
icon = "${pkgs.nixos-icons}/share/icons/hicolor/scalable/apps/nix-snowflake.svg";
alias = "@np";
};
nixos-options = {
url = "https://search.nixos.org/options?channel=25.11&query={searchTerms}";
icon = "${pkgs.nixos-icons}/share/icons/hicolor/scalable/apps/nix-snowflake.svg";
alias = "@no";
};
nixos-wiki = {
url = "https://wiki.nixos.org/w/index.php?search={searchTerms}";
icon = "https://wiki.nixos.org/favicon.png";
alias = "@nw";
};
noogle = {
url = "https://noogle.dev/q?term={searchTerms}";
icon = "${pkgs.nixos-icons}/share/icons/hicolor/scalable/apps/nix-snowflake.svg";
alias = "@nf";
};
nuschtos = {
url = "https://search.xn--nschtos-n2a.de/?query={searchTerms}";
icon = "${pkgs.nixos-icons}/share/icons/hicolor/scalable/apps/nix-snowflake.svg";
alias = "@nu";
};
nixpkgs-issues = {
url = "https://github.com/NixOS/nixpkgs/issues?q=is%3Aissue%20state%3Aopen%20{searchTerms}";
icon = "${pkgs.nixos-icons}/share/icons/hicolor/scalable/apps/nix-snowflake.svg";
alias = "@ni";
};
wikiless = {
url = "https://wikiless.metastem.su/wiki/{searchTerms}";
icon = "https://wikiless.metastem.su/wikiless-favicon.ico";
alias = "@wiki";
};
youtube = {
url = "https://www.youtube.com/results?search_query={searchTerms}";
icon = "https://www.youtube.com/favicon.ico";
alias = "@yt";
};
protondb = {
url = "https://www.protondb.com/search?q={searchTerms}";
icon = "https://www.protondb.com/favicon.ico";
alias = "@pdb";
};
steamdb = {
url = "https://steamdb.info/search/?a=all&q={searchTerms}";
icon = "https://steamdb.info/favicon.ico";
alias = "@stdb";
};
keyforsteam = {
url = "https://www.keyforsteam.de/katalog/?search_name={searchTerms}";
icon = "https://www.keyforsteam.de/favicon.ico";
alias = "@k4s";
};
howlongtobeat = {
url = "https://howlongtobeat.com/?q={searchTerms}";
icon = "https://howlongtobeat.com/favicon.ico";
alias = "@hltb";
};
}

View file

@ -0,0 +1,20 @@
{
"browser.cache.disk.enable" = false;
"browser.cache.disk_cache_ssl" = false;
"browser.cache.insecure.enable" = false;
"browser.cache.memory.enable" = false;
"browser.cache.offline.enable" = false;
"browser.newtabpage.enabled" = false;
"browser.startup.homepage" = "chrome://browser/content/blanktab.html";
"browser.toolbars.bookmarks.visibility" = "never";
"browser.urlbar.shortcuts.history" = false;
"browser.urlbar.shortcuts.tabs" = false;
"browser.urlbar.suggest.history" = false;
"browser.urlbar.suggest.openpage" = false;
"browser.urlbar.suggest.recentsearches" = false;
"places.history.enabled" = false;
"plugin.scan.plid.all" = false;
"privacy.donottrackheader.enabled" = true;
"sidebar.revmap" = true;
"sidebar.verticalTabs" = true;
}

View file

@ -0,0 +1,55 @@
{
config,
lib,
pkgs,
...
}:
let
cfg = config.programs.networkmanager-dmenu;
inherit (lib)
mkEnableOption
mkIf
mkOption
types
;
in
{
options.programs.networkmanager-dmenu = {
enable = mkEnableOption "networkmanager-dmenu.";
package = mkOption {
type = types.package;
default = pkgs.networkmanager_dmenu;
description = "The package to use for networkmanager-dmenu.";
};
config = {
dmenu = {
dmenu_command = mkOption {
type = types.str;
default = "dmenu";
description = "Command for dmenu, can include arguments.";
};
};
};
};
config = mkIf cfg.enable {
home.packages = [
cfg.package
pkgs.modemmanager # for "Enable WWAN"
pkgs.networkmanager # for `nmcli`
pkgs.networkmanagerapplet # for "Launch Connection Manager"
pkgs.networkmanager-openconnect # VPN support
pkgs.openconnect # VPN support
];
xdg.configFile."networkmanager-dmenu/config.ini".text = ''
[dmenu]
dmenu_command=${cfg.config.dmenu.dmenu_command}
'';
};
}

View file

@ -0,0 +1,104 @@
{
inputs,
config,
lib,
...
}:
let
cfg = config.programs.nixvim;
inherit (lib) mkDefault mkIf;
in
{
imports = [
inputs.nixvim.homeModules.nixvim
./plugins
./spellfiles.nix
];
config = {
programs.nixvim = {
clipboard.providers.wl-copy.enable = mkDefault true;
defaultEditor = mkDefault true;
enableMan = mkDefault true;
viAlias = mkDefault true;
vimAlias = mkDefault true;
vimdiffAlias = mkDefault true;
# vim.g.*
globals = {
mapleader = mkDefault " ";
};
# vim.opt.*
opts = {
# behavior
cursorline = mkDefault true; # highlights the line under the cursor
mouse = mkDefault "a"; # enable mouse support
nu = mkDefault true; # line numbers
relativenumber = mkDefault true; # relative line numbers
scrolloff = mkDefault 20; # keeps some context above/below cursor
signcolumn = mkDefault "yes"; # reserve space for signs (e.g., GitGutter)
undofile = mkDefault true; # persistent undo
updatetime = mkDefault 500; # ms to wait for trigger an event (default 4000ms)
wrap = mkDefault true; # wraps text if it exceeds the width of the window
# search
ignorecase = mkDefault true; # ignore case in search patterns
smartcase = mkDefault true; # smart case
incsearch = mkDefault true; # incremental search
hlsearch = mkDefault true; # highlight search
# windows
splitbelow = mkDefault true; # new windows are created below current
splitright = mkDefault true; # new windows are created to the right of current
equalalways = mkDefault true; # window sizes are automatically updated.
# tabs
expandtab = mkDefault true; # convert tabs into spaces
shiftwidth = mkDefault 2; # number of spaces to use for each step of (auto)indent
smartindent = mkDefault true; # smart autoindenting on new lines
softtabstop = mkDefault 2; # number of spaces in tab when editing
tabstop = mkDefault 2; # number of visual spaces per tab
# spell checking
spell = mkDefault true;
spelllang = mkDefault [
"en_us"
"de_20"
];
};
# vim.diagnostic.config.*
diagnostic.settings = {
virtual_text = {
spacing = 4;
prefix = "";
severity_sort = true;
};
signs = true;
underline = true;
update_in_insert = false;
};
extraConfigLua = ''
vim.cmd "set noshowmode" -- Hides "--INSERT--" mode indicator
'';
keymaps = import ./keymaps.nix;
};
home = {
sessionVariables = {
EDITOR = mkIf cfg.enable "nvim";
VISUAL = mkIf cfg.enable "nvim";
};
shellAliases = {
v = mkIf cfg.enable "nvim";
};
};
};
}

View file

@ -0,0 +1,347 @@
[
# cursor navigation
{
# scroll down, recenter
key = "<C-d>";
action = "<C-d>zz";
mode = "n";
}
{
# scroll up, recenter
key = "<C-u>";
action = "<C-u>zz";
mode = "n";
}
# searching
{
# center cursor after search next
key = "n";
action = "nzzzv";
mode = "n";
}
{
# center cursor after search previous
key = "N";
action = "Nzzzv";
mode = "n";
}
{
# ex command
key = "<leader>pv";
action = "<cmd>Ex<CR>";
mode = "n";
}
# search and replace
{
# search and replace word under cursor
key = "<leader>s";
action = ":%s/<C-r><C-w>/<C-r><C-w>/gI<Left><Left><Left>";
mode = "n";
}
# search and replace selected text
{
key = "<leader>s";
action = "y:%s/<C-r>0/<C-r>0/gI<Left><Left><Left>";
mode = "v";
}
# clipboard operations
{
# copy to system clipboard in visual mode
key = "<C-c>";
action = ''"+y '';
mode = "v";
}
{
# paste from system clipboard in visual mode
key = "<C-v>";
action = ''"+p '';
mode = "v";
}
{
# yank to system clipboard
key = "<leader>Y";
action = "+Y";
mode = "n";
}
{
# replace selected text with clipboard content
key = "<leader>p";
action = "_dP";
mode = "x";
}
{
# delete without copying to clipboard
key = "<leader>d";
action = "_d";
mode = [
"n"
"v"
];
}
# line operations
{
# move lines down in visual mode
key = "J";
action = ":m '>+1<CR>gv=gv";
mode = "v";
}
{
# move lines up in visual mode
key = "K";
action = ":m '<-2<CR>gv=gv";
mode = "v";
}
{
# join lines
key = "J";
action = "mzJ`z";
mode = "n";
}
# quickfix
{
# Run make command
key = "<leader>m";
action = "<cmd>:make<CR>";
mode = "n";
}
{
# previous quickfix item
key = "<C-A-J>";
action = "<cmd>cprev<CR>zz";
mode = "n";
}
{
# next quickfix item
key = "<C-A-K>";
action = "<cmd>cnext<CR>zz";
mode = "n";
}
# location list navigation
{
# previous location list item
key = "<leader>j";
action = "<cmd>lprev<CR>zz";
mode = "n";
}
{
# next location list item
key = "<leader>k";
action = "<cmd>lnext<CR>zz";
mode = "n";
}
# disabling keys
{
# disable the 'Q' key
key = "Q";
action = "<nop>";
mode = "n";
}
# text selection
{
# select whole buffer
key = "<C-a>";
action = "ggVG";
mode = "n";
}
# window operations
{
# focus next window
key = "<C-j>";
action = ":wincmd W<CR>";
options = {
noremap = true;
silent = true;
};
mode = "n";
}
{
# focus previous window
key = "<C-k>";
action = ":wincmd w<CR>";
options = {
noremap = true;
silent = true;
};
mode = "n";
}
# window size adjustments
{
# increase window width
key = "<C-l>";
action = ":vertical resize +5<CR>";
options = {
noremap = true;
silent = true;
};
mode = "n";
}
{
# decrease window width
key = "<C-h>";
action = ":vertical resize -5<CR>";
options = {
noremap = true;
silent = true;
};
mode = "n";
}
# window closing and opening
{
# close current window
key = "<leader-S>c";
action = ":q<CR>";
options = {
noremap = true;
silent = true;
};
mode = "n";
}
{
# new vertical split at $HOME
key = "<leader>n";
action = ":vsp $HOME<CR>";
options = {
noremap = true;
silent = true;
};
mode = "n";
}
# window split orientation toggling
{
# toggle split orientation
key = "<leader>t";
action = ":wincmd T<CR>";
options = {
noremap = true;
silent = true;
};
mode = "n";
}
# spell checking
{
# toggle spell checking
key = "<leader>ss";
action = ":setlocal spell!<CR>";
options = {
noremap = true;
silent = true;
};
mode = "n";
}
{
# switch to english spell checking
key = "<leader>se";
action = ":setlocal spelllang=en_us<CR>";
options = {
noremap = true;
silent = true;
};
mode = "n";
}
{
# switch to german spell checking
key = "<leader>sg";
action = ":setlocal spelllang=de_20<CR>";
options = {
noremap = true;
silent = true;
};
mode = "n";
}
{
# move to next misspelling
key = "]s";
action = "]szz";
options = {
noremap = true;
silent = true;
};
mode = "n";
}
{
# move to previous misspelling
key = "[s";
action = "[szz";
options = {
noremap = true;
silent = true;
};
mode = "n";
}
{
# correction suggestions for a misspelled word
key = "z=";
action = "z=";
options = {
noremap = true;
silent = true;
};
mode = "n";
}
{
# adding words to the dictionary
key = "zg";
action = "zg";
options = {
noremap = true;
silent = true;
};
mode = "n";
}
# buffer navigation
{
# next buffer
key = "<C-S-J>";
action = ":bnext<CR>";
options = {
noremap = true;
silent = true;
};
mode = "n";
}
{
# previous buffer
key = "<C-S-K>";
action = ":bprevious<CR>";
options = {
noremap = true;
silent = true;
};
mode = "n";
}
{
# close current buffer
key = "<leader>bd";
action = ":bdelete<CR>";
options = {
noremap = true;
silent = true;
};
mode = "n";
}
{
# apply code action
key = "<leader>ca";
action = ":lua vim.lsp.buf.code_action()<CR>";
options = {
noremap = true;
silent = true;
};
mode = "n";
}
]

View file

@ -0,0 +1,54 @@
{ config, lib, ... }:
let
cfg = config.programs.nixvim;
plugin = cfg.plugins.cmp;
inherit (lib) mkDefault mkIf;
in
{
programs.nixvim = {
plugins = {
cmp = {
enable = mkDefault true;
settings = {
autoEnableSources = mkDefault true;
experimental.ghost_text = mkDefault true;
snippet.expand = mkDefault "luasnip";
formatting.fields = mkDefault [
"kind"
"abbr"
"menu"
];
sources = [
{ name = "git"; }
{ name = "nvim_lsp"; }
{
name = "buffer";
option.get_bufnrs.__raw = "vim.api.nvim_list_bufs";
keywordLength = 3;
}
{
name = "path";
keywordLength = 3;
}
{ name = "luasnip"; }
];
mapping = {
"<C-Space>" = "cmp.mapping.complete()";
"<C-d>" = "cmp.mapping.scroll_docs(-4)";
"<C-e>" = "cmp.mapping.close()";
"<C-f>" = "cmp.mapping.scroll_docs(4)";
"<C-CR>" = "cmp.mapping.confirm({ select = true })";
"<S-Tab>" = "cmp.mapping(cmp.mapping.select_prev_item(), {'i', 's'})";
"<Tab>" = "cmp.mapping(cmp.mapping.select_next_item(), {'i', 's'})";
};
};
};
cmp-cmdline = mkIf plugin.enable { enable = mkDefault false; }; # autocomplete for cmdline
cmp_luasnip = mkIf plugin.enable { enable = mkDefault true; };
luasnip = mkIf plugin.enable { enable = mkDefault true; };
cmp-treesitter = mkIf (plugin.enable && cfg.plugins.treesitter.enable) { enable = mkDefault true; };
};
};
}

View file

@ -0,0 +1,18 @@
{ lib, ... }:
{
imports = [
./cmp.nix
./lsp.nix
./lualine.nix
./telescope.nix
# ./treesitter.nix # HOTFIX: does not build
./trouble.nix
];
config.programs.nixvim.plugins = {
markdown-preview.enable = lib.mkDefault true;
# warning: Nixvim: `plugins.web-devicons` was enabled automatically because the following plugins are enabled. This behaviour is deprecated. Please explicitly define `plugins.web-devicons.enable`
web-devicons.enable = true;
};
}

View file

@ -0,0 +1,69 @@
{
config,
lib,
pkgs,
...
}:
let
cfg = config.programs.nixvim;
plugin = cfg.plugins.lsp;
inherit (lib) mkDefault mkIf optional;
in
{
config = {
programs.nixvim = {
plugins = {
lsp-format = mkIf plugin.enable { enable = mkDefault true; };
lsp = {
enable = mkDefault true;
postConfig = "";
keymaps = {
silent = mkDefault true;
diagnostic = mkDefault {
# Navigate in diagnostics
"<leader>k" = "goto_prev";
"<leader>j" = "goto_next";
};
lspBuf = mkDefault {
gd = "definition";
gD = "references";
gt = "type_definition";
gi = "implementation";
K = "hover";
"<F2>" = "rename";
};
};
servers = {
bashls.enable = mkDefault true;
clangd.enable = mkDefault true;
cssls.enable = mkDefault true;
dockerls.enable = mkDefault true;
gopls.enable = mkDefault true;
html.enable = mkDefault true;
jsonls.enable = mkDefault true;
nixd.enable = mkDefault true;
pyright.enable = mkDefault true;
rust_analyzer = {
enable = mkDefault true;
installCargo = mkDefault true;
installRustc = mkDefault true;
settings.rustfmt.overrideCommand = mkDefault [
"${pkgs.rustfmt}/bin/rustfmt --edition 2021" # --config tab_spaces=2"
];
};
texlab.enable = mkDefault true;
vhdl_ls.enable = mkDefault true;
yamlls.enable = mkDefault true;
};
};
};
};
home.packages = optional (cfg.enable && plugin.servers.nixd.enable) pkgs.nixfmt;
};
}

View file

@ -0,0 +1,18 @@
{ config, lib, ... }:
let
cfg = config.programs.nixvim;
plugin = cfg.plugins.lualine;
inherit (lib) mkDefault;
in
{
config = {
programs.nixvim = {
plugins.lualine = {
enable = mkDefault true;
settings.options.icons_enabled = mkDefault false;
};
};
};
}

View file

@ -0,0 +1,52 @@
{
config,
lib,
pkgs,
...
}:
let
cfg = config.programs.nixvim;
plugin = cfg.plugins.telescope;
inherit (lib) mkDefault optionals;
in
{
config = {
programs.nixvim = {
plugins.telescope = {
enable = mkDefault true;
extensions = {
file-browser.enable = mkDefault true;
fzf-native.enable = mkDefault true;
live-grep-args.enable = mkDefault true;
manix.enable = mkDefault true;
};
keymaps = mkDefault {
"<C-e>" = "file_browser";
"<C-p>" = "git_files";
"<leader>bl" = "buffers";
"<leader>fd" = "diagnostics";
"<leader>ff" = "find_files";
"<leader>fg" = "live_grep";
"<leader>fh" = "help_tags";
"<leader>fm" = "man_pages";
"<leader>fn" = "manix";
"<leader>fo" = "oldfiles";
"<space>fb" = "file_browser";
};
};
keymaps = optionals plugin.enable [
{
key = "<C-f>";
action = ":lua require('telescope').extensions.live_grep_args.live_grep_args()<CR>";
mode = "n";
}
];
};
home.packages = optionals plugin.enable [
pkgs.ripgrep # for "live_grep"
];
};
}

View file

@ -0,0 +1,42 @@
{
config,
lib,
pkgs,
...
}:
let
cfg = config.programs.nixvim;
plugin = cfg.plugins.treesitter;
cc = "${pkgs.gcc}/bin/gcc";
inherit (lib) mkDefault mkIf;
in
{
config = {
programs.nixvim = {
plugins.treesitter = {
enable = mkDefault true;
nixvimInjections = mkDefault true;
settings = {
folding.enable = mkDefault true;
highlight.enable = mkDefault true;
indent.enable = mkDefault true;
};
};
plugins.treesitter-context = mkIf plugin.enable { enable = mkDefault true; };
plugins.treesitter-textobjects = mkIf plugin.enable { enable = mkDefault true; };
};
# Fix for: ERROR `cc` executable not found.
home.sessionVariables = mkIf plugin.enable {
CC = mkDefault cc;
};
# Fix for: WARNING `tree-sitter` executable not found
home.packages = mkIf plugin.enable [
plugin.package
];
};
}

View file

@ -0,0 +1,43 @@
{ config, lib, ... }:
let
cfg = config.programs.nixvim;
plugin = cfg.plugins.trouble;
inherit (lib) mkDefault mkIf;
in
{
config = {
programs.nixvim = {
plugins.trouble = {
enable = mkDefault true;
};
keymaps = mkIf plugin.enable [
{
mode = "n";
key = "<leader>xq";
action = "<CMD>Trouble qflist toggle<CR>";
options = {
desc = "Trouble quifick toggle";
};
}
{
mode = "n";
key = "<leader>xl";
action = "<CMD>Trouble loclist toggle<CR>";
options = {
desc = "Trouble loclist toggle";
};
}
{
mode = "n";
key = "<leader>xx";
action = "<CMD>Trouble diagnostics toggle<CR>";
options = {
desc = "Trouble diagnostics toggle";
};
}
];
};
};
}

View file

@ -0,0 +1,26 @@
{ config, pkgs, ... }:
let
spellDir = config.xdg.dataHome + "/nvim/site/spell";
baseUrl = "http://ftp.de.vim.org/runtime/spell";
in
{
home.file = {
de-spl = {
enable = true;
source = pkgs.fetchurl {
url = baseUrl + "/de.utf-8.spl";
sha256 = "sha256-c8cQfqM5hWzb6SHeuSpFk5xN5uucByYdobndGfaDo9E=";
};
target = spellDir + "/de.utf8.spl";
};
de-sug = {
enable = true;
source = pkgs.fetchurl {
url = baseUrl + "/de.utf-8.sug";
sha256 = "sha256-E9Ds+Shj2J72DNSopesqWhOg6Pm6jRxqvkerqFcUqUg=";
};
target = spellDir + "/de.utf8.sug";
};
};
}

View file

@ -0,0 +1,115 @@
{
inputs,
config,
lib,
pkgs,
...
}:
let
cfg = config.programs.passwordManager;
passmenuScript = pkgs.writeShellScriptBin "passmenu-bemenu" (builtins.readFile ./passmenu); # TODO: override original passmenu script coming from pass itself
passff-host = pkgs.passff-host;
inherit (lib)
mkDefault
mkEnableOption
mkIf
mkOption
mkOverride
types
;
in
{
options.programs.passwordManager = {
enable = mkEnableOption "password manager using pass, passmenu, and passff.";
length = mkOption {
type = types.str;
default = "20";
description = "Default length for generated passwords.";
};
charset = mkOption {
type = types.enum [
"alphanumerical"
"ascii"
"custom"
];
default = "alphanumerical";
description = ''
Character set for generated passwords. "alphanumerical" and "ascii" will get overwritten by the corresponding charset. Anything else will get parsed as the charset directly.
'';
};
editor = mkOption {
type = types.str;
default = "nvim";
description = "Editor to use for editing passwords. Make sure it is installed on your system.";
};
wayland = mkOption {
type = types.bool;
default = false;
description = "If true, bemenu and ydotool will be used instead of dmenu and xdotool.";
};
key = mkOption {
type = types.str;
default = "";
description = "GPG key for password store.";
};
};
config = mkIf cfg.enable {
programs.password-store = {
enable = true;
package = pkgs.pass.withExtensions (exts: [ exts.pass-otp ]);
settings = {
PASSWORD_STORE_DIR = mkDefault "${config.xdg.dataHome}/password-store";
PASSWORD_STORE_KEY = mkIf (cfg.key != "") cfg.key;
PASSWORD_STORE_GENERATED_LENGTH = cfg.length;
PASSWORD_STORE_CHARACTER_SET =
if cfg.charset == "alphanumerical" then
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
else if cfg.charset == "ascii" then
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*()_+-=[]{}|;:',.<>/?"
else
cfg.charset;
PASSWORD_STORE_ENABLE_EXTENSIONS = "true";
EDITOR = cfg.editor;
};
};
services.gpg-agent.pinentry.package = mkOverride 1001 pkgs.pinentry-qt; # mkDefault collides with gpg home module
home.packages = [
passmenuScript
pkgs.zbar
]
++ (
if cfg.wayland then
[
pkgs.bemenu
pkgs.ydotool
]
else
[
pkgs.dmenu
pkgs.xdotool
]
);
home.sessionVariables.PASSWORD_STORE_MENU = if cfg.wayland then "bemenu" else "dmenu";
# FIXME: passff does not autofill OTPs
programs.librewolf = mkIf config.programs.librewolf.enable {
package = pkgs.librewolf.override {
nativeMessagingHosts = [
passff-host
];
hasMozSystemDirPatch = true;
};
nativeMessagingHosts = [ passff-host ];
profiles.default.extensions.packages =
with inputs.nur.legacyPackages."${pkgs.stdenv.hostPlatform.system}".repos.rycee.firefox-addons; [
passff
];
};
};
}

View file

@ -0,0 +1,38 @@
#!/usr/bin/env bash
shopt -s nullglob globstar
typeit=0
if [[ $1 == "--type" ]]; then
typeit=1
shift
fi
if [[ -n $WAYLAND_DISPLAY ]]; then
dmenu="dmenu-wl"
xdotool="ydotool type --file -"
elif [[ -n $DISPLAY ]]; then
dmenu="dmenu"
xdotool="xdotool type --clearmodifiers --file -"
else
echo "Error: No Wayland or X11 display detected" >&2
exit 1
fi
# Overwrite dmenu if PASSMENU_SCRIPT_MENU is set and not empty
dmenu=${PASSWORD_STORE_MENU:-$dmenu}
prefix=${PASSWORD_STORE_DIR-~/.password-store}
password_files=( "$prefix"/**/*.gpg )
password_files=( "${password_files[@]#"$prefix"/}" )
password_files=( "${password_files[@]%.gpg}" )
password=$(printf '%s\n' "${password_files[@]}" | "$dmenu" "$@")
[[ -n $password ]] || exit
if [[ $typeit -eq 0 ]]; then
pass show -c "$password" 2>/dev/null
else
pass show "$password" | { IFS= read -r pass; printf %s "$pass"; } | $xdotool
fi

View file

@ -0,0 +1,55 @@
{
config,
lib,
pkgs,
...
}:
let
cfg = config.programs.rofi-rbw;
inherit (lib)
generators
mkEnableOption
mkIf
mkOption
mkPackageOption
types
;
in
{
options = {
programs.rofi-rbw = {
enable = mkEnableOption "rofi-rbw";
package = mkPackageOption pkgs "rofi-rbw" { };
settings = mkOption {
type = types.attrsOf (
types.oneOf [
types.str
types.int
types.bool
]
);
default = { };
example = {
action = "copy";
prompt = "Bitwarden";
selector = "rofi";
selector-args = "-i";
};
description = ''
Configuration settings for rofi-rbw.
See https://github.com/fdw/rofi-rbw/blob/main/docs/rofi-rbw.1.md
'';
};
};
};
config = mkIf cfg.enable {
home.packages = [ cfg.package ];
xdg.configFile."rofi-rbw.rc".text = generators.toKeyValue {
mkKeyValue = key: value: "${key} = ${toString value}";
} cfg.settings;
};
}

View file

@ -0,0 +1,22 @@
{
inputs,
config,
lib,
pkgs,
...
}:
let
secrets = "${toString inputs.self}/users/${config.home.username}/home/secrets/secrets.yaml";
in
{
imports = [ inputs.sops-nix.homeManagerModules.sops ];
home.packages = with pkgs; [
age
sops
];
sops.defaultSopsFile = lib.mkIf (builtins.pathExists secrets) (lib.mkDefault secrets);
sops.age.keyFile = lib.mkDefault "${config.home.homeDirectory}/.config/sops/age/keys.txt";
}

View file

@ -0,0 +1,91 @@
{
inputs,
config,
lib,
pkgs,
...
}:
let
cfg = config.stylix;
# all valid options for `cfg.scheme`
validSchemes = [
"ayu"
"dracula"
"gruvbox"
"moonfly"
"nord"
"oxocarbon"
];
# schemes names in `pkgs.base16-schemes` that need a suffix
needsSuffix = [
"ayu"
"gruvbox"
];
# schemes in ./schemes
customSchemes = [
"moonfly"
"oxocarbon"
];
schemeName =
if builtins.elem cfg.scheme needsSuffix then "${cfg.scheme}-${cfg.polarity}" else cfg.scheme;
scheme =
if builtins.elem cfg.scheme customSchemes then
./schemes/${schemeName}.yaml
else
"${pkgs.base16-schemes}/share/themes/${schemeName}.yaml";
inherit (lib)
mkDefault
mkIf
types
;
in
{
imports = [
inputs.stylix.homeModules.stylix
./targets
];
options.stylix = {
scheme = lib.mkOption {
type = types.str;
default = "dracula";
description = ''
Base16 color scheme name. Available options are:
${toString validSchemes}
'';
};
};
config = mkIf cfg.enable {
assertions = [
{
assertion = builtins.elem cfg.scheme validSchemes;
message = "Stylix: Invalid colorscheme '${cfg.scheme}'. Available options: ${toString validSchemes}";
}
];
stylix = {
autoEnable = mkDefault true;
base16Scheme = scheme;
fonts = {
monospace = mkDefault {
package = pkgs.hack-font;
name = "Hack";
};
};
polarity = mkDefault "dark";
targets = {
librewolf.profileNames = [ "default" ];
};
};
home.packages = [
(pkgs.callPackage ./print-colors { })
];
};
}

View file

@ -0,0 +1,22 @@
{
python3Packages,
...
}:
python3Packages.buildPythonApplication {
pname = "print-colors";
version = "1.0.0";
src = ./.;
pyproject = true;
build-system = [ python3Packages.setuptools ];
propagatedBuildInputs = [ python3Packages.pyyaml ];
doCheck = false;
meta = {
description = "Display colors from a YAML color palette file in the terminal.";
};
}

View file

@ -0,0 +1,81 @@
#!/usr/bin/env python3
import yaml
import argparse
def hex_to_rgb(hex_color):
"""Converts a hex color string (e.g., 'RRGGBB') to an RGB tuple."""
hex_color = hex_color.lstrip('#')
if len(hex_color) != 6:
raise ValueError(f"Invalid hex color format: {hex_color}. Expected 6 characters.")
return tuple(int(hex_color[i:i+2], 16) for i in (0, 2, 4))
def print_color_block(hex_color, label):
"""Prints a colored block with a label using ANSI escape codes."""
try:
r, g, b = hex_to_rgb(hex_color)
except ValueError as e:
print(f"Error converting hex '{hex_color}' for '{label}': {e}")
return
luminosity = (r * 0.2126 + g * 0.7152 + b * 0.0722)
if luminosity > 186:
text_color_code = ";38;2;0;0;0" # black
else:
text_color_code = ";38;2;255;255;255" # white
print(f"\x1b[48;2;{r};{g};{b}{text_color_code}m {label.ljust(15)} \x1b[0m")
def main():
parser = argparse.ArgumentParser(
description="Display colors from a YAML color palette file in the terminal."
)
parser.add_argument(
"yaml_file",
metavar="YAML_FILE",
type=str,
help="Path to the YAML file containing the color palette."
)
args = parser.parse_args()
yaml_file_path = args.yaml_file
try:
with open(yaml_file_path, 'r') as f:
data = yaml.safe_load(f)
except FileNotFoundError:
print(f"Error: '{yaml_file_path}' not found.")
return
except yaml.YAMLError as e:
print(f"Error parsing YAML file '{yaml_file_path}': {e}")
return
except Exception as e:
print(f"An unexpected error occurred while reading '{yaml_file_path}': {e}")
return
system_name = data.get('system', 'N/A')
theme_name = data.get('name', 'N/A')
description = data.get('description', 'N/A')
palette = data.get('palette', {})
print(f"\x1b[1mSystem:\x1b[0m {system_name}")
print(f"\x1b[1mTheme Name:\x1b[0m {theme_name}")
print(f"\x1b[1mDescription:\x1b[0m {description}\n")
print("\x1b[1mPalette Colors:\x1b[0m")
sorted_palette_keys = sorted(palette.keys(), key=lambda x: (x.startswith('base'), x))
for key in sorted_palette_keys:
hex_color = palette.get(key)
if hex_color:
print_color_block(hex_color, key)
else:
print(f"Warning: Key '{key}' has no hexadecimal color value.")
if __name__ == "__main__":
main()

View file

@ -0,0 +1,7 @@
from setuptools import setup
setup(
name='print-colors',
version='1.0.0',
scripts=['print-colors'],
)

View file

@ -0,0 +1,22 @@
system: "base16"
name: "Moonfly"
description: "A dark theme inspired by the Moonfly color scheme."
slug: "moonfly-theme"
variant: "dark"
palette:
base00: "080808"
base01: "323437"
base02: "9e9e9e"
base03: "bdbdbd"
base04: "b2ceee"
base05: "c6c6c6"
base06: "e4e4e4"
base07: "eeeeee"
base08: "ff5454"
base09: "cf87e8"
base0A: "8cc85f"
base0B: "e3c78a"
base0C: "79dac8"
base0D: "80a0ff"
base0E: "36c692"
base0F: "74b2ff"

View file

@ -0,0 +1,22 @@
system: "base16"
name: "Oxocarbon"
description: "A dark theme inspired by the Oxocarbon Dark color scheme."
slug: "oxocarbon-theme"
variant: "dark"
palette:
base00: "161616"
base01: "262626"
base02: "393939"
base03: "525252"
base04: "dde1e6"
base05: "f2f4f8"
base06: "ffffff"
base07: "08bdba"
base08: "ee5396"
base09: "ff7eb6"
base0A: "3ddbd9"
base0B: "42be65"
base0C: "82cfff"
base0D: "33b1ff"
base0E: "be95ff"
base0F: "78a9ff"

View file

@ -0,0 +1,55 @@
{ config, lib, ... }:
let
cfg = config.stylix;
target = cfg.targets.bemenu';
colors = config.lib.stylix.colors.withHashtag;
inherit (lib)
mkEnableOption
mkIf
mkOption
types
;
in
{
options.stylix.targets.bemenu' = {
enable = mkEnableOption "bemenu' target for Stylix.";
radius = mkOption {
type = types.int;
default = cfg.targets.hyprland.radius;
description = "Window corner radius in pixels.";
};
};
config = mkIf (cfg.enable && target.enable) {
stylix.targets.bemenu.enable = false;
programs.bemenu = mkIf (cfg.enable && target.enable) {
settings = {
border-radius = target.radius;
bdr = colors.blue; # Border
tb = colors.base00; # Title background
tf = colors.green; # Title foreground
fb = colors.base00; # Filter background
ff = colors.base05; # Filter foreground
cb = colors.base00; # Cursor background
cf = colors.base02; # Cursor foreground
nb = colors.base00; # Normal background
nf = colors.base05; # Normal foreground
hb = colors.base01; # Highlighted background
hf = colors.blue; # Highlighted foreground
fbb = colors.base00; # Feedback background
fbf = colors.base05; # Feedback foreground
sb = colors.base01; # Selected background
sf = colors.base05; # Selected foreground
ab = colors.base00; # Alternating background
af = colors.base05; # Alternating foreground
scb = colors.base00; # Scrollbar background
scf = colors.blue; # Scrollbar foreground
};
};
};
}

View file

@ -0,0 +1,8 @@
{
imports = [
./bemenu.nix
./hyprland.nix
./nixvim.nix
./waybar.nix
];
}

View file

@ -0,0 +1,40 @@
{ config, lib, ... }:
let
cfg = config.stylix;
target = cfg.targets.hyprland;
inherit (lib)
mkIf
mkOption
types
;
in
{
options.stylix.targets.hyprland = {
gaps = mkOption {
type = types.int;
default = 0;
description = "Window gaps in pixels.";
};
radius = mkOption {
type = types.int;
default = 0;
description = "Window corner radius in pixels.";
};
};
config = mkIf (cfg.enable && target.enable) {
wayland.windowManager.hyprland = {
settings = {
general = {
gaps_in = target.gaps / 2;
gaps_out = target.gaps;
};
decoration = {
rounding = target.radius;
};
};
};
};
}

View file

@ -0,0 +1,14 @@
{ config, lib, ... }:
let
cfg = config.stylix;
target = cfg.targets.nixvim;
inherit (lib) mkIf;
in
{
config = mkIf cfg.enable {
stylix.targets.nixvim.enable = false;
programs.nixvim.colorschemes."${cfg.scheme}".enable = !target.enable;
};
}

View file

@ -0,0 +1,130 @@
{ config, lib, ... }:
let
cfg = config.stylix;
target = cfg.targets.waybar';
colors = config.lib.stylix.colors.withHashtag;
gaps = toString (4 + target.gaps);
halfgaps = toString (2 + target.gaps / 2);
radius = toString target.radius;
bar = {
margin = "0 ${gaps} 0 ${gaps}";
tray = {
spacing = target.gaps;
};
# calendar has no css
clock.calendar.format = {
months = "<span color='${colors.blue}'><b>{}</b></span>";
weeks = "<span color='${colors.magenta}'><b>W{}</b></span>";
weekdays = "<span color='${colors.green}'><b>{}</b></span>";
today = "<span color='${colors.red}'><b><u>{}</u></b></span>";
};
};
inherit (lib)
mkEnableOption
mkIf
mkOption
types
;
in
{
options.stylix.targets.waybar' = {
enable = mkEnableOption "waybar' target for Stylix.";
gaps = mkOption {
type = types.int;
default = cfg.targets.hyprland.gaps;
description = "Widget gaps in pixels.";
};
radius = mkOption {
type = types.int;
default = cfg.targets.hyprland.radius;
description = "Widget corner radius in pixels.";
};
};
config = mkIf (cfg.enable && target.enable) {
stylix.targets.waybar.enable = false;
programs.waybar = {
settings = {
mainBar = bar;
otherBar = bar;
};
style = ''
* {
border-radius: ${radius}px;
border: none;
font-family: monospace;
font-size: 15px;
min-height: 5px;
transition: none;
}
window#waybar {
background: transparent;
}
#workspaces {
color: ${colors.base05};
background: ${colors.base00};
}
#workspaces button {
padding: ${halfgaps}px;
}
#workspaces button.active {
color: ${colors.blue};
}
#workspaces button.urgent {
color: ${colors.orange};
}
#workspaces button:hover {
color: ${colors.base00};
background: ${colors.base02};
}
#clock {
padding: ${gaps}px;
}
#cpu, #memory, #network, #battery, #keyboard-state, #disk, #bluetooth, #wireplumber, #pulseaudio, #language, #custom-newsboat, #custom-timer, #tray {
margin-left: ${gaps}px;
padding: ${gaps}px;
}
#keyboard-state label.locked {
background-color: ${colors.base00};
color: ${colors.blue};
}
#battery.charging {
background-color: ${colors.green};
color: ${colors.base00};
}
#battery.warning:not(.charging) {
background-color: ${colors.yellow};
color: ${colors.base00};
}
#battery.critical:not(.charging) {
background-color: ${colors.red};
color: ${colors.base00};
}
#bluetooth.discovering {
background-color: ${colors.blue};
color: ${colors.base00};
}
'';
};
};
}

View file

@ -0,0 +1,15 @@
let
uri = "qemu:///system";
in
{
dconf.settings = {
"org/virt-manager/virt-manager/connections" = {
autoconnect = [ uri ];
uris = [ uri ];
};
};
home.shellAliases = {
virsh = "virsh --connect ${uri}";
};
}

View file

@ -0,0 +1,133 @@
{
config,
lib,
pkgs,
...
}:
let
cfg = config.programs.waybar;
clock = {
format = mkDefault "{:%a %d %b %H:%M}";
tooltip-format = mkDefault "<tt><small>{calendar}</small></tt>";
timezone = mkDefault "Europe/Berlin";
locale = mkDefault "en_US.UTF-8";
calendar = {
mode = mkDefault "year";
mode-mon-col = mkDefault 3;
weeks-pos = mkDefault "right";
on-scroll = mkDefault 1;
};
actions = {
on-click-right = mkDefault "mode";
on-click-forward = mkDefault "tz_up";
on-click-backward = mkDefault "tz_down";
on-scroll-up = mkDefault "shift_up";
on-scroll-down = mkDefault "shift_down";
};
};
"hyprland/workspaces" = {
active-only = mkDefault false;
all-outputs = mkDefault false;
format = mkDefault "{name}";
on-click = mkDefault "activate";
on-scroll-up = mkDefault "hyprctl dispatch workspace e-1";
on-scroll-down = mkDefault "hyprctl dispatch workspace e+1";
};
keyboard-state = {
numlock = mkDefault true;
capslock = mkDefault true;
scrolllock = mkDefault true;
format = {
scrolllock = mkDefault "S ";
capslock = mkDefault "C ";
numlock = mkDefault "N";
};
};
"hyprland/language" = {
format = mkDefault "{}";
format-en = mkDefault "us";
format-de = mkDefault "de";
# TODO: switch language on click
};
# Add your custom modules here
"custom/newsboat" = import ./modules/newsboat.nix { inherit lib pkgs; };
"pulseaudio#input" = import ./modules/pulseaudio/input.nix { inherit lib pkgs; };
"pulseaudio#output" = import ./modules/pulseaudio/output.nix { inherit lib pkgs; };
battery = import ./modules/battery.nix { inherit lib; };
bluetooth = import ./modules/bluetooth.nix { inherit lib; };
cpu = import ./modules/cpu.nix { inherit lib; };
disk = import ./modules/disk.nix { inherit lib; };
memory = import ./modules/memory.nix { inherit lib; };
network = import ./modules/network.nix { inherit lib; };
wireplumber = import ./modules/wireplumber.nix { inherit lib; };
inherit (lib) mkDefault mkIf;
in
{
imports = [
./modules/timer # TODO: Do not use imports. Move to let-in-block.
];
config = mkIf cfg.enable {
home.packages = with pkgs; [ font-awesome ];
programs.waybar = {
systemd.enable = mkDefault true;
settings = {
mainBar = {
output = mkDefault "";
modules-left = mkDefault [
"hyprland/workspaces"
"keyboard-state"
"hyprland/language"
];
modules-center = mkDefault [ "clock" ];
modules-right = mkDefault [
"network"
"cpu"
"memory"
"disk"
"pulseaudio#input"
"pulseaudio#output"
"tray"
];
inherit
"custom/newsboat"
"hyprland/language"
"hyprland/workspaces"
"pulseaudio#input"
"pulseaudio#output"
battery
bluetooth
clock
cpu
disk
keyboard-state
memory
network
wireplumber
;
};
otherBar = {
output = with cfg.settings.mainBar; if (output != "") then "!${output}" else "nowhere";
modules-left = mkDefault [
"hyprland/workspaces"
];
modules-center = mkDefault [ "clock" ];
inherit
"hyprland/workspaces"
clock
;
};
};
};
};
}

View file

@ -0,0 +1,28 @@
# battery
{ lib, ... }:
let
inherit (lib) mkDefault;
in
{
interval = mkDefault 10;
states = {
warning = mkDefault 20;
critical = mkDefault 10;
};
format = mkDefault "{icon} {capacity}";
format-icons = mkDefault [
""
""
""
""
""
];
tooltip-format = mkDefault ''
{timeTo}
Capacity: {capacity}%
Power Draw: {power} W
Charge Cycles: {cycles}
Health: {health}%
'';
}

View file

@ -0,0 +1,20 @@
# bluetooth
{ lib, ... }:
let
inherit (lib) mkDefault;
in
{
format = mkDefault " {status}";
format-connected = mkDefault " {device_alias}";
format-connected-battery = mkDefault " {device_alias} {device_battery_percentage}%";
format-disabled = mkDefault "";
format-off = mkDefault "";
format-on = mkDefault "";
max-length = mkDefault 12;
on-click = "bluetoothctl power off";
tooltip-format = mkDefault "{controller_alias}\t{controller_address}\n\n{num_connections} connected";
tooltip-format-connected = mkDefault "{controller_alias}\t{controller_address}\n\n{num_connections} connected\n\n{device_enumerate}";
tooltip-format-enumerate-connected = mkDefault "{device_alias}\t{device_address}";
tooltip-format-enumerate-connected-battery = mkDefault "{device_alias}\t{device_address}\t{device_battery_percentage}%";
}

View file

@ -0,0 +1,25 @@
# cpu
{ lib, ... }:
let
inherit (lib) mkDefault;
in
{
interval = mkDefault 10;
format = mkDefault " {usage}";
tooltip-format = mkDefault ''
CPU Load: {load}
CPU Usage: {usage}%
Core 0 Usage: {usage0}%
Core 1 Usage: {usage1}%
Core 2 Usage: {usage2}%
Core 3 Usage: {usage3}%
Core 4 Usage: {usage4}%
Core 5 Usage: {usage5}%
Core 6 Usage: {usage6}%
Core 7 Usage: {usage7}%
Avg Frequency: {avg_frequency} GHz
Max Frequency: {max_frequency} GHz
Min Frequency: {min_frequency} GHz
'';
}

View file

@ -0,0 +1,11 @@
# disk
{ lib, ... }:
let
inherit (lib) mkDefault;
in
{
interval = mkDefault 3600;
format = mkDefault " {percentage_used}";
path = mkDefault "/";
}

View file

@ -0,0 +1,18 @@
# memory
{ lib, ... }:
let
inherit (lib) mkDefault;
in
{
interval = mkDefault 10;
format = mkDefault " {percentage}";
tooltip-format = mkDefault ''
Total Memory: {total} GiB
Used Memory: {used} GiB ({percentage}%)
Available Memory: {avail} GiB
Total Swap: {swapTotal} GiB
Used Swap: {swapUsed} GiB ({swapPercentage}%)
Available Swap: {swapAvail} GiB
'';
}

View file

@ -0,0 +1,48 @@
# network
{ lib, ... }:
let
inherit (lib) mkDefault;
in
{
interval = mkDefault 10;
format-wifi = mkDefault " {signalStrength}";
format-ethernet = mkDefault "";
format-disconnected = mkDefault ""; # An empty format will hide the module.
tooltip-format = mkDefault ''
Interface: {ifname}
IP Address: {ipaddr}
Gateway: {gwaddr}
Netmask: {netmask}
CIDR: {cidr}
ESSID: {essid}
Signal: {signaldBm} dBm / {signalStrength}%
Frequency: {frequency} GHz
Bandwidth Up: {bandwidthUpBits} / {bandwidthUpBytes}
Bandwidth Down: {bandwidthDownBits} / {bandwidthDownBytes}
Total Bandwidth: {bandwidthTotalBits} / {bandwidthTotalBytes}
Icon: {icon}
'';
tooltip-format-wifi = mkDefault ''
Interface: {ifname}
IP Address: {ipaddr}/{cidr}
Gateway: {gwaddr}
Netmask: {netmask}
ESSID: {essid}
Signal: {signaldBm} dBm / {signalStrength}%
Frequency: {frequency} GHz
Bandwidth Up: {bandwidthUpBits} / {bandwidthUpBytes}
Bandwidth Down: {bandwidthDownBits} / {bandwidthDownBytes}
Total Bandwidth: {bandwidthTotalBits} / {bandwidthTotalBytes}
'';
tooltip-format-ethernet = mkDefault ''
Interface: {ifname}
IP Address: {ipaddr}/{cidr}
Gateway: {gwaddr}
Netmask: {netmask}
Bandwidth Up: {bandwidthUpBits} / {bandwidthUpBytes}
Bandwidth Down: {bandwidthDownBits} / {bandwidthDownBytes}
Total Bandwidth: {bandwidthTotalBits} / {bandwidthTotalBytes}
'';
tooltip-format-disconnected = mkDefault "Disconnected";
}

View file

@ -0,0 +1,29 @@
# custom/newsboat
{
lib,
pkgs,
...
}:
let
newsboat-print-unread =
let
newsboat = "${pkgs.newsboat}/bin/newsboat";
in
(pkgs.writeShellScriptBin "newsboat-print-unread" ''
UNREAD=$(${newsboat} -x print-unread | awk '{print $1}')
if [[ $UNREAD -gt 0 ]]; then
printf " %i" "$UNREAD"
fi
'');
inherit (lib) mkDefault;
in
{
exec = mkDefault "${newsboat-print-unread}/bin/newsboat-print-unread";
format = mkDefault "{}";
hide-empty-text = mkDefault true; # disable module when output is empty
signal = mkDefault 10;
on-click = mkDefault "newsboat-reload";
}

View file

@ -0,0 +1,20 @@
# pulseaudio input
{ lib, pkgs, ... }:
let
helvum = "${pkgs.helvum}/bin/helvum";
pactl = "${pkgs.pulseaudio}/bin/pactl";
inherit (lib) mkDefault;
in
{
format = mkDefault "{format_source}";
format-source = mkDefault " {volume}";
format-source-muted = mkDefault "";
on-click = mkDefault "${pactl} set-source-mute 0 toggle";
on-click-middle = mkDefault helvum;
on-scroll-down = mkDefault "${pactl} set-source-volume 0 -5%";
on-scroll-up = mkDefault "${pactl} set-source-volume 0 +5%";
scroll-step = mkDefault 1;
smooth-scrolling-threshold = mkDefault 1;
}

View file

@ -0,0 +1,27 @@
# pulseaudio output
{ lib, pkgs, ... }:
let
helvum = "${pkgs.helvum}/bin/helvum";
pactl = "${pkgs.pulseaudio}/bin/pactl";
inherit (lib) mkDefault;
in
{
format = mkDefault "{icon} {volume}";
format-muted = mkDefault "x";
format-icons = mkDefault {
default = mkDefault [
""
""
""
];
};
max-volume = mkDefault 150;
on-click = mkDefault "${pactl} set-sink-mute 0 toggle";
on-click-middle = mkDefault helvum;
on-scroll-down = mkDefault "${pactl} set-sink-volume 0 -5%";
on-scroll-up = mkDefault "${pactl} set-sink-volume 0 +5%";
scroll-step = mkDefault 5;
smooth-scrolling-threshold = mkDefault 1;
}

View file

@ -0,0 +1,28 @@
# custom/timer
{
config,
lib,
pkgs,
...
}:
let
cfg = config.programs.waybar;
timer = pkgs.writeShellScriptBin "timer" (builtins.readFile ./timer.sh);
inherit (lib) mkDefault mkIf;
in
{
config = mkIf cfg.enable {
programs.waybar.settings.mainBar."custom/timer" = {
exec = mkDefault "${timer}/bin/timer print";
# `interval` is not needed since timer script will update the status bar
format = mkDefault "{}";
hide-empty-text = mkDefault true; # disable module when output is empty
signal = mkDefault 11;
on-click = mkDefault "${timer}/bin/timer stop";
};
home.packages = [ timer ]; # Add an additional check if the widget is enabled? Currently, the waybar module installs this package regardless of the config.
};
}

View file

@ -0,0 +1,78 @@
TIMER_FILE="/tmp/timer" # file to store the current time
SIGNAL=11 # signal number to send to status bar
STATUS_BAR="waybar" # Support for more status bars?
help() {
echo "Usage: $0 {start -h H -m M -s S|stop|print}"
}
start_timer() {
local hours=$1
local minutes=$2
local seconds=$3
local total_seconds=$((hours * 3600 + minutes * 60 + seconds))
(
notify-send "Timer Started" "Your countdown timer has been started."
trap "exit" INT TERM
trap "rm -f -- '$TIMER_FILE'" EXIT
while [ $total_seconds -gt 0 ]; do
hours=$(( total_seconds / 3600 ))
minutes=$(( (total_seconds % 3600) / 60 ))
seconds=$(( total_seconds % 60 ))
printf "%02d:%02d:%02d\n" $hours $minutes $seconds > $TIMER_FILE
pkill -RTMIN+$SIGNAL $STATUS_BAR
sleep 1
total_seconds=$(( total_seconds - 1 ))
done
notify-send "Timer Finished" "Your countdown timer has ended."
stop_timer
) &
}
stop_timer() {
rm -f $TIMER_FILE
pkill -RTMIN+$SIGNAL $STATUS_BAR
exit 0
}
print_time() {
if [[ -f $TIMER_FILE ]]; then
printf " %s" "$(cat $TIMER_FILE)"
else
echo "" # waybar widget will be hidden if stdout is empty
fi
}
if [ "$1" = "start" ]; then
shift
while getopts "h:m:s:" opt; do
case $opt in
h) HOURS=$OPTARG ;;
m) MINUTES=$OPTARG ;;
s) SECONDS=$OPTARG ;;
*) echo "Invalid option"; exit 1 ;;
esac
done
HOURS=${HOURS:-0}
MINUTES=${MINUTES:-0}
SECONDS=${SECONDS:-0}
start_timer $HOURS $MINUTES $SECONDS
elif [ "$1" = "stop" ]; then
notify-send "Timer Stopped" "Your countdown timer has been stopped."
stop_timer
elif [ "$1" = "print" ]; then
print_time
else
echo "Invalid command $1"
help
exit 1
fi

View file

@ -0,0 +1,18 @@
# wireplumber
{ lib, ... }:
let
inherit (lib) mkDefault;
in
{
format = mkDefault "{icon} {volume}";
format-muted = mkDefault "mute"; # <U+f6a9> does not render. See issue #144
format-icons = mkDefault [
""
""
""
];
on-click = mkDefault "helvum";
max-volume = mkDefault 150;
scroll-step = mkDefault 1;
}