From 642d3f55f1f4adaaac1d9790db3d4caa3cb88b5c Mon Sep 17 00:00:00 2001 From: thiloho <123883702+thiloho@users.noreply.github.com> Date: Wed, 29 Jan 2025 00:51:37 +0100 Subject: [PATCH] Organize configuration better --- modules/core.nix | 42 ++++ modules/desktop.nix | 46 ++++ modules/development.nix | 28 +++ modules/home.nix | 112 ++++++++++ modules/media.nix | 22 ++ nixos-configurations/laptop/default.nix | 30 ++- .../laptop/hardware-configuration.nix | 49 +++-- nixos-configurations/pc/default.nix | 56 +++-- .../pc/hardware-configuration.nix | 50 +++-- nixos-configurations/shared-desktop.nix | 199 ------------------ nixos-configurations/shared.nix | 43 ---- 11 files changed, 355 insertions(+), 322 deletions(-) create mode 100644 modules/core.nix create mode 100644 modules/desktop.nix create mode 100644 modules/development.nix create mode 100644 modules/home.nix create mode 100644 modules/media.nix delete mode 100644 nixos-configurations/shared-desktop.nix delete mode 100644 nixos-configurations/shared.nix diff --git a/modules/core.nix b/modules/core.nix new file mode 100644 index 0000000..6f0d54d --- /dev/null +++ b/modules/core.nix @@ -0,0 +1,42 @@ +{ pkgs, ... }: +{ + boot = { + loader = { + systemd-boot.enable = true; + efi.canTouchEfiVariables = true; + }; + kernelPackages = pkgs.linuxPackages_latest; + }; + + nix.settings.experimental-features = [ + "nix-command" + "flakes" + ]; + nixpkgs.config.allowUnfree = true; + + networking = { + networkmanager.enable = true; + firewall = { + allowedTCPPorts = [ 53317 ]; + allowedUDPPorts = [ 53317 ]; + }; + }; + + time.timeZone = "Europe/Berlin"; + + users = { + mutableUsers = false; + users = { + root.hashedPassword = "$y$j9T$gdQiD91dRc1rEURkntnkh1$9VvI8xhvCMqhSSOeOkiSnjHsQVUOOH/4Sbou.w6P5TC"; + thiloho = { + isNormalUser = true; + extraGroups = [ + "wheel" + "networkmanager" + "docker" + ]; + hashedPassword = "$y$j9T$0wgXXBJMy5lzuwmdvx5Lb.$G5JmfDXeXzH7sq66R.clvmlovuh1ZsZMf1SfDsWpNcB"; + }; + }; + }; +} diff --git a/modules/desktop.nix b/modules/desktop.nix new file mode 100644 index 0000000..8d53bb0 --- /dev/null +++ b/modules/desktop.nix @@ -0,0 +1,46 @@ +{ pkgs, ... }: +{ + environment.sessionVariables.NIXOS_OZONE_WL = "1"; + + fonts.packages = with pkgs; [ + jetbrains-mono + ]; + + services.xserver = { + enable = true; + displayManager.gdm.enable = true; + desktopManager.gnome.enable = true; + excludePackages = [ pkgs.xterm ]; + }; + + environment.gnome.excludePackages = with pkgs; [ + gnome-tour + gnome-connections + geary + evince + gnome-contacts + gnome-maps + gnome-music + snapshot + simple-scan + ]; + + environment.systemPackages = with pkgs; [ + gnome-tweaks + gnome-themes-extra + ]; + + programs.dconf.enable = true; + + programs.steam.enable = true; + + home-manager.users.thiloho.dconf.settings = { + "org/gnome/mutter" = { + experimental-features = [ + "scale-monitor-framebuffer" + "variable-refresh-rate" + "xwayland-native-scaling" + ]; + }; + }; +} diff --git a/modules/development.nix b/modules/development.nix new file mode 100644 index 0000000..cdbf493 --- /dev/null +++ b/modules/development.nix @@ -0,0 +1,28 @@ +{ pkgs, ... }: +{ + virtualisation.docker.enable = true; + + virtualisation.libvirtd = { + enable = true; + qemu.swtpm.enable = true; + }; + programs.virt-manager.enable = true; + + programs.adb.enable = true; + users.users.thiloho.extraGroups = [ "adbusers" ]; + + programs.nix-ld = { + enable = true; + libraries = with pkgs; [ + nodejs + nodePackages.pnpm + ]; + }; + + programs.gnupg.agent = { + enable = true; + enableSSHSupport = true; + }; + + programs.java.enable = true; +} diff --git a/modules/home.nix b/modules/home.nix new file mode 100644 index 0000000..67d5ced --- /dev/null +++ b/modules/home.nix @@ -0,0 +1,112 @@ +{ pkgs, ... }: +{ + home-manager.users.thiloho = { + programs.bash = { + enable = true; + shellAliases = { + rbs = "sudo nixos-rebuild switch --flake ."; + cleanup = "nix store optimise && nix-collect-garbage -d && sudo nix store optimise && sudo nix-collect-garbage -d"; + }; + }; + + programs.helix = { + enable = true; + settings.theme = "ayu_dark"; + }; + + programs = { + git = { + enable = true; + userName = "thiloho"; + userEmail = "123883702+thiloho@users.noreply.github.com"; + signing = { + signByDefault = true; + }; + }; + + vscode = { + enable = true; + package = pkgs.vscodium; + mutableExtensionsDir = false; + extensions = + with pkgs.vscode-extensions; + [ + jnoortheen.nix-ide + ritwickdey.liveserver + esbenp.prettier-vscode + ] + ++ pkgs.vscode-utils.extensionsFromVscodeMarketplace [ + { + name = "svelte-vscode"; + publisher = "svelte"; + version = "108.5.4"; + sha256 = "0sjq5ifnz08pkxslzz2qnrc76gvl6lkygcr3042safbvfral4xm1"; + } + { + name = "playwright"; + publisher = "ms-playwright"; + version = "1.1.10"; + sha256 = "0y0jlrxpjzd7drdmcr9kfy5g12zax9q4d8cblzzb6ia4c98ipfq0"; + } + ]; + userSettings = { + "editor.wordWrap" = "on"; + "editor.fontFamily" = "JetBrains Mono"; + "editor.fontLigatures" = true; + "editor.indentSize" = 2; + "editor.tabSize" = 2; + "typescript.preferences.importModuleSpecifier" = "relative"; + "[svelte]" = { + "editor.defaultFormatter" = "svelte.svelte-vscode"; + }; + "svelte.enable-ts-plugin" = true; + "svelte.plugin.svelte.defaultScriptLanguage" = "ts"; + "svelte.plugin.svelte.format.config.svelteStrictMode" = true; + }; + }; + + firefox = { + enable = true; + package = pkgs.firefox-devedition.override { + cfg = { + speechSynthesisSupport = true; + }; + }; + }; + + chromium = { + enable = true; + package = pkgs.ungoogled-chromium; + }; + + direnv = { + enable = true; + enableBashIntegration = true; + nix-direnv.enable = true; + }; + + yt-dlp.enable = true; + + obs-studio.enable = true; + }; + + home.packages = with pkgs; [ + tldr + ventoy-full + qbittorrent + neofetch + backblaze-b2 + localsend + postman + melonDS + prismlauncher + papers + endeavour + gapless + mullvad-browser + picocrypt-cli + tutanota-desktop + inkscape + ]; + }; +} diff --git a/modules/media.nix b/modules/media.nix new file mode 100644 index 0000000..df48c30 --- /dev/null +++ b/modules/media.nix @@ -0,0 +1,22 @@ +{ pkgs, ... }: +{ + services.pipewire = { + enable = true; + alsa.enable = true; + alsa.support32Bit = true; + pulse.enable = true; + jack.enable = true; + }; + services.pulseaudio.enable = false; + + hardware.bluetooth.enable = true; + + services.printing.enable = true; + + services.mullvad-vpn = { + enable = true; + package = pkgs.mullvad-vpn; + }; + + services.resolved.enable = true; +} diff --git a/nixos-configurations/laptop/default.nix b/nixos-configurations/laptop/default.nix index ed9dd5a..4235de3 100644 --- a/nixos-configurations/laptop/default.nix +++ b/nixos-configurations/laptop/default.nix @@ -1,30 +1,26 @@ { inputs, pkgs, ... }: - { imports = [ inputs.nixos-hardware.nixosModules.lenovo-thinkpad-t480s ./hardware-configuration.nix - ../shared-desktop.nix - ../shared.nix + + ../../modules/core.nix + ../../modules/desktop.nix + ../../modules/development.nix + ../../modules/home.nix + ../../modules/media.nix ]; networking.hostName = "laptop"; - boot.initrd = { - luks.devices = { - cryptroot = { - device = "/dev/disk/by-uuid/f1b5a08f-e515-4fba-b3f4-2a1091063cdc"; - }; - }; + boot.initrd.luks.devices.cryptroot = { + device = "/dev/disk/by-uuid/f1b5a08f-e515-4fba-b3f4-2a1091063cdc"; + }; + + home-manager.users.thiloho = { + programs.git.signing.key = "3B62137A89493F7D"; + home.stateVersion = "24.11"; }; - home-manager.users.thiloho = - { pkgs, ... }: - { - programs.git.signing.key = "3B62137A89493F7D"; - home = { - stateVersion = "24.11"; - }; - }; system.stateVersion = "24.11"; } diff --git a/nixos-configurations/laptop/hardware-configuration.nix b/nixos-configurations/laptop/hardware-configuration.nix index 1cd904d..6d47996 100644 --- a/nixos-configurations/laptop/hardware-configuration.nix +++ b/nixos-configurations/laptop/hardware-configuration.nix @@ -1,32 +1,47 @@ # 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, ... }: +{ + config, + lib, + pkgs, + modulesPath, + ... +}: { - imports = - [ (modulesPath + "/installer/scan/not-detected.nix") - ]; + imports = [ + (modulesPath + "/installer/scan/not-detected.nix") + ]; - boot.initrd.availableKernelModules = [ "xhci_pci" "nvme" "usbhid" "usb_storage" "sd_mod" ]; + boot.initrd.availableKernelModules = [ + "xhci_pci" + "nvme" + "usbhid" + "usb_storage" + "sd_mod" + ]; boot.initrd.kernelModules = [ "dm-snapshot" ]; boot.kernelModules = [ ]; boot.extraModulePackages = [ ]; - fileSystems."/" = - { device = "/dev/disk/by-uuid/8c24d51b-f02d-4c0c-9894-50b4209cf8c0"; - fsType = "ext4"; - }; + fileSystems."/" = { + device = "/dev/disk/by-uuid/8c24d51b-f02d-4c0c-9894-50b4209cf8c0"; + fsType = "ext4"; + }; - fileSystems."/boot" = - { device = "/dev/disk/by-uuid/222F-191E"; - fsType = "vfat"; - options = [ "fmask=0077" "dmask=0077" ]; - }; - - swapDevices = - [ { device = "/dev/disk/by-uuid/c6a47a90-a892-43c0-82e2-74b489aabc17"; } + fileSystems."/boot" = { + device = "/dev/disk/by-uuid/222F-191E"; + fsType = "vfat"; + options = [ + "fmask=0077" + "dmask=0077" ]; + }; + + swapDevices = [ + { device = "/dev/disk/by-uuid/c6a47a90-a892-43c0-82e2-74b489aabc17"; } + ]; # 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 diff --git a/nixos-configurations/pc/default.nix b/nixos-configurations/pc/default.nix index 300c2cf..3ac340b 100644 --- a/nixos-configurations/pc/default.nix +++ b/nixos-configurations/pc/default.nix @@ -1,12 +1,15 @@ { inputs, pkgs, ... }: - { imports = [ inputs.nixos-hardware.nixosModules.common-gpu-amd inputs.nixos-hardware.nixosModules.common-cpu-amd ./hardware-configuration.nix - ../shared-desktop.nix - ../shared.nix + + ../../modules/core.nix + ../../modules/desktop.nix + ../../modules/development.nix + ../../modules/home.nix + ../../modules/media.nix ]; networking = { @@ -23,28 +26,22 @@ }; }; - boot.initrd = { - luks.devices = { - cryptroot = { - device = "/dev/disk/by-uuid/1202158c-cf4a-49f5-83f6-d54af16bca65"; - }; + boot = { + initrd.luks.devices.cryptroot = { + device = "/dev/disk/by-uuid/1202158c-cf4a-49f5-83f6-d54af16bca65"; }; + kernelParams = [ "amd_iommu=on" ]; + kernelModules = [ "v4l2loopback" ]; + extraModulePackages = [ pkgs.linuxPackages_latest.v4l2loopback ]; + extraModprobeConfig = '' + options v4l2loopback exclusive_caps=1 card_label="Virtual Webcam" + ''; }; environment.sessionVariables = { - MUTTER_DEBUG_FORCE_KMS_MODE = "simple"; + MUTTER_DEBUG_DISABLE_HW_CURSORS = "1"; }; - boot.kernelParams = [ "amd_iommu=on" ]; - - virtualisation.libvirtd.enable = true; - virtualisation.libvirtd.qemu.swtpm.enable = true; - programs.virt-manager.enable = true; - - programs.adb.enable = true; - users.users.thiloho.extraGroups = [ "adbusers" ]; - - # Use same monitor settings for GDM as for GNOME user systemd.tmpfiles.rules = [ "L+ /run/gdm/.config/monitors.xml - - - - ${pkgs.writeText "gdm-monitors.xml" '' @@ -73,16 +70,17 @@ ''}" ]; - home-manager.users.thiloho = - { pkgs, lib, ... }: - { - programs.git.signing.key = "273D6150B9741CCF"; - home = { - packages = with pkgs; [ - inkscape - ]; - stateVersion = "24.11"; - }; + home-manager.users.thiloho = { + programs.git.signing.key = "273D6150B9741CCF"; + xdg.desktopEntries.andcam = { + name = "Android Virtual Camera"; + exec = "${pkgs.writeScript "andcam" '' + ${pkgs.android-tools}/bin/adb start-server + ${pkgs.scrcpy}/bin/scrcpy --camera-id=0 --video-source=camera --no-audio --v4l2-sink=/dev/video0 -m1024 + ''}"; }; + home.stateVersion = "24.11"; + }; + system.stateVersion = "24.11"; } diff --git a/nixos-configurations/pc/hardware-configuration.nix b/nixos-configurations/pc/hardware-configuration.nix index 3e2706d..c07f2f0 100644 --- a/nixos-configurations/pc/hardware-configuration.nix +++ b/nixos-configurations/pc/hardware-configuration.nix @@ -1,32 +1,48 @@ # 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, ... }: +{ + config, + lib, + pkgs, + modulesPath, + ... +}: { - imports = - [ (modulesPath + "/installer/scan/not-detected.nix") - ]; + imports = [ + (modulesPath + "/installer/scan/not-detected.nix") + ]; - boot.initrd.availableKernelModules = [ "xhci_pci" "ahci" "nvme" "usb_storage" "usbhid" "sd_mod" ]; + boot.initrd.availableKernelModules = [ + "xhci_pci" + "ahci" + "nvme" + "usb_storage" + "usbhid" + "sd_mod" + ]; boot.initrd.kernelModules = [ "dm-snapshot" ]; boot.kernelModules = [ "kvm-amd" ]; boot.extraModulePackages = [ ]; - fileSystems."/" = - { device = "/dev/disk/by-uuid/69528c2b-4fe1-4ff8-a77b-2fc000669629"; - fsType = "ext4"; - }; + fileSystems."/" = { + device = "/dev/disk/by-uuid/69528c2b-4fe1-4ff8-a77b-2fc000669629"; + fsType = "ext4"; + }; - fileSystems."/boot" = - { device = "/dev/disk/by-uuid/139D-6775"; - fsType = "vfat"; - options = [ "fmask=0077" "dmask=0077" ]; - }; - - swapDevices = - [ { device = "/dev/disk/by-uuid/aafdb506-7d0b-40ef-b87a-c14c39688b76"; } + fileSystems."/boot" = { + device = "/dev/disk/by-uuid/139D-6775"; + fsType = "vfat"; + options = [ + "fmask=0077" + "dmask=0077" ]; + }; + + swapDevices = [ + { device = "/dev/disk/by-uuid/aafdb506-7d0b-40ef-b87a-c14c39688b76"; } + ]; # 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 diff --git a/nixos-configurations/shared-desktop.nix b/nixos-configurations/shared-desktop.nix deleted file mode 100644 index 8435b45..0000000 --- a/nixos-configurations/shared-desktop.nix +++ /dev/null @@ -1,199 +0,0 @@ -{ pkgs, lib, ... }: - -{ - environment.sessionVariables.NIXOS_OZONE_WL = "1"; - - fonts.packages = with pkgs; [ - jetbrains-mono - ]; - - services = { - xserver = { - enable = true; - displayManager.gdm.enable = true; - desktopManager.gnome = { - enable = true; - }; - excludePackages = [ pkgs.xterm ]; - }; - pipewire = { - enable = true; - alsa.enable = true; - alsa.support32Bit = true; - pulse.enable = true; - jack.enable = true; - }; - printing.enable = true; - resolved.enable = true; - mullvad-vpn = { - enable = true; - package = pkgs.mullvad-vpn; - }; - }; - - environment.gnome.excludePackages = with pkgs; [ - gnome-tour - gnome-connections - geary - evince - gnome-contacts - gnome-maps - gnome-music - snapshot - simple-scan - ]; - - users = { - mutableUsers = false; - users = { - root.hashedPassword = "$y$j9T$gdQiD91dRc1rEURkntnkh1$9VvI8xhvCMqhSSOeOkiSnjHsQVUOOH/4Sbou.w6P5TC"; - thiloho = { - isNormalUser = true; - extraGroups = [ - "wheel" - "networkmanager" - "docker" - ]; - hashedPassword = "$y$j9T$0wgXXBJMy5lzuwmdvx5Lb.$G5JmfDXeXzH7sq66R.clvmlovuh1ZsZMf1SfDsWpNcB"; - }; - }; - }; - - networking.firewall = { - allowedTCPPorts = [ 53317 ]; - allowedUDPPorts = [ 53317 ]; - }; - - programs = { - dconf.enable = true; - steam.enable = true; - gnupg.agent = { - enable = true; - enableSSHSupport = true; - }; - java.enable = true; - nix-ld = { - enable = true; - libraries = with pkgs; [ - nodejs - nodePackages.pnpm - ]; - }; - }; - - services.pulseaudio.enable = false; - - hardware.bluetooth.enable = true; - - home-manager.users.thiloho = - { - pkgs, - lib, - config, - ... - }: - { - dconf.settings = { - "org/gnome/mutter" = { - experimental-features = [ - "scale-monitor-framebuffer" - "variable-refresh-rate" - "xwayland-native-scaling" - ]; - }; - }; - programs = { - yt-dlp = { - enable = true; - }; - firefox = { - enable = true; - package = pkgs.firefox-devedition.override { - cfg = { - speechSynthesisSupport = true; - }; - }; - }; - chromium = { - enable = true; - package = pkgs.ungoogled-chromium; - }; - vscode = { - enable = true; - package = pkgs.vscodium; - mutableExtensionsDir = false; - extensions = - with pkgs.vscode-extensions; - [ - # svelte.svelte-vscode - jnoortheen.nix-ide - ritwickdey.liveserver - esbenp.prettier-vscode - ] - ++ pkgs.vscode-utils.extensionsFromVscodeMarketplace [ - { - name = "svelte-vscode"; - publisher = "svelte"; - version = "108.5.4"; - sha256 = "0sjq5ifnz08pkxslzz2qnrc76gvl6lkygcr3042safbvfral4xm1"; - } - { - name = "playwright"; - publisher = "ms-playwright"; - version = "1.1.10"; - sha256 = "0y0jlrxpjzd7drdmcr9kfy5g12zax9q4d8cblzzb6ia4c98ipfq0"; - } - ]; - userSettings = { - "editor.wordWrap" = "on"; - "editor.fontFamily" = "JetBrains Mono"; - "editor.fontLigatures" = true; - "editor.indentSize" = 2; - "editor.tabSize" = 2; - "typescript.preferences.importModuleSpecifier" = "relative"; - "[svelte]" = { - "editor.defaultFormatter" = "svelte.svelte-vscode"; - }; - "svelte.enable-ts-plugin" = true; - "svelte.plugin.svelte.defaultScriptLanguage" = "ts"; - "svelte.plugin.svelte.format.config.svelteStrictMode" = true; - }; - }; - git = { - enable = true; - userName = "thiloho"; - userEmail = "123883702+thiloho@users.noreply.github.com"; - signing = { - signByDefault = true; - }; - }; - direnv = { - enable = true; - enableBashIntegration = true; - nix-direnv.enable = true; - }; - obs-studio.enable = true; - }; - home = { - packages = with pkgs; [ - tldr - ventoy-full - qbittorrent - neofetch - backblaze-b2 - localsend - postman - gnome-tweaks - gnome-themes-extra - melonDS - prismlauncher - papers - endeavour - gapless - mullvad-browser - picocrypt-cli - tutanota-desktop - ]; - }; - }; -} diff --git a/nixos-configurations/shared.nix b/nixos-configurations/shared.nix deleted file mode 100644 index 120198f..0000000 --- a/nixos-configurations/shared.nix +++ /dev/null @@ -1,43 +0,0 @@ -{ pkgs, ... }: - -{ - boot = { - loader = { - systemd-boot.enable = true; - efi.canTouchEfiVariables = true; - }; - kernelPackages = pkgs.linuxPackages_latest; - }; - - nix.settings.experimental-features = [ - "nix-command" - "flakes" - ]; - - time.timeZone = "Europe/Berlin"; - - nixpkgs.config.allowUnfree = true; - - networking.networkmanager.enable = true; - - virtualisation.docker.enable = true; - - home-manager.users.thiloho = - { ... }: - { - programs = { - bash = { - enable = true; - shellAliases = { - rbs = "sudo nixos-rebuild switch --flake ."; - cleanup = "nix store optimise && nix-collect-garbage -d && sudo nix store optimise && sudo nix-collect-garbage -d"; - }; - }; - helix = { - enable = true; - defaultEditor = true; - settings.theme = "ayu_dark"; - }; - }; - }; -}