configuration.nix.j2 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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 = [ 8080 ];
  21. networking.firewall.allowedUDPPorts = [ 8080 ];
  22. # Kodi
  23. services.xserver.enable = true;
  24. services.xserver.desktopManager.kodi.enable = true;
  25. services.xserver.desktopManager.kodi.package = pkgs.kodi.withPackages (p: with p; [ kodi pvr-hts ]);
  26. services.xserver.displayManager.autoLogin.enable = true;
  27. services.xserver.displayManager.autoLogin.user = "kodi";
  28. services.xserver.displayManager.job.preStart = "/run/current-system/sw/bin/systemctl start network-online.target";
  29. users.users.kodi.isNormalUser = true;
  30. # Inhibit Screen/Power Off
  31. services.logind.extraConfig = "HandlePowerKey=ignore";
  32. services.xserver.displayManager.sessionCommands = ''
  33. xset dpms 0 0 0
  34. xset s off -dpms
  35. '';
  36. # Hardware
  37. sound.enable = true;
  38. hardware.pulseaudio.enable = true;
  39. boot.kernelPackages = pkgs.linuxPackages_latest; # Nix defaults to LTS kernel
  40. # Packages
  41. environment.systemPackages = with pkgs; [
  42. python3
  43. vim
  44. nano
  45. htop
  46. glances
  47. nethogs
  48. tmux
  49. inxi
  50. ];
  51. # SSH
  52. services.openssh.enable = true;
  53. users.users.root.openssh.authorizedKeys.keys = [
  54. {% for pubkey in ssh_root_keys %}
  55. "{{ pubkey }}"
  56. {% endfor %}
  57. ];
  58. # NixOS Auto Upgrades and Cleanup
  59. nix.gc.automatic = true;
  60. nix.gc.dates = "monthly";
  61. system.autoUpgrade.enable = true;
  62. system.autoUpgrade.allowReboot = true;
  63. system.autoUpgrade.dates = "weekly";
  64. # This value determines the NixOS release from which the default
  65. # settings for stateful data, like file locations and database versions
  66. # on your system were taken. It‘s perfectly fine and recommended to leave
  67. # this value at the release version of the first install of this system.
  68. # Before changing this value read the documentation for this option
  69. # (e.g. man configuration.nix or on https://nixos.org/nixos/options.html).
  70. system.stateVersion = "21.11"; # Did you read the comment?
  71. }