all repos — dotfiles @ a250b9d1612e40cf329939a9176db2f6775a3a62

my *nix dotfiles

nix/hosts/wyndle/configuration.nix (view raw)

  1let
  2  asusctl-tar = fetchTarball "https://github.com/NixOS/nixpkgs/archive/a4a81b6f6c27e5a964faea25b7b5cbe611f98691.tar.gz";
  3in
  4{ self, config, pkgs, theme, lib, ... }:
  5
  6{
  7  imports =
  8    [
  9      ./hardware-configuration.nix
 10      "${asusctl-tar}/nixos/modules/services/misc/asusctl.nix"
 11      "${asusctl-tar}/nixos/modules/services/misc/supergfxctl.nix"
 12    ];
 13
 14  boot = {
 15    loader.systemd-boot.enable = true;
 16    loader.efi.canTouchEfiVariables = true;
 17    kernel.sysctl."net.ipv4.ip_forward" = 1;
 18    kernelParams = [ "mem_sleep_default=deep" ];
 19    kernelPatches = [{
 20      name = "three-hundred-hertz";
 21      patch = null;
 22      extraConfig = ''
 23        HZ_300 y
 24        HZ 300
 25      '';
 26    }];
 27  };
 28
 29  networking = {
 30    nameservers = [ "1.1.1.1" "1.0.0.1" ];
 31    wireless = {
 32      enable = true;
 33      interfaces = [ "wlp6s0" ];
 34      environmentFile = "/home/icy/secrets/wireless.env";
 35      networks = {
 36        Sanic.psk = "@PSK_SANI@";
 37        Gopalan.psk = "@PSK_GOPA@";
 38        "GoSpaze 2" = {
 39          psk = "@PSK_GOSP@";
 40        };
 41      };
 42      extraConfig = ''
 43        ctrl_interface=/run/wpa_supplicant
 44        ctrl_interface_group=wheel
 45      '';
 46    };
 47    # dhcpcd.enable = true;
 48    hostName = "wyndle";
 49    useDHCP = false;
 50    interfaces.wlp6s0.useDHCP = true;
 51  };
 52
 53  i18n.defaultLocale = "en_US.UTF-8";
 54  time.timeZone = "Asia/Kolkata";
 55
 56  nixpkgs.config = {
 57    allowUnfree = true;
 58    allowUnfreePredicate = pkg: builtins.elem (lib.getName pkg) [
 59      "steam"
 60      "steam-original"
 61      "steam-runtime"
 62    ];
 63    st = {
 64      conf = builtins.readFile ../../programs/st/config.h;
 65      extraLibs = with pkgs; [ harfbuzz ];
 66      patches = [
 67        ../../patches/st/xres.diff
 68        ../../patches/st/bright.diff
 69        ../../patches/st/ligatures.diff
 70      ];
 71    };
 72  };
 73
 74  nixpkgs.overlays = with self.overlays; [
 75    (self: super: {
 76      asusctl = pkgs.callPackage "${asusctl-tar}/pkgs/tools/misc/asusctl/default.nix" { };
 77      supergfxctl = pkgs.callPackage "${asusctl-tar}/pkgs/tools/misc/supergfxctl/default.nix" { };
 78    })
 79    nvim-nightly
 80    prompt
 81  ];
 82
 83  environment = {
 84    systemPackages = with pkgs; [
 85      asusctl
 86      supergfxctl
 87      cwm
 88      man-pages
 89      git
 90      man-pages-posix
 91      (lib.hiPrio pkgs.bashInteractive_5)
 92    ];
 93    variables = {
 94      MOZ_USE_XINPUT2 = "1";
 95      GDK_SCALE = "2";
 96      GDK_DPI_SCALE = "0.5";
 97    };
 98    etc = {
 99      "wireplumber/bluetooth.lua.d/51-bluez-config.lua".text = ''
100        bluez_monitor.properties = {
101          ["bluez5.enable-sbc-xq"] = true,
102          ["bluez5.enable-msbc"] = true,
103          ["bluez5.enable-hw-volume"] = true,
104          ["bluez5.headset-roles"] = "[ hsp_hs hsp_ag hfp_hf hfp_ag ]"
105        }
106      '';
107    };
108  };
109
110  documentation = {
111    dev.enable = true;
112    man.generateCaches = true;
113  };
114
115  users.motd = with config; ''
116    Host       ${networking.hostName}
117    OS         NixOS ${system.nixos.release} (${system.nixos.codeName})
118    Version    ${system.nixos.version}
119    Kernel     ${boot.kernelPackages.kernel.version}
120  '';
121
122  console = {
123    font = "${pkgs.terminus_font}/share/consolefonts/ter-u28n.psf.gz";
124    keyMap = "us";
125  };
126
127  sound.enable = true;
128  hardware = {
129    bluetooth = {
130      enable = true;
131      powerOnBoot = true;
132      disabledPlugins = [ "sap" ];
133    };
134    nvidia.prime = {
135      offload.enable = true;
136      amdgpuBusId = "PCI:8:0:0";
137      nvidiaBusId = "PCI:1:0:0";
138    };
139  };
140
141  services = {
142    asusctl.enable = true;
143    supergfxctl.enable = true;
144    pipewire = {
145      enable = true;
146      alsa.enable = true;
147      alsa.support32Bit = true;
148      pulse.enable = true;
149    };
150    xserver = {
151      enable = true;
152      layout = "us";
153      displayManager.startx.enable = true;
154      libinput.enable = true;
155      dpi = 192;
156      videoDrivers = [ "nvidia" ];
157      screenSection = ''
158        Option         "metamodes" "nvidia-auto-select +0+0 {ForceFullCompositionPipeline=On}"
159        Option         "AllowIndirectGLXProtocol" "off"
160        Option         "TripleBuffer" "on"
161      '';
162    };
163    tailscale.enable = true;
164    tlp.enable = true;
165    # 1. chmod for rootless backligh1t
166    # 2. lotus58 bootloader mode for rootless qmk flashing
167    udev = {
168      extraRules = ''
169        ACTION=="add", SUBSYSTEM=="backlight", KERNEL=="amdgpu_bl1", MODE="0666", RUN+="${pkgs.coreutils}/bin/chmod a+w /sys/class/backlight/%k/brightness"
170        ACTION=="add", SUBSYSTEM=="usb", ATTRS{idVendor}=="2341", ATTRS{idProduct}=="0036", TAG+="uaccess", ENV{ID_MM_DEVICE_IGNORE}="1"
171      '';
172      extraHwdb = ''
173        evdev:input:b0003v0B05p19B6*
174          KEYBOARD_KEY_ff31007c=f20 # x11 mic-mute
175      '';
176      path = [
177        pkgs.coreutils
178      ];
179    };
180  };
181
182  virtualisation.docker = {
183    enable = true;
184    logDriver = "json-file";
185  };
186
187  security = {
188    doas.enable = true;
189    sudo.enable = true;
190    doas.extraConfig = ''
191      permit nopass :wheel
192    '';
193    doas.extraRules = [{
194      users = [ "icy" ];
195    }];
196    pki.certificateFiles = [ "/home/icy/.local/share/caddy/pki/authorities/local/root.crt" ];
197  };
198
199  powerManagement = {
200    enable = true;
201    powertop.enable = true;
202  };
203
204  users.users.icy = {
205    isNormalUser = true;
206    extraGroups = [ "wheel" "docker" "audio" "video" "dialout" ];
207  };
208
209  programs = {
210    steam.enable = true;
211  };
212
213  nix = {
214    package = pkgs.nixFlakes;
215    extraOptions = ''
216      experimental-features = nix-command flakes ca-derivations
217      warn-dirty = false
218      keep-outputs = false
219    '';
220    settings = {
221      trusted-users = [
222        "root"
223        "icy"
224      ];
225    };
226  };
227
228
229  # This value determines the NixOS release from which the default
230  # settings for stateful data, like file locations and database versions
231  # on your system were taken. It‘s perfectly fine and recommended to leave
232  # this value at the release version of the first install of this system.
233  # Before changing this value read the documentation for this option
234  # (e.g. man configuration.nix or on https://nixos.org/nixos/options.html).
235  system.stateVersion = "21.11"; # Did you read the comment?
236
237}
238