From 8dcf355819cc6cd1e87924218c1adcd900ecda84 Mon Sep 17 00:00:00 2001 From: Alexander Kassouni Date: Fri, 28 Aug 2026 23:27:52 -0700 Subject: refactor base nixos modules --- flake.lock | 25 ++++- flake.nix | 44 +++++++- machines/common/base.nix | 19 ++++ machines/common/default.nix | 12 +++ machines/common/pipewire.nix | 18 ++++ machines/common/printer.nix | 17 +++ machines/common/rip.nix | 3 + machines/common/tailscale.nix | 8 ++ machines/common/user.nix | 13 +++ machines/common/x11.nix | 14 +++ machines/hierophant/configuration.nix | 150 +-------------------------- machines/magician/configuration.nix | 49 +++++++++ machines/magician/hardware-configuration.nix | 32 ++++++ users/kassouni/fonts.nix | 6 ++ users/kassouni/home.nix | 5 + 15 files changed, 264 insertions(+), 151 deletions(-) create mode 100644 machines/common/base.nix create mode 100644 machines/common/default.nix create mode 100644 machines/common/pipewire.nix create mode 100644 machines/common/printer.nix create mode 100644 machines/common/rip.nix create mode 100644 machines/common/tailscale.nix create mode 100644 machines/common/user.nix create mode 100644 machines/common/x11.nix create mode 100644 machines/magician/configuration.nix create mode 100644 machines/magician/hardware-configuration.nix create mode 100644 users/kassouni/fonts.nix diff --git a/flake.lock b/flake.lock index bf9fb94..2b489e2 100644 --- a/flake.lock +++ b/flake.lock @@ -121,6 +121,26 @@ "type": "github" } }, + "nixos-hardware": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1787144466, + "narHash": "sha256-HHfv2/HkNSKbbSyU9iD/g8lbP6r4tl33sSw1W4rXCk0=", + "owner": "NixOS", + "repo": "nixos-hardware", + "rev": "0471accf8d0a8210b31d947497d179ecc99e0021", + "type": "github" + }, + "original": { + "owner": "NixOS", + "repo": "nixos-hardware", + "type": "github" + } + }, "nixpkgs": { "locked": { "lastModified": 1786089803, @@ -240,6 +260,7 @@ "root": { "inputs": { "home-manager": "home-manager", + "nixos-hardware": "nixos-hardware", "nixpkgs": "nixpkgs", "nixpkgs-unstable": "nixpkgs-unstable", "nixvim": "nixvim", @@ -311,8 +332,8 @@ "nixpkgs": "nixpkgs_4" }, "locked": { - "lastModified": 1787544164, - "narHash": "sha256-ez8+EU0G06ITmoAr3ubNGbYpIKf4Gl+QiX31Eu6B6l4=", + "lastModified": 1787899585, + "narHash": "sha256-X5CUTMB5s1oaHId2vg/h51lPdU5Sl/LFkiSmsR0r+s4=", "path": "/home/kassouni/Developer/xmonad-config", "type": "path" }, diff --git a/flake.nix b/flake.nix index 847d3ab..66b1f5a 100644 --- a/flake.nix +++ b/flake.nix @@ -12,6 +12,10 @@ slippi.url = "github:lytedev/slippi-nix"; slippi.inputs.nixpkgs.follows = "nixpkgs"; slippi.inputs.home-manager.follows = "home-manager"; + nixos-hardware = { + url = "github:NixOS/nixos-hardware"; + inputs.nixpkgs.follows = "nixpkgs"; + }; }; outputs = @@ -22,6 +26,7 @@ home-manager, nixvim, xmonad-config, + nixos-hardware, sidra, slippi, ... @@ -48,8 +53,44 @@ }; modules = [ ./machines/hierophant/configuration.nix - ./machines/hierophant/hardware-configuration.nix + ./machines/common + xmonad-config.nixosModules.default + slippi.nixosModules.default + home-manager.nixosModules.home-manager + { + home-manager.useGlobalPkgs = true; + home-manager.useUserPackages = true; + home-manager.extraSpecialArgs = { + pkgs-unstable = import nixpkgs-unstable { + system = "x86_64-linux"; + config.allowUnfree = true; + }; + }; + home-manager.users.kassouni = { pkgs, ... }: { + imports = [ + ./users/kassouni/home.nix + nixvim.homeModules.nixvim + xmonad-config.homeManagerModules.default + slippi.homeManagerModules.default + ]; + home.packages = [ sidra.packages.${pkgs.system}.default ]; + }; + } + ]; + }; + magician = nixpkgs.lib.nixosSystem { + system = "x86_64-linux"; + specialArgs = { + pkgs-unstable = import nixpkgs-unstable { + system = "x86_64-linux"; + config.allowUnfree = true; + }; + }; + modules = [ + ./machines/magician/configuration.nix + ./machines/common xmonad-config.nixosModules.default + nixos-hardware.nixosModules.framework-intel-core-ultra-series3 slippi.nixosModules.default home-manager.nixosModules.home-manager { @@ -73,6 +114,7 @@ } ]; }; + }; devShells = forAllSystems (system: { diff --git a/machines/common/base.nix b/machines/common/base.nix new file mode 100644 index 0000000..46c82d9 --- /dev/null +++ b/machines/common/base.nix @@ -0,0 +1,19 @@ +{...}: { + virtualisation.docker = { + enable = true; + }; + + nix.settings.experimental-features = [ + "nix-command" + "flakes" + ]; + + nixpkgs.config.allowUnfree = true; + + programs.steam.enable = true; + + time.timeZone = "America/Los_Angeles"; + i18n.defaultLocale = "en_US.UTF-8"; + + networking.networkmanager.enable = true; +} diff --git a/machines/common/default.nix b/machines/common/default.nix new file mode 100644 index 0000000..df8e60c --- /dev/null +++ b/machines/common/default.nix @@ -0,0 +1,12 @@ +{ ... }: +{ + imports = [ + ./base.nix + ./pipewire.nix + ./printer.nix + ./rip.nix + ./tailscale.nix + ./user.nix + ./x11.nix + ]; +} diff --git a/machines/common/pipewire.nix b/machines/common/pipewire.nix new file mode 100644 index 0000000..662d7fe --- /dev/null +++ b/machines/common/pipewire.nix @@ -0,0 +1,18 @@ +{...}: { + security.rtkit.enable = true; + + services.pipewire = { + enable = true; + pulse.enable = true; + alsa.enable = true; + extraConfig.pipewire."10-clock-rates" = { + "context.properties" = { + "default.clock.rate" = 48000; + "default.clock.allowed-rates" = [ + 44100 + 48000 + ]; + }; + }; + }; +} diff --git a/machines/common/printer.nix b/machines/common/printer.nix new file mode 100644 index 0000000..695d1fe --- /dev/null +++ b/machines/common/printer.nix @@ -0,0 +1,17 @@ +{pkgs, ...}: { + services.avahi = { + enable = true; + nssmdns4 = true; + openFirewall = true; + }; + + services.printing = { + enable = true; + drivers = with pkgs; [ + cups-filters + cups-browsed + ]; + }; + + services.ipp-usb.enable = true; +} diff --git a/machines/common/rip.nix b/machines/common/rip.nix new file mode 100644 index 0000000..c02ad7f --- /dev/null +++ b/machines/common/rip.nix @@ -0,0 +1,3 @@ +{ ... }: { + boot.kernelModules = [ "sg" ]; +} diff --git a/machines/common/tailscale.nix b/machines/common/tailscale.nix new file mode 100644 index 0000000..4e99eaa --- /dev/null +++ b/machines/common/tailscale.nix @@ -0,0 +1,8 @@ +{pkgs-unstable, ...}: { + services.tailscale = { + package = pkgs-unstable.tailscale; + enable = true; + extraSetFlags = [ "--ssh" ]; + extraDaemonFlags = [ "--no-logs-no-support" ]; + }; +} diff --git a/machines/common/user.nix b/machines/common/user.nix new file mode 100644 index 0000000..adac815 --- /dev/null +++ b/machines/common/user.nix @@ -0,0 +1,13 @@ +{...}: { + users.users.kassouni = { + isNormalUser = true; + home = "/home/kassouni"; + extraGroups = [ + "wheel" + "video" + "docker" + "input" + "audio" + ]; + }; +} diff --git a/machines/common/x11.nix b/machines/common/x11.nix new file mode 100644 index 0000000..ed2084a --- /dev/null +++ b/machines/common/x11.nix @@ -0,0 +1,14 @@ +{...}: { + services.displayManager.ly = { + enable = true; + x11Support = true; + }; + + services.xserver = { + enable = true; + xkb = { + layout = "us"; + options = "caps:escape"; + }; + }; +} diff --git a/machines/hierophant/configuration.nix b/machines/hierophant/configuration.nix index a9a8d2c..01a2d25 100644 --- a/machines/hierophant/configuration.nix +++ b/machines/hierophant/configuration.nix @@ -1,12 +1,5 @@ -# Edit this configuration file to define what should be installed on -# your system. Help is available in the configuration.nix(5) man page, on -# https://search.nixos.org/options and in the NixOS manual (`nixos-help`). - { - config, - lib, pkgs, - pkgs-unstable, ... }: @@ -16,158 +9,19 @@ ./hardware-configuration.nix ]; - security.polkit.enable = true; - boot.loader.systemd-boot.enable = true; boot.loader.efi.canTouchEfiVariables = true; - boot.kernelModules = [ "sg" ]; - - virtualisation.docker = { - enable = true; - }; - - nix.settings.experimental-features = [ - "nix-command" - "flakes" - ]; - - services.avahi = { - enable = true; - nssmdns4 = true; - openFirewall = true; - }; - - services.printing = { - enable = true; - drivers = with pkgs; [ - cups-filters - cups-browsed - ]; - }; - - services.ipp-usb.enable = true; - - services.gnome.gnome-keyring.enable = true; - - services.tailscale = { - package = pkgs-unstable.tailscale; - enable = true; - extraSetFlags = [ "--ssh" ]; - extraDaemonFlags = [ "--no-logs-no-support" ]; - }; - - nixpkgs.config.allowUnfree = true; hardware.graphics.enable = true; - services.xserver.enable = true; services.xserver.videoDrivers = [ "nvidia" ]; hardware.nvidia.open = true; - programs.steam.enable = true; - - services.displayManager.ly.enable = true; - services.displayManager.ly.x11Support = true; - services.xserver.displayManager.sessionCommands = '' xrandr --output DP-0 --mode 3840x2160 --rate 159.98 ''; - networking.hostName = "hierophant"; # 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. - time.timeZone = "America/Los_Angeles"; - - # 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 xkb.options in tty. - # }; - - # Configure keymap in X11 - # services.xserver.xkb.layout = "us"; - # services.xserver.xkb.options = "eurosign:e,caps:escape"; - - # Enable CUPS to print documents. - # services.printing.enable = true; - - # Enable sound. - # services.pulseaudio.enable = true; - # OR - - security.rtkit.enable = true; - - services.pipewire = { - enable = true; - pulse.enable = true; - alsa.enable = true; - extraConfig.pipewire."10-clock-rates" = { - "context.properties" = { - "default.clock.rate" = 48000; - "default.clock.allowed-rates" = [ - 44100 - 48000 - ]; - }; - }; - }; - - # Enable touchpad support (enabled default in most desktopManager). - # services.libinput.enable = true; - - # Define a user account. Don't forget to set a password with ‘passwd’. - users.users.kassouni = { - isNormalUser = true; - home = "/home/kassouni"; - extraGroups = [ - "wheel" - "video" - "docker" - "input" - "audio" - ]; # Enable 'sudo' for the user. - }; - - fonts.packages = with pkgs; [ - dejavu_fonts - ]; - - - # List packages installed in system profile. - # You can use https://search.nixos.org/ to find more packages (and options). - environment.systemPackages = with pkgs; [ ]; - - # 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; - # }; - - # List services that you want to enable: - - # Enable the OpenSSH daemon. - - # Open ports in the firewall. - # networking.firewall.allowedTCPPorts = [ ... ]; - # networking.firewall.allowedUDPPorts = [ ... ]; - # Or disable the firewall altogether. - # networking.firewall.enable = false; - - # 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; - + networking.hostName = "hierophant"; + # This option defines the first version of NixOS you have installed on this particular machine, # and is used to maintain compatibility with application data (e.g. databases) created on older NixOS versions. # diff --git a/machines/magician/configuration.nix b/machines/magician/configuration.nix new file mode 100644 index 0000000..01734eb --- /dev/null +++ b/machines/magician/configuration.nix @@ -0,0 +1,49 @@ +{...}: +{ + imports = [ + # Include the results of the hardware scan. + ./hardware-configuration.nix + ]; + + services.upower.enable = true; + + boot.loader.systemd-boot.enable = true; + boot.loader.efi.canTouchEfiVariables = true; + + hardware.graphics.enable = true; + services.xserver.videoDrivers = [ "modesetting" ]; + + environment.variables = { + "MOZ_USE_XINPUT2" = "1"; + }; + + services.xserver.displayManager.sessionCommands = '' + xrandr --output eDP-1 --mode 2880x1920 --rate 120.00 + ''; + + services.xserver.dpi = 192; + + networking.hostName = "magician"; + + services.libinput.enable = true; + + # This option defines the first version of NixOS you have installed on this particular machine, + # and is used to maintain compatibility with application data (e.g. databases) created on older NixOS versions. + # + # Most users should NEVER change this value after the initial install, for any reason, + # even if you've upgraded your system to a new NixOS release. + # + # This value does NOT affect the Nixpkgs version your packages and OS are pulled from, + # so changing it will NOT upgrade your system - see https://nixos.org/manual/nixos/stable/#sec-upgrading for how + # to actually do that. + # + # This value being lower than the current NixOS release does NOT mean your system is + # out of date, out of support, or vulnerable. + # + # Do NOT change this value unless you have manually inspected all the changes it would make to your configuration, + # and migrated your data accordingly. + # + # For more information, see `man configuration.nix` or https://nixos.org/manual/nixos/stable/options#opt-system.stateVersion . + system.stateVersion = "26.05"; # Did you read the comment? + +} diff --git a/machines/magician/hardware-configuration.nix b/machines/magician/hardware-configuration.nix new file mode 100644 index 0000000..970852d --- /dev/null +++ b/machines/magician/hardware-configuration.nix @@ -0,0 +1,32 @@ +# 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/6ec028fe-0eda-4877-83d3-dabb244f6078"; + fsType = "ext4"; + }; + + fileSystems."/boot" = + { device = "/dev/disk/by-uuid/8980-2C75"; + fsType = "vfat"; + options = [ "fmask=0077" "dmask=0077" ]; + }; + + swapDevices = [ ]; + + nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux"; + hardware.cpu.intel.npu.enable = true; + hardware.cpu.intel.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware; +} diff --git a/users/kassouni/fonts.nix b/users/kassouni/fonts.nix new file mode 100644 index 0000000..d6d40f7 --- /dev/null +++ b/users/kassouni/fonts.nix @@ -0,0 +1,6 @@ +{pkgs, ...}: { + fonts.fontconfig.enable = true; + home.packages = with pkgs; [ + dejavu_fonts + ]; +} diff --git a/users/kassouni/home.nix b/users/kassouni/home.nix index dc4675e..1b9fe48 100644 --- a/users/kassouni/home.nix +++ b/users/kassouni/home.nix @@ -11,6 +11,7 @@ ./fuzzel.nix ./rofi.nix ./music.nix + ./fonts.nix ./slippi.nix ./ssh.nix ./rip.nix @@ -65,6 +66,10 @@ services.picom = { enable = true; + # modesetting has no TearFree option, so the compositor has to do the + # syncing. home-manager defaults vSync to false, which tears. + backend = "glx"; + vSync = true; }; services.syncthing.enable = true; -- cgit v1.3.1