rearrange directory structure

This commit is contained in:
Tristan 2024-01-05 21:53:27 +00:00
parent 2fe0f94a23
commit 67cb4995f9
33 changed files with 213 additions and 219 deletions

266
home/default.nix Normal file
View file

@ -0,0 +1,266 @@
{
config,
pkgs,
...
}:
# https://nix-community.github.io/home-manager/options.html
let
my-deps = {
notify-send = "${pkgs.libnotify}/bin/notify-send";
playerctl = "${pkgs.playerctl}/bin/playerctl";
grim = "${pkgs.grim}/bin/grim";
slurp = "${pkgs.slurp}/bin/slurp";
amixer = "${pkgs.alsa-utils}/bin/amixer";
swaybg = "${pkgs.swaybg}/bin/swaybg";
terminal = "${config.programs.terminal}/bin/${config.programs.terminal.pname}";
chafa = "${pkgs.chafa}/bin/chafa";
exiftool = "${pkgs.exiftool}/bin/exiftool";
wc = "${pkgs.coreutils}/bin/wc";
jq = "${pkgs.jq}/bin/jq";
hyprctl = "${pkgs.hyprland}/bin/hyprctl";
xargs = "${pkgs.findutils}/bin/xargs";
menu = "${config.programs.menu.package}${config.programs.menu.dmenuCommand}";
fileman = "${pkgs.pcmanfm}/bin/pcmanfm";
gawk = "${pkgs.gawk}/bin/awk";
glow = "${pkgs.glow}/bin/glow";
ffmpegthumbnailer = "${pkgs.ffmpegthumbnailer}/bin/ffmpegthumbnailer";
};
lf-sixel = pkgs.callPackage ../custom/lf-sixel/. {};
in {
imports = [
./modules/terminal.nix
./modules/scripts.nix
./modules/email.nix
./modules/editor.nix
./modules/mpd.nix
./modules/menu.nix
./modules/scripts.nix
./programs/graphical.nix
./programs/scripts.nix
./programs/neovim/.
./programs/git.nix
];
programs.home-manager.enable = true;
home.homeDirectory = "/home/${config.home.username}";
xdg.userDirs.enable = true;
home.packages = with pkgs; [
libnotify
dig
jq
fx
mosh
ripgrep
usbutils
wl-clipboard
du-dust
htop
libsixel
yt-dlp
playerctl
neofetch
tree
ansible
];
programs.fish = {
enable = true;
};
services.udiskie = {
enable = true;
notify = true;
};
programs.rbw = {
enable = true;
settings = {
email = "tristan@tristans.cloud";
base_url = "https://vault.tristans.cloud";
pinentry = "gnome3";
};
};
programs.ssh.enable = true;
programs.ssh.matchBlocks = {
"git.tristans.cloud" = {
user = "git";
hostname = "100.116.82.65";
port = 2222;
};
"alpine" = {
hostname = "100.116.82.65";
user = "tristan";
};
};
programs.lf.enable = true;
programs.lf.package = lf-sixel;
programs.lf.keybindings = {
D = "trash";
R = "drag";
"<f-2>" = ":rename";
"<enter>" = "open-with";
};
programs.lf.commands = {
drag = "%${pkgs.ripdrag}/bin/ripdrag -x \"$fx\"";
trash = "%${pkgs.trash-cli}/bin/trash-put \"$fx\"";
open = "$set -f; ${pkgs.ranger}/bin/rifle -p 0 \"$fx\"";
open-with = '' ''${{
set -f
${pkgs.ranger}/bin/rifle -l "$fx"
read -p "Open with: " method
${pkgs.ranger}/bin/rifle -p "$method" "$fx"
}}'';
bulk-rename = '' ''${{
old="$(mktemp)"
new="$(mktemp)"
if [ -n "$fs" ]; then
fs="$(basename -a $fs)"
else
fs="$(ls)"
fi
printf '%s\n' "$fs" >"$old"
printf '%s\n' "$fs" >"$new"
$EDITOR "$new"
[ "$(wc -l < "$new")" -ne "$(wc -l < "$old")" ] && exit
paste "$old" "$new" | while IFS= read -r names; do
src="$(printf '%s' "$names" | cut -f1)"
dst="$(printf '%s' "$names" | cut -f2)"
if [ "$src" = "$dst" ] || [ -e "$dst" ]; then
continue
fi
mv -- "$src" "$dst"
done
rm -- "$old" "$new"
lf -remote "send $id unselect"
}}'';
};
programs.lf.previewer.source = pkgs.writeShellScript "preview" ''
image () {
echo "$1"
${my-deps.chafa} "$1" -f sixel -s "$(($2/2))x$3" | sed 's/#/\n#/g'
${my-deps.exiftool} "$1"
}
batted () {
cat "$@"
}
mkdir -p "$HOME/.cache/lf"
CACHE="$HOME/.cache/lf/thumbnail.$(stat --printf '%n\0%i\0%F\0%s\0%W\0%Y' -- "$(readlink -f "$1")" | sha256sum | awk '{print $1}'))"
case "$(printf "%s\n" "$(readlink -f "$1")" | awk '{print tolower($0)}')" in
*.tgz|*.tar.gz) tar tzf "$1" ;;
*.tar.bz2|*.tbz2) tar tjf "$1" ;;
*.tar.txz|*.txz) xz --list "$1" ;;
*.tar) tar tf "$1" ;;
*.zip|*.jar|*.war|*.ear|*.oxt) unzip -l "$1" ;;
*.rar) unrar l "$1" ;;
*.md) ${my-deps.glow} -s dark "$1" ;;
*.7z) 7z l "$1" ;;
*.[1-8]) man "$1" | col -b ;;
*.o) nm "$1";;
*.torrent) transmission-show "$1" ;;
*.iso) iso-info --no-header -l "$1" ;;
*.odt|*.ods|*.odp|*.sxw) odt2txt "$1" ;;
*.doc) catdoc "$1" ;;
*.docx) docx2txt "$1" - ;;
*.xml|*.html) w3m -dump "$1";;
*.xls|*.xlsx)
ssconvert --export-type=Gnumeric_stf:stf_csv "$1" "fd://1" | batted --language=csv
;;
*.wav|*.mp3|*.flac|*.m4a|*.wma|*.ape|*.ac3|*.og[agx]|*.spx|*.opus|*.as[fx]|*.mka)
${my-deps.exiftool} "$1"
;;
*.pdf)
[ ! -f "$CACHE.jpg" ] && \
pdftoppm -jpeg -f 1 -singlefile "$1" "$CACHE"
image "$CACHE.jpg" "$2" "$3" "$4" "$5"
;;
*.epub)
[ ! -f "$CACHE" ] && \
epub-thumbnailer "$1" "$CACHE" 1024
image "$CACHE" "$2" "$3" "$4" "$5"
;;
*.cbz|*.cbr|*.cbt)
[ ! -f "$CACHE" ] && \
comicthumb "$1" "$CACHE" 1024
image "$CACHE" "$2" "$3" "$4" "$5"
;;
*.avi|*.mp4|*.wmv|*.dat|*.3gp|*.ogv|*.mkv|*.mpg|*.mpeg|*.vob|*.fl[icv]|*.m2v|*.mov|*.webm|*.ts|*.mts|*.m4v|*.r[am]|*.qt|*.divx)
[ ! -f "$CACHE.jpg" ] && \
${my-deps.ffmpegthumbnailer} -i "$1" -o "$CACHE.jpg" -s 0 -q 5
image "$CACHE.jpg" "$2" "$3" "$4" "$5"
;;
*.bmp|*.jpg|*.jpeg|*.png|*.xpm|*.webp|*.jfif)
image "$1" "$2" "$3" "$4" "$5"
;;
*.svg)
[ ! -f "$CACHE.jpg" ] && \
convert "$1" "$CACHE.jpg"
image "$CACHE.jpg" "$2" "$3" "$4" "$5"
;;
*.ino)
batted --language=cpp "$1"
;;
*)
batted "$1"
;;
esac
'';
home.file.".icons/default".source = "${pkgs.vanilla-dmz}/share/icons/Vanilla-DMZ";
programs.helix = {
enable = true;
languages = {
nix = {
auto-format = true;
language-server = {
command = "${pkgs.rnix-lsp}/bin/rnix-lsp";
};
};
go = {
auto-format = true;
language-server = {
command = "${pkgs.gopls}/bin/gopls";
};
};
typescript = {
auto-format = true;
language-server = {
command = "${pkgs.nodePackages.typescript-language-server}/bin/typescript-language-server";
};
};
};
};
home.file.".config/pipewire/pipewire.conf.d/raop-discover.conf".text = ''
context.modules = [
{
name = libpipewire-module-raop-discover
args = { }
}
]
'';
services.kdeconnect = {
enable = true;
indicator = true;
};
programs.pandoc = {
enable = true;
defaults = {
metadata = {
author = "Tristan Beedell";
};
pdf-engine = "xelatex";
};
};
programs.direnv.enable = true;
}

49
home/modules/editor.nix Normal file
View file

@ -0,0 +1,49 @@
{
lib,
pkgs,
config,
...
}: let
editor = config.programs.editor;
pkg = editor.package;
menu = config.programs.menu.package + config.programs.menu.dmenuCommand;
editorCmd = "NIXOS_OZONE_WL= ${pkg}/bin/${pkg.executableName}";
in {
options.programs = with lib; {
editor = {
package = mkPackageOption pkgs "vscodium" {
example = "pkgs.vscode";
};
};
};
config = {
programs.vscode = {
enable = true;
package = editor.package;
extensions = [];
userSettings = {
"keyboard.dispatch" = "keyCode";
"terminal.integrated.sendKeybindingsToShell" = true;
"aws.telemetry" = false;
"gitlens.telemetry.enabled" = false;
"redhat.telemetry.enabled" = false;
"cSpell.language" = "en,en-GB";
};
};
programs.scripts = [
{
name = "open-code";
text = ''
code_dir=~/Documents/code
cd $code_dir
repo=$(ls | ${menu})
[ -e "$repo" ] && ${editorCmd} $repo
'';
install = false;
hotkeys = [{key = "C";}];
}
];
};
}

228
home/modules/email.nix Normal file
View file

@ -0,0 +1,228 @@
{
lib,
pkgs,
config,
...
}: let
cfg = config.roles.email;
terminal = config.programs.terminal;
termcmd = "${terminal}/bin/${terminal.pname}";
in {
options.roles = with lib; {
email = {
enable = mkEnableOption "email settings";
email = mkOption {
description = "email address";
};
terminal = mkOption {
type = types.bool;
default = true;
};
};
};
config = lib.mkIf cfg.enable {
programs.scripts = [
{
name = "email";
text = ''
${termcmd} -e aerc
'';
install = false;
hotkeys = [{key = "E";}];
}
];
programs.git = {
userName = config.home.userFullname;
userEmail = cfg.email;
};
accounts.email.accounts.${cfg.email} = lib.mkIf cfg.terminal {
notmuch.enable = true;
neomutt.enable = true;
aerc.enable = true;
mbsync.enable = true;
mbsync.create = "both";
userName = cfg.email;
realName = config.home.userFullname;
address = cfg.email;
primary = true;
passwordCommand = "${pkgs.rbw}/bin/rbw get privateemail";
smtp = {
host = "mail.privateemail.com";
port = 465;
tls.enable = true;
};
imap = {
host = "mail.privateemail.com";
port = 993;
tls.enable = true;
};
};
programs.notmuch.enable = cfg.terminal;
programs.neomutt = {
enable = cfg.terminal;
vimKeys = true;
sort = "reverse-date";
sidebar.enable = true;
};
programs.mbsync.enable = cfg.terminal;
services.mbsync.enable = cfg.terminal;
programs.aerc = {
enable = cfg.terminal;
extraBinds = ''
# Binds are of the form <key sequence> = <command to run>
# To use '=' in a key sequence, substitute it with "Eq": "<Ctrl+Eq>"
# If you wish to bind #, you can wrap the key sequence in quotes: "#" = quit
<C-p> = :prev-tab<Enter>
<C-n> = :next-tab<Enter>
<C-t> = :term<Enter>
[messages]
Q = :quit<Enter>
T = :toggle-threads<Enter>
j = :next<Enter>
<Down> = :next<Enter>
<C-d> = :next 50%<Enter>
<C-f> = :next 100%<Enter>
<PgDn> = :next -s 100%<Enter>
k = :prev<Enter>
<Up> = :prev<Enter>
<C-u> = :prev 50%<Enter>
<C-b> = :prev<Enter>
<PgUp> = :prev -s 100%<Enter>
gg = :select 0<Enter>
G = :select -1<Enter>
J = :next-folder<Enter>
K = :prev-folder<Enter>
v = :mark -t<Enter>
V = :mark -v<Enter>
f = :flag<Enter>
F = :unflag<Enter>
t = :toggle-threads<Enter>
<Enter> = :view<Enter>
D = :mv Trash<Enter>
C = :compose<enter>
Rr = :reply<Enter>
Rq = :reply -q<Enter>
rr = :reply -a<Enter>
rq = :reply -aq<Enter>
rt = :unflag<Enter>:reply -a -Tthanks<Enter>
Rt = :unflag<Enter>:reply -qa -Tquoted_thanks<Enter>
a = :mv Archive<Enter>
c = :cf<space>
$ = :term<space>
! = :term<space>
| = :pipe<space>
ga = :flag<Enter>:pipe -mb git am -3<Enter>
gp = :term git push<Enter>
gl = :term git log<Enter>
/ = :search<space>
\ = :filter<space>
n = :next-result<Enter>
N = :prev-result<Enter>
o = :term mbsync -a<Enter>
q = :quit<Enter>
[view]
/ = :toggle-key-passthrough<Enter>/
q = :close<Enter>
| = :pipe -m<space>
S = :save<space>
H = :toggle-headers<Enter>
D = :mv Trash<Enter>
<C-k> = :prev-part<Enter>
<C-j> = :next-part<Enter>
J = :next<Enter>
K = :prev<Enter>
f = :forward<Enter>
Rr = :reply<Enter>
Rq = :reply -q<Enter>
rr = :reply -a<Enter>
rq = :reply -aq<Enter>
rt = :reply -Tthanks<Enter>
ga = :pipe -b git am -3<Enter>
gp = :term git push<Enter>
gl = :term git log<Enter>
[view::passthrough]
$noinherit = true
$ex = <C-x>
<Esc> = :toggle-key-passthrough<Enter>
[compose]
$ex = <C-x>
<C-k> = :prev-field<Enter>
<C-j> = :next-field<Enter>
<tab> = :next-field<Enter>
[compose::editor]
# Keybindings used when the embedded terminal is selected in the compose view
$noinherit = true
$ex = <C-x>
<C-t> = :term<Enter>
<C-k> = :prev-field<Enter>
<C-j> = :next-field<Enter>
<C-p> = :prev-tab<Enter>
<C-n> = :next-tab<Enter>
[compose::review]
# Keybindings used when reviewing a message to be sent
y = :send<Enter>
n = :abort<Enter>
e = :edit<Enter>
a = :attach<space>
c = :encrypt<Enter>
s = :sign<Enter>
V = :header -f X-Sourcehut-Patchset-Update NEEDS_REVISION<Enter>
A = :header -f X-Sourcehut-Patchset-Update APPLIED<Enter>
R = :header -f X-Sourcehut-Patchset-Update REJECTED<Enter>
[terminal]
$noinherit = true
$ex = <C-x>
<C-t> = :term<Enter>
<C-p> = :prev-tab<Enter>
<C-n> = :next-tab<Enter>
'';
extraConfig = {
general = {
pgp-provider = "gpg";
unsafe-accounts-conf = true;
};
ui = {};
viewer = {};
filters = {
"text/plain" = "colorize";
"text/calendar" = "calendar";
"message/delivery-status" = "colorize";
"message/rfc822" = "colorize";
"image/*" = "img2sixel";
"text/html" = "html | colorize";
};
};
};
};
}

34
home/modules/menu.nix Normal file
View file

@ -0,0 +1,34 @@
{
lib,
pkgs,
config,
...
}: let
cfg = config.programs.menu;
terminal = config.programs.terminal;
termcmd = "${terminal}/bin/${terminal.pname}";
in {
options.programs = with lib; {
menu = {
package = mkPackageOption pkgs "wofi" {
example = "pkgs.dmenu-wayland";
};
dmenuCommand = mkOption {
default = "/bin/wofi --show dmenu";
example = "/bin/dmenu";
};
};
};
config = {
programs.wofi = lib.mkIf (cfg.package == pkgs.wofi) {
enable = true;
settings = {
term = termcmd;
insensitive = true;
};
};
home.packages = [cfg.package];
};
}

65
home/modules/mpd.nix Normal file
View file

@ -0,0 +1,65 @@
{
lib,
pkgs,
config,
...
}:
with lib; let
cfg = config.roles.mpd;
in {
options.roles.mpd = {
enable = mkEnableOption "setup mpd client";
host = mkOption {default = "192.168.1.2";};
};
config = mkIf cfg.enable {
programs.ncmpcpp = {
enable = true;
settings.mpd_host = cfg.host;
bindings = [
{
key = "j";
command = "scroll_down";
}
{
key = "k";
command = "scroll_up";
}
{
key = "l";
command = "next_column";
}
{
key = "h";
command = "previous_column";
}
{
key = "J";
command = ["select_item" "scroll_down"];
}
{
key = "K";
command = ["select_item" "scroll_up"];
}
];
};
services.mpd-mpris = {
enable = true;
mpd.host = cfg.host;
};
programs.waybar.settings.mainBar.mpd.server = cfg.host;
systemd.user.services = {
snapclient = {
Unit = {
Description = "Snapclient";
};
Service = {
ExecStart = "${pkgs.snapcast}/bin/snapclient -h ${cfg.host}";
};
Install = {
WantedBy = ["graphical-session.target"];
};
};
};
};
}

76
home/modules/scripts.nix Normal file
View file

@ -0,0 +1,76 @@
{
lib,
pkgs,
config,
...
}:
with lib; let
scripts = config.programs.scripts;
hotkeyType = types.submodule ({...}: {
options = {
key = mkOption {
description = "the key";
};
modifier = mkOption {
description = "modifiers for the key";
default = "SUPER";
example = "SUPER_SHIFT";
};
args = mkOption {
description = "args for the script when use this key";
default = "";
};
};
});
scriptType = types.submodule ({...}: {
options = {
name = mkOption {
description = "name of the executable";
};
text = mkOption {
description = "the text of the script";
};
hotkeys = mkOption {
type = types.listOf hotkeyType;
description = "keys that run this script";
default = [];
};
install = mkOption {
type = types.bool;
default = true;
};
};
});
scriptToPackage = script:
pkgs.writeShellScriptBin script.name script.text;
scriptExec = {
script,
hotkey,
}: "${scriptToPackage script}/bin/${script.name} ${hotkey.args}";
installScripts = scripts: (map scriptToPackage (filter (s: s.install) scripts));
bindScript = script: (
map
(
hotkey: "${hotkey.modifier}, ${hotkey.key}, exec, ${scriptExec {inherit script hotkey;}}"
)
script.hotkeys
);
in {
options.programs = {
scripts = mkOption {
type = types.listOf scriptType;
default = [];
};
};
config = {
home.packages = installScripts scripts;
wayland.windowManager.hyprland.settings.bind = builtins.concatMap bindScript scripts;
};
}

23
home/modules/terminal.nix Normal file
View file

@ -0,0 +1,23 @@
{
lib,
pkgs,
config,
...
}: let
term = config.programs.terminal;
in {
options.programs = {
terminal = lib.mkPackageOption pkgs "foot" {
example = "pkgs.alacritty";
};
};
config = {
programs.foot = lib.mkIf (term == pkgs.foot) {
enable = true;
server.enable = true;
};
home.packages = [term];
};
}

15
home/programs/git.nix Normal file
View file

@ -0,0 +1,15 @@
{
programs.git = {
enable = true;
aliases = {
graph = "log --oneline --all --graph";
amend = "commit --amend --no-edit";
};
delta = {
enable = true;
};
extraConfig = {
pull.rebase = true;
};
};
}

View file

@ -0,0 +1,95 @@
{pkgs, ...}: {
home.packages = with pkgs; [
imv
obs-studio
selectdefaultapplication
easyeffects
inkscape
libsForQt5.okular
pavucontrol
qpwgraph
element-desktop
brave
gimp
quickemu
bitwarden
libsForQt5.kasts
libreoffice
logseq
insomnia
dbeaver
];
gtk = {
enable = true;
iconTheme = {
name = "Vimix-Doder";
package = pkgs.vimix-icon-theme;
};
cursorTheme = {
name = "Vanilla-DMZ";
package = pkgs.vanilla-dmz;
size = 24;
};
gtk3.bookmarks = [
"file:///home/tristan/Documents"
"file:///home/tristan/Pictures/Screenshots"
"file:///home/tristan/Downloads"
];
};
programs.mpv.enable = true;
programs.mpv.bindings = {
l = "seek 5";
h = "seek -5";
e = "add chapter 1";
b = "add chapter -1";
">" = "multiply speed 1.1";
"<" = "multiply speed 1/1.1";
"." = "frame-step";
"," = "frame-back-step";
"ctrl+n" = "playlist-next";
"ctrl+p" = "playlist-prev";
k = "add volume 2";
j = "add volume -2";
m = "cycle mute";
c = "cycle sub-visibility";
};
programs.mpv.scripts = [
pkgs.mpvScripts.mpris
];
programs.librewolf.enable = true;
programs.qutebrowser = {
enable = true;
searchEngines = {
DEFAULT = "https://search.brave.com/search?q={}";
w = "https://en.wikipedia.org/wiki/Special:Search?search={}&go=Go&ns0=1";
aw = "https://wiki.archlinux.org/?search={}";
nw = "https://nixos.wiki/index.php?search={}";
nixpkgs = "https://search.nixos.org/packages?channel=unstable&query={}";
};
settings = {
colors = {
webpage.preferred_color_scheme = "dark";
};
tabs = {
background = false;
indicator.width = 0;
favicons.scale = 2.0;
position = "left";
show = "always";
width = 40;
};
};
extraConfig = ''
c.tabs.padding = {
"bottom" : 10,
"left" : 5,
"right" : 5,
"top" : 10
}
'';
};
}

160
home/programs/hyprland.nix Normal file
View file

@ -0,0 +1,160 @@
{
lib,
pkgs,
...
}: {
imports = [
(import ./swaylock.nix)
(import ./swayidle.nix)
];
xdg.portal = {
enable = true;
configPackages = [pkgs.hyprland];
extraPortals = [pkgs.xdg-desktop-portal-hyprland pkgs.xdg-desktop-portal-gtk];
};
wayland.windowManager.hyprland = {
enable = true;
systemd.enable = true;
settings = {
input = {
touchpad = {
natural_scroll = true;
scroll_factor = 0.5;
};
};
gestures = {
workspace_swipe = true;
workspace_swipe_numbered = true;
};
decoration = {
rounding = 5;
drop_shadow = false;
};
bezier = [
"overshot, 0.05, 0.9, 0.1, 1.1"
"linear, 0.0, 0.0, 1.0, 1.0"
];
animations = {
enabled = true;
animation = [
"windows, 1, 1, default, popin"
"border, 1, 1, default"
"fade, 1, 1, default"
"workspaces, 1, 3, overshot"
"borderangle,1, 50, linear, loop"
];
};
bind = [
"SUPER, h, movefocus,l"
"SUPER, l, movefocus,r"
"SUPER, j, layoutmsg,cyclenext"
"SUPER, k, layoutmsg,cycleprev"
"SUPER, space, layoutmsg,swapwithmaster master"
"SUPER, F, fullscreen,"
"SUPER, V, togglefloating,"
"SUPER, W, layoutmsg, orientationprev"
"SUPER_SHIFT, W, layoutmsg, orientationnext"
"SUPER_SHIFT, V, togglegroup,"
"SUPER_SHIFT, h, changegroupactive,b"
"SUPER_SHIFT, h, moveintogroup,l"
"SUPER_SHIFT, l, moveintogroup,r"
"SUPER_SHIFT, l, changegroupactive,f"
"SUPER, Y, togglespecialworkspace"
"SUPER_SHIFT, Y, movetoworkspace, special"
"SUPER_SHIFT, X, killactive"
"SUPER, slash, focuswindow, brave-browser"
"SUPER, n, focuswindow, Logseq"
"SUPER, R, submap, resize"
"SUPER,1,workspace,1"
"SUPER,2,workspace,2"
"SUPER,3,workspace,3"
"SUPER,4,workspace,4"
"SUPER,5,workspace,5"
"SUPER,6,workspace,6"
"SUPER,7,workspace,7"
"SUPER,8,workspace,8"
"SUPER,9,workspace,9"
"SUPER,0,workspace,10"
"SUPER,left,workspace,r-1"
"SUPER,right,workspace,r+1"
"SUPER_SHIFT,1,movetoworkspace,1"
"SUPER_SHIFT,2,movetoworkspace,2"
"SUPER_SHIFT,3,movetoworkspace,3"
"SUPER_SHIFT,4,movetoworkspace,4"
"SUPER_SHIFT,5,movetoworkspace,5"
"SUPER_SHIFT,6,movetoworkspace,6"
"SUPER_SHIFT,7,movetoworkspace,7"
"SUPER_SHIFT,8,movetoworkspace,8"
"SUPER_SHIFT,9,movetoworkspace,9"
"SUPER_SHIFT,0,movetoworkspace,10"
];
bindm = [
"SUPER, mouse:272, movewindow"
"SUPER, mouse:273, resizewindow"
];
env = [
"GDK_BACKEND,wayland,x11"
"QT_QPA_PLATFORM,wayland;xcb"
"SDL_VIDEODRIVER,wayland"
"CLUTTER_BACKEND,wayland"
"XDG_CURRENT_DESKTOP,Hyprland"
"XDG_SESSION_TYPE,wayland"
"XDG_SESSION_DESKTOP,Hyprland"
"QT_AUTO_SCREEN_SCALE_FACTOR,1"
"QT_WAYLAND_DISABLE_WINDOWDECORATION,1"
"NIXOS_OZONE_WL,1"
"WLR_NO_HARDWARE_CURSORS,1"
];
windowrule = [
"float, title:wlogout"
"idleinhibit always, vrmonitor"
"idleinhibit focus, steam_app"
];
workspace = [
"11, default:true"
];
general = {
gaps_out = 10;
resize_on_border = true;
layout = "master";
# "col.active_border" = "rgb(FFFF00) rgb(00FFFF) rgb(FF00FF)";
border_size = lib.mkDefault 5;
};
master = {
mfact = 0.7;
new_on_top = true;
};
misc = {
vrr = 2;
focus_on_activate = true;
};
};
# https://wiki.hyprland.org/Configuring/Variables/
extraConfig = ''
submap = resize
binde = ,right,resizeactive,10 0
binde = ,left,resizeactive,-10 0
binde = ,up,resizeactive,0 -10
binde = ,down,resizeactive,0 10
binde = ,k,resizeactive,0 -10
binde = ,j,resizeactive,0 10
binde = ,l,splitratio,0.05
binde = ,h,splitratio,-0.05
binde = SHIFT,l,splitratio,0.3
binde = SHIFT,h,splitratio,-0.3
bind = , escape, submap,reset
bind = , enter, submap,reset
bind = SUPER, R, submap,reset
bind = CONTROL, C, submap,reset
submap = reset
'';
};
services.mako = {
enable = true;
};
programs.waybar.settings.mainBar.modules-left = ["hyprland/workspaces" "hyprland/window"];
}

View file

@ -0,0 +1,28 @@
vim.g.mapleader = ' '
vim.g.maplocalleader = ' '
vim.o.relativenumber = true
vim.o.signcolumn = 'yes'
vim.o.tabstop = 2
vim.o.shiftwidth = 2
vim.o.expandtab = true
vim.o.smartindent = true
vim.o.hlsearch = false
vim.o.scrolloff = 4
vim.keymap.set("v", "J", ":m '>+1<CR>gv=gv")
vim.keymap.set("v", "K", ":m '<-2<CR>gv=gv")
vim.keymap.set("x", "p", "\"_dP")
vim.keymap.set("n", "<leader>y", "\"+y")
vim.keymap.set("v", "<leader>y", "\"+y")
-- Global mappings.
-- See `:help vim.diagnostic.*` for documentation on any of the below functions
vim.keymap.set('n', '<leader>e', vim.diagnostic.open_float)
vim.keymap.set('n', '[d', vim.diagnostic.goto_prev)
vim.keymap.set('n', ']d', vim.diagnostic.goto_next)
vim.keymap.set('n', '<leader>q', vim.diagnostic.setloclist)
vim.keymap.set('v', '<C-c>', '"+y')
vim.keymap.set('i', '<C-v>', '<escape>"+p')

View file

@ -0,0 +1,51 @@
{
config,
pkgs,
lib,
...
}: {
programs.neovim = {
enable = true;
defaultEditor = true;
extraLuaConfig = ''
${builtins.readFile ./config.lua}
'';
extraPackages = with pkgs; [
nodePackages_latest.typescript-language-server
vscode-langservers-extracted
gopls
nil
];
plugins = with pkgs.vimPlugins; [
vim-surround
vim-commentary
{
plugin = telescope-nvim;
type = "lua";
config = ''
local builtin = require('telescope.builtin')
vim.keymap.set('n', '<leader>ff', builtin.find_files, {})
vim.keymap.set('n', '<leader>fg', builtin.live_grep, {})
vim.keymap.set('n', '<leader>fb', builtin.buffers, {})
vim.keymap.set('n', '<leader>fh', builtin.help_tags, {})
'';
}
{
plugin = nvim-lspconfig;
type = "lua";
config = builtins.readFile ./lspconfig.lua;
}
firenvim
];
};
programs.vscode = {
extensions = [pkgs.vscode-extensions.asvetliakov.vscode-neovim];
userSettings = {
"vscode-neovim.neovimExecutablePaths.linux" = "${pkgs.neovim}/bin/nvim";
"extensions.experimental.affinity" = {
"asvetliakov.vscode-neovim" = 1;
};
};
};
}

View file

@ -0,0 +1,48 @@
-- Setup language servers.
local lspconfig = require('lspconfig')
lspconfig.tsserver.setup {
on_attach = function(client)
client.server_capabilities.documentFormattingProvider = false
end
}
lspconfig.eslint.setup {
on_attach = function(client)
client.server_capabilities.documentFormattingProvider = true
end
}
lspconfig.gopls.setup {}
lspconfig.nil_ls.setup {}
-- Use LspAttach autocommand to only map the following keys
-- after the language server attaches to the current buffer
vim.api.nvim_create_autocmd('LspAttach', {
group = vim.api.nvim_create_augroup('UserLspConfig', {}),
callback = function(ev)
-- Enable completion triggered by <c-x><c-o>
vim.bo[ev.buf].omnifunc = 'v:lua.vim.lsp.omnifunc'
-- Buffer local mappings.
-- See `:help vim.lsp.*` for documentation on any of the below functions
local opts = { buffer = ev.buf }
vim.keymap.set('n', 'gD', vim.lsp.buf.declaration, opts)
vim.keymap.set('n', 'gd', vim.lsp.buf.definition, opts)
vim.keymap.set('n', 'K', vim.lsp.buf.hover, opts)
vim.keymap.set('n', 'gi', vim.lsp.buf.implementation, opts)
vim.keymap.set('n', '<C-k>', vim.lsp.buf.signature_help, opts)
vim.keymap.set('n', '<leader>wa', vim.lsp.buf.add_workspace_folder, opts)
vim.keymap.set('n', '<leader>wr', vim.lsp.buf.remove_workspace_folder, opts)
vim.keymap.set('n', '<leader>wl', function()
print(vim.inspect(vim.lsp.buf.list_workspace_folders()))
end, opts)
vim.keymap.set('n', '<leader>D', vim.lsp.buf.type_definition, opts)
vim.keymap.set('n', '<leader>rn', vim.lsp.buf.rename, opts)
vim.keymap.set({ 'n', 'v' }, '<space>ca', vim.lsp.buf.code_action, opts)
vim.keymap.set('n', 'gr', vim.lsp.buf.references, opts)
vim.keymap.set('n', '<leader>f', function()
vim.lsp.buf.format { async = true }
end, opts)
end,
})

320
home/programs/scripts.nix Normal file
View file

@ -0,0 +1,320 @@
{
config,
pkgs,
lib,
...
}: let
terminal = config.programs.terminal;
termcmd = "${terminal}/bin/${terminal.pname}";
my-deps = {
notify-send = "${pkgs.libnotify}/bin/notify-send";
playerctl = "${pkgs.playerctl}/bin/playerctl";
grim = "${pkgs.grim}/bin/grim";
slurp = "${pkgs.slurp}/bin/slurp";
amixer = "${pkgs.alsa-utils}/bin/amixer";
swaybg = "${pkgs.swaybg}/bin/swaybg";
chafa = "${pkgs.chafa}/bin/chafa";
exiftool = "${pkgs.exiftool}/bin/exiftool";
wc = "${pkgs.coreutils}/bin/wc";
jq = "${pkgs.jq}/bin/jq";
hyprctl = "${pkgs.hyprland}/bin/hyprctl";
xargs = "${pkgs.findutils}/bin/xargs";
menu = "${config.programs.menu.package}${config.programs.menu.dmenuCommand}";
runmenu = "${config.programs.menu.package}/bin/wofi --show drun";
fileman = "${pkgs.pcmanfm}/bin/pcmanfm";
gawk = "${pkgs.gawk}/bin/awk";
hyprpicker = "${pkgs.hyprpicker}/bin/hyprpicker";
sed = "${pkgs.gnused}/bin/sed";
};
in {
programs.scripts = [
{
name = "play-pause";
text = ''
if [ "$(${my-deps.playerctl} --list-all | ${my-deps.wc} -l)" -lt 2 ]
then
${my-deps.playerctl} play-pause
else
${my-deps.playerctl} --list-all | \
${my-deps.xargs} -I _ ${my-deps.playerctl} --player _ metadata --format '_ - {{title}}' | \
${my-deps.menu} | ${my-deps.gawk} '{print $1}' | \
${my-deps.xargs} -I _ ${my-deps.playerctl} --player _ play-pause
fi
'';
hotkeys = [
{
modifier = "";
key = "XF86AudioPlay";
}
];
}
{
name = "bwmenu";
text = ''
items="$(rbw list)"
echo "$items" | ${my-deps.menu} | xargs -I_ rbw get _ | wl-copy
'';
hotkeys = [{key = "P";}];
install = false;
}
{
name = "bwotpmenu";
text = ''
items="$(rbw list)"
echo "$items" | ${my-deps.menu} | xargs -I_ rbw code _ | wl-copy
'';
hotkeys = [
{
modifier = "SUPER_SHIFT";
key = "P";
}
];
install = false;
}
{
name = "screenshot";
text = ''
OUT_DIR=~/Pictures/Screenshots
mkdir -p "$OUT_DIR"
FILE=$OUT_DIR/$(date +"%Y-%m-%dT%H:%M:%SZ").png
${my-deps.grim} -g "$(${my-deps.slurp} -o)" "$FILE"
${my-deps.notify-send} "Screenshot Taken" "$FILE"
cat "$FILE" | wl-copy -t image/png
'';
hotkeys = [
{
modifier = "SUPER_SHIFT";
key = "S";
}
];
}
{
name = "brightness-down";
text = ''
light -U $1
${my-deps.notify-send} "Brightness" -h int:value:$(light) -a brightness-down -t 1000
'';
hotkeys = [
{
modifier = "";
key = "XF86MonBrightnessDown";
args = "10";
}
{
modifier = "SHIFT";
key = "XF86MonBrightnessDown";
args = "1";
}
];
install = false;
}
{
name = "brightness-up";
text = ''
light -A $1
${my-deps.notify-send} "Brightness" -h int:value:$(light) -a brightness-up -t 1000
'';
hotkeys = [
{
modifier = "";
key = "XF86MonBrightnessUp";
args = "10";
}
{
modifier = "SHIFT";
key = "XF86MonBrightnessUp";
args = "1";
}
];
install = false;
}
{
name = "switch-window";
text = ''
${my-deps.hyprctl} clients -j | \
${my-deps.jq} '.[] | .title' -r | \
${my-deps.sed} '/^$/d' |
${my-deps.menu} | \
${my-deps.sed} 's/\([\[\(\)]\)/\\\\\1/g' | \
${my-deps.xargs} -I_ ${my-deps.hyprctl} dispatch focuswindow title:"_"
'';
hotkeys = [
{key = "TAB";}
];
}
{
name = "picker";
text = ''
${my-deps.hyprpicker} | wl-copy && notify-send "Copied Colour" "$(wl-paste)"
'';
hotkeys = [
{
key = "G";
}
];
}
(lib.mkIf config.roles.mpd.enable {
name = "ncmpcpp";
text = ''
${termcmd} -e ncmpcpp
'';
hotkeys = [
{
key = "M";
}
];
install = false;
})
{
name = "menu";
text = ''
${my-deps.runmenu}
'';
hotkeys = [
{
key = "D";
}
];
install = false;
}
{
name = "zoom-in";
text = ''
hyprctl keyword misc:cursor_zoom_factor 2
'';
hotkeys = [
{
modifier = "SUPER";
key = "EQUAL";
}
];
install = false;
}
{
name = "zoom-out";
text = ''
hyprctl keyword misc:cursor_zoom_factor 1
'';
hotkeys = [
{
modifier = "SUPER";
key = "MINUS";
}
];
install = false;
}
{
name = "raise-volume";
text = ''
${my-deps.amixer} sset Master 5%+ && ${my-deps.amixer} sset Master unmute
'';
hotkeys = [
{key = "bracketright";}
{
modifier = "";
key = "XF86AudioRaiseVolume";
}
];
install = false;
}
{
name = "lower-volume";
text = ''
${my-deps.amixer} sset Master 5%-
'';
hotkeys = [
{key = "bracketleft";}
{
modifier = "";
key = "XF86AudioLowerVolume";
}
];
install = false;
}
{
name = "skip-track";
text = ''
${my-deps.playerctl} next
'';
hotkeys = [
{
modifier = "SUPER_SHIFT";
key = "period";
}
{
modifier = "";
key = "XF86AudioNext";
}
];
install = false;
}
{
name = "skip-track-back";
text = ''
${my-deps.playerctl} previous
'';
hotkeys = [
{
modifier = "SUPER_SHIFT";
key = "comma";
}
{
modifier = "";
key = "XF86AudioPrev";
}
];
install = false;
}
{
name = "terminal";
text = termcmd;
hotkeys = [
{key = "RETURN";}
];
install = false;
}
{
name = "fileman";
text = my-deps.fileman;
hotkeys = [
{key = "O";}
];
install = false;
}
{
name = "lock";
text = ''
res=$(echo "lock
sleep
hibernate" | ${my-deps.menu})
case $res in
lock) swaylock;;
sleep) systemctl suspend;;
hibernate) systemctl hibernate;;
esac
'';
hotkeys = [
{key = "Z";}
];
install = false;
}
{
name = "git clone";
text = ''
url=$(wl-paste)
${my-deps.notify-send} "Cloning $url"
${termcmd} -e -- git clone "$url"
${my-deps.notify-send} "Finished cloning $url"
'';
install = true;
hotkeys = [
{
key = "C";
modifier = "SUPER_SHIFT";
}
];
}
];
}

View file

@ -0,0 +1,26 @@
{pkgs, ...}: {
services.swayidle = {
enable = true;
systemdTarget = "graphical-session.target";
events = [
{
event = "before-sleep";
command = "${pkgs.swaylock-effects}/bin/swaylock";
}
{
event = "lock";
command = "${pkgs.swaylock-effects}/bin/swaylock";
}
];
timeouts = [
{
timeout = 300;
command = "${pkgs.swaylock-effects}/bin/swaylock -f";
}
{
timeout = 600;
command = "systemctl suspend";
}
];
};
}

View file

@ -0,0 +1,13 @@
{pkgs, ...}: {
programs.swaylock = {
enable = true;
package = pkgs.swaylock-effects;
settings = {
clock = true;
screenshots = true;
effect-scale = 0.5;
effect-blur = "10x10";
grace = 5;
};
};
}

47
home/programs/waybar.nix Normal file
View file

@ -0,0 +1,47 @@
{pkgs, ...}: {
programs.waybar = {
enable = true;
settings = {
mainBar = {
layer = "top";
position = "top";
height = 36;
modules-right = ["mpris" "pulseaudio" "clock" "tray" "battery"];
clock = {
format = "📅 {:%a %b-%d %I:%M %p}";
};
pulseaudio = {
format-muted = "🔇 {volume}";
format = "{icon} {volume}";
format-icons.default = ["🔈" "🔉" "🔊"];
on-click = "${pkgs.pavucontrol}/bin/pavucontrol";
};
mpris = {
format = "{player_icon} {artist} - {title}";
format-paused = "{status_icon} {player_icon} {artist} - {title}";
player-icons = {
default = "";
mpd = "🎵";
kdeconnect = "";
};
status-icons = {
paused = "";
};
};
battery = {
format = "{icon} {capacity}%";
format-icons = ["🤏" "🪫" "🔋" "🔋"];
format-charging = "🔌 {capacity}%";
states = {
warning = 30;
critical = 15;
};
};
};
};
systemd = {
enable = true;
target = "graphical-session.target";
};
};
}