diff --git a/nixcfgs/modules/nixos/desktop/fonts.nix b/nixcfgs/modules/nixos/desktop/fonts.nix index 69110b0..358a49f 100644 --- a/nixcfgs/modules/nixos/desktop/fonts.nix +++ b/nixcfgs/modules/nixos/desktop/fonts.nix @@ -8,6 +8,7 @@ pkgs.noto-fonts-color-emoji pkgs.nerd-fonts.jetbrains-mono pkgs.nur.repos.definfo.sarasa-term-sc-nerd + pkgs.nur.repos.guanran928.harmonyos-sans pkgs.vollkorn pkgs.font-awesome ]; diff --git a/nixcfgs/users/js0ny/packages/cli.nix b/nixcfgs/users/js0ny/packages/cli.nix index dbbc6a9..d97f31a 100644 --- a/nixcfgs/users/js0ny/packages/cli.nix +++ b/nixcfgs/users/js0ny/packages/cli.nix @@ -75,6 +75,7 @@ pass # rar: Unfree, the only way (afaik) to unarchive some very old partition rars rar + newsboat ] ++ ( if pkgs.stdenv.isDarwin diff --git a/nixcfgs/users/js0ny/packages/gui.nix b/nixcfgs/users/js0ny/packages/gui.nix index e873dd1..e45bab9 100644 --- a/nixcfgs/users/js0ny/packages/gui.nix +++ b/nixcfgs/users/js0ny/packages/gui.nix @@ -129,6 +129,10 @@ in { (jetbrains.clion.override { vmopts = ''-Dawt.toolkit.name=WLToolkit''; }) + + seafile-client + seadrive-gui + seafile-shared ] ++ (mkFcitxIM [ pkgs.neovim-qt diff --git a/nixcfgs/users/js0ny/packages/stylix.nix b/nixcfgs/users/js0ny/packages/stylix.nix index 63e5910..4b2f547 100644 --- a/nixcfgs/users/js0ny/packages/stylix.nix +++ b/nixcfgs/users/js0ny/packages/stylix.nix @@ -30,8 +30,8 @@ in { fonts = { sansSerif = { - package = pkgs.lxgw-neoxihei; - name = "LXGW Neo XiHei"; + package = pkgs.nur.repos.guanran928.harmonyos-sans; + name = "HarmonyOS Sans"; }; serif = { @@ -71,7 +71,7 @@ in { }; }; - base16Scheme = "${pkgs.base16-schemes}/share/themes/material-palenight.yaml"; + base16Scheme = "${pkgs.base16-schemes}/share/themes/tokyo-night-storm.yaml"; image = ./wallpaper.jpg; polarity = "dark"; }; diff --git a/nixcfgs/users/js0ny/programs/cleaner.nix b/nixcfgs/users/js0ny/programs/cleaner.nix new file mode 100644 index 0000000..b209e8b --- /dev/null +++ b/nixcfgs/users/js0ny/programs/cleaner.nix @@ -0,0 +1,14 @@ +{config, ...}: { + imports = [ + ./lib-cleaner.nix + ]; + my.cleanup.jobs = { + vicky3-crash-reports = { + path = "${config.home.homeDirectory}/.local/share/Paradox Interactive/Victoria 3/crashes/"; + olderThan = 7; + filesOnly = false; + recursive = false; + onCalendar = "weekly"; + }; + }; +} diff --git a/nixcfgs/users/js0ny/programs/lib-cleaner.nix b/nixcfgs/users/js0ny/programs/lib-cleaner.nix new file mode 100644 index 0000000..02dda22 --- /dev/null +++ b/nixcfgs/users/js0ny/programs/lib-cleaner.nix @@ -0,0 +1,159 @@ +{ + config, + lib, + pkgs, + ... +}: let + inherit + (lib) + mkOption + mkIf + types + mapAttrs' + nameValuePair + optionalString + escapeShellArg + getExe + ; + + cfg = config.my.cleanup; + + jobType = types.submodule ({name, ...}: { + options = { + path = mkOption { + type = types.str; + description = "Directory to clean."; + }; + + olderThan = mkOption { + type = types.int; + default = 7; + description = "Delete entries older than this many days."; + }; + + filesOnly = mkOption { + type = types.bool; + default = false; + description = "Only delete regular files."; + }; + + recursive = mkOption { + type = types.bool; + default = false; + description = "Whether to recurse into subdirectories."; + }; + + onCalendar = mkOption { + type = types.str; + default = "daily"; + description = "systemd timer schedule."; + }; + + dryRun = mkOption { + type = types.bool; + default = false; + description = "Print what would be deleted without deleting."; + }; + }; + }); + + mkCleanupScript = jobName: job: + pkgs.writeShellApplication { + name = "cleanup-${jobName}"; + runtimeInputs = with pkgs; [fd coreutils gnused]; + text = '' + job_name=${escapeShellArg jobName} + dir=${escapeShellArg job.path} + dry_run=${ + if job.dryRun + then "true" + else "false" + } + + log() { + printf '[cleanup:%s] %s\n' "$job_name" "$*" + } + + if [ ! -d "$dir" ]; then + log "skip: directory does not exist: $dir" + exit 0 + fi + + log "start" + + cmd=( + fd + "." "$dir" + "--hidden" + "--no-ignore" + ${optionalString (!job.recursive) ''"--max-depth" "1"''} + ${optionalString job.filesOnly ''"--type" "file"''} + "--changed-before" "${toString job.olderThan}d" + "--absolute-path" + ) + + count="$("''${cmd[@]}" --print0 | tr -dc '\0' | wc -c)" + log "matched=$count" + + if [ "$count" -eq 0 ]; then + log "nothing to do" + exit 0 + fi + + if [ "$dry_run" = "true" ]; then + log "dry-run: matched entries:" + "''${cmd[@]}" | sed 's/^/ /' + log "done (dry-run)" + else + log "deleting matched entries..." + # 批量安全删除 + "''${cmd[@]}" --print0 --exec-batch rm -rf -- + log "done" + fi + ''; + }; +in { + options.my.cleanup.jobs = mkOption { + type = types.attrsOf jobType; + default = {}; + description = "Cleanup jobs."; + }; + + config = mkIf (cfg.jobs != {}) { + systemd.user.services = + mapAttrs' ( + jobName: job: + nameValuePair "cleanup-${jobName}" { + Unit = { + Description = "Cleanup job ${jobName}"; + }; + + Service = { + Type = "oneshot"; + ExecStart = getExe (mkCleanupScript jobName job); + }; + } + ) + cfg.jobs; + + systemd.user.timers = + mapAttrs' ( + jobName: job: + nameValuePair "cleanup-${jobName}" { + Unit = { + Description = "Timer for cleanup job ${jobName}"; + }; + + Timer = { + OnCalendar = job.onCalendar; + Persistent = true; + }; + + Install = { + WantedBy = ["timers.target"]; + }; + } + ) + cfg.jobs; + }; +} diff --git a/nixcfgs/users/js0ny/programs/newsflash.nix b/nixcfgs/users/js0ny/programs/newsflash.nix new file mode 100644 index 0000000..02bc7fd --- /dev/null +++ b/nixcfgs/users/js0ny/programs/newsflash.nix @@ -0,0 +1,38 @@ +# TODO: Remove pkgs.newsflash in gui.nix once done. +{ + pkgs, + lib, + config, + ... +}: let + mergetools = import ../../../../modules/lib/mergetools.nix {inherit pkgs lib config;}; + mkMergedJson = mergetools.mkMergedJson; + newsflashConfig = mkMergedJson { + name = "newsflash_gtk-config"; + target = "${config.home.homeDirectory}/.config/news-flash/newsflash_gtk.json"; + settings = { + "general" = { + }; + theme = "system"; + window_has_frame = false; + release_channel = "latest"; + global_media_hotkeys = true; + window_window_bar_style = "windows"; + disable_auto_updates = true; + lyrics = [ + "NetEase" + "lrclib.net" + ]; + # For window manager (hide on close) + window_exit_to_tray = true; + window_prevent_sleep_on_playback = true; + }; + }; +in { + home.packages = [ + pkgs.newsflash + ]; + imports = [ + newsflashConfig + ]; +} diff --git a/nixcfgs/users/js0ny/zephyrus.nix b/nixcfgs/users/js0ny/zephyrus.nix index c4addb2..20e5e3a 100644 --- a/nixcfgs/users/js0ny/zephyrus.nix +++ b/nixcfgs/users/js0ny/zephyrus.nix @@ -6,6 +6,7 @@ username = config.home.username; in { imports = [ + ./programs/cleaner.nix # General config ./default.nix