diff --git a/flake.nix b/flake.nix index 153b273..896bf65 100644 --- a/flake.nix +++ b/flake.nix @@ -9,12 +9,19 @@ name = "${hostname}"; value = let - args = { inherit self inputs type; }; + args = { + inherit + self + inputs + type + hostname + ; + }; in inputs.nixpkgs.lib.nixosSystem { specialArgs = args; modules = [ - ./systems/${hostname}.nix + ./systems inputs.home-manager.nixosModules.home-manager { @@ -32,10 +39,8 @@ }; in { - # System Configurations nixosConfigurations = builtins.listToAttrs [ (mkSystem "desktop" "nemesis") - (mkSystem "desktop" "mellinoe") ]; }; diff --git a/systems/common.nix b/systems/default.nix similarity index 59% rename from systems/common.nix rename to systems/default.nix index c62ed74..9c02c5f 100644 --- a/systems/common.nix +++ b/systems/default.nix @@ -1,17 +1,93 @@ { + lib, + hostname, + pkgs, + type, + modulesPath, inputs, config, ... }: { - imports = [ - ./modules/programs/tailscale.nix - ./modules/bootloaders/systemd-boot.nix - ./modules/programs/zsh.nix - inputs.nix-index-database.nixosModules.nix-index - inputs.sops-nix.nixosModules.sops + imports = builtins.concatLists [ + [ + (modulesPath + "/installer/scan/not-detected.nix") + ./modules/bootloaders/systemd-boot.nix + ./modules/programs/tailscale.nix + ./modules/programs/zsh.nix + inputs.sops-nix.nixosModules.sops + ] + (lib.optionals (type == "desktop") [ + ../themes/cursors/banana-cursor.nix + ../themes/darkviolet.nix + ../themes/fonts/sauce-code-pro.nix + ./modules/hardware/audio.nix + ./modules/hardware/bluetooth.nix + ./modules/programs/getty.nix + ./modules/programs/hyprland.nix + ./modules/programs/hyprlock.nix + inputs.stylix.nixosModules.stylix + { + # Enable basic fonts for reasonable Unicode coverage + fonts.enableDefaultPackages = true; + + stylix = { + enable = true; + image = ../../media/wallpaper.jpg; + homeManagerIntegration.autoImport = false; + homeManagerIntegration.followSystem = false; + }; + } + ]) + (lib.optionals (hostname == "nemesis") [ + ./hw-nemesis.nix + ./modules/hardware/nvidia.nix + ./modules/hardware/cpu_amd.nix + ]) ]; + boot = { + kernelPackages = pkgs.linuxPackages_latest; + initrd.availableKernelModules = [ + "nvme" + "xhci_pci" + "ahci" + "usbhid" + "usb_storage" + "sd_mod" + ]; + }; + + system.stateVersion = "24.11"; + networking = { + hostName = hostname; + useDHCP = lib.mkDefault true; + networkmanager.enable = true; + networkmanager.wifi.backend = "iwd"; + + # Configures a simple stateful firewall. + # By default, it doesn't allow any incoming connections. + firewall = { + enable = true; + allowedTCPPorts = [ + 22 # SSH + ]; + allowedUDPPorts = [ ]; + }; + + interfaces.enp12s0.wakeOnLan.policy = [ + "phy" + "unicast" + "multicast" + "broadcast" + "arp" + "magic" + "secureon" + ]; + interfaces.enp12s0.wakeOnLan.enable = true; + + }; + users.mutableUsers = false; # Always reset users on system activation users.users.rafiq = { isNormalUser = true; @@ -57,34 +133,6 @@ i18n.defaultLocale = "en_SG.UTF-8"; - programs.nix-index-database.comma.enable = true; - - networking = { - networkmanager.enable = true; - networkmanager.wifi.backend = "iwd"; - - # Configures a simple stateful firewall. - # By default, it doesn't allow any incoming connections. - firewall = { - enable = true; - allowedTCPPorts = [ - 22 # SSH - ]; - allowedUDPPorts = [ ]; - }; - - interfaces.enp12s0.wakeOnLan.policy = [ - "phy" - "unicast" - "multicast" - "broadcast" - "arp" - "magic" - "secureon" - ]; - interfaces.enp12s0.wakeOnLan.enable = true; - }; - services.openssh.enable = true; sops = { diff --git a/systems/desktop.nix b/systems/desktop.nix deleted file mode 100644 index e5c2b4e..0000000 --- a/systems/desktop.nix +++ /dev/null @@ -1,35 +0,0 @@ -{ inputs, ... }: -{ - imports = [ - ../themes/cursors/banana-cursor.nix - ../themes/darkviolet.nix - ../themes/fonts/sauce-code-pro.nix - ./modules/programs/getty.nix - ./modules/programs/hyprland.nix - ./modules/programs/hyprlock.nix - inputs.stylix.nixosModules.stylix - ./modules/hardware/bluetooth.nix - ]; - - # Enable basic fonts for reasonable Unicode coverage - fonts.enableDefaultPackages = true; - - stylix = { - enable = true; - image = ../../media/wallpaper.jpg; - homeManagerIntegration.autoImport = false; - homeManagerIntegration.followSystem = false; - }; - - security.rtkit.enable = true; - services.pipewire = { - enable = true; - extraConfig = { }; - jack.enable = true; - pulse.enable = true; - alsa = { - enable = true; - support32Bit = true; - }; - }; -} diff --git a/systems/hw-mellinoe.nix b/systems/hw-mellinoe.nix deleted file mode 100644 index 5c20b05..0000000 --- a/systems/hw-mellinoe.nix +++ /dev/null @@ -1,39 +0,0 @@ -# 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" - "nvme" - "usb_storage" - "usbhid" - "sd_mod" - "rtsx_pci_sdmmc" - ]; - boot.initrd.kernelModules = [ ]; - boot.kernelModules = [ "kvm-intel" ]; - boot.extraModulePackages = [ ]; - - # 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.eth0.useDHCP = lib.mkDefault true; - # networking.interfaces.wlp1s0.useDHCP = lib.mkDefault true; - - nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux"; - hardware.cpu.intel.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware; -} diff --git a/systems/hw-nemesis.nix b/systems/hw-nemesis.nix index b78add1..c1aea0d 100644 --- a/systems/hw-nemesis.nix +++ b/systems/hw-nemesis.nix @@ -1,22 +1,4 @@ -# 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 = ["nvme" "xhci_pci" "ahci" "usbhid" "usb_storage" "sd_mod"]; - boot.initrd.kernelModules = []; - boot.kernelModules = ["kvm-amd"]; - boot.extraModulePackages = []; - fileSystems."/" = { device = "/dev/disk/by-uuid/e5005ea6-6c5a-4ab3-9767-ce7772582024"; fsType = "ext4"; @@ -25,19 +7,9 @@ fileSystems."/boot" = { device = "/dev/disk/by-uuid/6BBE-0E70"; fsType = "vfat"; - options = ["fmask=0077" "dmask=0077"]; + options = [ + "fmask=0077" + "dmask=0077" + ]; }; - - 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.enp12s0.useDHCP = lib.mkDefault true; - # networking.interfaces.wlp13s0.useDHCP = lib.mkDefault true; - - nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux"; - hardware.cpu.amd.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware; } diff --git a/systems/mellinoe.nix b/systems/mellinoe.nix deleted file mode 100644 index 319fc6b..0000000 --- a/systems/mellinoe.nix +++ /dev/null @@ -1,12 +0,0 @@ -{ - imports = [ - ./hw-mellinoe.nix - ./modules/common.nix - ./modules/desktop.nix - ./modules/bootloaders/systemd-boot.nix - ./modules/hardware/bluetooth.nix - ./modules/ephemeral-root.nix - ]; - networking.hostName = "mellinoe"; - system.stateVersion = "24.11"; -} diff --git a/systems/modules/hardware/audio.nix b/systems/modules/hardware/audio.nix new file mode 100644 index 0000000..eebcef7 --- /dev/null +++ b/systems/modules/hardware/audio.nix @@ -0,0 +1,13 @@ +{ + security.rtkit.enable = true; + services.pipewire = { + enable = true; + extraConfig = { }; + jack.enable = true; + pulse.enable = true; + alsa = { + enable = true; + support32Bit = true; + }; + }; +} diff --git a/systems/modules/hardware/cpu_amd.nix b/systems/modules/hardware/cpu_amd.nix new file mode 100644 index 0000000..54b9a51 --- /dev/null +++ b/systems/modules/hardware/cpu_amd.nix @@ -0,0 +1,6 @@ +{ lib, config, ... }: +{ + boot.kernelModules = [ "kvm-amd" ]; + nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux"; + hardware.cpu.amd.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware; +} diff --git a/systems/nemesis.nix b/systems/nemesis.nix deleted file mode 100644 index 76fe0b4..0000000 --- a/systems/nemesis.nix +++ /dev/null @@ -1,13 +0,0 @@ -{ pkgs, ... }: -{ - imports = [ - ./hw-nemesis.nix - ./common.nix - ./desktop.nix - ./modules/hardware/nvidia.nix - ]; - - networking.hostName = "nemesis"; - system.stateVersion = "24.11"; - boot.kernelPackages = pkgs.linuxPackages_latest; -} diff --git a/users/modules/programs/comma.nix b/users/modules/programs/comma.nix new file mode 100644 index 0000000..618fe91 --- /dev/null +++ b/users/modules/programs/comma.nix @@ -0,0 +1,9 @@ +{ inputs, ... }: +{ + imports = [ + inputs.nix-index-database.hmModules.nix-index + ]; + + programs.nix-index.enable = true; + programs.nix-index-database.comma.enable = true; +} diff --git a/users/modules/sh.nix b/users/modules/sh.nix index d7af8bc..415402f 100644 --- a/users/modules/sh.nix +++ b/users/modules/sh.nix @@ -15,6 +15,7 @@ ./programs/zoxide.nix ./programs/thefuck.nix ./programs/clipse.nix + ./programs/comma.nix ./scripts ]; home.shell.enableShellIntegration = true;