From 79b53eb0df6a906affdb10e09cac082bf488b04e Mon Sep 17 00:00:00 2001 From: Noa Aarts Date: Fri, 30 Aug 2024 18:26:19 +0200 Subject: [PATCH] feat: create muOS (laptop) config --- flake.nix | 17 ++ hosts/muos/configuration.nix | 319 +++++++++++++++++++++++++++++++++++ hosts/muos/disk-config.nix | 41 +++++ hosts/muos/home.nix | 180 ++++++++++++++++++++ hosts/muos/root.nix | 97 +++++++++++ 5 files changed, 654 insertions(+) create mode 100644 hosts/muos/configuration.nix create mode 100644 hosts/muos/disk-config.nix create mode 100644 hosts/muos/home.nix create mode 100644 hosts/muos/root.nix diff --git a/flake.nix b/flake.nix index 5f00405..0eb9557 100644 --- a/flake.nix +++ b/flake.nix @@ -44,6 +44,11 @@ inputs.nixpkgs.follows = "nixpkgs"; }; + hardware = { + url = "github:NixOS/nixos-hardware/master"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + }; outputs = { self, nixpkgs, nix-colors, automapaper, disko, hyprland, lazy, ... }@inputs: @@ -72,6 +77,18 @@ inputs.home-manager.nixosModules.default ]; }; + muOS = nixpkgs.lib.nixosSystem { + specialArgs = { + inherit inputs; + inherit nix-colors; + inherit automapaper; + }; + modules = [ + disko.nixosModules.disko + inputs.home-manager.nixosModules.default + inputs.hardware.nixosModules.framework-11th-gen-intel + ]; + }; }; nixosModules = { automapaper = ./modules/automapaper; diff --git a/hosts/muos/configuration.nix b/hosts/muos/configuration.nix new file mode 100644 index 0000000..b02bdf4 --- /dev/null +++ b/hosts/muos/configuration.nix @@ -0,0 +1,319 @@ +# 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’). + +{ config, pkgs, inputs, nix-colors, lib, ... }: +{ + imports = + [ + # Include the results of the hardware scan. + ../../modules/games/steam.nix + ../../modules/plasma + ./disk-config.nix + + ../../common + ]; + + + + + hardware = { + bluetooth = { + enable = true; + powerOnBoot = true; + }; + enableRedistributableFirmware = true; + enableAllFirmware = true; + graphics = { + enable = true; + enable32Bit = true; + }; + nvidia = { + modesetting.enable = true; + powerManagement = { + enable = true; + finegrained = false; + }; + open = false; + nvidiaSettings = true; + package = config.boot.kernelPackages.nvidiaPackages.beta; + }; + }; + + # Allow unfree packages + nixpkgs.config = { + allowUnfree = true; + nvidia.acceptLicense = true; + }; + nixpkgs.overlays = [ ]; + + networking = { + hostName = "muOS"; # Define your hostname. + }; + + networking.networkmanager.enable = true; + + programs.nm-applet.enable = true; + + nix = { + settings = { + # auto optimise every so often + # auto-optimise-store = true; + experimental-features = [ "nix-command" "flakes" ]; + substituters = [ + "https://hyprland.cachix.org" + "https://cache.iog.io" + "https://cuda-maintainers.cachix.org" + ]; + trusted-public-keys = [ + "hyprland.cachix.org-1:a7pgxzMz7+chwVL3/pzj6jIBMioiJM7ypFP8PwtkuGc=" + "hydra.iohk.io:f/Ea+s+dFdN+3Y/G+FDgSq+a5NEWhJGzdjvKNGv0/EQ=" + "cuda-maintainers.cachix.org-1:0dq3bujKpuEPMCX6U4WylrUDZ9JyUG0VpVZa7CNfq5E=" + ]; + }; + optimise.automatic = true; + gc = { + automatic = false; + dates = "weekly"; + options = "--delete-older-than 7d"; + }; + }; + + # Set your time zone. + time.timeZone = "Europe/Amsterdam"; + + + # Configure console keymap + console.keyMap = "us-acentos"; + + # Define a user account. Don't forget to set a password with ‘passwd’. + users.users = { + root = { + hashedPassword = "!"; + }; + noa = { + isNormalUser = true; + description = "Noa Aarts"; + extraGroups = [ "networkmanager" "wheel" "docker" "wireshark" ]; + hashedPassword = "$6$rounds=512400$Zip3xoK2zcoR4qEL$N13YTHO5tpWfx2nKb1sye.ZPwfoRtMQ5f3YrMZqKzzoFoSSHHJ.l5ulCEa9HygFxZmBtPnwlseFEtl8ERnwF50"; + openssh.authorizedKeys.keys = [ + "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIBFemc4Pzp7I0y8FHxgRO/c/ReBmXuqXR6CWqbhiQ+0t noa@Noas_flaptop" + ]; + }; + }; + + home-manager = { + extraSpecialArgs = { + inherit inputs; + inherit nix-colors; + }; + users = { + "noa" = import ./home.nix; + "root" = import ./root.nix; + }; + }; + + # TODO: find list of fonts to install + fonts.packages = with pkgs; [ + font-awesome + noto-fonts + fira-code + fira-code-symbols + liberation_ttf + maple-mono-NF + ]; + + # 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; + pinentryPackage = pkgs.pinentry-curses; + }; + + xdg.portal.enable = true; + + programs = { + zsh.enable = true; + + hyprland = { + enable = true; + package = inputs.hyprland.packages.${pkgs.system}.hyprland; + }; + + nix-ld.enable = true; + nix-ld.libraries = with pkgs; [ + wayland + ]; + + wireshark.enable = true; + }; + + modules = { + games.steam.enable = true; + plasma.enable = true; + }; + + users.defaultUserShell = pkgs.zsh; + + security.rtkit.enable = true; + boot = rec { + + + kernelPackages = pkgs.linuxPackages_latest; + extraModulePackages = with kernelPackages; [ + v4l2loopback + ]; + consoleLogLevel = 0; + initrd.verbose = false; + plymouth = rec { + enable = true; + theme = "colorful"; + themePackages = [ (pkgs.adi1090x-plymouth-themes.override { selected_themes = [ theme ]; }) ]; + }; + kernelParams = [ + "quiet" + "splash" + "boot.shell_on_fail" + "i915.fastboot=1" + "loglevel=3" + "rd.systemd.show_status=false" + "rd.udev.log_level=3" + "udev.log_priority=3" + ]; + + kernelModules = [ + "v4l2loopback" + "nct6775" + "k10temp" + ]; + + extraModprobeConfig = '' + options v4l2loopback devices=1 video_nr=2 card_label="OBS Cam" exclusive_caps=1 + ''; + + loader = { + timeout = 3; + efi.canTouchEfiVariables = true; + systemd-boot = { + enable = true; + editor = false; + configurationLimit = 100; + }; + }; + + }; + + services = { + pcscd.enable = true; # for yubikey + pipewire = { + enable = true; + alsa.enable = true; + alsa.support32Bit = true; + pulse.enable = true; + jack.enable = true; + }; + greetd = { + enable = false; + settings = rec { + initial_session = { + command = "${pkgs.hyprland}/bin/Hyprland"; + user = "noa"; + }; + default_session = initial_session; + }; + }; + openssh = { + enable = true; + settings.PasswordAuthentication = false; + settings.KbdInteractiveAuthentication = false; + }; + xserver = { + enable = true; + xkb = { + layout = "us"; + variant = "intl"; + }; + }; + displayManager.sddm = { + enable = true; + wayland.enable = true; + }; + flatpak.enable = true; + udev.packages = [ pkgs.yubikey-personalization ]; + }; + + systemd = { + + timers."update-from-flake" = { + wantedBy = [ "timers.target" ]; + timerConfig = { + OnCalendar = "daily"; + Persistent = true; + }; + }; + + services."update-from-flake" = { + path = with pkgs; [ + nixos-rebuild + ]; + script = ''nixos-rebuild switch --flake github:itepastra/nixconf''; + serviceConfig = { + Type = "oneshot"; + User = "root"; + }; + wants = [ + "network-online.target" + ]; + after = [ + "network-online.target" + ]; + }; + user.services.polkit-gnome-authentication-agent-1 = { + description = "polkit-gnome-authentication-agent-1"; + wantedBy = [ "graphical-session.target" ]; + wants = [ "graphical-session.target" ]; + after = [ "graphical-session.target" ]; + serviceConfig = { + Type = "simple"; + ExecStart = "${pkgs.polkit_gnome}/libexec/polkit-gnome-authentication-agent-1"; + Restart = "on-failure"; + RestartSec = 1; + TimeoutStopSec = 10; + }; + }; + }; + + virtualisation.docker = { + enable = true; + package = pkgs.docker_27; + rootless = { + enable = true; + setSocketVariable = true; + }; + }; + security = { + polkit.enable = true; + }; + + # Open ports in the firewall. + networking.firewall.allowedTCPPorts = [ + 53317 # Localsend + ]; + networking.firewall.allowedUDPPorts = [ + 53317 + ]; + # 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/muos/disk-config.nix b/hosts/muos/disk-config.nix new file mode 100644 index 0000000..a2870b0 --- /dev/null +++ b/hosts/muos/disk-config.nix @@ -0,0 +1,41 @@ +# Example to create a bios compatible gpt partition +{ lib, ... }: +{ + disko.devices = { + disk.disk1 = { + device = lib.mkDefault "/dev/nvme0n1"; + type = "disk"; + content = { + type = "gpt"; + partitions = { + boot = { + name = "boot"; + size = "1M"; + type = "EF02"; + }; + esp = { + name = "ESP"; + size = "500M"; + type = "EF00"; + content = { + type = "filesystem"; + format = "vfat"; + mountpoint = "/boot"; + }; + }; + root = { + size = "100%"; + content = { + type = "filesystem"; + format = "ext4"; + mountpoint = "/"; + mountOptions = [ + "defaults" + ]; + }; + }; + }; + }; + }; + }; +} diff --git a/hosts/muos/home.nix b/hosts/muos/home.nix new file mode 100644 index 0000000..88b4637 --- /dev/null +++ b/hosts/muos/home.nix @@ -0,0 +1,180 @@ +{ config, pkgs, inputs, lib, ... }: + +{ + imports = + [ + ../../modules/hyprland.nix + ../../modules/games + ../../modules/applications + ../../common/nvim/nvim.nix + ../../common/discord/discord.nix + ../../common/spotify.nix + ]; + # Home Manager needs a bit of information about you and the paths it should + # manage. + home.username = "noa"; + home.homeDirectory = "/home/noa"; + + # This value determines the Home Manager release that your configuration is + # compatible with. This helps avoid breakage when a new Home Manager release + # introduces backwards incompatible changes. + # + # You should not change this value, even if you update Home Manager. If you do + # want to update the value, then make sure to first check the Home Manager + # release notes. + home.stateVersion = "23.11"; # Please read the comment before changing. + + nixpkgs.config.allowUnfree = true; + + modules = { + hyprland.enable = true; + games.enable = true; + apps = { + enable = true; + git = { + name = "Noa Aarts"; + email = "noa@voorwaarts.nl"; + do_sign = true; + }; + }; + }; + + # The home.packages option allows you to install Nix packages into your + # environment. + home.packages = with pkgs; [ + file + unzip + zip + + dig + mtr + + obs-studio + wayvnc + + signal-desktop + + btop + + dconf + pipewire + lsd + + localsend + blueberry + qbittorrent + planify + keepassxc + yubikey-manager-qt + yubico-piv-tool + ]; + + + # Home Manager is pretty good at managing dotfiles. The primary way to manage + # plain files is through 'home.file'. + home.file = { + # # Building this configuration will create a copy of 'dotfiles/screenrc' in + # # the Nix store. Activating the configuration will then make '~/.screenrc' a + # # symlink to the Nix store copy. + # ".screenrc".source = dotfiles/screenrc; + + # # You can also set the file content immediately. + # ".gradle/gradle.properties".text = '' + # org.gradle.console=verbose + # org.gradle.daemon.idletimeout=3600000 + # ''; + "ykcs/ykcs11.so".source = "${pkgs.yubico-piv-tool}/lib/libykcs11.so"; + }; + + # Home Manager can also manage your environment variables through + # 'home.sessionVariables'. If you don't want to manage your shell through Home + # Manager then you have to manually source 'hm-session-vars.sh' located at + # either + # + # ~/.nix-profile/etc/profile.d/hm-session-vars.sh + # + # or + # + # ~/.local/state/nix/profiles/profile/etc/profile.d/hm-session-vars.sh + # + # or + # + # /etc/profiles/per-user/noa/etc/profile.d/hm-session-vars.sh + # + + + home.sessionVariables = { + EDITOR = "nvim"; + TERM = "kitty"; + GDK_BACKEND = "wayland,x11"; + QT_QPA_PLATFORM = "wayland;xcb"; + CLUTTER_BACKEND = "wayland"; + XDG_CURRENT_DESKTOP = "Hyprland"; + XDG_SESSION_TYPE = "wayland"; + XDG_SESSION_DESKTOP = "Hyprland"; + WLR_NO_HARDWARE_CURSORS = "1"; + }; + + xdg = { + enable = true; + userDirs = { + enable = true; + createDirectories = true; + }; + }; + + + + dconf = { + enable = true; + settings = { + "org/gnome/desktop/interface" = { + color-scheme = "prefer-dark"; + }; + }; + }; + + gtk = { + enable = true; + gtk2.extraConfig = '' + gtk-enable-animations=1 + gtk-primary-button-warps-slider=1 + gtk-toolbar-style=3 + gtk-menu-images=1 + gtk-button-images=1 + gtk-sound-theme-name="ocean" + gtk-font-name="Noto Sans, 10" + ''; + theme = { + name = "Adwaita-dark"; + package = pkgs.gnome-themes-extra; + }; + }; + + # Let Home Manager install and manage itself. + programs = { + home-manager.enable = true; + }; + + home.pointerCursor = + let + getFrom = url: hash: name: { + gtk.enable = true; + x11.enable = true; + name = name; + size = 32; + package = + pkgs.runCommand "moveUp" { } '' + mkdir -p $out/share/icons + ln -s ${pkgs.fetchzip { + url = url; + hash = hash; + }} $out/share/icons/${name} + ''; + }; + in + getFrom + "https://github.com/ful1e5/Bibata_Cursor_Rainbow/releases/download/v1.1.2/Bibata-Rainbow-Modern.tar.gz" + "sha256-Ps+IKPwQoRwO9Mqxwc/1nHhdBT2R25IoeHLKe48uHB8=" + "Bibata-Rainbow-Modern"; +} diff --git a/hosts/muos/root.nix b/hosts/muos/root.nix new file mode 100644 index 0000000..73555dc --- /dev/null +++ b/hosts/muos/root.nix @@ -0,0 +1,97 @@ +{ config, pkgs, inputs, ... }: + +{ + imports = [ + ../../modules/applications + ]; + # Home Manager needs a bit of information about you and the paths it should + # manage. + home.username = "root"; + home.homeDirectory = "/root"; + + # This value determines the Home Manager release that your configuration is + # compatible with. This helps avoid breakage when a new Home Manager release + # introduces backwards incompatible changes. + # + # You should not change this value, even if you update Home Manager. If you do + # want to update the value, then make sure to first check the Home Manager + # release notes. + home.stateVersion = "23.11"; # Please read the comment before changing. + + nixpkgs.config.allowUnfree = true; + + # The home.packages option allows you to install Nix packages into your + # environment. + home.packages = with pkgs; [ + file + unzip + zip + + dig + mtr + + kitty + lsd + ]; + + + modules = { + apps = { + enable = true; + git = { + name = "Noa Aarts"; + email = "noa@voorwaarts.nl"; + }; + }; + }; + + # Home Manager is pretty good at managing dotfiles. The primary way to manage + # plain files is through 'home.file'. + home.file = { + # # Building this configuration will create a copy of 'dotfiles/screenrc' in + # # the Nix store. Activating the configuration will then make '~/.screenrc' a + # # symlink to the Nix store copy. + # ".screenrc".source = dotfiles/screenrc; + + # # You can also set the file content immediately. + # ".gradle/gradle.properties".text = '' + # org.gradle.console=verbose + # org.gradle.daemon.idletimeout=3600000 + # ''; + }; + + # Home Manager can also manage your environment variables through + # 'home.sessionVariables'. If you don't want to manage your shell through Home + # Manager then you have to manually source 'hm-session-vars.sh' located at + # either + # + # ~/.nix-profile/etc/profile.d/hm-session-vars.sh + # + # or + # + # ~/.local/state/nix/profiles/profile/etc/profile.d/hm-session-vars.sh + # + # or + # + # /etc/profiles/per-user/noa/etc/profile.d/hm-session-vars.sh + # + home.sessionVariables = { + EDITOR = "nvim"; + TERM = "kitty"; + }; + + xdg.userDirs.enable = true; + xdg.userDirs.createDirectories = true; + + dconf = { + enable = true; + settings = { + "org/gnome/desktop/interface" = { + color-scheme = "prefer-dark"; + }; + }; + }; + + # Let Home Manager install and manage itself. + programs.home-manager.enable = true; +}