feat: better modules aragement.

This commit is contained in:
CronyAkatsuki 2025-03-23 20:01:51 +01:00
parent de11ee0676
commit 6e967a751f
49 changed files with 27 additions and 19 deletions

View file

@ -0,0 +1,23 @@
{
config,
pkgs,
lib,
...
}: {
options = {
crony.browsers.chromium.enable = lib.mkEnableOption "Enable chromium";
};
config = lib.mkIf config.crony.browsers.chromium.enable {
# Enable theming chromium + use ungoogled chromium package
programs.chromium = {
enable = true;
package = pkgs.ungoogled-chromium;
# Fix for wayland
commandLineArgs = [
"--ozone-platform-hint=auto"
"--ozone-platform=wayland"
];
};
};
}

View file

@ -0,0 +1,19 @@
{
config,
lib,
...
}: {
imports = [
./librewolf.nix
./chromium.nix
];
options = {
crony.browsers.enable = lib.mkEnableOption "Enable my browsers and customize them";
};
config = lib.mkIf config.crony.browsers.enable {
crony.browsers.librewolf.enable = lib.mkDefault true;
crony.browsers.chromium.enable = lib.mkDefault true;
};
}

View file

@ -0,0 +1,35 @@
{
config,
pkgs,
lib,
...
}: {
options = {
crony.browsers.librewolf.enable = lib.mkEnableOption "Enable librewolf and related options";
};
config = lib.mkIf config.crony.browsers.librewolf.enable {
# Install librewolf
programs.librewolf = {
enable = true;
nativeMessagingHosts = with pkgs; [
tridactyl-native
bukubrow
keepassxc
];
};
# This tricks messaging hosts into working for no
# real reason other than to make me rage at hour of debugging
# (5 hours in total)
programs.firefox = {
package = pkgs.librewolf;
enable = true;
nativeMessagingHosts = with pkgs; [
tridactyl-native
bukubrow
keepassxc
];
};
};
}

View file

@ -0,0 +1,29 @@
{lib, ...}: {
imports = [
./browsers
./desktop.nix
./emulators.nix
./gaming.nix
./hyprland.nix
./mangohud.nix
./mpv.nix
./nh.nix
./nnn.nix
./obs-studio.nix
./restic.nix
./scripts.nix
];
crony.mangohud.enable = lib.mkDefault true;
crony.nnn.enable = lib.mkDefault true;
crony.mpv.enable = lib.mkDefault true;
crony.obs-studio.enable = lib.mkDefault true;
crony.nh.enable = lib.mkDefault true;
crony.restic.enable = lib.mkDefault true;
crony.hyprland.enable = lib.mkDefault true;
crony.browsers.enable = lib.mkDefault true;
crony.scripts.enable = lib.mkDefault true;
crony.emulators.enable = lib.mkDefault true;
crony.desktop.enable = lib.mkDefault true;
crony.gaming.enable = lib.mkDefault true;
}

View file

@ -0,0 +1,32 @@
{
config,
pkgs,
lib,
...
}: {
options = {
crony.desktop.enable = lib.mkEnableOption "Settings for setting up my desktop linux (mostly just my apps)";
};
config = lib.mkIf config.crony.desktop.enable {
home.packages = with pkgs; [
keepassxc
tutanota-desktop
spice-gtk
vesktop
piper
jellyfin-mpv-shim
overskride
delfin
];
# Install thunderbird
programs.thunderbird = {
enable = true;
profiles.default.isDefault = true;
};
# Install imv
programs.imv.enable = true;
};
}

View file

@ -0,0 +1,29 @@
{
config,
pkgs,
lib,
...
}: {
options = {
crony.emulators.enable = lib.mkEnableOption "Install my emulators";
};
config = lib.mkIf config.crony.emulators.enable {
home.packages = with pkgs; [
(retroarch.withCores (
cores:
with cores; [
beetle-saturn
mupen64plus
flycast
desmume
]
))
duckstation
pcsx2
dolphin-emu
rpcs3
mame-tools
];
};
}

View file

@ -0,0 +1,23 @@
{
config,
pkgs,
lib,
...
}: {
options = {
crony.gaming.enable = lib.mkEnableOption "Install gaming related packages";
};
config = lib.mkIf config.crony.gaming.enable {
home.packages = with pkgs; [
heroic
prismlauncher
protonup-qt
protontricks
itch
wineWowPackages.staging
osu-lazer-bin
steam-rom-manager
];
};
}

View file

@ -0,0 +1,495 @@
{
config,
pkgs,
lib,
...
}: let
hyprgamemode = pkgs.writeShellScriptBin "gamemode" ''
#!/usr/bin/env sh
HYPRGAMEMODE=$(hyprctl getoption animations:enabled | awk 'NR==1{print $2}')
if [ "$HYPRGAMEMODE" = 1 ] ; then
hyprctl --batch "\
keyword animations:enabled 0;\
keyword decoration:shadow:enabled 0;\
keyword decoration:blur:enabled 0;\
keyword general:gaps_in 0;\
keyword general:gaps_out 0;\
keyword general:border_size 1;\
keyword decoration:rounding 0"
exit
fi
hyprctl reload
hyprctl monitors | grep 'HDMI' && hyprctl keyword monitor "eDP-1, disable"
'';
volume-notify = pkgs.writeShellScriptBin "volume-notify" ''
#!/usr/bin/env sh
volumep="$(wpctl get-volume @DEFAULT_AUDIO_SINK@)"
case "$volumep" in
*0.0*) volumep="''${volumep##* 0.0}%" ;;
*0.*) volumep="''${volumep##* 0.}%" ;;
*MUTED*) volumep='MUTED' ;;
*) volumep="100%" ;;
esac
notify-send -h string:x-canonical-private-synchronous:sys-notify "🔊 Volume: ''${volumep}"
'';
toggle-sound-output = pkgs.writeShellScriptBin "toggle-sound-output" ''
#!/usr/bin/env sh
speakers="alsa_output.pci-0000_05_00.1.hdmi-stereo"
headphones="alsa_output.usb-Xtrfy_SC1_Xtrfy_SC1-00.analog-stereo"
current="$(wpctl status -n | grep Audio/Sink | grep -oE '[^ ]+$')"
if [ "''${current}" = "''${headphones}" ]; then
wpctl set-default "$(pw-cli info $speakers | head -n 1 | awk '{print $2}')"
else
wpctl set-default "$(pw-cli info $headphones | head -n 1 | awk '{print $2}')"
fi
'';
power-menu = pkgs.writeShellScriptBin "power-menu" ''
#!/usr/bin/env sh
case "$(printf "shutdown\\nreboot" | tofi --prompt "Choose your poison")" in
"shutdown") poweroff ;;
"reboot") reboot ;;
esac
'';
grim = "${pkgs.grim}/bin/grim";
vpn-toggle = pkgs.writeShellScriptBin "vpn-toggle" ''
#!/usr/bin/env sh
if [ "$(nmcli --overview -f GENERAL.STATE connection show hetz)" = "" ]; then
nmcli con up hetz
notify-send "VPN" "UP"
else
nmcli con down hetz
notify-send "VPN" "DOWN"
fi
'';
playerctl = "${pkgs.playerctl}/bin/playerctl";
in {
options = {
crony.hyprland.enable = lib.mkEnableOption "Enable hyprland and configure it for me";
};
config = lib.mkIf config.crony.hyprland.enable {
home.packages = with pkgs; [
(writeShellScriptBin "tofi-pass" ''
tofi --hide-input true --prompt-text 'Password: ' --require-match false --hidden-character '.' < /dev/null
'')
cliphist
wl-clipboard
];
# Enable and setup tofi
programs.tofi = {
enable = true;
settings = {
anchor = "top";
width = "100%";
height = "34";
horizontal = true;
history = false;
require-match = false;
terminal = "foot";
outline-width = 0;
border-width = 0;
min-input-width = 120;
result-spacing = 15;
padding-top = 4;
padding-bottom = 0;
padding-left = 5;
padding-right = 5;
};
};
# Install foot
programs.foot.enable = true;
# Setup and enable mako
services.mako = {
enable = true;
defaultTimeout = 5000;
layer = "overlay";
width = 200;
};
# Enable hyprpaper
services.hyprpaper.enable = true;
# Enable hypridle
services.hypridle = {
enable = true;
settings = {
general = {
lock_cmd = "pidof hyprlock || hyprlock"; # avoid starting multiple hyprlock instances.
before_sleep_cmd = "loginctl lock-session"; # lock before suspend.
after_sleep_cmd = "hyprctl dispatch dpms on"; # to avoid having to press a key twice to turn on the display.
};
listener = [
{
timeout = 10; # 10 sec
on-timeout = "pidof hyprlock && hyprctl dispatch dpms off"; # Turn off screen if hyprlock is running
on-resume = "hyprctl dispatch dpms on"; # Turn on screen when activiy is detected after timeout has fired
}
{
timeout = 300; # 5min
on-timeout = "loginctl lock-session"; # lock screen when timeout has passed
}
{
timeout = 310; # 5min and 10 sec
on-timeout = "hyprctl dispatch dpms off"; # Turn off screen if hyprlock is running
on-resume = "hyprctl dispatch dpms on"; # Turn on screen when activiy is detected after timeout has fired
}
];
};
};
# Enable hyprlock
programs.hyprlock = {
enable = true;
settings = {
general = {
disable_loading_bar = true;
grace = 0;
hide_cursor = true;
no_fade_in = false;
};
image = {
path = "$HOME/.face";
size = 150;
border_size = 4;
border_color = "rgb(d5c4a1)";
position = "0, 285";
halign = "center";
valign = "center";
};
label = [
{
text = "$TIME";
font_size = 90;
color = "rgb(d5c4a1)";
position = "0, 165";
halign = "center";
valight = "center";
}
{
text = ''cmd[update:43200000] date +"%Y %m %d"'';
font_size = 25;
color = "rgb(d5c4a1)";
position = "0, -225";
halign = "center";
valign = "center";
}
];
};
};
# Disable stylix to add full css, I only need it to add colors
stylix.targets.waybar.addCss = false;
# Enable and install waybar
programs.waybar = {
enable = true;
style = ''
.modules-left {
padding-left: 10px;
}
#workspaces {
background-color: @base01;
margin: 0.25em;
border-radius: 1em;
}
#workspaces button {
padding: 0 0.5em;
color: @base06;
}
#workspaces button.empty {
color: @base03;
}
#workspaces button.visible {
color: @base06;
}
#workspaces button.active {
color: @base0D;
}
#window {
color: @base0D;
padding: 0 1em;
}
#cpu,
#memory,
#temperature,
#battery,
#disk,
#clock {
color: @base00;
background-color: @base0D;
margin: 0.25em;
border-radius: 0.5em;
padding: 0 0.5em;
}
#tray {
background-color: @base00;
}
.modules-right {
padding-right: 10px;
}
'';
settings = {
mainBar = {
height = 34;
modules-left = [
"hyprland/workspaces"
"hyprland/window"
];
modules-center = [
];
modules-right = [
"cpu"
"memory"
"temperature"
"disk"
"battery"
"clock"
"tray"
];
"hyprland/workspaces" = {
persistent-workspaces = {
"*" = [1 2 3 4 5 6 7 8 9];
};
};
disk = {
path = "/";
unit = "GB";
format = "󰋊 {percentage_used}%";
};
tray = {
spacing = 10;
};
clock = {
format = " {:%Y.%m.%d %H:%M}";
};
cpu = {
format = " {usage}%";
};
memory = {
format = " {}%";
};
temperature = {
critical-threshold = 80;
hwmon-path = "/sys/class/hwmon/hwmon2/temp1_input";
format = " {temperatureC}°C";
};
battery = {
states = {
warning = 30;
critical = 15;
};
format = "{icon} {capacity}%";
format-full = "{icon} {capacity}%";
format-charging = " {icon} {capacity}%";
format-plugged = " {capacity}%";
format-icons = [" " " " " " " " " "];
};
};
};
};
# Setup and enable hyprland
wayland.windowManager.hyprland = {
enable = true;
systemd.enable = false; # Using USWM globally
settings = {
"$mod" = "SUPER";
"$menu" = "tofi";
"$terminal" = "foot";
exec = [
# Fix laptop monitor getting turned on while my external monitor connected
"hyprctl monitors | grep 'HDMI' && hyprctl keyword monitor 'eDP-1, disable'"
];
exec-once = [
"wl-paste --type text --watch cliphist store" # Stores only text data
"wl-paste --type image --watch cliphist store" # Stores only image data
"keepassxc" # Startup my password manager
"waybar" # Start waybar on start
];
monitor = [
"HDMI-A-1, 1920x1080@144, 0x0, 1"
];
animations = {
enabled = "yes";
};
decoration = {
blur = {
enabled = true;
};
shadow = {
enabled = true;
};
rounding = 10;
};
general = {
border_size = 3;
gaps_in = 5;
gaps_out = 10;
layout = "master";
allow_tearing = true;
};
misc = {
vrr = 1;
};
input = {
kb_layout = "us,hr";
kb_options = "caps:escape,grp:alt_space_toggle";
accel_profile = "flat";
};
master = {
mfact = "0.5";
new_status = "slave";
};
binds = {
allow_workspace_cycles = true;
};
bind = [
"$mod, Return, exec, $terminal"
"$mod SHIFT, Q, killactive"
"$mod CTRL, E, exit"
"$mod SHIFT, Space, togglefloating"
"$mod, D, exec, tofi-run | xargs hyprctl dispatch exec --"
"$mod SHIFT, D, exec, tofi-drun | xargs hyprctl dispatch exec --"
"$mod, F, fullscreen"
"$mod SHIFT, L, exec, hyprlock --immediate"
"$mod, B, exec, chromium"
"$mod SHIFT, B, exec, librewolf"
"$mod, G, exec, ${hyprgamemode}/bin/gamemode"
"$mod, F1, exec, ${toggle-sound-output}/bin/toggle-sound-output"
"$mod SHIFT, E, exec, ${power-menu}/bin/power-menu"
"$mod, w, exec, ${vpn-toggle}/bin/vpn-toggle"
"$mod, F12, exec, ${grim} $HOME/Pictures/screenshots/$(date +'%s_grim.png')"
"$mod, V, exec, cliphist list | tofi --horizontal false --height 380 | cliphist decode | wl-copy"
"$mod, j, layoutmsg, cyclenext"
"$mod, k, layoutmsg, cycleprev"
"$mod SHIFT, j, layoutmsg, swapnext"
"$mod SHIFT, k, layoutmsg, swapprev"
"$mod, h, layoutmsg, mfact -0.05"
"$mod, l, layoutmsg, mfact +0.05"
"$mod, Tab, workspace, previous"
"$mod, 1, 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 SHIFT, 1, movetoworkspacesilent, 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"
];
bindel = [
", XF86AudioRaiseVolume, exec, wpctl set-volume @DEFAULT_AUDIO_SINK@ 5%+ --limit 1 && ${volume-notify}/bin/volume-notify"
", XF86AudioLowerVolume, exec, wpctl set-volume @DEFAULT_AUDIO_SINK@ 5%- --limit 1 && ${volume-notify}/bin/volume-notify"
", XF86AudioMute, exec, wpctl set-mute @DEFAULT_AUDIO_SINK@ toggle && ${volume-notify}/bin/volume-notify"
];
# Requires playerctl
bindl = [
", XF86AudioPlay, exec, ${playerctl} play-pause"
", XF86AudioPrev, exec, ${playerctl} previous"
", XF86AudioNext, exec, ${playerctl} next"
'', switch:off:Lid Switch,exec,hyprctl keyword monitor "eDP-1, 1920x1080, 0x0, 1"''
'', switch:on:Lid Switch,exec,hyprctl keyword monitor "eDP-1, disable"''
];
bindm = [
# mouse movements
"$mod, mouse:272, movewindow"
"$mod, mouse:273, resizewindow"
"$mod ALT, mouse:272, resizewindow"
];
windowrulev2 = [
# Hide xwaylandvideobridge
"opacity 0.0 override, class:^(xwaylandvideobridge)$"
"noanim, class:^(xwaylandvideobridge)$"
"noinitialfocus, class:^(xwaylandvideobridge)$"
"maxsize 1 1, class:^(xwaylandvideobridge)$"
"noblur, class:^(xwaylandvideobridge)$"
"nofocus, class:^(xwaylandvideobridge)$"
# Disable animations for ueberzugpp
"noanim, class:^(ueberzugpp.*)$"
# Allow tearing for sifu
"immediate, class:^(steam_app_2138710)$"
"immediate, class:^(steam_app_1145360)$"
"immediate, class:^(Graveyard Keeper.x86_64)$"
"immediate, class:^(gamescope)$"
"immediate, class:^(steam_app_1087760)$"
# Make workspace 6 a floating layout
"float, workspace:6"
# Make keepassxc floating
"float, class:^(org.keepassxc.KeePassXC)$"
# Move to workspace 5
"workspace 5, class:^(vesktop)$"
];
};
};
};
}

View file

@ -0,0 +1,45 @@
{
config,
lib,
...
}: {
options = {
crony.mangohud.enable = lib.mkEnableOption "Enable mangohud and customize it";
};
config = lib.mkIf config.crony.mangohud.enable {
# Setup nice view for mangohud
programs.mangohud = {
enable = true;
settings = {
fps_limit = "0,30,60,120,144";
gpu_stats = true;
gpu_temp = true;
gpu_core_clock = true;
gpu_power = true;
gpu_text = "GPU";
gpu_load_change = true;
cpu_stats = true;
cpu_temp = true;
cpu_text = "CPU";
cpu_mhz = true;
cpu_load_change = true;
vram = true;
ram = true;
fps = true;
fps_sampling_period = "1000";
fps_color_change = true;
gpu_name = true;
vulka_driver = true;
round_corder = "10";
offset_x = "10";
offset_y = "10";
width = "250";
};
};
};
}

View file

@ -0,0 +1,54 @@
{
config,
pkgs,
lib,
...
}: {
options = {
crony.mpv.enable = lib.mkEnableOption "Enable mpv and customize it to my preference.";
};
config = lib.mkIf config.crony.mpv.enable {
programs.mpv = {
enable = true;
config = {
ytdl-format = "ytdl-format=bestvideo[height<=?1080][fps<=?60][vcodec!~='vp0?9'][vcodec!*=av01]+bestaudio/best";
fs = true;
force-window = "immediate";
hr-seek-framedrop = "no";
profile = "gpu-hq";
hwdec = "nvdec-copy";
gpu-api = "vulkan";
vo = "gpu-next";
screenshot-format = "png";
screenshot-high-bit-depth = "yes";
screenshot-png-compression = "7";
screenshot-directory = "~/pics/mpv/";
screenshot-template = "%F - [%P]v%#01n";
alang = "'jpn,jp,eng,en'";
sub-file-paths = "Subs;subs";
sub-auto = "all";
slang = "english,eng,en,enUS";
reset-on-next-file = "pause";
# no-osd-bar = false;
osd-duration = "500";
deband = "yes";
deband-iterations = "2";
deband-threshold = "35";
deband-range = "20";
deband-grain = "5";
dither-depth = "auto";
scale = "ewa_lanczossharp";
dscale = "mitchell";
cscale = "spline36";
};
scripts = with pkgs.mpvScripts; [
mpris
sponsorblock
thumbfast
quality-menu
];
};
};
}

View file

@ -0,0 +1,21 @@
{
config,
lib,
...
}: {
options = {
crony.nh.enable = lib.mkEnableOption "Enable nh and set it up for automatic cleaning.";
};
config = lib.mkIf config.crony.nh.enable {
# Install nh
programs.nh = {
enable = true;
flake = "/home/crony/Repos/nixos";
clean = {
enable = true;
extraArgs = "--keep 5 --keep-since 3d";
};
};
};
}

View file

@ -0,0 +1,56 @@
{
config,
lib,
pkgs,
...
}: {
options = {
crony.nnn.enable = lib.mkEnableOption "Enable nnn and customize it for me.";
};
config = lib.mkIf config.crony.nnn.enable {
# Needed enviromental variables
home.sessionVariables = {
NNN_FIFO = "/tmp/nnn.fifo";
};
# NNN Settings
programs.nnn = {
enable = true;
package = pkgs.nnn.override {withNerdIcons = true;};
bookmarks = {
d = "~/Documents";
D = "~/Downloads";
p = "~/Pictures";
v = "~/Videos";
};
extraPackages = with pkgs; [
pmount
ffmpegthumbnailer
mediainfo
poppler_utils
gnome-epub-thumbnailer
nsxiv
libarchive
ueberzugpp
];
plugins.mappings = {
u = "nmount";
c = "chksum";
r = "gitroot";
v = "imgview";
m = "mtpmount";
d = "xdgdefault";
x = "togglex";
p = "preview-tui";
};
plugins.src =
(pkgs.fetchFromGitHub {
owner = "jarun";
repo = "nnn";
rev = "62c84dd2549770e15c70328863a63da4fd2da2f9";
hash = "sha256-Q/p4+v0sthcsmi8/EoAVT4dNl+hZNKZM4fjhffMpato=";
})
+ "/plugins";
};
};
}

View file

@ -0,0 +1,20 @@
{
config,
pkgs,
lib,
...
}: {
options = {
crony.obs-studio.enable = lib.mkEnableOption "Enable obs and install plugins.";
};
config = lib.mkIf config.crony.obs-studio.enable {
# Install obs-studio
programs.obs-studio = {
enable = true;
plugins = with pkgs.obs-studio-plugins; [
obs-vkcapture
];
};
};
}

View file

@ -0,0 +1,92 @@
{
config,
pkgs,
lib,
...
}: {
options = {
crony.restic.enable = lib.mkEnableOption "Install and setup restic and backup services.";
};
config = lib.mkIf config.crony.restic.enable {
# Install restic package
home.packages = with pkgs; [
restic
];
##-- Restic Timers And Services --##
# Restic backup
systemd.user.services = {
restic_backup = {
Unit.Description = "Restic backup service";
Service = {
Type = "oneshot";
ExecStart = toString (pkgs.writeShellScript "restic-backup" ''
. /etc/restic/local
restic backup --files-from /home/crony/.config/restic/list --verbose && restic forget --keep-last 10 --keep-daily 7 --keep-weekly 5 --keep-monthly 12
. /etc/restic/online
restic backup --files-from /home/crony/.config/restic/list --verbose && restic forget --keep-last 10 --keep-daily 7 --keep-weekly 5 --keep-monthly 12
rsync -avP --delete "$HOME/.local/backup/" "$HOME/Documents/Share/"
'');
};
};
};
systemd.user.timers = {
restic_backup = {
Unit.Description = "Restic backup timer";
Timer = {
OnBootSec = "5m";
OnUnitActiveSec = "6h";
};
Install.WantedBy = ["timers.target"];
};
};
# Restic check
systemd.user.services = {
restic_check = {
Unit.Description = "Restic check service";
Service = {
Type = "oneshot";
ExecStart = toString (pkgs.writeShellScript "restic-check" ''
. /etc/restic/local
restic check --read-data-subset=10%
. /etc/restic/online
restic check --read-data-subset=10%
'');
};
};
};
systemd.user.timers = {
restic_check = {
Unit.Description = "Restic check timer";
Timer = {OnCalendar = "Thu *-*-* 18:00:00";};
Install.WantedBy = ["timers.target"];
};
};
# Restic prune
systemd.user.services = {
restic_prune = {
Unit.Description = "Restic prune service";
Service = {
Type = "oneshot";
ExecStart = toString (pkgs.writeShellScript "restic-prune" ''
. /etc/restic/local
restic prune
. /etc/restic/online
restic prune
'');
};
};
};
systemd.user.timers = {
restic_prune = {
Unit.Description = "Restic prune timer";
Timer = {OnCalendar = "Fri *-*-* 18:00:00";};
Install.WantedBy = ["timers.target"];
};
};
};
}

View file

@ -0,0 +1,16 @@
{
config,
pkgs,
lib,
...
}: {
options = {
crony.scripts.enable = lib.mkEnableOption "Enable my custom scripts";
};
config = lib.mkIf config.crony.scripts.enable {
home.packages = with pkgs; [
(callPackage ./scripts {inherit pkgs;})
];
};
}

View file

@ -0,0 +1,7 @@
#!/usr/bin/env sh
for File in *.cue; do
[ -f "$File" ] || continue
chdman createcd -i "$File" -o "${File%.cue}.chd"
rm -v "$File" "${File%.cue}"*.bin
done

View file

@ -0,0 +1,7 @@
#!/usr/bin/env sh
for File in *.iso; do
[ -f "$File" ] || continue
chdman createdvd -i "$File" -o "${File%.iso}.chd"
rm -v "$File"
done

View file

@ -0,0 +1,27 @@
{pkgs, ...}:
with pkgs;
stdenv.mkDerivation {
pname = "scripts";
version = "1";
src = ./bin;
nativeBuildInputs = [makeWrapper];
installPhase = ''
mkdir -p $out/bin
# move scripts to bin
mv ./* $out/bin
# Fix shebangs for scripts
patchShebangs $out/bin
# Add dependencies to the runtime for my cue2chd script
wrapProgram $out/bin/cue2chd \
--prefix PATH : ${lib.makeBinPath [mame-tools]}
# Add dependencies to the runtime for my iso2chd script
wrapProgram $out/bin/cue2chd \
--prefix PATH : ${lib.makeBinPath [mame-tools]}
'';
}

View file

@ -0,0 +1,17 @@
{
config,
lib,
...
}: {
imports = [
./graphics-tablet.nix
];
options = {
crony.additional-hardware.enable = lib.mkEnableOption "Enable additional hardware modules.";
};
config = lib.mkIf config.crony.additional-hardware.enable {
crony.additional-hardware.otd.enable = lib.mkDefault true;
};
}

View file

@ -0,0 +1,14 @@
{
config,
lib,
...
}: {
options = {
crony.additional-hardware.otd.enable = lib.mkEnableOption "Enable OpenTabletDriver";
};
config = lib.mkIf config.crony.additional-hardware.otd.enable {
# Setup OpenTabletDriver graphic tablet driver
hardware.opentabletdriver.enable = true;
};
}

View file

@ -0,0 +1,15 @@
{
config,
lib,
...
}: {
options = {
crony.amdgpu.enable = lib.mkEnableOption "Load amdgpu modules at boot.";
};
config = lib.mkIf config.crony.amdgpu.enable {
# Try to fix amdgpu
boot.initrd.kernelModules = ["amdgpu"];
services.xserver.videoDrivers = ["amdgpu"];
};
}

View file

@ -0,0 +1,28 @@
{
config,
lib,
...
}: {
options = {
crony.auto-cpufreq.enable = lib.mkEnableOption "Enable auto-cpufreq and set it up for my laptop.";
};
config = lib.mkIf config.crony.auto-cpufreq.enable {
# Setup auto-cpufreq
programs.auto-cpufreq = {
enable = true;
settings = {
battery = {
governor = "powersave";
turbo = "never";
};
charger = {
governor = "performance";
turbo = "auto";
};
};
};
};
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 56 KiB

View file

@ -0,0 +1,15 @@
{
lib,
config,
...
}: {
# Enable bluetooth
options = {
crony.bluetooth.enable = lib.mkEnableOption "enable bluetooth";
};
config = lib.mkIf config.crony.bluetooth.enable {
hardware.bluetooth.enable = true;
hardware.bluetooth.powerOnBoot = true;
};
}

View file

@ -0,0 +1,43 @@
{lib, ...}: {
imports = [
./bluetooth.nix
./nvidia.nix
./plasma.nix
./disable-hibernation.nix
./gaming.nix
./zsh.nix
./stylix.nix
./nbfc.nix
./ryzenadj.nix
./qemu.nix
./amdgpu.nix
./nfs-share.nix
./auto-cpufreq.nix
./wireguard.nix
./hyprland.nix
./sddm.nix
./watchdog.nix
./general-services.nix
./additional-hardware
];
crony.bluetooth.enable = lib.mkDefault true;
crony.nvidia.enable = lib.mkDefault true;
crony.plasma.enable = lib.mkDefault false;
crony.hibernation.disable = lib.mkDefault true;
crony.gaming.enable = lib.mkDefault true;
crony.zsh.enable = lib.mkDefault true;
crony.stylix.enable = lib.mkDefault true;
crony.nbfc.enable = lib.mkDefault true;
crony.ryzenadj.enable = lib.mkDefault true;
crony.qemu.enable = lib.mkDefault true;
crony.amdgpu.enable = lib.mkDefault false;
crony.nfs-share.enable = lib.mkDefault true;
crony.auto-cpufreq.enable = lib.mkDefault true;
crony.wireguard.enable = lib.mkDefault true;
crony.hyprland-nixos.enable = lib.mkDefault true;
crony.sddm.enable = lib.mkDefault true;
crony.watchdog.disable = lib.mkDefault true;
crony.general-services.enable = lib.mkDefault true;
crony.additional-hardware.enable = lib.mkDefault true;
}

View file

@ -0,0 +1,30 @@
{
config,
lib,
...
}: {
options = {
crony.hibernation.disable = lib.mkEnableOption "disable hibernation and friends";
};
config = lib.mkIf config.crony.hibernation.disable {
# Disable hibernation, sleep and other friends
systemd.targets = {
sleep = {
enable = false;
unitConfig.DefaultDependencies = "no";
};
suspend = {
enable = false;
unitConfig.DefaultDependencies = "no";
};
hibernate = {
enable = false;
unitConfig.DefaultDependencies = "no";
};
"hybrid-sleep" = {
enable = false;
unitConfig.DefaultDependencies = "no";
};
};
};
}

View file

@ -0,0 +1,50 @@
{
config,
pkgs,
lib,
...
}: {
# Getting gaming setup
options = {
crony.gaming.enable = lib.mkEnableOption "enable gaming related stuff, like steam and gamemode";
};
config = lib.mkIf config.crony.gaming.enable {
environment.systemPackages = with pkgs; [
mangohud
];
# Install steam
programs.steam = {
enable = true;
};
# Enable gamescope
programs.gamescope = {
enable = true;
capSysNice = true;
};
# Install gamemode
programs.gamemode = {
enable = true;
enableRenice = true;
settings = {
general = {
softrealtime = "on";
renice = 10;
};
custom = {
start = "${pkgs.libnotify}/bin/notify-send 'GameMode started'";
end = "${pkgs.libnotify}/bin/notify-send 'GameMode ended'";
};
};
};
# Setup esync
systemd.extraConfig = "DefaultLimitNOFILE=1048576";
security.pam.loginLimits = [
{
domain = "*";
type = "hard";
item = "nofile";
value = "1048576";
}
];
};
}

View file

@ -0,0 +1,25 @@
{
config,
pkgs,
lib,
...
}: {
options = {
crony.general-services.enable = lib.mkEnableOption "Enable general services that just should be enabled by default.";
};
config = lib.mkIf config.crony.general-services.enable {
# Enable upower
services.upower.enable = true;
# Setup udev for android rules
services.udev.packages = [
pkgs.android-udev-rules
];
# Enable firmware updater
services.fwupd.enable = true;
# Enable zram swap device
zramSwap.enable = true;
};
}

View file

@ -0,0 +1,30 @@
{
config,
lib,
...
}: {
options = {
crony.hyprland-nixos.enable = lib.mkEnableOption "Enable hyprland globally";
};
config = lib.mkIf config.crony.hyprland-nixos.enable {
programs.uwsm = {
enable = true;
waylandCompositors = {
hyprland = {
prettyName = "Hyprland";
comment = "Hyprland compositor managed by UWSM";
binPath = "/run/current-system/sw/bin/Hyprland";
};
};
};
programs.hyprland = {
enable = true;
withUWSM = true;
};
security.pam.services.hyprlock = {};
};
}

View file

@ -0,0 +1,30 @@
{
config,
inputs,
pkgs,
lib,
...
}: {
options = {
crony.nbfc.enable = lib.mkEnableOption "enable nbfc and set it up for my laptop";
};
config = lib.mkIf config.crony.nbfc.enable {
# Install nbfc-linux
environment.systemPackages = [
inputs.nbfc-linux.packages.x86_64-linux.default
];
# Setup nbfc package
systemd.services.nbfc_service = {
enable = true;
description = "NoteBook FanControl Service";
serviceConfig.Type = "simple";
path = [pkgs.kmod];
script = "${inputs.nbfc-linux.packages.x86_64-linux.default}/bin/nbfc_service --config-file '/home/crony/.config/nbfc.json'";
wantedBy = ["multi-user.target"];
};
};
}

View file

@ -0,0 +1,18 @@
{
config,
lib,
...
}: {
options = {
crony.nfs-share.enable = lib.mkEnableOption "Setup personal nfs share mount.";
};
config = lib.mkIf config.crony.nfs-share.enable {
# Nfs share
fileSystems."/mnt/share" = {
device = "192.168.0.4:/mnt/nfs";
fsType = "nfs";
options = ["_netdev" "noauto" "x-systemd.automount" "x-systemd.mount-timeout=10" "timeo=14" "x-systemd.idle-timeout=600"];
};
};
}

View file

@ -0,0 +1,37 @@
{
lib,
pkgs,
config,
...
}: {
# Allow for nvidia
options = {
crony.nvidia.enable = lib.mkEnableOption "enable nvidia";
};
config = lib.mkIf config.crony.nvidia.enable {
# Setup vaapi for nvidia
hardware.graphics.extraPackages = with pkgs; [
nvidia-vaapi-driver
];
# Setup nvidia drivers
services.xserver.videoDrivers = ["nvidia"];
hardware.nvidia = {
open = true;
modesetting.enable = true;
powerManagement.enable = true;
nvidiaSettings = true;
prime = {
reverseSync.enable = true;
offload = {
enableOffloadCmd = true;
enable = false;
};
nvidiaBusId = "PCI:1:0:0";
amdgpuBusId = "PCI:5:0:0";
};
};
};
}

View file

@ -0,0 +1,20 @@
{
pkgs,
config,
lib,
...
}: {
options = {
crony.plasma.enable = lib.mkEnableOption "enable plasma";
};
config = lib.mkIf config.crony.plasma.enable {
# Enable the KDE Plasma Desktop Environment.
services.desktopManager.plasma6.enable = true;
environment.plasma6.excludePackages = with pkgs.kdePackages; [
plasma-browser-integration
konsole
oxygen
];
};
}

View file

@ -0,0 +1,19 @@
{
config,
pkgs,
lib,
...
}: {
options = {
crony.qemu.enable = lib.mkEnableOption "Enable qemu and setup quickemu";
};
config = lib.mkIf config.crony.qemu.enable {
systemd.tmpfiles.rules = ["L+ /var/lib/qemu/firmware - - - - ${pkgs.qemu}/share/qemu/firmware"];
environment.systemPackages = with pkgs; [
qemu
quickemu
];
};
}

View file

@ -0,0 +1,153 @@
{
config,
pkgs,
lib,
...
}: let
ryzenadj-service =
pkgs.writers.writePython3Bin "ryzenadj-service" {
libraries = [pkgs.ryzenadj];
flakeIgnore = ["E501" "F405" "F403" "E265"];
} ''
#!/bin/env python3
import argparse
import os
import sys
import time
from ctypes import *
lib_path = os.path.dirname(os.path.abspath(__file__))
os.chdir(lib_path)
lib = cdll.LoadLibrary("${pkgs.ryzenadj}/lib/libryzenadj.so")
# define ctype mappings for types which can not be mapped automatically
# ryzenadj tables
lib.init_ryzenadj.restype = c_void_p
lib.refresh_table.argtypes = [c_void_p]
# Stapm value and limit
lib.get_stapm_limit.restype = c_float
lib.get_stapm_limit.argtypes = [c_void_p]
# Slow limit and value
lib.get_slow_limit.restype = c_float
lib.get_slow_limit.argtypes = [c_void_p]
# Fast limit and value
lib.get_fast_limit.restype = c_float
lib.get_fast_limit.argtypes = [c_void_p]
# Slow time and value
lib.get_slow_time.restype = c_float
lib.get_slow_time.argtypes = [c_void_p]
# stapm time and value
lib.get_stapm_time.restype = c_float
lib.get_stapm_time.argtypes = [c_void_p]
# Vrm Max Current and value
lib.get_vrmmax_current.restype = c_float
lib.get_vrmmax_current.argtypes = [c_void_p]
# Tctl cpu temp
lib.get_tctl_temp.restype = c_float
lib.get_tctl_temp.argtypes = [c_void_p]
ry = lib.init_ryzenadj()
if not ry:
sys.exit("RyzenAdj could not get initialized")
error_messages = {
-1: "{:s} is not supported on this family\n",
-3: "{:s} is not supported on this SMU\n",
-4: "{:s} is rejected by SMU\n",
}
def adjust(field, value):
function_name = "set_" + field
adjust_func = lib.__getattr__(function_name)
adjust_func.argtypes = [c_void_p, c_ulong]
res = adjust_func(ry, value)
if res:
error = error_messages.get(res, "{:s} did fail with {:d}\n")
sys.stderr.write(error.format(function_name, res))
else:
print(f"Succesfully set {field} to {value}")
def enable(field):
function_name = "set_" + field
adjust_func = lib.__getattr__(function_name)
adjust_func.argtypes = [c_void_p]
res = adjust_func(ry)
if res:
error = error_messages.get(res, "{:s} did fail with {:d}\n")
sys.stderr.write(error.format(function_name, res))
else:
print(f"Sucessfully enable {field}")
def set(args):
adjust("stapm_limit", args.stapm_limit)
adjust("fast_limit", args.fast_limit)
adjust("slow_limit", args.slow_limit)
# adjust("slow_time", args.slow_time)
# adjust("stapm_time", args.stapm_time)
adjust("tctl_temp", args.tctl_temp)
adjust("vrmmax_current", args.vrmmax_current)
enable("max_performance")
def loop(args):
set(args)
while True:
lib.refresh_table(ry)
current = round(lib.get_tctl_temp(ry))
if current != 85:
set(args)
time.sleep(3)
def parse_args():
parser = argparse.ArgumentParser(
prog="Ryzenadj Service",
description="Simple Ryzenadj python service to keep values set",
)
parser.add_argument("--stapm-limit", action="store", required=True, type=int)
parser.add_argument("--fast-limit", action="store", required=True, type=int)
parser.add_argument("--slow-limit", action="store", required=True, type=int)
# parser.add_argument("--slow-time", action="store", required=True, type=int)
# parser.add_argument("--stapm-time", action="store", required=True, type=int)
parser.add_argument("--tctl-temp", action="store", required=True, type=int)
parser.add_argument("--vrmmax-current", action="store", required=True, type=int)
return parser.parse_args()
def main():
args = parse_args()
loop(args)
if __name__ == "__main__":
main()
'';
in {
options = {
crony.ryzenadj.enable = lib.mkEnableOption "Enable ryzenadj and customize it for my system.";
};
config = lib.mkIf config.crony.ryzenadj.enable {
# Add ryzen-smu driver to allow reading values
boot.extraModulePackages = with config.boot.kernelPackages; [ryzen-smu];
# Install ryzenadj globally
environment.systemPackages = with pkgs; [
ryzenadj
];
# Setup python service for ryzenadj
systemd.services.ryzenadj = {
enable = true;
description = "Set my cpu power usage power to something more manageable.";
wantedBy = ["multi-user.target"];
script = "${ryzenadj-service}/bin/ryzenadj-service --stapm-limit 35000 --fast-limit 35000 --slow-limit 35000 --tctl-temp 90 --vrmmax-current 70000";
};
};
}

View file

@ -0,0 +1,30 @@
{
config,
pkgs,
lib,
...
}: {
options = {
crony.sddm.enable = lib.mkEnableOption "Enable sddm.";
};
config = lib.mkIf config.crony.sddm.enable {
environment.systemPackages = [
(pkgs.where-is-my-sddm-theme.override {
variants = ["qt6" "qt5"];
themeConfig.General = {
showSessionsByDefault = true;
background = "${pkgs.nixos-icons}/share/icons/hicolor/scalable/apps/nix-snowflake.svg";
backgroundFill = "#282828";
backgroundMode = "none";
};
})
];
services.displayManager.sddm = {
enable = true;
wayland.enable = true;
theme = "where_is_my_sddm_theme_qt5";
};
};
}

View file

@ -0,0 +1,60 @@
{
pkgs,
config,
lib,
...
}: {
options = {
crony.stylix.enable = lib.mkEnableOption "enable stylix and style my system";
};
config = lib.mkIf config.crony.stylix.enable {
# Enable sytling using stylix
stylix.enable = true;
stylix.autoEnable = true;
stylix.image = ./background.png;
stylix.base16Scheme = "${pkgs.base16-schemes}/share/themes/gruvbox-dark-medium.yaml";
# Change Cursor
stylix.cursor.package = pkgs.bibata-cursors;
stylix.cursor.name = "Bibata-Modern-Ice";
stylix.cursor.size = 32;
# Fix stuff not automatically using dark theme on websites
stylix.polarity = "dark";
# Change u those fonts
stylix.fonts = {
serif = {
package = pkgs.dejavu_fonts;
name = "DejaVu Serif";
};
sansSerif = {
package = pkgs.dejavu_fonts;
name = "DejaVu Sans";
};
monospace = {
package = pkgs.nerd-fonts.commit-mono;
name = "CommitMono Nerd Font";
};
emoji = {
package = pkgs.noto-fonts-emoji;
name = "Noto Color Emoji";
};
};
# Change font sizes
stylix.fonts.sizes = {
applications = 15;
desktop = 13;
popups = 13;
terminal = 15;
};
# Change chrome settings
stylix.targets.chromium.enable = false;
};
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.4 MiB

View file

@ -0,0 +1,14 @@
{
config,
lib,
...
}: {
options = {
crony.watchdog.disable = lib.mkEnableOption "Disable watchdog for my laptop.";
};
config = lib.mkIf config.crony.watchdog.disable {
boot.kernelParams = ["nmi_watchdog=0"];
boot.blacklistedKernelModules = ["sp5100_tco"];
};
}

View file

@ -0,0 +1,26 @@
{
config,
lib,
...
}: {
options = {
crony.wireguard.enable = lib.mkEnableOption "Open ports in firewall for wireguard to work.";
};
config = lib.mkIf config.crony.wireguard.enable {
# Allow for wireguard traffic
networking.firewall = {
# if packets are still dropped, they will show up in dmesg
logReversePathDrops = true;
# wireguard trips rpfilter up
extraCommands = ''
ip46tables -t mangle -I nixos-fw-rpfilter -p udp -m udp --sport 51820 -j RETURN
ip46tables -t mangle -I nixos-fw-rpfilter -p udp -m udp --dport 51820 -j RETURN
'';
extraStopCommands = ''
ip46tables -t mangle -D nixos-fw-rpfilter -p udp -m udp --sport 51820 -j RETURN || true
ip46tables -t mangle -D nixos-fw-rpfilter -p udp -m udp --dport 51820 -j RETURN || true
'';
};
};
}

View file

@ -0,0 +1,18 @@
{
config,
lib,
pkgs,
...
}: {
options = {
crony.zsh.enable = lib.mkEnableOption "install and enable zsh for all users";
};
config = lib.mkIf config.crony.zsh.enable {
# Installing zsh
programs.zsh.enable = true;
programs.zsh.enableCompletion = false;
users.defaultUserShell = pkgs.zsh;
environment.pathsToLink = ["/share/zsh"];
};
}