]> jxnshi.xyz Git - nix-config.git/commitdiff
Add auto upgrade and auto cleanup
authorjxnshi <jxnshi@proton.me>
Sat, 25 Jan 2025 14:49:26 +0000 (15:49 +0100)
committerjxnshi <jxnshi@proton.me>
Sat, 25 Jan 2025 14:49:26 +0000 (15:49 +0100)
configuration.nix
flake.nix
home.nix

index 2af3c0aff4e7eff3fc4cf639f3350ebe02581102..5905af059b0ba65d957d232ce19e704259a46fa8 100644 (file)
     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;
     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;
 
     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
-    '';
 }
index 022f9a25a51d3d0f3a70b5630183d2d59fce5c3a..c215442e98d6cf1f7013579585abfe5e58517e4a 100644 (file)
--- 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 ];
         };
     };
index bda811f6976cd1183191f85a3210318bb8dd4970..2acb65d91f6324137730dbb980d079fae820fa87 100644 (file)
--- 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.
 
         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: {
     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;