Skip to content

Instantly share code, notes, and snippets.

@rickardrosen
Created November 5, 2017 17:05
Show Gist options
  • Save rickardrosen/9444070d544668597a5b8d59e6dcb61f to your computer and use it in GitHub Desktop.
Save rickardrosen/9444070d544668597a5b8d59e6dcb61f to your computer and use it in GitHub Desktop.
Mac mini headless spotify
# Edit this configuration file to define what should be installed on
# your system. Help is available in the configuration.nix(5) man page
# and in the NixOS manual (accessible by running ‘nixos-help’).
{ config, pkgs, ... }:
{
nix.nixPath = [ "nixpkgs=/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs" "nixos-config=/etc/nixos/configuration.nix" "/nix/var/nix/profiles/per-user/root/channels" ];
imports =
[ # Include the results of the hardware scan.
./hardware-configuration.nix
];
# Use the systemd-boot EFI boot loader.
boot.loader.systemd-boot.enable = true;
boot.loader.efi.canTouchEfiVariables = true;
hardware.pulseaudio.enable = false;
boot.extraModprobeConfig = ''
options snd-usb-audio index=0
'';
sound.extraConfig = ''
pcm.!default {
type hw
card 0
}
ctl.!default {
type hw
card 0
}
'';
boot.extraModulePackages = [
config.boot.kernelPackages.broadcom_sta
];
boot.initrd.kernelModules = [
"wl"
];
boot.blacklistedKernelModules = [ "snd_hda_intel" "b43" ];
networking.hostName = "mini"; # Define your hostname.
networking.wireless.enable = true; # Enables wireless support via wpa_supplicant.
# Select internationalisation properties.
# i18n = {
# consoleFont = "Lat2-Terminus16";
# consoleKeyMap = "us";
# defaultLocale = "en_US.UTF-8";
# };
# Set your time zone.
time.timeZone = "Europe/Amsterdam";
nixpkgs.config = {
allowUnfree = true;
};
# List packages installed in system profile. To search by name, run:
# $ nix-env -qaP | grep wget
environment.systemPackages = with pkgs; [
wget
pciutils
usbutils
vim
spotify
xvfb_run
dialog
htop
lirc
];
# List services that you want to enable:
services.acpid.enable = true;
# Enable the OpenSSH daemon.
services.openssh.enable = true;
services.openssh.permitRootLogin = "yes";
services.openssh.forwardX11 = true;
# Open ports in the firewall.
# networking.firewall.allowedTCPPorts = [ ... ];
# networking.firewall.allowedUDPPorts = [ ... ];
# Or disable the firewall altogether.
networking.firewall.enable = false;
# Enable CUPS to print documents.
# services.printing.enable = true;
# Enable the X11 windowing system.
# services.xserver.enable = true;
# services.xserver.layout = "us";
# services.xserver.xkbOptions = "eurosign:e";
# Enable the KDE Desktop Environment.
# services.xserver.displayManager.sddm.enable = true;
# services.xserver.desktopManager.plasma5.enable = true;
# Define a user account. Don't forget to set a password with ‘passwd’.
# users.extraUsers.guest = {
# isNormalUser = true;
# uid = 1000;
# };
users.extraUsers.spotify =
{ isNormalUser = true;
home = "/home/spotify";
description = "Snotify user";
extraGroups = [ "audio" ];
};
# The NixOS release to be compatible with for stateful data such as databases.
system.stateVersion = "17.09";
systemd.services.spotify = {
description = "Spotify headless service";
after = [ "network-online.target" ];
serviceConfig = {
User = "spotify";
#Type = "forking";
WorkingDirectory="/home/spotify";
ExecStart = "/run/current-system/sw/bin/dbus-run-session --dbus-daemon=/run/current-system/sw/bin/dbus-daemon ${pkgs.xvfb_run}/bin/xvfb-run ${pkgs.spotify}/bin/spotify -disable-gpu";
Restart = "on-failure";
};
wantedBy = [ "multi-user.target" ];
};
systemd.services.spotify.enable = true;
services.plex.enable = true;
systemd.services.plex.enable = true;
services.unifi.enable = false;
services.deluge.enable = false;
services.avahi = {
enable = true;
publish.enable = true;
};
powerManagement.enable = true;
services.cron = {
enable = true;
systemCronJobs = [
#"* * * * * root /root/sound.sh"
];
};
environment.etc."lirc_options" = {
text = ''
[lircd]
nodaemon = False
driver = macmini
device = /dev/usb/hiddev0
output = /dev/lirc0
pidfile = /var/run/lircd.pid
plugindir = ${pkgs.lirc}/lib/lirc/plugins
permission = 666
allow-simulate = No
repeat-max = 600
[lircmd]
uinput = False
nodaemon = False
'';
target = "lirc/lirc_options.conf";
};
environment.etc."lircd.conf" = {
text = ''
begin remote
name apple
driver macmini
bits 8
eps 30
aeps 100
one 0 0
zero 0 0
pre_data_bits 24
pre_data 0x87EE9B
gap 111981
toggle_bit_mask 0x59
begin codes
up 0x0A
down 0x0C
left 0x09
right 0x06
enter 0x5C
menu 0x03
play 0x5F
end codes
end remote
'';
target = "lirc/lircd.conf";
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment