chore: use nixfmt instead of nixpkgs-fmt and add zenergy kernel module

This commit is contained in:
Alexandre Cavalheiro 2024-03-25 22:29:41 -03:00
parent d784cb0241
commit caa804bf86
Signed by: wizardlink
GPG key ID: A5767B54367CFBDF
5 changed files with 107 additions and 49 deletions

View file

@ -21,27 +21,16 @@
}; };
}; };
outputs = outputs = { self, home-manager, hyprland, nixpkgs, ... }@inputs:
{ self let system = "x86_64-linux";
, home-manager in {
, hyprland nixosConfigurations."nixos" = let
, nixpkgs
, ...
} @ inputs:
let
system = "x86_64-linux";
in
{
nixosConfigurations."nixos" =
let
specialArgs = inputs; specialArgs = inputs;
modules = [ modules = [
./nixos.nix ./nixos.nix
hyprland.nixosModules.default hyprland.nixosModules.default
{ { programs.hyprland.enable = true; }
programs.hyprland.enable = true;
}
home-manager.nixosModules.home-manager home-manager.nixosModules.home-manager
{ {
@ -52,9 +41,8 @@
home-manager.users.wizardlink = import ./home-manager.nix; home-manager.users.wizardlink = import ./home-manager.nix;
} }
]; ];
in in nixpkgs.lib.nixosSystem { inherit system specialArgs modules; };
nixpkgs.lib.nixosSystem { inherit system specialArgs modules; };
formatter = nixpkgs.legacyPackages.${system}.nixpkgs-fmt; formatter."${system}" = nixpkgs.legacyPackages.${system}.nixfmt;
}; };
} }

43
kernel/zenergy.nix Normal file
View file

@ -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" ];
};
}

View file

@ -9,8 +9,7 @@
## NIXOS ## ## NIXOS ##
## ##
imports = imports = [
[
# Include the results of the hardware scan. # Include the results of the hardware scan.
./hardware-configuration.nix ./hardware-configuration.nix
# Include service configuration # Include service configuration
@ -44,13 +43,18 @@
## ##
# Kernel # Kernel
boot.kernelPackages = pkgs.linuxPackages_xanmod_latest; boot.kernelPackages = pkgs.linuxPackages_latest;
# Add AMD drivers. # Add AMD drivers.
boot.initrd.kernelModules = [ "amdgpu" ]; boot.initrd.kernelModules = [ "amdgpu" ];
# TODO: FIX IT BEING BEING OVERWRITTEN # 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. # Bootloader.
boot.loader = { boot.loader = {
@ -87,11 +91,15 @@
8211 # Palworld 8211 # Palworld
]; ];
allowedTCPPortRanges = [ allowedTCPPortRanges = [{
{ from = 1714; to = 1764; } # KDEConnect from = 1714;
to = 1764;
} # KDEConnect
]; ];
allowedUDPPortRanges = [ allowedUDPPortRanges = [{
{ from = 1714; to = 1764; } # KDEConnect from = 1714;
to = 1764;
} # KDEConnect
]; ];
}; };
# Or disable the firewall altogether. # Or disable the firewall altogether.
@ -125,9 +133,18 @@
# Select internationalisation properties. # Select internationalisation properties.
i18n = { i18n = {
defaultLocale = "en_US.UTF-8"; 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 = { extraLocaleSettings = {
LANGUAGE = "en_US.UTF-8";
LC_ADDRESS = "en_US.UTF-8"; LC_ADDRESS = "en_US.UTF-8";
LC_ALL = "en_US.UTF-8";
LC_IDENTIFICATION = "en_US.UTF-8"; LC_IDENTIFICATION = "en_US.UTF-8";
LC_MEASUREMENT = "pt_BR.UTF-8"; LC_MEASUREMENT = "pt_BR.UTF-8";
LC_MONETARY = "en_US.UTF-8"; LC_MONETARY = "en_US.UTF-8";
@ -137,6 +154,11 @@
LC_TELEPHONE = "pt_BR.UTF-8"; LC_TELEPHONE = "pt_BR.UTF-8";
LC_TIME = "en_GB.UTF-8"; LC_TIME = "en_GB.UTF-8";
}; };
inputMethod = {
enabled = "fcitx5";
fcitx5.addons = [ pkgs.fcitx5-mozc pkgs.fcitx5-gtk ];
};
}; };
# Enable CUPS to print documents. # Enable CUPS to print documents.
@ -315,6 +337,11 @@
## SERVICES # ## 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 # Enable flatpak
services.flatpak.enable = true; services.flatpak.enable = true;

View file

@ -33,7 +33,7 @@
# Nix # Nix
nil nil
nixpkgs-fmt nixfmt
# TypeScript # TypeScript
nodePackages.typescript-language-server nodePackages.typescript-language-server

View file

@ -11,7 +11,7 @@ return {
-- Set a formatter -- Set a formatter
-- null_ls.builtins.formatting.stylua, -- null_ls.builtins.formatting.stylua,
-- null_ls.builtins.formatting.prettier, -- 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.prettier,
null_ls.builtins.formatting.rustfmt, null_ls.builtins.formatting.rustfmt,
null_ls.builtins.formatting.stylua, null_ls.builtins.formatting.stylua,