chore: routine maintenance

This commit is contained in:
danny 2025-11-23 16:24:38 +08:00
parent c45ba82b90
commit c7743490a7
75 changed files with 1200 additions and 634 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 116 KiB

After

Width:  |  Height:  |  Size: 1.3 MiB

Before After
Before After

5
home/options/default.nix Normal file
View file

@ -0,0 +1,5 @@
{
imports = [
./ntfy-client.nix
];
}

View file

@ -0,0 +1,81 @@
{
config,
lib,
pkgs,
...
}:
let
inherit (lib)
literalExpression
mkEnableOption
mkPackageOption
mkOption
types
mkIf
getExe'
;
cfg = config.services.ntfy-client;
in
{
options.services.ntfy-client = {
enable = mkEnableOption "enable ntfy client subscription";
package = mkPackageOption pkgs "ntfy-sh" { };
extraArgs = mkOption {
type = with types; listOf str;
default = [ ];
};
settings = mkOption {
type = with types; attrs;
description = "The settings for `client.yml`";
default = { };
example = literalExpression ''
{
default-host = "https://ntfy.sh";
subscribe = [
{
topic = "common";
command = ''\''notify-send "$m"''\'';
token = "$TOKEN";
}
];
}
'';
};
environmentFile = mkOption {
type = with types; path;
default = null;
description = "environmentFile contains secrets";
example = ''
/var/run/secrets
content:
NTFY_USER="username:password"
'';
};
};
config = mkIf cfg.enable (
let
configFile = (pkgs.formats.yaml { }).generate "ntfy-client.yml" cfg.settings;
in
{
systemd.user.services.ntfy-client = {
Unit.X-Restart-Triggers = [ config.xdg.configFile."ntfy/client.yml".source ];
Install = {
WantedBy = [ "graphical-session.target" ];
};
Service = {
ExecStart = "${getExe' cfg.package "ntfy"} subscribe --from-config ${toString cfg.extraArgs}";
EnvironmentFile = [
cfg.environmentFile
];
};
};
xdg.configFile."ntfy/client.yml".source = configFile;
}
);
}

View file

@ -1,6 +1,7 @@
{ ... }:
{
imports = [
../options
../user/internationalisation.nix
../user/config.nix
../user/direnv.nix

View file

@ -10,7 +10,7 @@ let
curl -sL "$url" -o "$filepath"
fi
${config.services.swww.package}/bin/swww img "$filepath" \
${config.services.swww.package}/bin/awww img "$filepath" \
--transition-fps 45 \
--transition-duration 1 \
--transition-type random

15
home/scripts/ntfy.nix Normal file
View file

@ -0,0 +1,15 @@
{
config,
pkgs,
lib,
}:
let
inherit (lib) getExe';
in
pkgs.writeShellScriptBin "ntfy" ''
set -o allexport
source "${config.sops.secrets."ntfy".path}"
set +o allexport
${getExe' pkgs.ntfy-sh "ntfy"} "$@"
''

View file

@ -1,4 +1,17 @@
{ pkgs, ... }:
{
osConfig,
config,
pkgs,
}:
let
inherit (osConfig.networking) hostName;
shouldNotify =
(builtins.hasAttr "ntfy-client" config.services) && config.services.ntfy-client.enable;
rebuildCommand = ''
nixos-rebuild switch --target-host "$TARGET" \
--build-host "$BUILD" \
--sudo --ask-sudo-password $@'';
in
pkgs.writeShellScriptBin "rRebuild" ''
TARGET=$1
BUILD=$2
@ -6,5 +19,20 @@ pkgs.writeShellScriptBin "rRebuild" ''
shift
shift
nixos-rebuild switch --target-host "$TARGET" --build-host "$BUILD" --sudo --ask-sudo-password $@
${
if shouldNotify then
''
export NTFY_TITLE="🎯 $TARGET built by 🏗 ''\${BUILD:-${hostName}}"
export NTFY_TAGS="gear"
if ${rebuildCommand}
then
ntfy pub system-build " Build success" > /dev/null 2>&1
else
ntfy pub system-build " Build failed" > /dev/null 2>&1
fi
''
else
rebuildCommand
}
''

View file

@ -15,7 +15,6 @@ in
recursive = true;
source = "${configDir}/gh";
};
".face".source = "${configDir}/.face";
};
xdg.mimeApps = {

View file

@ -8,7 +8,7 @@
XDG_CACHE_HOME = "\${HOME}/.cache";
XDG_CONFIG_HOME = "\${HOME}/.config";
XDG_DATA_HOME = "\${HOME}/.local/share";
XDG_DATA_DIRS = "\${XDG_DATA_DIRS}:/usr/share:/var/lib/flatpak/exports/share:\${HOME}/.local/share/flatpak/exports/share";
XDG_DATA_DIRS = "\${XDG_DATA_DIRS}:/usr/share";
WLR_RENDERER = "vulkan";

View file

@ -6,9 +6,9 @@
{
programs.git = {
enable = true;
userName = username;
userEmail = email;
extraConfig = {
settings = {
user.name = username;
user.email = email;
safe.directory = [ "/etc/nixos" ];
init.defaultBranch = "main";
pull.rebase = true;

View file

@ -2,7 +2,6 @@
{
osConfig,
config,
lib,
pkgs,
...
}:
@ -18,6 +17,7 @@ let
browser = "${prefix}${browser-bin}";
terminal = "${prefix}ghostty";
filemanager = "${terminal} -e yazi";
mailClient = "${prefix}thunderbird";
screenshotFolder = "--output-folder ~/Pictures/Screenshots";
clipboardOnly = "${screenshotFolder}";
@ -49,7 +49,8 @@ in
''CTRL ALT, T, exec, ${terminal}''
''${mainMod}, Q, killactive, ''
''${mainMod}, M, exec, ${toggleWlogout}''
''${mainMod} SHIFT, M, exec, ${toggleWlogout}''
''${mainMod}, M, exec, ${mailClient}''
''${mainMod}, E, exec, ${filemanager}''
''${mainMod}, V, togglefloating, ''
''ALT, SPACE, exec, rofi -config ~/.config/rofi/apps.rasi -show drun''

View file

@ -3,11 +3,12 @@
lib,
inputs,
config,
system,
osConfig,
...
}:
let
inherit (lib) mkForce escapeShellArgs getExe';
inherit (pkgs.stdenv.hostPlatform) system;
inherit (osConfig.systemConf) username;
inherit (osConfig.systemConf.hyprland) monitors;
terminal = "ghostty";
@ -64,7 +65,6 @@ in
plugins = (
with inputs.hyprland-plugins.packages.${system};
[
xtra-dispatchers
hyprwinwrap
]
);
@ -138,12 +138,15 @@ in
};
};
# === Swww === #
# === Awww === #
services.swww = {
enable = true;
package = inputs.swww.packages.${system}.swww;
package = inputs.awww.packages.${system}.awww;
};
systemd.user.services.swww.Service.ExecStart =
mkForce "${getExe' config.services.swww.package "awww-daemon"} ${escapeShellArgs config.services.swww.extraArgs}";
# === hyprlock === #
programs.hyprlock = {
enable = true;

View file

@ -8,7 +8,7 @@ let
addons = with pkgs; [
fcitx5-gtk
fcitx5-mozc # Japanese
fcitx5-chinese-addons
qt6Packages.fcitx5-chinese-addons
fcitx5-rime # Bopomofo
rime-data
];

View file

@ -28,16 +28,25 @@ in
imports = [
./plugins/snacks-nvim
./plugins/lualine
./plugins/leetcode
./extra-lsp.nix
];
home.packages = with pkgs; [
(rust-bin.stable.latest.default.override {
extensions = [ "rust-src" ];
})
];
programs.nvf = {
enable = true;
settings = {
vim = {
enableLuaLoader = true;
vimAlias = true;
extraPackages = with pkgs; [ nixfmt ];
extraPackages = with pkgs; [
nixfmt
];
clipboard = {
enable = true;
@ -380,12 +389,9 @@ in
enable = true;
lsp = {
enable = true;
package = [
"rust-analyzer"
];
opts = ''
['rust-analyzer'] = {
cargo = {allFeature = true},
cargo = { allFeature = true },
checkOnSave = true,
procMacro = {
enable = true,
@ -528,7 +534,8 @@ in
yazi-nvim = {
enable = true;
mappings.openYaziDir = "<leader>e";
mappings.openYaziDir = "<leader>-";
mappings.openYazi = "<leader>e";
};
images = {

View file

@ -0,0 +1,72 @@
{
lib,
config,
osConfig,
...
}:
let
inherit (lib.generators) mkLuaInline;
inherit (osConfig.systemConf) username;
relativeDir = "projects/leetcode";
dataDir = "${config.home.homeDirectory}/${relativeDir}";
in
{
programs.nvf.settings.vim.utility.leetcode-nvim = {
enable = true;
setupOpts = {
image_support = true;
lang = "rust";
plugins.non_standalone = true;
storage.home = mkLuaInline ''"${dataDir}"'';
injector = mkLuaInline ''
{
['rust'] = {
before = { '#[allow(dead_code)]', 'fn main() {}', '#[allow(dead_code)]', 'struct Solution;' },
}
}
'';
hooks."question_enter" = [
(mkLuaInline
# lua
''
function (question)
if question.lang ~= 'rust' then
return
end
local config = require("leetcode.config")
local problem_dir = config.user.storage.home .. "/Cargo.toml"
local content = [[
[package]
name = "leetcode"
edition = "2024"
[lib]
name = "%s"
path = "%s"
[dependencies]
rand = "0.8"
regex = "1"
itertools = "0.14.0"
]]
local file = io.open(problem_dir, "w")
if file then
local formatted = (content:gsub(" +", "")):format(question.q.frontend_id, question:path())
file:write(formatted)
file:close()
else
print("Failed to open file " .. problem_dir)
end
end
''
)
];
};
};
systemd.user.tmpfiles.rules = [
"d ${dataDir} 0744 ${username} users -"
];
}

View file

@ -1,12 +1,10 @@
{
pkgs,
lib,
inputs,
system,
osConfig,
...
}:
let
inherit (pkgs.stdenv.hostPlatform) system;
md2html = pkgs.callPackage ../scripts/md2html.nix { };
ghosttyShaders = pkgs.fetchFromGitHub {
owner = "sahaj-b";
@ -60,61 +58,46 @@ in
};
};
home.packages =
with pkgs;
[
obsidian
home.packages = with pkgs; [
obsidian
# Discord
# vesktop
discord
# Discord
# vesktop
discord
# Dev stuff
(python3.withPackages (python-pkgs: [
python-pkgs.pip
python-pkgs.requests
]))
# Dev stuff
(python3.withPackages (python-pkgs: [
python-pkgs.pip
python-pkgs.requests
]))
# Work stuff
libreoffice-qt
pandoc
# Work stuff
libreoffice-qt
pandoc
# Bluetooth
blueberry
# Bluetooth
blueberry
# Downloads
qbittorrent
# Downloads
qbittorrent
# Utils
cava
papirus-folders
inkscape
# Utils
cava
papirus-folders
inkscape
# PDF Preview
poppler
trash-cli
# PDF Preview
poppler
trash-cli
# File Manager
nemo
# File Manager
nemo
# Thumbnail
ffmpegthumbnailer
thunderbird
thunderbird
# Thumbnail
ffmpegthumbnailer
md2html
]
++ (
if osConfig.programs.steam.enable then
[
steam-run
protonup
]
else
[ ]
);
home.sessionVariables = lib.mkIf osConfig.programs.steam.enable {
STEAM_EXTRA_COMPAT_TOOLS_PATHS = "\${HOME}/.steam/root/compatibilitytools.d";
};
md2html
];
}

View file

@ -1,9 +1,17 @@
{ osConfig, pkgs, ... }:
{
osConfig,
config,
pkgs,
...
}:
let
shellAlias = import ./shellAlias.nix { hostname = osConfig.networking.hostName; };
remoteRebuld = pkgs.callPackage ../scripts/remoteRebuild.nix { };
remoteRebuld = import ../scripts/remoteRebuild.nix { inherit osConfig config pkgs; };
in
{
imports = [
./shellAlias.nix
];
home.packages = with pkgs; [
# Shell
grc
@ -34,7 +42,6 @@ in
src = pkgs.fishPlugins.hydro.src;
}
];
shellAliases = shellAlias;
};
bash = {

View file

@ -1,27 +1,68 @@
{ hostname }:
{
ls = "exa --icons";
lp = "exa"; # Pure output
cat = "bat";
g = "git";
t = "tmux";
osConfig,
config,
pkgs,
...
}:
let
hostname = osConfig.networking.hostName;
# Nixos
rebuild = "sudo nixos-rebuild switch --flake /etc/nixos#${hostname}";
fullClean = "sudo nix store gc && sudo nix-collect-garbage -d && sudo /run/current-system/bin/switch-to-configuration boot";
shouldNotify =
(builtins.hasAttr "ntfy-client" config.services) && config.services.ntfy-client.enable;
# Hyprland
hyprlog = "grep -v \"arranged\" $XDG_RUNTIME_DIR/hypr/$HYPRLAND_INSTANCE_SIGNATURE/hyprland.log | cat";
rebuildCommand = ''
sudo nixos-rebuild switch --target-host "$TARGET" \
--build-host "$BUILD" \
--sudo --ask-sudo-password $@'';
# Systemd Boot
setWin = "sudo bootctl set-oneshot auto-windows";
goWin = "sudo bootctl set-oneshot auto-windows && reboot";
goBios = "sudo bootctl set-oneshot auto-reboot-to-firmware-setup && reboot";
rebuild = pkgs.writeShellScriptBin "rebuild" ''
${
if shouldNotify then
''
export NTFY_TITLE="🎯 ${hostname}"
export NTFY_TAGS="gear"
# TTY
hideTTY = ''sudo sh -c "echo 0 > /sys/class/graphics/fb0/blank"'';
showTTY = ''sudo sh -c "echo 1 > /sys/class/graphics/fb0/blank"'';
if ${rebuildCommand}
then
ntfy pub system-build " Build success" > /dev/null 2>&1
else
ntfy pub system-build " Build failed" > /dev/null 2>&1
fi
''
else
rebuildCommand
}
'';
in
{
home.packages = [
rebuild
];
# Recover from hyprlock corruption
letMeIn = ''hyprctl --instance 0 "keyword misc:allow_session_lock_restore 1" && hyprctl --instance 0 dispatch "exec hyprlock"'';
programs.fish.shellAliases = {
ls = "exa --icons";
lp = "exa"; # Pure output
cat = "bat";
g = "git";
t = "tmux";
podt = "podman-tui";
# Nixos
fullClean = "sudo nix store gc && sudo nix-collect-garbage -d && sudo /run/current-system/bin/switch-to-configuration boot";
# Hyprland
hyprlog = "grep -v \"arranged\" $XDG_RUNTIME_DIR/hypr/$HYPRLAND_INSTANCE_SIGNATURE/hyprland.log | cat";
# Systemd Boot
setWin = "sudo bootctl set-oneshot auto-windows";
goWin = "sudo bootctl set-oneshot auto-windows && reboot";
goBios = "sudo bootctl set-oneshot auto-reboot-to-firmware-setup && reboot";
# TTY
hideTTY = ''sudo sh -c "echo 0 > /sys/class/graphics/fb0/blank"'';
showTTY = ''sudo sh -c "echo 1 > /sys/class/graphics/fb0/blank"'';
# Recover from hyprlock corruption
letMeIn = ''hyprctl --instance 0 "keyword misc:allow_session_lock_restore 1" && hyprctl --instance 0 dispatch "exec hyprlock"'';
};
}

View file

@ -4,7 +4,6 @@
{
osConfig,
config,
username,
lib,
pkgs,
helper,
@ -72,7 +71,7 @@ let
exit 1
fi
${config.services.swww.package}/bin/swww img "$selected" --transition-fps 45 --transition-duration 1 --transition-type random
${config.services.swww.package}/bin/awww img "$selected" --transition-fps 45 --transition-duration 1 --transition-type random
'';
rbwSelector = import ../scripts/rbwSelector.nix { inherit pkgs; };
@ -84,11 +83,6 @@ in
mkWall
];
# For wallpapers
systemd.user.tmpfiles.rules = [
"d /tmp/wall_cache 700 ${username} -"
];
# === gamemoded -r === #
systemd.user.services.gamemodedr = lib.mkIf osConfig.programs.gamemode.enable {
Service = {

View file

@ -1,11 +1,12 @@
{
inputs,
system,
config,
pkgs,
lib,
...
}:
let
inherit (pkgs.stdenv.hostPlatform) system;
yaziPlugins = pkgs.fetchFromGitHub {
owner = "yazi-rs";
repo = "plugins";
@ -63,7 +64,7 @@ in
opener = {
set-wallpaper = [
{
run = ''${pkgs.swww}/bin/swww img "$1" --transition-fps 45 --transition-duration 1 --transition-type random'';
run = ''${config.services.swww.package}/bin/awww img "$1" --transition-fps 45 --transition-duration 1 --transition-type random'';
for = "linux";
desc = "Set as wallpaper";
}
@ -111,7 +112,7 @@ in
"g"
"w"
];
run = ''shell -- ${pkgs.swww}/bin/swww img "$1" --transition-fps 45 --transition-duration 1 --transition-type random'';
run = ''shell -- ${config.services.swww.package}/bin/awww img "$1" --transition-fps 45 --transition-duration 1 --transition-type random'';
desc = "Set as wallpaper";
}
# Git Changes
@ -178,9 +179,7 @@ in
"c"
"D"
];
run = ''
shell '${pkgs.ripdrag.out}/bin/ripdrag "$@" -x 2>/dev/null &' --confirm
'';
run = ''shell 'ripdrag "$0" "$@" -x 2>/dev/null &' --confirm'';
desc = "Drag the file";
}
# Start terminal
@ -214,7 +213,7 @@ in
{
on = [
"F" # file
"m" # markdown
"M" # markdown
"H" # html
];
for = "unix";
@ -251,5 +250,6 @@ in
home.packages = with pkgs; [
ueberzugpp
pdfNormalize
ripdrag
];
}