nix-cfg/hosts/laptop/configuration.nix

462 lines
13 KiB
Nix
Raw Normal View History

2023-09-09 16:31:01 +02:00
# 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`).
2024-05-16 22:41:38 +02:00
{ lib, config, pkgs, pkgs-stable, ... }:
2023-09-09 16:31:01 +02:00
2024-01-21 19:53:13 +01:00
let
nixPath = "/etc/nixPath";
in
2024-01-09 23:36:02 +01:00
{
2024-02-18 10:48:52 +01:00
imports = [
./mounts.nix
2024-02-18 10:48:52 +01:00
./akkotest.nix
];
2023-12-11 17:47:25 +01:00
# boot.kernelPackages = pkgs.linuxPackages_zen;
2023-09-09 16:31:01 +02:00
# Use the systemd-boot EFI boot loader.
# NOT! Let's use GRUB instead
# https://nixos.org/manual/nixos/stable/#sec-installation
# boot.loader.efi.efiSysMountPoint = "/boot";
boot.loader.systemd-boot.enable = false;
boot.loader.efi.canTouchEfiVariables = true;
boot.loader.grub = {
enable = true;
device = "nodev";
efiSupport = true;
2023-10-30 17:20:54 +01:00
theme = "${pkgs.fetchFromGitHub {
owner = "catppuccin";
repo = "grub";
rev = "803c5df0e83aba61668777bb96d90ab8f6847106";
hash = "sha256-/bSolCta8GCZ4lP0u5NVqYQ9Y3ZooYCNdTwORNvR7M0=";
}}/src/catppuccin-macchiato-grub-theme/";
2023-09-09 16:31:01 +02:00
efiInstallAsRemovable = false;
# useOSProber = true;
extraEntries =
''
menuentry 'Windows 10' --class windows --class os {
insmod part_gpt
insmod fat
set root='hd0,gpt4'
if [ x$feature_platform_search_hint = xy ]; then
search --no-floppy --fs-uuid --set=root --hint-bios=hd0,gpt4 --hint-efi=hd0,gpt4 --hint-baremetal=ahci0,gpt4 8D94-2A4E
2023-09-09 16:31:01 +02:00
else
search --no-floppy --fs-uuid --set=root 8D94-2A4E
2023-09-09 16:31:01 +02:00
fi
chainloader /EFI/Microsoft/Boot/bootmgfw.efi
}
menuentry 'Ventoy' {
insmod part_gpt
insmod fat
# set root='hd0,gpt4'
# if [ x$feature_platform_search_hint = xy ]; then
# search --no-floppy --fs-uuid --set=root --hint-bios=hd0,gpt4 --hint-efi=hd0,gpt4 --hint-baremetal=ahci0,gpt4 BDAD-470D
2023-09-09 16:31:01 +02:00
# else
# search --no-floppy --fs-uuid --set=root BDAD-470D
2023-09-09 16:31:01 +02:00
# fi
search --no-floppy --fs-uuid --set=root BDAD-470D
2023-09-09 16:31:01 +02:00
chainloader /EFI/BOOT/BOOTX64.EFI
}
'';
};
2024-01-09 08:01:25 +01:00
boot.tmp.cleanOnBoot = true;
2023-09-09 16:31:01 +02:00
# NTFS support
boot.supportedFilesystems = [ "ntfs" ];
# btrfs options
fileSystems = {
"/".options = [ "compress=zstd" ];
"/home".options = [ "compress=zstd" ];
"/nix".options = [ "compress=zstd" "noatime" ];
};
boot.kernel.sysctl."kernel.sysrq" = 244;
2023-10-30 17:20:54 +01:00
boot.plymouth = {
enable = true;
themePackages = [ (pkgs.catppuccin-plymouth.override { variant = "macchiato"; }) ];
theme = "catppuccin-macchiato";
};
boot.initrd.systemd.enable = true;
2023-09-09 16:31:01 +02:00
# ==[SECURITY]==
# LUKS options
2023-10-30 17:20:54 +01:00
# boot.initrd.luks.fido2Support = true;
boot.initrd.luks.devices = {
2023-09-09 16:31:01 +02:00
crypted = {
device = "/dev/disk/by-path/pci-0000:02:00.0-nvme-1";
header = "/dev/disk/by-partuuid/3c43dda3-6a23-7148-add5-84354a28a59e";
2023-09-09 16:31:01 +02:00
preLVM = true;
2023-10-30 17:20:54 +01:00
crypttabExtraOpts = [ "fido2-device=auto" "token-timeout=10s" ];
# fido2.credential = "";
# fido2.passwordLess = true;
2023-09-09 16:31:01 +02:00
};
};
# sudo and doas
security.doas = {
enable = true;
extraRules = [{
users = [ "lgm" ];
persist = true;
}];
};
# PAM
security.pam.services = {
login.u2fAuth = true;
sudo.u2fAuth = true;
doas.u2fAuth = true;
};
security.pam.u2f = {
enable = true;
settings = {
cue = true;
interactive = true;
};
2023-09-09 16:31:01 +02:00
};
# Make sure opengl is enabled
hardware.graphics = {
2023-09-09 16:31:01 +02:00
enable = true;
2023-12-11 17:47:25 +01:00
# These extrapackages I added later but it didn't help
extraPackages = with pkgs; [
intel-media-driver # LIBVA_DRIVER_NAME=iHD
vaapiIntel # LIBVA_DRIVER_NAME=i965 (older but works better for Firefox/Chromium)
vaapiVdpau
libvdpau-va-gl
];
2023-09-09 16:31:01 +02:00
};
# Tell Xorg to use the nvidia driver (also valid for Wayland)
services.xserver.videoDrivers = ["nvidia"];
hardware.nvidia = {
# Modesetting is needed for most Wayland compositors
modesetting.enable = true;
# Use the open source version of the kernel module
# Only available on driver 515.43.04+
open = false;
# Enable the nvidia settings menu
nvidiaSettings = true;
# Optionally, you may need to select the appropriate driver version for your specific GPU.
package = config.boot.kernelPackages.nvidiaPackages.stable;
};
# NVIDIA
hardware.nvidia.prime = {
offload = {
enable = true;
enableOffloadCmd = true;
};
2024-05-16 22:41:38 +02:00
sync.enable = false;
2023-09-09 16:31:01 +02:00
intelBusId = "PCI:0:2:0";
nvidiaBusId = "PCI:1:0:0";
};
2024-05-16 22:41:38 +02:00
specialisation."nvidia-full".configuration = {
environment.etc."specialisation".text = "nvidia-full";
system.nixos.tags = ["nvidia-full"];
hardware.nvidia.prime = {
offload.enable = lib.mkForce false;
offload.enableOffloadCmd = lib.mkForce false;
sync.enable = lib.mkForce true;
};
environment.systemPackages = [
(pkgs.writeShellScriptBin "nvidia-offload" ''
echo "nvidia full mode on, simply executing $@"
exec "$@"
'')
];
};
2023-09-09 16:31:01 +02:00
programs.gamemode.enable = true;
# VirtualBox
2023-10-30 17:20:54 +01:00
virtualisation.docker.enable = true;
2023-12-11 17:47:25 +01:00
virtualisation.waydroid.enable = true;
2023-10-30 17:20:54 +01:00
virtualisation.virtualbox.host.enable = true;
virtualisation.virtualbox.host.package = pkgs.virtualbox;
2023-10-30 17:20:54 +01:00
users.extraGroups.vboxusers.members = [ "lgm" ];
2023-09-09 16:31:01 +02:00
networking.hostName = "lgm-nixos"; # Define your hostname.
# Pick only one of the below networking options.
# networking.wireless.enable = true; # Enables wireless support via wpa_supplicant.
networking.networkmanager.enable = true; # Easiest to use and most distros use this by default.
# Set your time zone.
2024-08-12 00:33:26 +02:00
time.timeZone = "Asia/Tbilisi";
2023-09-09 16:31:01 +02:00
# Configure network proxy if necessary
# networking.proxy.default = "http://user:password@proxy:port/";
# networking.proxy.noProxy = "127.0.0.1,localhost,internal.domain";
# Select internationalisation properties.
# i18n.defaultLocale = "en_US.UTF-8";
# console = {
# font = "Lat2-Terminus16";
# keyMap = "us";
# useXkbConfig = true; # use xkbOptions in tty.
# };
i18n.defaultLocale = "en_US.UTF-8";
i18n.extraLocaleSettings = {
# LC_ADDRESS = "ru_RU.UTF-8";
# LC_IDENTIFICATION = "ru_RU.UTF-8";
# LC_MEASUREMENT = "ru_RU.UTF-8";
# LC_MONETARY = "ru_RU.UTF-8";
# LC_NAME = "ru_RU.UTF-8";
# LC_NUMERIC = "ru_RU.UTF-8";
# LC_PAPER = "ru_RU.UTF-8";
# LC_TELEPHONE = "ru_RU.UTF-8";
LC_TIME = "ru_RU.UTF-8";
};
# Enable the X11 windowing system.
services.xserver.enable = true;
2024-05-11 13:14:26 +02:00
services.displayManager.sddm.enable = true;
2023-10-30 17:20:54 +01:00
# Didn't like, the theme is a bit buggy
# services.xserver.displayManager.sddm.theme = "${pkgs.fetchFromGitHub {
# owner = "catppuccin";
# repo = "sddm";
# rev = "7fc67d1027cdb7f4d833c5d23a8c34a0029b0661";
# hash = "sha256-SjYwyUvvx/ageqVH5MmYmHNRKNvvnF3DYMJ/f2/L+Go=";
# }}/src/catppuccin-latte/";
2024-05-11 00:44:03 +02:00
services.desktopManager.plasma6.enable = true;
2024-05-11 13:14:26 +02:00
services.displayManager.defaultSession = "plasma";
2023-09-09 16:31:01 +02:00
2023-10-30 17:20:54 +01:00
# programs.command-not-found.enable = false;
# programs.nix-index.enable = true;
2024-05-11 00:42:20 +02:00
programs.wireshark.enable = true;
programs.wireshark.package = pkgs.wireshark;
2023-10-30 17:20:54 +01:00
2023-09-09 16:31:01 +02:00
# fish
programs.fish = {
enable = true;
};
2024-05-11 00:00:14 +02:00
programs.nh = {
enable = true;
clean.enable = true;
clean.extraArgs = "--keep-since 7d --keep 2";
};
2023-09-09 16:31:01 +02:00
# KDE Programs
2024-03-02 17:45:54 +01:00
# Currently installs plasma5 variant, disabled as module, enabled manually instead
services.dbus.packages = [ pkgs.kdePackages.kpmcore ];
# programs.partition-manager.enable = true;
2023-09-09 16:31:01 +02:00
programs.kdeconnect.enable = true;
programs.adb.enable = true;
# Steam
programs.steam = {
enable = true;
2024-03-02 17:45:54 +01:00
gamescopeSession.enable = true;
2024-01-09 08:01:25 +01:00
remotePlay.openFirewall = true;
2023-09-09 16:31:01 +02:00
# dedicatedServer.openFirewall = true;
};
2024-08-12 00:33:26 +02:00
services.xrdp = {
enable = true;
defaultWindowManager = "startplasma-x11";
# openFirewall = true;
};
services.postgresql = {
enable = true;
ensureDatabases = [ "testdb" ];
ensureUsers = [ { name = "lgm"; } ];
authentication = pkgs.lib.mkOverride 10 ''
#type database DBuser auth-method
local all all trust
'';
};
2023-09-09 16:31:01 +02:00
# Configure keymap in X11
# services.xserver.layout = "us";
# services.xserver.xkbOptions = "eurosign:e,caps:escape";
# Enable CUPS to print documents.
# services.printing.enable = true;
# Enable sound.
hardware.pulseaudio.enable = false;
security.rtkit.enable = true;
services.pipewire = {
enable = true;
alsa.enable = true;
alsa.support32Bit = true;
pulse.enable = true;
# If you want to use JACK applications, uncomment this
#jack.enable = true;
# use the example session manager (no others are packaged yet so this is enabled by default,
# no need to redefine it in your config for now)
#media-session.enable = true;
};
# Enable touchpad support (enabled default in most desktopManager).
2024-05-11 13:14:26 +02:00
services.libinput.enable = true;
2023-09-09 16:31:01 +02:00
# Define a user account. Don't forget to set a password with ‘passwd’.
users.users.lgm = {
isNormalUser = true;
description = "lgm";
2024-05-11 00:42:20 +02:00
extraGroups = [ "networkmanager" "wheel" "adbusers" "docker" "wireshark"];
2023-09-09 16:31:01 +02:00
shell = pkgs.fish;
};
nixpkgs.config.allowUnfree = true;
2024-01-21 19:53:13 +01:00
systemd.tmpfiles.rules = [
"L+ ${nixPath} - - - - ${pkgs.path}"
];
2023-09-09 16:31:01 +02:00
nix.settings.experimental-features = [ "nix-command" "flakes" ];
2024-01-21 19:53:13 +01:00
nix.nixPath = [ "nixpkgs=${nixPath}" ];
nix.channel.enable = false;
# Sops
sops = {
defaultSopsFile = ../../secrets/secrets.yaml;
defaultSopsFormat = "yaml";
secrets.example_key = {};
2024-02-18 13:36:52 +01:00
# secrets.porkbun = {
# sopsFile = ../../secrets/porkbun.env;
# format = "dotenv";
# };
2024-01-21 19:53:13 +01:00
};
2023-09-09 16:31:01 +02:00
# OnlyKey
hardware.onlykey.enable = true;
# List packages installed in system profile. To search, run:
# $ nix search wget
environment.systemPackages = with pkgs; [
2024-03-02 17:45:54 +01:00
# programs.partition-manager installs plasma5 variant, so we have to work around
kdePackages.partitionmanager
kdePackages.kpmcore
kdePackages.kaccounts-providers
kdePackages.kaccounts-integration
2023-09-09 16:31:01 +02:00
git
2023-10-31 00:31:02 +01:00
git-crypt
2023-09-09 16:31:01 +02:00
vim # Do not forget to add an editor to edit configuration.nix! The Nano editor is also installed by default.
wget
python3
2024-03-02 17:45:54 +01:00
curl
2023-09-09 16:31:01 +02:00
# more stuff
2023-10-30 17:20:54 +01:00
gnome-network-displays
miraclecast
2023-09-09 16:31:01 +02:00
parted
exfatprogs
gparted
tmux
2023-10-30 17:20:54 +01:00
# graalvm17-ce
distrobox
2023-09-09 16:31:01 +02:00
(let base = pkgs.appimageTools.defaultFhsEnvArgs; in
pkgs.buildFHSUserEnv (base // {
name = "fhs";
targetPkgs = pkgs: (
(base.targetPkgs pkgs) ++ [
pkg-config
ncurses
]
);
profile = "export FHS=1";
runScript = "bash";
extraOutputsToInstall = ["dev"];
}))
];
2023-11-29 17:19:19 +01:00
fonts.packages = with pkgs; [
noto-fonts
2024-11-14 00:39:49 +01:00
noto-fonts-cjk-sans
2023-11-29 17:19:19 +01:00
noto-fonts-emoji
];
2023-09-09 16:31:01 +02:00
environment.variables.EDITOR = "vim";
2023-11-13 20:46:28 +01:00
environment.variables.FLAKE = "/home/lgm/nixos-cfg?submodules=1";
2023-09-09 16:31:01 +02:00
# Some programs need SUID wrappers, can be configured further or are
# started in user sessions.
# programs.mtr.enable = true;
programs.gnupg.agent = {
enable = true;
2023-10-30 17:20:54 +01:00
# enableSSHSupport = true;
2023-09-09 16:31:01 +02:00
};
2023-10-30 17:20:54 +01:00
programs.ssh.startAgent = true;
2023-09-09 16:31:01 +02:00
2023-11-09 13:06:06 +01:00
zramSwap = {
enable = true;
# swapDevices = 2;
};
2023-09-09 16:31:01 +02:00
# List services that you want to enable:
2023-10-30 17:20:54 +01:00
# services.peroxide.enable = true;
2023-09-09 16:31:01 +02:00
# Enable the OpenSSH daemon.
# services.openssh.enable = true;
2024-02-18 10:48:52 +01:00
services.openssh = {
enable = true;
settings.PermitRootLogin = "no";
};
2023-09-09 16:31:01 +02:00
# Open ports in the firewall.
2024-08-12 00:33:26 +02:00
networking.firewall.trustedInterfaces = [ "p2p-wl+" "tailscale0" ];
2023-10-30 17:20:54 +01:00
networking.firewall.allowedTCPPorts = [ 5900 5905 7236 7250 ];
2024-02-29 13:03:20 +01:00
networking.firewall.allowedUDPPorts = [ 5900 5905 7236 5353 26000 ];
2024-02-18 10:48:52 +01:00
2023-09-09 16:31:01 +02:00
# Or disable the firewall altogether.
# networking.firewall.enable = false;
2024-02-18 10:48:52 +01:00
# enable NAT for the containers
networking.nat.enable = true;
networking.nat.internalInterfaces = ["ve-+"];
networking.nat.externalInterface = "wlp3s0";
networking.networkmanager.unmanaged = [ "interface-name:ve-*" ];
services.tailscale = {
enable = true;
};
services.logind.lidSwitchExternalPower = "lock";
2024-05-11 00:44:21 +02:00
hardware.bluetooth.enable = true;
hardware.bluetooth.powerOnBoot = true;
2023-09-09 16:31:01 +02:00
# Copy the NixOS configuration file and link it from the resulting system
# (/run/current-system/configuration.nix). This is useful in case you
# accidentally delete configuration.nix.
# system.copySystemConfiguration = 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 = "23.05"; # Did you read the comment?
}