summaryrefslogtreecommitdiff
path: root/hosts/local/master/configuration.nix
blob: cad65c8ef770b5d098726005c90babc289eab9cb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
# 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’).
{
  pkgs,
  inputs,
  ...
}: let
in {
  imports = [
    # Include the results of the hardware scan.
    ../../base.nix
    ../../linux.nix
    ../../unfree.nix
    #../../android.nix
    ../gui.nix
    ../i3.nix
    # ../gnome.nix
    # ../wayland.nix
    ../nvidia.nix
    ./keyboard.nix
    # ./rgb.nix
  ];

  # Use the systemd-boot EFI boot loader.
  boot.loader.systemd-boot.enable = true;
  boot.loader.efi.canTouchEfiVariables = true;
  # boot.kernelPackages = pkgs.linuxPackages_latest;
  boot.kernelPackages = pkgs.linuxPackages_zen;
  boot.kernelParams = ["intel_pstate=active"];
  # boot.supportedFilesystems = ["ntfs"];
  services.fprintd.enable = true;
  nix.settings.trusted-users = ["root" "y"];

  networking = {
    hostName = "master"; # Define your hostname.
  };
  environment.etc."X11/xorg.conf.d/20-nvidia.conf".source = ./xorg.conf;
  services.xserver.displayManager.xserverArgs = ["-config ${./xorg.conf}"];

  # Set your time zone.
  time.timeZone = "Asia/Bangkok";

  # Enable the OpenSSH daemon.
  services.openssh = {
    enable = true;
    ports = [5555];
    settings.PasswordAuthentication = false;
  };
  services.tailscale = {
    enable = true;
  };
  #services.meilisearch = {
  #  enable = true;
  #};

  zramSwap = {
    enable = true;
    memoryPercent = 100;
    algorithm = "zstd";
    # memoryPercent = 30;
  };

  # This value determines the NixOS release from which the default
  # settings for stateful data, like file locations and database versions
  # on your system were taken. It‘s perfectly fine and recommended to leave
  # this value at the release version of the first install of this system.
  # Before changing this value read the documentation for this option
  # (e.g. man configuration.nix or on https://nixos.org/nixos/options.html).
  #
  #
  system.stateVersion = "23.11"; # Did you read the comment?

  #debugging segfaults
  # powerManagement.cpufreq.max = 4000000;
  # powerManagement.cpufreq.min = 800000;

  # Define the systemd service
  # systemd.services.my-custom-script = {
  #   description = "Run my custom script on startup";
  #   wantedBy = ["multi-user.target"];
  #   after = ["network.target"]; # or any other service you need to wait for
  #   serviceConfig = {
  #     ExecStart = "${pkgs.bash}/bin/bash /etc/startup.sh";
  #     Type = "oneshot";
  #     RemainAfterExit = true;
  #   };
  # };

  # Ensure the script is copied to the system
  # environment.etc."startup.sh".source = ./startup.sh;
  # temp!
  # run vllm through docker (its broken in nixpkgs, but this may be better anyway?)
  # virtualisation.oci-containers = {
  #   backend = "podman";
  #   containers = {
  #     vllm = {
  #       autoStart = false;
  #       image = "vllm/vllm-openai:latest";
  #       ports = ["5000:5000"];
  #       extraOptions = [
  #         "--runtime"
  #         "nvidia"
  #         "--gpus"
  #         "all"
  #         "--ipc"
  #         "host"
  #         "--pull=always"
  #         "--network=host"
  #       ];
  #       cmd = [
  #         "--model"
  #         "mistralai/Mistral-7B-v0.1"
  #       ];
  #     };
  #   };
  # };
  # stop fucking crashing

  systemd.services.nix-daemon.serviceConfig = {
    MemoryHigh = "22G"; # throttle above this
    MemoryMax = "28G"; # hard kill above this
    # optional niceties:
    CPUWeight = 50;
    IOWeight = 50;
    TasksMax = 4096;
    # Let systemd-oomd preferentially kill these if needed:
    ManagedOOMMemoryPressure = "kill";
    ManagedOOMMemoryPressureLimit = "50%";
  };
  systemd.oomd.enable = true;
}