How to Install MPD on NixOS Latest

MPD (Music Player Daemon) is a free, open-source, and flexible music player server that runs on various platforms, including NixOS. In this tutorial, we will guide you through the process of installing MPD on NixOS Latest.

Prerequisites

Installing MPD on NixOS Latest

  1. Open a terminal emulator on your NixOS system.

  2. Update the package lists:

    sudo nix-channel --update
    
  3. Install MPD and its dependencies:

    sudo nix-env -iA nixos.mpd
    
  4. Verify that MPD has been installed successfully:

    mpd --version
    

    If the command returns the version number of MPD, the installation was successful.

  5. Configure MPD

    MPD's configuration file is located at /etc/mpd.conf. Before starting MPD, you need to configure it according to your preferences. You can use any editor to modify the /etc/mpd.conf file.

    Here is an example configuration that you can use as a starting point:

    # This is the MPD configuration file
    # See https://www.musicpd.org/doc/user/config_file.html for documentation
    # General music daemon options
    # See https://www.musicpd.org/doc/user/daemon.html for documentation
    
    music_directory "/home/username/Music"
    playlist_directory "/home/username/.mpd/playlists"
    db_file "/var/lib/mpd/tag_cache"
    log_file "/var/log/mpd/mpd.log"
    pid_file "/run/mpd/pid"
    state_file "/var/lib/mpd/state"
    
    audio_output {
        type       "alsa"
        name       "My ALSA Device"
    }
    

    Once you have made your changes to /etc/mpd.conf, save the file and exit the editor.

  6. Start MPD:

    sudo systemctl start mpd
    

    This will start the MPD service.

  7. Verify that MPD is running:

    systemctl status mpd
    

    If MPD is running, you should see output similar to the following:

    ● mpd.service - Music Player Daemon
       Loaded: loaded (/nix/store/.../mpd.service; enabled; vendor preset: enabled)
       Active: active (running) since Wed 2022-04-27 09:37:40 CEST; 29s ago
     Main PID: 18969 (mpd)
        Tasks: 4 (limit: 9839)
       Memory: 21.5M
       CGroup: /system.slice/mpd.service
               └─18969 /nix/store/.../bin/mpd --no-daemon
    
     Apr 27 09:37:40 nixos systemd[1]: Started Music Player Daemon.
    

Conclusion

You have successfully installed MPD on NixOS Latest and configured it to your needs. You can now start using MPD to listen to your music collection. Enjoy!

If you want to self-host in an easy, hands free way, need an external IP address, or simply want your data in your own hands, give IPv6.rs a try!

Alternatively, for the best virtual desktop, try Shells!