configuration.nix.j2 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  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. {
  6. imports =
  7. [ # Include the results of the hardware scan.
  8. ./hardware-configuration.nix
  9. ];
  10. # Boot
  11. boot.loader.timeout = 1;
  12. boot.loader.systemd-boot.enable = true;
  13. # Set hostname
  14. networking.hostName = "{% if 'bootstrap' not in group_names %}{{ inventory_hostname }}{% else %}nixos-kodi{% endif %}";
  15. # Set time zone.
  16. time.timeZone = "America/Los_Angeles";
  17. # Network settings
  18. networking.interfaces.{{ ansible_default_ipv4.interface }}.useDHCP = true;
  19. networking.enableIPv6 = false;
  20. networking.firewall.allowedTCPPorts = [
  21. 8080 # kodi webUI
  22. 5377 # wsdd
  23. ];
  24. networking.firewall.allowedUDPPorts = [
  25. 8080 # kodi webUI
  26. 5377 # wsdd
  27. ];
  28. # Kodi
  29. services.xserver.enable = true;
  30. services.xserver.desktopManager.kodi.enable = true;
  31. services.xserver.desktopManager.kodi.package = pkgs.kodi.withPackages (p: with p; [ kodi pvr-hts ]);
  32. services.xserver.displayManager.autoLogin.enable = true;
  33. services.xserver.displayManager.autoLogin.user = "kodi";
  34. services.xserver.displayManager.job.preStart = "/run/current-system/sw/bin/systemctl start network-online.target";
  35. users.users.kodi.isNormalUser = true;
  36. # Inhibit Screen/Power Off
  37. services.logind.extraConfig = "HandlePowerKey=ignore";
  38. services.xserver.displayManager.sessionCommands = ''
  39. xset dpms 0 0 0
  40. xset s off -dpms
  41. '';
  42. # Hardware
  43. sound.enable = true;
  44. hardware.pulseaudio.enable = true;
  45. boot.kernelPackages = pkgs.linuxPackages_latest; # Nix defaults to LTS kernel
  46. # Packages
  47. environment.systemPackages = with pkgs; [
  48. python3
  49. vim
  50. nano
  51. htop
  52. glances
  53. nethogs
  54. tmux
  55. inxi
  56. ];
  57. # SSH
  58. services.openssh.enable = true;
  59. users.users.root.openssh.authorizedKeys.keys = [
  60. {% for pubkey in ssh_root_keys %}
  61. "{{ pubkey }}"
  62. {% endfor %}
  63. ];
  64. # NixOS Auto Upgrades and Cleanup
  65. nix.gc.automatic = true;
  66. nix.gc.dates = "monthly";
  67. system.autoUpgrade.enable = true;
  68. system.autoUpgrade.allowReboot = true;
  69. system.autoUpgrade.dates = "weekly";
  70. services.samba-wsdd.enable = true; # makes shares visible for windows 10 clients
  71. services.samba = {
  72. enable = true;
  73. openFirewall = true;
  74. securityType = "user";
  75. extraConfig = ''
  76. workgroup = WORKGROUP
  77. server string = smb{{ inventory_hostname }}
  78. netbios name = smb{{ inventory_hostname }}
  79. security = user
  80. guest account = kodi
  81. map to guest = bad user
  82. '';
  83. shares = {
  84. kodi = {
  85. path = "/home/kodi";
  86. browseable = "yes";
  87. "read only" = "no";
  88. "guest ok" = "yes";
  89. "force user" = "kodi";
  90. "force group" = "users";
  91. "create mask" = "0644";
  92. "directory mask" = "0755";
  93. };
  94. };
  95. };
  96. # This value determines the NixOS release from which the default
  97. # settings for stateful data, like file locations and database versions
  98. # on your system were taken. It‘s perfectly fine and recommended to leave
  99. # this value at the release version of the first install of this system.
  100. # Before changing this value read the documentation for this option
  101. # (e.g. man configuration.nix or on https://nixos.org/nixos/options.html).
  102. system.stateVersion = "21.11"; # Did you read the comment?
  103. }