diff --git a/flake.nix b/flake.nix index 4f85e7b..e55e22a 100644 --- a/flake.nix +++ b/flake.nix @@ -21,40 +21,28 @@ }; }; - outputs = - { self - , home-manager - , hyprland - , nixpkgs - , ... - } @ inputs: - let - system = "x86_64-linux"; - in - { - nixosConfigurations."nixos" = - let - specialArgs = inputs; - modules = [ - ./nixos.nix + outputs = { self, home-manager, hyprland, nixpkgs, ... }@inputs: + let system = "x86_64-linux"; + in { + nixosConfigurations."nixos" = let + specialArgs = inputs; + modules = [ + ./nixos.nix - hyprland.nixosModules.default - { - programs.hyprland.enable = true; - } + hyprland.nixosModules.default + { programs.hyprland.enable = true; } - home-manager.nixosModules.home-manager - { - home-manager.useGlobalPkgs = true; - home-manager.useUserPackages = true; + home-manager.nixosModules.home-manager + { + home-manager.useGlobalPkgs = true; + home-manager.useUserPackages = true; - home-manager.extraSpecialArgs = inputs; - home-manager.users.wizardlink = import ./home-manager.nix; - } - ]; - in - nixpkgs.lib.nixosSystem { inherit system specialArgs modules; }; + home-manager.extraSpecialArgs = inputs; + home-manager.users.wizardlink = import ./home-manager.nix; + } + ]; + in nixpkgs.lib.nixosSystem { inherit system specialArgs modules; }; - formatter = nixpkgs.legacyPackages.${system}.nixpkgs-fmt; + formatter."${system}" = nixpkgs.legacyPackages.${system}.nixfmt; }; } diff --git a/kernel/zenergy.nix b/kernel/zenergy.nix new file mode 100644 index 0000000..d489edd --- /dev/null +++ b/kernel/zenergy.nix @@ -0,0 +1,43 @@ +{ lib, stdenv, fetchFromGitHub, kernel, kmod }: + +let + kernelDirectory = "${kernel.dev}/lib/modules/${kernel.modDirVersion}/build"; +in +stdenv.mkDerivation { + pname = "zenergy"; + version = "a3e124477ee8197015481156b90100d49fa3cd84"; + + src = fetchFromGitHub { + owner = "BoukeHaarsma23"; + repo = "zenergy"; + rev = "a3e124477ee8197015481156b90100d49fa3cd84"; + hash = "sha256-s1aoipSsLKO23kTd2uGxVUpqYSeitiz3UIoDIxg/Dj8="; + }; + + hardeningDisable = [ "format" "pic" ]; + + makeFlags = kernel.makeFlags ++ [ + "KDIR=${kernelDirectory}" + ]; + + preBuild = '' + substituteInPlace Makefile --replace-fail "PWD modules_install" "PWD INSTALL_MOD_PATH=$out modules_install" + ''; + + nativeBuildInputs = [ kmod ] ++ kernel.moduleBuildDependencies; + + installPhase = '' + make modules_install KDIR=${kernelDirectory} + ''; + + outputs = [ "out" ]; + + meta = with lib; { + description = "Based on AMD_ENERGY driver, but with some jiffies added so non-root users can read it safely."; + homepage = "https://github.com/BoukeHaarsma23/zenergy"; + license = licenses.gpl2Only; + maintainers = with maintainers; [ wizardlink ]; + platforms = platforms.linux; + outputsToInstall = [ "out" ]; + }; +} diff --git a/nixos.nix b/nixos.nix index 2fcffec..4dc2056 100644 --- a/nixos.nix +++ b/nixos.nix @@ -9,14 +9,13 @@ ## NIXOS ## ## - imports = - [ - # Include the results of the hardware scan. - ./hardware-configuration.nix - # Include service configuration - ./services/caddy.nix - ./services/jellyfin.nix - ]; + imports = [ + # Include the results of the hardware scan. + ./hardware-configuration.nix + # Include service configuration + ./services/caddy.nix + ./services/jellyfin.nix + ]; # Enable experimental features nix.settings.experimental-features = [ "nix-command" "flakes" ]; @@ -44,13 +43,18 @@ ## # Kernel - boot.kernelPackages = pkgs.linuxPackages_xanmod_latest; + boot.kernelPackages = pkgs.linuxPackages_latest; # Add AMD drivers. boot.initrd.kernelModules = [ "amdgpu" ]; # TODO: FIX IT BEING BEING OVERWRITTEN - boot.extraModulePackages = with config.boot.kernelPackages; [ v4l2loopback ]; + boot.extraModulePackages = [ + config.boot.kernelPackages.v4l2loopback + (pkgs.callPackage ./kernel/zenergy.nix { + kernel = pkgs.linux_xanmod_latest; + }) + ]; # Bootloader. boot.loader = { @@ -87,12 +91,16 @@ 8211 # Palworld ]; - allowedTCPPortRanges = [ - { from = 1714; to = 1764; } # KDEConnect - ]; - allowedUDPPortRanges = [ - { from = 1714; to = 1764; } # KDEConnect - ]; + allowedTCPPortRanges = [{ + from = 1714; + to = 1764; + } # KDEConnect + ]; + allowedUDPPortRanges = [{ + from = 1714; + to = 1764; + } # KDEConnect + ]; }; # Or disable the firewall altogether. # networking.firewall.enable = false; @@ -125,9 +133,18 @@ # Select internationalisation properties. i18n = { defaultLocale = "en_US.UTF-8"; + supportedLocales = [ + "C.UTF-8/UTF-8" + "en_GB.UTF-8/UTF-8" + "en_US.UTF-8/UTF-8" + "ja_JP.UTF-8/UTF-8" + "pt_BR.UTF-8/UTF-8" + ]; extraLocaleSettings = { + LANGUAGE = "en_US.UTF-8"; LC_ADDRESS = "en_US.UTF-8"; + LC_ALL = "en_US.UTF-8"; LC_IDENTIFICATION = "en_US.UTF-8"; LC_MEASUREMENT = "pt_BR.UTF-8"; LC_MONETARY = "en_US.UTF-8"; @@ -137,6 +154,11 @@ LC_TELEPHONE = "pt_BR.UTF-8"; LC_TIME = "en_GB.UTF-8"; }; + + inputMethod = { + enabled = "fcitx5"; + fcitx5.addons = [ pkgs.fcitx5-mozc pkgs.fcitx5-gtk ]; + }; }; # Enable CUPS to print documents. @@ -315,6 +337,11 @@ ## SERVICES # ## + services.udev.extraRules = '' + # Monsgeek M1 + KERNEL=="hidraw*", SUBSYSTEM=="hidraw", ATTRS{idVendor}=="fffe", ATTRS{idProduct}=="0005", MODE="0660", GROUP="users", TAG+="uaccess", TAG+="udev-acl" + ''; + # Enable flatpak services.flatpak.enable = true; diff --git a/programs/neovim/default.nix b/programs/neovim/default.nix index dbc4f92..5006f5d 100644 --- a/programs/neovim/default.nix +++ b/programs/neovim/default.nix @@ -33,7 +33,7 @@ # Nix nil - nixpkgs-fmt + nixfmt # TypeScript nodePackages.typescript-language-server diff --git a/programs/neovim/user/plugins/null-ls.lua b/programs/neovim/user/plugins/null-ls.lua index 0631e7d..9e850fd 100644 --- a/programs/neovim/user/plugins/null-ls.lua +++ b/programs/neovim/user/plugins/null-ls.lua @@ -11,7 +11,7 @@ return { -- Set a formatter -- null_ls.builtins.formatting.stylua, -- null_ls.builtins.formatting.prettier, - null_ls.builtins.formatting.nixpkgs_fmt, + null_ls.builtins.formatting.nixfmt, null_ls.builtins.formatting.prettier, null_ls.builtins.formatting.rustfmt, null_ls.builtins.formatting.stylua,