From 75c2af4aedd2ac5c2cfc74b346625fa4b265541d Mon Sep 17 00:00:00 2001 From: Petri Hienonen Date: Thu, 23 May 2024 09:44:38 +0300 Subject: Nixos --- hosts/saarni/default.nix | 250 ++++++++++++++++++++++++++++++++ hosts/saarni/hardware-configuration.nix | 37 +++++ 2 files changed, 287 insertions(+) create mode 100644 hosts/saarni/default.nix create mode 100644 hosts/saarni/hardware-configuration.nix (limited to 'hosts/saarni') diff --git a/hosts/saarni/default.nix b/hosts/saarni/default.nix new file mode 100644 index 0000000..010a8eb --- /dev/null +++ b/hosts/saarni/default.nix @@ -0,0 +1,250 @@ +# 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’). + +{ inputs, outputs, lib, config, pkgs, vars, ... }: + +{ + imports = [ + ./hardware-configuration.nix + inputs.home-manager.nixosModules.home-manager + ]; + + nix = { + nixPath = [ "/etc/nix/path" ]; + gc = { + automatic = true; + }; + settings = { + auto-optimise-store = true; + experimental-features = "nix-command flakes"; + }; + registry = (lib.mapAttrs (_: flake: { inherit flake; })) + ((lib.filterAttrs (_: lib.isType "flake")) inputs); + }; + nixpkgs.config.allowUnfree = true; + security.rtkit.enable = true; + + home-manager = { + extraSpecialArgs = { inherit inputs outputs vars; }; + users = { ${vars.user} = import ../../home; }; + }; + + powerManagement = { + enable = true; + powertop.enable = true; + }; + + # Bootloader. + boot = { + loader = { + systemd-boot.enable = true; + efi.canTouchEfiVariables = true; + }; + kernelPackages = pkgs.linuxPackages_latest; + plymouth.enable = true; + kernelParams = [ "quiet" "splash" ]; + }; + + networking = { + nameservers = [ "1.1.1.1#one.one.one.one" "1.0.0.1#one.one.one.one" ]; + hostName = "saarni"; + useNetworkd = true; + wireless.iwd.enable = true; + }; + + systemd = { + watchdog = { + device = "/dev/watchdog"; + runtimeTime = "30s"; + }; + sleep.extraConfig = "HibernateDelaysSec=90m"; + network = { + enable = true; + wait-online.enable = false; + networks = { + "10-lan" = { + matchConfig.Name = "enp0s20f0u9"; + networkConfig.DHCP = "yes"; + }; + "11-lan" = { + matchConfig.Name = "wlan0"; + networkConfig.DHCP = "yes"; + }; + }; + }; + }; + + system.autoUpgrade = { + enable = true; + }; + + sound.enable = true; + + hardware = { + opengl = { + enable = true; + driSupport = true; + extraPackages = with pkgs; [ + intel-media-driver + libvdpau-va-gl + ]; + }; + bluetooth = { + enable = true; + powerOnBoot = true; + }; + }; + + # Set your time zone. + time.timeZone = "Europe/Helsinki"; + + # Select internationalisation properties. + i18n = { + defaultLocale = "en_US.UTF-8"; + extraLocaleSettings = { + LC_ADDRESS = "fi_FI.UTF-8"; + LC_IDENTIFICATION = "fi_FI.UTF-8"; + LC_MEASUREMENT = "fi_FI.UTF-8"; + LC_MONETARY = "fi_FI.UTF-8"; + LC_NAME = "fi_FI.UTF-8"; + LC_NUMERIC = "fi_FI.UTF-8"; + LC_PAPER = "fi_FI.UTF-8"; + LC_TELEPHONE = "fi_FI.UTF-8"; + LC_TIME = "fi_FI.UTF-8"; + }; + }; + + console.keyMap = "fi"; + + # Define a user account. Don't forget to set a password with ‘passwd’. + users.users.${vars.user} = { + isNormalUser = true; + description = "${vars.name}"; + extraGroups = [ "input" "network" "wheel" ]; + packages = with pkgs; [ ]; + ignoreShellProgramCheck = true; + shell = pkgs.${vars.shell}; + }; + + programs = { + firefox.enable = true; + hyprland.enable = true; + gnupg.agent = { + enable = true; + enableSSHSupport = true; + }; + mtr.enable = true; + }; + + environment = { + sessionVariables = { + LIBVA_DRIVER_NAME = "iHD"; + }; + systemPackages = with pkgs; [ + fastfetch + vulkan-tools + libva-utils + wget + curl + git + gzip + btop + glxinfo + sqlite + openssh + gnupg + helix + nixfmt + ]; + etc = lib.mapAttrs' (name: value: { + name = "nix/path/${name}"; + value.source = value.flake; + }) config.nix.registry; + }; + + fonts = { + enableDefaultPackages = true; + packages = with pkgs; [ noto-fonts fira-code fira-code-symbols ]; + fontconfig = { + defaultFonts = { + serif = [ "Noto Serif" ]; + sansSerif = [ "Noto Sans" ]; + monospace = [ "Fira Code" ]; + }; + }; + }; + + # List services that you want to enable: + services = { + getty.autologinUser = "petri"; + resolved = { + enable = true; + dnsovertls = "true"; + }; + xserver = { + layout = "fi"; + xkbVariant = "normal"; + }; + pipewire = { + enable = true; + alsa.enable = true; + pulse.enable = true; + }; + openssh.enable = true; + printing.enable = true; + kmscon = { + enable = true; + hwRender = true; + extraOptions = "--xkb-layout=fi"; + }; + blueman.enable = true; + upower.enable = true; + upower.criticalPowerAction = "Hibernate"; + fstrim.enable = false; + thermald.enable = true; + auto-cpufreq.enable = true; + greetd = { + enable = true; + settings = rec { + initial_session = { + command = "${pkgs.hyprland}/bin/Hyprland"; + user = "petri"; + }; + default_session = initial_session; + }; + }; + }; + + xdg.portal = { + enable = true; + xdgOpenUsePortal = true; + extraPortals = [ + pkgs.xdg-desktop-portal-hyprland + pkgs.xdg-desktop-portal-gtk + ]; + wlr = { + enable = true; + settings = { + screencast = { + chooser_type = "simple"; + chooser_cmd = "${pkgs.slurp}/bin/slurp -f %o -ro"; + }; + }; + }; + }; + + # Open ports in the firewall. + # networking.firewall.allowedTCPPorts = [ ... ]; + # networking.firewall.allowedUDPPorts = [ ... ]; + # Or disable the firewall altogether. + # networking.firewall.enable = false; + + # 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? +} diff --git a/hosts/saarni/hardware-configuration.nix b/hosts/saarni/hardware-configuration.nix new file mode 100644 index 0000000..6aef572 --- /dev/null +++ b/hosts/saarni/hardware-configuration.nix @@ -0,0 +1,37 @@ +# 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 = [ "xhci_pci" "thunderbolt" "nvme" "usb_storage" "sd_mod" ]; + boot.initrd.kernelModules = [ ]; + boot.kernelModules = [ "kvm-intel" ]; + boot.extraModulePackages = [ ]; + + fileSystems."/" = + { device = "/dev/disk/by-uuid/3968a07a-5e37-4bdb-9e3a-6c74950fd03d"; + fsType = "ext4"; + }; + + fileSystems."/boot" = + { device = "/dev/disk/by-uuid/9B7E-3D1B"; + 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..useDHCP`. + # networking.useDHCP = lib.mkDefault true; + # networking.interfaces.wlan0.useDHCP = lib.mkDefault true; + + nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux"; + hardware.cpu.intel.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware; +} -- cgit v1.2.3-70-g09d2