Skip to content

Commit

Permalink
nixos machine config
Browse files Browse the repository at this point in the history
  • Loading branch information
TheKnarf committed Jul 10, 2024
1 parent 6d3bcea commit 34a641e
Show file tree
Hide file tree
Showing 5 changed files with 237 additions and 2 deletions.
27 changes: 25 additions & 2 deletions os/nixos/Readme.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,27 @@
# NixOS using Home Manager
# NixOS setup

Check up to date guide here: https://nix-community.github.io/home-manager/
## Machine config

```bash
$ sudo cat /etc/nixos/configuration.nix
{ config, pkgs, ... }:

{
imports = [
/home/knarf/configs/os/nixos/machine/configuration.nix
];
}
```
This way I can version control my config by having an empty configurations.nix that just imports the one in the repo.
After making changes simply run:
```bash
sudo nixos-rebuild switch
```
## home-manager
[home-manager guide](https://nix-community.github.io/home-manager/)
59 changes: 59 additions & 0 deletions os/nixos/machine/audio-video.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
{ config, pkgs, ... }:

{
services.seatd.enable = true; # seatd is needed to run hyprland
programs.hyprland.enable = true;

# Enable OpenGL
hardware.opengl = {
enable = true;
driSupport = true;
driSupport32Bit = true;
};

# Load nvidia driver for Xorg and Wayland
services.xserver.videoDrivers = ["nvidia"];

hardware.nvidia = {
# Modesetting is required.
modesetting.enable = true;

# Nvidia power management. Experimental, and can cause sleep/suspend to fail.
# Enable this if you have graphical corruption issues or application crashes after waking
# up from sleep. This fixes it by saving the entire VRAM memory to /tmp/ instead
# of just the bare essentials.
powerManagement.enable = false;

# Fine-grained power management. Turns off GPU when not in use.
# Experimental and only works on modern Nvidia GPUs (Turing or newer).
powerManagement.finegrained = false;

# Use the NVidia open source kernel module (not to be confused with the
# independent third-party "nouveau" open source driver).
# Support is limited to the Turing and later architectures. Full list of
# supported GPUs is at:
# https://github.com/NVIDIA/open-gpu-kernel-modules#compatible-gpus
# Only available from driver 515.43.04+
# Currently alpha-quality/buggy, so false is currently the recommended setting.
open = false;

# Enable the Nvidia settings menu,
# accessible via `nvidia-settings`.
nvidiaSettings = true;

# Optionally, you may need to select the appropriate driver version for your specific GPU.
package = config.boot.kernelPackages.nvidiaPackages.stable;
};

# Sound
sound.enable = false;
hardware.pulseaudio.enable = false;
security.rtkit.enable = true;
services.pipewire = {
enable = true;
alsa.enable = true;
alsa.support32Bit = true;
pulse.enable = true;
#jack.enable = true;
};
}
91 changes: 91 additions & 0 deletions os/nixos/machine/configuration.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
{ config, pkgs, ... }:

{
imports = [
./hardware-configuration.nix
./steam.nix
./audio-video.nix
<home-manager/nixos>
];

# Bootloader
boot.loader.systemd-boot.enable = true;
boot.loader.efi.canTouchEfiVariables = true;

# Enable networking
networking.hostName = "nixos";
networking.interfaces.enp5s0.wakeOnLan.enable = true;
networking.networkmanager.enable = true;

# Time zone & locale
time.timeZone = "Europe/Oslo";
i18n.defaultLocale = "en_US.UTF-8";

# Configure keymap in X11
services.xserver.xkb = {
layout = "no";
variant = "";
};

# Configure console keymap
console.keyMap = "no";

# Define a user account. Don't forget to set a password with ‘passwd’.
users.users.knarf = {
isNormalUser = true;
description = "Knarf";
extraGroups = [
"networkmanager"
"wheel"
"docker"
"audio"
"seat" # seatd group
];
packages = with pkgs; [];
shell = pkgs.zsh;
};

# System packages (allow unfree packages)
nixpkgs.config.allowUnfree = true;
environment.systemPackages = with pkgs; [
vim
wget
git
tmux
bash
home-manager
zsh
kitty
pciutils
];

programs.zsh.enable = true;

# enable docker
virtualisation.docker.enable = true;

home-manager.users.knarf = { pkgs, ... }: {
# The state version is required and should stay at the version you
# originally installed.
home.stateVersion = "24.05";
};

# Some programs need SUID wrappers, can be configured further or are
# started in user sessions.
# programs.mtr.enable = true;
# programs.gnupg.agent = {
# enable = true;
# enableSSHSupport = true;
# };

# Enable the OpenSSH daemon.
services.openssh.enable = true;

# 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 = "24.05"; # Did you read the comment?
}
41 changes: 41 additions & 0 deletions os/nixos/machine/hardware-configuration.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Do not modify this file! It was generated by ‘nixos-generate-config’
# and may be overwritten by future invocations. Please make changes
# to /etc/nixos/configuration.nix instead.
{ config, lib, pkgs, modulesPath, ... }:

{
imports =
[ (modulesPath + "/installer/scan/not-detected.nix")
];

boot.initrd.availableKernelModules = [ "vmd" "xhci_pci" "ahci" "nvme" "usbhid" ];
boot.initrd.kernelModules = [ ];
boot.kernelModules = [ "kvm-intel" ];
boot.extraModulePackages = [ ];

fileSystems."/" =
{ device = "/dev/disk/by-uuid/d01192a5-534a-492e-a74c-097a15e44ae0";
fsType = "ext4";
};

fileSystems."/boot" =
{ device = "/dev/disk/by-uuid/E0B6-14F4";
fsType = "vfat";
options = [ "fmask=0022" "dmask=0022" ];
};

swapDevices = [ ];

# Enables DHCP on each ethernet and wireless interface. In case of scripted networking
# (the default) this is the recommended approach. When using systemd-networkd it's
# still possible to use this option, but it's recommended to use it in conjunction
# with explicit per-interface declarations with `networking.interfaces.<interface>.useDHCP`.
networking.useDHCP = lib.mkDefault true;
# networking.interfaces.docker0.useDHCP = lib.mkDefault true;
# networking.interfaces.enp5s0.useDHCP = lib.mkDefault true;
# networking.interfaces.enp6s0.useDHCP = lib.mkDefault true;
# networking.interfaces.enp7s0.useDHCP = lib.mkDefault true;

nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux";
hardware.cpu.intel.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware;
}
21 changes: 21 additions & 0 deletions os/nixos/machine/steam.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{ config, pkgs, ... }:

{
environment.systemPackages = with pkgs; [
mangohud # overlay showing cpu / gpu load, etc
protonup
lutris
];

programs.gamemode.enable = true;

programs.steam = {
enable = true;

remotePlay.openFirewall = true; # Open ports in the firewall for Steam Remote Play
dedicatedServer.openFirewall = true; # Open ports in the firewall for Source Dedicated Server
localNetworkGameTransfers.openFirewall = true; # Open ports in the firewall for Steam Local Network Game Transfers

gamescopeSession.enable = true;
};
}

0 comments on commit 34a641e

Please sign in to comment.