configurations of hq services
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

configuration.nix 5.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  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. octoprintPort = 8080;
  7. in
  8. {
  9. imports = [ # Include the results of the hardware scan.
  10. <this-host/hardware-configuration.nix>
  11. ];
  12. boot.loader.grub.enable = false;
  13. boot.loader.generic-extlinux-compatible.enable = false;
  14. boot.loader.raspberryPi = { enable = true; version = 4; uboot.enable = false; };
  15. #boot.kernelPackages = pkgs.linuxPackages_rpi4;
  16. boot.kernelPackages = pkgs.linuxPackages_latest;
  17. boot.tmpOnTmpfs = true;
  18. nix.buildCores = 4;
  19. nix.maxJobs = 4;
  20. networking.hostName = "pulsebert"; # Define your hostname.
  21. # networking.wireless.enable = true; # Enables wireless support via wpa_supplicant.
  22. # The global useDHCP flag is deprecated, therefore explicitly set to false here.
  23. # Per-interface useDHCP will be mandatory in the future, so this generated config
  24. # replicates the default behaviour.
  25. networking.useDHCP = false;
  26. networking.interfaces.eth0.useDHCP = true;
  27. networking.interfaces.wlan0.useDHCP = true;
  28. # Configure network proxy if necessary
  29. # networking.proxy.default = "http://user:password@proxy:port/";
  30. # networking.proxy.noProxy = "127.0.0.1,localhost,internal.domain";
  31. # Select internationalisation properties.
  32. # i18n.defaultLocale = "en_US.UTF-8";
  33. # console = {
  34. # font = "Lat2-Terminus16";
  35. # keyMap = "us";
  36. # };
  37. # Set your time zone.
  38. # time.timeZone = "Europe/Amsterdam";
  39. # List packages installed in system profile. To search, run:
  40. # $ nix search wget
  41. environment.systemPackages = with pkgs; [
  42. wget vim git
  43. raspberrypi-tools
  44. ];
  45. # Some programs need SUID wrappers, can be configured further or are
  46. # started in user sessions.
  47. # programs.mtr.enable = true;
  48. # programs.gnupg.agent = {
  49. # enable = true;
  50. # enableSSHSupport = true;
  51. # pinentryFlavor = "gnome3";
  52. # };
  53. # List services that you want to enable:
  54. # Do not log to flash:
  55. services.journald.extraConfig = ''
  56. Storage=volatile
  57. '';
  58. # Enable the OpenSSH daemon.
  59. services.openssh.enable = true;
  60. services.openssh.permitRootLogin = "yes";
  61. security.sudo = {
  62. enable = true;
  63. wheelNeedsPassword = false;
  64. };
  65. users.users.k-ot = {
  66. isNormalUser = true;
  67. extraGroups = [ "wheel" "audio" ];
  68. };
  69. # Open ports in the firewall.
  70. # networking.firewall.allowedTCPPorts = [ ... ];
  71. # networking.firewall.allowedUDPPorts = [ ... ];
  72. # Or disable the firewall altogether.
  73. networking.firewall.enable = false;
  74. # Enable CUPS to print documents.
  75. # services.printing.enable = true;
  76. # Enable sound.
  77. sound.enable = true;
  78. hardware.bluetooth = {
  79. enable = true;
  80. config = {
  81. Policy.AutoEnable = true;
  82. General = {
  83. Enable = "Source,Sink,Media,Socket";
  84. #DiscoverableTimeout = 0;
  85. #Discoverable = true;
  86. };
  87. };
  88. };
  89. hardware.pulseaudio = {
  90. enable = true;
  91. systemWide = true;
  92. tcp.enable = true;
  93. tcp.anonymousClients.allowedIpRanges = [
  94. "127.0.0.0/8" "::1/128"
  95. "172.22.99.0/24" "2a02:8106:208:5201:58::/64"
  96. ];
  97. zeroconf.publish.enable = true;
  98. package = pkgs.pulseaudioFull;
  99. extraModules = [ pkgs.pulseaudio-modules-bt ];
  100. };
  101. # tell Avahi to publish CUPS and PulseAudio
  102. services.avahi = {
  103. enable = true;
  104. publish.enable = true;
  105. publish.addresses = true;
  106. publish.userServices = true;
  107. };
  108. security.acme = {
  109. acceptTerms = true;
  110. email = "mail@c3d2.de";
  111. };
  112. services.nginx = {
  113. enable = true;
  114. #recommendedGzipSettings = true;
  115. recommendedProxySettings = true;
  116. virtualHosts = {
  117. "drkkr.hq.c3d2.de" = {
  118. default = true;
  119. enableACME = true;
  120. forceSSL = true;
  121. locations."/" = {
  122. proxyPass = "http://127.0.0.1:${toString octoprintPort}";
  123. proxyWebsockets = true;
  124. extraConfig = ''
  125. proxy_set_header X-Scheme $scheme;
  126. proxy_set_header Accept-Encoding identity;
  127. client_max_body_size 200M;
  128. '';
  129. };
  130. };
  131. };
  132. };
  133. services.octoprint = rec {
  134. enable = true;
  135. port = octoprintPort;
  136. # extraConfig.webcam = {
  137. # snapshot = "http://localhost:5050?action=snapshot";
  138. # stream = "http://octoprint.local:5050?action=stream";
  139. # };
  140. # plugins = let
  141. # python = pkgs.octoprint.python;
  142. # octoprint-filament-sensor-universal = python.pkgs.buildPythonPackage rec {
  143. # pname = "OctoPrint-Filament-Sensor-Universal";
  144. # version = "1.0.0";
  145. # src = pkgs.fetchFromGitHub {
  146. # owner = "lopsided98";
  147. # repo = pname;
  148. # rev = "8a72696867a9a008c5a79b49a9b029a4fc426720";
  149. # sha256 = "1a7lzmjbwx47qhrkjp3hggiwnx172x4axcz0labm9by17zxlsimr";
  150. # };
  151. # propagatedBuildInputs = [ pkgs.octoprint python.pkgs.libgpiod ];
  152. # };
  153. # #in p: [ octoprint-filament-sensor-universal ];
  154. # in p: [];
  155. };
  156. # Allow access to printer serial port and GPIO
  157. users.users.${config.services.octoprint.user}.extraGroups = [ "dialout" "gpio" ];
  158. # services.mjpg-streamer = {
  159. # enable = true;
  160. # inputPlugin = "input_uvc.so -r 1280x720";
  161. # };
  162. # Allow gpio group to access GPIO devices
  163. users.groups.gpio = { };
  164. services.udev.extraRules = ''
  165. KERNEL=="gpiochip*", GROUP="gpio", MODE="0660"
  166. '';
  167. # This value determines the NixOS release from which the default
  168. # settings for stateful data, like file locations and database versions
  169. # on your system were taken. It‘s perfectly fine and recommended to leave
  170. # this value at the release version of the first install of this system.
  171. # Before changing this value read the documentation for this option
  172. # (e.g. man configuration.nix or on https://nixos.org/nixos/options.html).
  173. system.stateVersion = "20.09"; # Did you read the comment?
  174. }