configurations of hq services
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

configuration.nix 8.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271
  1. # Edit this configuration file to define what should be installed on
  2. # your system. Help is available in the configuration.nix(5) man page
  3. # and in the NixOS manual (accessible by running ‘nixos-help’).
  4. { config, pkgs, ... }:
  5. let
  6. ympdPort = 8080;
  7. mpdVhost = "mpd.hq.c3d2.de";
  8. in {
  9. imports =
  10. [ # Include the results of the hardware scan.
  11. ./hardware-configuration.nix
  12. ../../lib/admins.nix
  13. ];
  14. # Use the systemd-boot EFI boot loader.
  15. boot.loader.systemd-boot.enable = true;
  16. boot.loader.efi.canTouchEfiVariables = true;
  17. networking.hostName = "pulsebert"; # Define your hostname.
  18. # networking.wireless.enable = true; # Enables wireless support via wpa_supplicant.
  19. # Configure network proxy if necessary
  20. # networking.proxy.default = "http://user:password@proxy:port/";
  21. # networking.proxy.noProxy = "127.0.0.1,localhost,internal.domain";
  22. # Select internationalisation properties.
  23. i18n = {
  24. consoleFont = "${pkgs.terminus_font}/share/consolefonts/ter-u28n.psf.gz";
  25. consoleKeyMap = "us";
  26. defaultLocale = "en_US.UTF-8";
  27. };
  28. # Set your time zone.
  29. time.timeZone = "Europe/Berlin";
  30. # List packages installed in system profile. To search, run:
  31. # $ nix search wget
  32. environment.systemPackages = with pkgs; [
  33. # specific printer drivers for our printers
  34. epson-escpr
  35. splix
  36. # utilities
  37. nix-index
  38. usbutils
  39. tmux
  40. vim
  41. git
  42. openssl
  43. # NCurses Music Player Client (Plus Plus)
  44. # a commandline front-end client for mpd
  45. # 2019-01-21 mag vater gern gleich einen schoenen lokalen Verwaltung fuer MPD haben.
  46. # ncmpcpp
  47. home-manager
  48. mumble
  49. ];
  50. # Some programs need SUID wrappers, can be configured further or are
  51. # started in user sessions.
  52. # programs.mtr.enable = true;
  53. # programs.gnupg.agent = { enable = true; enableSSHSupport = true; };
  54. # List services that you want to enable:
  55. # Enable the OpenSSH daemon.
  56. services.openssh.enable = true;
  57. # X11 Forwarding for mumble...
  58. programs.ssh.forwardX11 = true;
  59. services.openssh.forwardX11 = true;
  60. # Open ports in the firewall.
  61. networking.firewall.allowedTCPPorts = [
  62. 4713 # PulseAudio
  63. 631 # cups
  64. 80 443 # Web/ympd
  65. 6600 # mpd
  66. ];
  67. networking.firewall.allowedUDPPorts = [
  68. 631
  69. ];
  70. networking.firewall.extraCommands = ''
  71. iptables -I INPUT -p udp --dport mdns -d 224.0.0.251 -j ACCEPT # zeroconf
  72. iptables -I OUTPUT -p udp --dport mdns -d 224.0.0.251 -j ACCEPT # zeroconf
  73. ''; # networking.firewall.allowedUDPPorts = [ ... ];
  74. # Or disable the firewall altogether.
  75. # networking.firewall.enable = false;
  76. # Enable CUPS to print documents.
  77. services.printing = {
  78. enable = true;
  79. browsing = true;
  80. listenAddresses = [ "*:631" ];
  81. defaultShared = true;
  82. # logLevel = "debug";
  83. drivers = [ pkgs.gutenprint pkgs.hplip pkgs.splix ];
  84. extraConf =
  85. ''
  86. DefaultAuthType Basic
  87. <Location />
  88. Order allow,deny
  89. Allow ALL
  90. </Location>
  91. <Location /admin>
  92. Order allow,deny
  93. Allow ALL
  94. </Location>
  95. <Location /admin/conf>
  96. AuthType Basic
  97. Require user @SYSTEM
  98. Order allow,deny
  99. Allow ALL
  100. </Location>
  101. <Policy default>
  102. <Limit Send-Document Send-URI Hold-Job Release-Job Restart-Job Purge-Jobs Set-Job-Attributes Create-Job-Subscription Renew-Subscription Cancel-Subscription Get-Notifications Reprocess-Job Cancel-Current-Job Suspend-Current-Job Resume-Job CUPS-Move-Job>
  103. Require user @OWNER @SYSTEM
  104. Order deny,allow
  105. </Limit>
  106. <Limit Pause-Printer Resume-Printer Set-Printer-Attributes Enable-Printer Disable-Printer Pause-Printer-After-Current-Job Hold-New-Jobs Release-Held-New-Jobs Deactivate-Printer Activate-Printer Restart-Printer Shutdown-Printer Startup-Printer Promote-Job Schedule-Job-After CUPS-Add-Printer CUPS-Delete-Printer CUPS-Add-Class CUPS-Delete-Class CUPS-Accept-Jobs CUPS-Reject-Jobs CUPS-Set-Default>
  107. AuthType Basic
  108. Require user @SYSTEM
  109. Order deny,allow
  110. </Limit>
  111. <Limit Cancel-Job CUPS-Authenticate-Job>
  112. Require user @OWNER @SYSTEM
  113. Order deny,allow
  114. </Limit>
  115. <Limit All>
  116. Order deny,allow
  117. </Limit>
  118. </Policy>
  119. '';
  120. };
  121. # Enable sound.
  122. sound.enable = true;
  123. hardware.pulseaudio.enable = true;
  124. # PulseAudio as-a-Service
  125. hardware.pulseaudio.systemWide = true;
  126. hardware.pulseaudio.tcp.anonymousClients.allowedIpRanges = [
  127. "127.0.0.0/8" "::1/128"
  128. "172.22.99.0/24" "2a02:8106:208:5201:58::/64"
  129. ];
  130. hardware.pulseaudio.tcp.enable = true;
  131. hardware.pulseaudio.zeroconf.publish.enable = true;
  132. # tell Avahi to publish CUPS and PulseAudio
  133. services.avahi = {
  134. enable = true;
  135. publish.enable = true;
  136. publish.userServices = true;
  137. };
  138. # Enable the X11 windowing system.
  139. # services.xserver.enable = true;
  140. # services.xserver.layout = "us";
  141. # services.xserver.xkbOptions = "eurosign:e";
  142. # Enable touchpad support.
  143. # services.xserver.libinput.enable = true;
  144. # Enable the KDE Desktop Environment.
  145. # services.xserver.displayManager.sddm.enable = true;
  146. # services.xserver.desktopManager.plasma5.enable = true;
  147. security.sudo = {
  148. enable = true;
  149. wheelNeedsPassword = false;
  150. };
  151. # Define a user account. Don't forget to set a password with ‘passwd’.
  152. users.users."k-ot" = {
  153. extraGroups = ["audio" "wheel"]; # allow k-ot to use PulseAudio
  154. isNormalUser = true;
  155. uid = 1000;
  156. };
  157. # This value determines the NixOS release with which your system is to be
  158. # compatible, in order to avoid breaking some software such as database
  159. # servers. You should change this only after NixOS release notes say you
  160. # should.
  161. system.stateVersion = "18.09"; # Did you read the comment?
  162. # vater hoerte, dass menschen im space gern mpd fuer das abspielen von musik erwarten wuerden
  163. #### https://nixos.org/nixos/options.html#services.mpd.enable
  164. services.mpd = {
  165. enable=true;
  166. dbFile = null;
  167. network.listenAddress = "any";
  168. musicDirectory = "/mnt/storage/Music";
  169. #### musicDirectory = "nfs://storage.hq.c3d2.de:/mnt/zroot/storage/rpool/Music";
  170. extraConfig = ''
  171. #### music_directory "nfs://storage.hq.c3d2.de:/mnt/zroot/storage/rpool/Music"
  172. ####
  173. audio_output {
  174. type "pulse"
  175. name "/proc"
  176. }
  177. audio_output {
  178. type "pulse"
  179. name "SDK"
  180. server "dacbert.hq.c3d2.de"
  181. }
  182. #### mpd startet bei der option nicht mehr
  183. database {
  184. plugin "proxy"
  185. #### vater was here!
  186. #### jail (auf storage)
  187. #### externe erstellung der datenbank von mpd in der naehe der ablage der daten
  188. host "172.22.99.98"
  189. }
  190. #### ausschalten der automatischen aktualisierung der datenbank von mpd
  191. #### angeblich gibt es 2019-02-13 probleme, die zum absturz vom dienst mpd fuehren
  192. #### wenn das problem behoben ist, dann kann die option wieder entfernt werden
  193. auto_update "no"
  194. '';
  195. };
  196. # mpd likes to crash a lot while indexing, so...
  197. systemd.services.mpd.serviceConfig.Restart="on-failure";
  198. services.caddy = {
  199. enable = true;
  200. agree = true;
  201. # TODO: add auth?
  202. config = ''
  203. ${mpdVhost} {
  204. proxy / localhost:${toString ympdPort}
  205. }
  206. :80 {
  207. redir https://${mpdVhost}{uri}
  208. }
  209. '';
  210. };
  211. fileSystems."/mnt/storage" = {
  212. device = "storage.hq.c3d2.de:/mnt/zroot/storage/rpool";
  213. fsType = "nfs";
  214. };
  215. #### nur zum spielen mit dem bereitstellen von einer per nfs angebundenen datei als datenbank fuer mpd
  216. fileSystems."/mnt/service-data/mpd_index" = {
  217. device = "storage.hq.c3d2.de:/mnt/zroot/iocage/jails/mpd_index/root/var/mpd/.mpd";
  218. fsType = "nfs";
  219. };
  220. # MPD music playing daemon with webinterface
  221. services.ympd = {
  222. enable = true;
  223. webPort = toString ympdPort;
  224. };
  225. nixpkgs.config.packageOverrides = pkgs: with pkgs; {
  226. ympd = ympd.overrideAttrs (oldAttrs: {
  227. src = fetchFromGitHub {
  228. owner = "c3d2";
  229. repo = "ympd";
  230. rev = "feature/somafm_browser";
  231. sha256 = "17x3jfys6gxghz5yp0gvd39ylvzfm59qxg75hwc5a52rj1n2jpb1";
  232. };
  233. });
  234. };
  235. }