From cf260ac8b8ee7f1ad3425f024f2c6e739c19c9d8 Mon Sep 17 00:00:00 2001 From: jxnshi Date: Sat, 25 Jan 2025 15:49:26 +0100 Subject: [PATCH] Add auto upgrade and auto cleanup --- configuration.nix | 39 ++++++++++++++++++++++----------- flake.nix | 8 ++----- home.nix | 55 ++++++++++++++++++++++++++++++++++++++++++++++- 3 files changed, 83 insertions(+), 19 deletions(-) diff --git a/configuration.nix b/configuration.nix index 2af3c0a..5905af0 100644 --- a/configuration.nix +++ b/configuration.nix @@ -47,9 +47,10 @@ users.users.jxnshi.extraGroups = [ "networkmanager" "wheel" ]; # Environment variables. - environment.variables.BROWSER = "qutebrowser"; - environment.variables.EDITOR = "hx"; - environment.variables.TERM = "st"; + environment.variables.BROWSER = "qutebrowser"; + environment.variables.EDITOR = "hx"; + environment.variables.MUSIC_PLAYER = "st ncmpcpp"; + environment.variables.TERM = "st"; # Allow unfree packages. nixpkgs.config.allowUnfree = true; @@ -62,9 +63,32 @@ services.displayManager.autoLogin.enable = true; services.displayManager.autoLogin.user = "jxnshi"; + # Auto update. + system.autoUpgrade.enable = true; + system.autoUpgrade.dates = "weekly"; + + # Auto cleanup. + nix.gc.automatic = true; + nix.gc.dates = "daily"; + nix.gc.options = "--delete-older-than 10d"; + nix.settings.auto-optimise-store = true; + # Upower. services.upower.enable = true; + # Fish. + programs.bash.interactiveShellInit = '' + if [[ $(${pkgs.procps}/bin/ps --no-header --pid=$PPID --format=comm) != "fish" && -z ''${BASH_EXECUTION_STRING} ]] then + shopt -q login_shell && LOGIN_OPTION='--login' || LOGIN_OPTION="" + exec ${pkgs.fish}/bin/fish $LOGIN_OPTION + fi + ''; + + # MPD. + services.mpd.user = "jxnshi"; + + systemd.services.mpd.environment.XDG_RUNTIME_DIR = "/run/user/${toString config.users.users.jxnshi.uid}"; + # SSH. programs.ssh.startAgent = true; @@ -75,14 +99,5 @@ nix.settings.experimental-features = "nix-command flakes"; # System. - system.autoUpgrade.enable = true; system.stateVersion = "24.11"; - - # Fish. - programs.bash.interactiveShellInit = '' - if [[ $(${pkgs.procps}/bin/ps --no-header --pid=$PPID --format=comm) != "fish" && -z ''${BASH_EXECUTION_STRING} ]] then - shopt -q login_shell && LOGIN_OPTION='--login' || LOGIN_OPTION="" - exec ${pkgs.fish}/bin/fish $LOGIN_OPTION - fi - ''; } diff --git a/flake.nix b/flake.nix index 022f9a2..c215442 100644 --- a/flake.nix +++ b/flake.nix @@ -8,13 +8,9 @@ home-manager.inputs.nixpkgs.follows = "nixpkgs"; }; - outputs = { self, nixpkgs, ... }@inputs: - let - system = "x86_64-linux"; - in - { + outputs = { self, nixpkgs, ... }@inputs: { nixosConfigurations.t420 = nixpkgs.lib.nixosSystem { - specialArgs = { inherit inputs system; }; + specialArgs = { inherit inputs "x86_64-linux"; }; modules = [ ./configuration.nix ]; }; }; diff --git a/home.nix b/home.nix index bda811f..2acb65d 100644 --- a/home.nix +++ b/home.nix @@ -13,6 +13,7 @@ helix # Text editor. krita # Drawing software. monero-gui # Monero wallet. + ncmpcpp # Music player. qutebrowser # Web browser. st # Terminal emulator. @@ -23,8 +24,10 @@ git home-manager htop + mpd pfetch-rs picom + slstatus timg tree upower @@ -39,7 +42,7 @@ dwm = prev.dwm.overrideAttrs (old: { src = pkgs.fetchgit { url = "git://jxnshi.xyz/dwm-config.git"; - hash = "sha256-2oOAUaaB0g68E9+ITfJeOxzzf33yQn2TeOxmSakH/qQ="; + hash = "sha256-BJ77olfRDYvlq1GrJcDXPd7ZNiQlxZ/rxzGn3ftH42k="; }; }); st = prev.st.overrideAttrs (old: { @@ -85,6 +88,56 @@ programs.git.userEmail = "jxnshi@proton.me"; programs.git.userName = "jxnshi"; + # MPD. + services.mpd.enable = true; + + services.mpd.dbFile = "~/.config/mpd/datebase"; + + services.mpd.musicDirectory = ./music; + services.mpd.playlistDirectory = ./.config/mpd/playlists; + + services.mpd.extraConfig = '' + log_file "~/.config/mpd/log" + + auto_update "yes" + bind_to_address "127.0.0.1" + port "6600" + restore_paused "yes" + max_output_buffer_size "16384" + + audio_output { + type "pipewire" + name "Pipewire Sound Server" + } + + audio_output { + type "fifo" + name "Visualizer feed" + path "/tmp/mpd.fifo" + format "44100:16:2" + } + ''; + + # Ncmpcpp. + programs.ncmpcpp.enable = true; + + ## Files. + programs.ncmpcpp.mpdMusicDir = ./music; + + programs.ncmpcpp.settings.lyrics_directory = "~/.ncmpcpp/lyrics"; + programs.ncmpcpp.settings.ncmpcpp_directory = "~/.ncmpcpp"; + programs.ncmpcpp.settings.mpd_host = "localhost"; + programs.ncmpcpp.settings.mpd_port = "6600"; + programs.ncmpcpp.settings.mpd_connection_timeout = "5"; + programs.ncmpcpp.settings.mpd_crossfade_time = "5"; + + ## Playlist. + programs.ncmpcpp.settings.playlist_disable_highlight_delay = "0"; + programs.ncmpcpp.settings.playlist_display_mode = "columns"; + programs.ncmpcpp.settings.playlist_show_remaining_time = "yes"; + programs.ncmpcpp.settings.browser_display_mode = "columns"; + programs.ncmpcpp.settings.allow_for_physical_item_deletion = "yes"; + # Picom. services.picom.enable = true; -- 2.49.0