diff --git a/flake.lock b/flake.lock index 3cd87ac..46b5e3d 100644 --- a/flake.lock +++ b/flake.lock @@ -223,16 +223,15 @@ "linux-ntfs": { "flake": false, "locked": { - "lastModified": 1778111793, - "narHash": "sha256-E+f1utc2Az4ZmqvkZ8lDgHpXsheJobUMbLff1vdpQHE=", - "owner": "Lumpiasty", + "lastModified": 1777784940, + "narHash": "sha256-Dbh1r86X0uNx8keTkdg+uzq4/+DHm+IiTuxrHXlklXA=", + "owner": "namjaejeon", "repo": "linux-ntfs", - "rev": "7fbf82056e26d99bfa4d5aab87ce287cd8c8cbef", + "rev": "9e031cf453d8b3c226aac7cb7105af46efd79690", "type": "github" }, "original": { - "owner": "Lumpiasty", - "ref": "main", + "owner": "namjaejeon", "repo": "linux-ntfs", "type": "github" } diff --git a/flake.nix b/flake.nix index 7bbc006..dbdd86d 100644 --- a/flake.nix +++ b/flake.nix @@ -38,7 +38,6 @@ ntfsplus = { url = "github:cmspam/ntfsplus-flake"; inputs.nixpkgs.follows = "nixpkgs"; - inputs.linux-ntfs.url = "github:Lumpiasty/linux-ntfs/main"; }; nix-skills = { url = "github:sudosubin/nix-skills"; diff --git a/lib/mkNixosSystem.nix b/lib/mkNixosSystem.nix index 5269077..c0bc477 100644 --- a/lib/mkNixosSystem.nix +++ b/lib/mkNixosSystem.nix @@ -23,6 +23,7 @@ nixpkgs.lib.nixosSystem { inherit plasma-manager; inherit acer-wmi-ext; inherit nixpkgs-linuxeol; + inherit ntfsplus; }; modules = [ { @@ -41,7 +42,6 @@ nixpkgs.lib.nixosSystem { home-manager.nixosModules.home-manager nix-sweep.nixosModules.default peerix.nixosModules.peerix - ntfsplus.nixosModules.default ../modules hostConfig ]; diff --git a/modules/default.nix b/modules/default.nix index f01d345..a4036ec 100644 --- a/modules/default.nix +++ b/modules/default.nix @@ -7,6 +7,7 @@ hardware/no-mitigations.nix hardware/acer-undervolt.nix + system/ntfsplus.nix system/roles.nix system/nixpkgs.nix system/location.nix diff --git a/modules/hardware/acer-undervolt.nix b/modules/hardware/acer-undervolt.nix index 52d7bd0..ad25374 100644 --- a/modules/hardware/acer-undervolt.nix +++ b/modules/hardware/acer-undervolt.nix @@ -1,42 +1,35 @@ -{ config, lib, pkgs, modulesPath, ... }: +{ config, lib, pkgs, ... }: + +# Manual undervolting / power tuning for Ryzen 7 8845HS (Hawk Point, znver4). +# +# Provides: +# - ryzen_smu kernel module (loaded at boot) +# - ryzenadj userspace tool for poking the SMU +# +# nixpkgs already ships: +# - linuxPackages.ryzen-smu from the amkillam fork (Phoenix/Hawk Point aware) +# - ryzenadj v0.17.0 which has Hawk Point support and talks to ryzen_smu +# via the kernel module backend (preferred over /dev/mem). +# So no custom forks/overrides are needed any more. +# +# This module deliberately does NOT apply any tuning automatically. +# Run `ryzenadj` manually as root to experiment, then come back with +# results and we'll decide whether to wire in a systemd service to +# persist values across boot / resume. { - options.lumpiasty.acerUndervolt = lib.mkEnableOption "Enable Acer undervolt module"; + options.lumpiasty.acerUndervolt = lib.mkEnableOption "ryzenadj + ryzen_smu tooling for Acer 8845HS"; - config = lib.mkIf config.lumpiasty.acerUndervolt ( - let - # Use forked version of ryzen_smu - # https://github.com/FlyGoat/RyzenAdj/issues/350#issuecomment-2971428510 - ryzen-smu = config.boot.kernelPackages.ryzen-smu.overrideAttrs (oldAttrs: { - src = pkgs.fetchFromGitHub { - owner = "amkillam"; - repo = "ryzen_smu"; - rev = "172c316f53ac8f066afd7cb9e1da517084273368"; - sha256 = "sha256-U2UMWY7XgLXOpNgl2OsFBRvZSC4/qLa9rzJxFOpZ830="; - }; - }); - ryzenadj = pkgs.ryzenadj.overrideAttrs (oldAttrs: { - src = pkgs.fetchFromGitHub { - owner = "FlyGoat"; - repo = "RyzenAdj"; - rev = "7aeb2f4869ee52ac161ee4cb4871e29113487885"; - sha256 = "sha256-KE2dbGv4V3+ibyxJ/DHNnBOGzjAcZbGrC3cVGNDsTTQ="; - }; - }); - in { - # Undervolting - boot.kernelModules = [ "ryzen-smu" ]; + config = lib.mkIf config.lumpiasty.acerUndervolt { + boot.kernelModules = [ "ryzen_smu" ]; + boot.extraModulePackages = [ config.boot.kernelPackages.ryzen-smu ]; - boot.extraModulePackages = [ - ryzen-smu - ]; - - environment.systemPackages = [ - ryzenadj - ryzen-smu - ]; + environment.systemPackages = [ pkgs.ryzenadj ]; + # CoreCtrl for GPU/iGPU tuning + amdgpu overdrive for clock/voltage + # control on the 780M iGPU. Orthogonal to CPU undervolt but lives + # naturally in the same module. programs.corectrl.enable = true; hardware.amdgpu.overdrive.enable = true; - }); -} \ No newline at end of file + }; +} diff --git a/modules/system/ntfsplus-patches/0001-fix-windows_names-option.patch b/modules/system/ntfsplus-patches/0001-fix-windows_names-option.patch new file mode 100644 index 0000000..9067952 --- /dev/null +++ b/modules/system/ntfsplus-patches/0001-fix-windows_names-option.patch @@ -0,0 +1,25 @@ +From 8b5c5d23c1218a996a1d6780ca56853454813418 Mon Sep 17 00:00:00 2001 +From: Lumpiasty +Date: Thu, 7 May 2026 01:50:05 +0200 +Subject: [PATCH 1/2] fix windows_names option + +--- + super.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/super.c b/super.c +index 875fb5a..49ad898 100644 +--- a/super.c ++++ b/super.c +@@ -91,7 +91,7 @@ static const struct fs_parameter_spec ntfs_parameters[] = { + fsparam_flag("sys_immutable", Opt_sys_immutable), + fsparam_flag("nohidden", Opt_nohidden), + fsparam_flag("hide_dot_files", Opt_hide_dot_files), +- fsparam_flag("windows_names", Opt_check_windows_names), ++ fsparam_bool("windows_names", Opt_check_windows_names), + fsparam_flag("acl", Opt_acl), + fsparam_flag("discard", Opt_discard), + fsparam_flag("sparse", Opt_sparse), +-- +2.53.0 + diff --git a/modules/system/ntfsplus-patches/0002-gate-bad-character-check-by-windows_names.patch b/modules/system/ntfsplus-patches/0002-gate-bad-character-check-by-windows_names.patch new file mode 100644 index 0000000..41cf026 --- /dev/null +++ b/modules/system/ntfsplus-patches/0002-gate-bad-character-check-by-windows_names.patch @@ -0,0 +1,32 @@ +From 7fbf82056e26d99bfa4d5aab87ce287cd8c8cbef Mon Sep 17 00:00:00 2001 +From: Lumpiasty +Date: Thu, 7 May 2026 01:56:33 +0200 +Subject: [PATCH 2/2] gate bad character check by windows_names + +--- + namei.c | 6 +++--- + 1 file changed, 3 insertions(+), 3 deletions(-) + +diff --git a/namei.c b/namei.c +index 9e937d1..7369943 100644 +--- a/namei.c ++++ b/namei.c +@@ -61,12 +61,12 @@ static int ntfs_check_bad_windows_name(struct ntfs_volume *vol, + const __le16 *wc, + unsigned int wc_len) + { +- if (ntfs_check_bad_char(wc, wc_len)) +- return -EINVAL; +- + if (!NVolCheckWindowsNames(vol)) + return 0; + ++ if (ntfs_check_bad_char(wc, wc_len)) ++ return -EINVAL; ++ + /* Check for trailing space or dot. */ + if (wc_len > 0 && + (wc[wc_len - 1] == cpu_to_le16(' ') || +-- +2.53.0 + diff --git a/modules/system/ntfsplus.nix b/modules/system/ntfsplus.nix new file mode 100644 index 0000000..a4a3552 --- /dev/null +++ b/modules/system/ntfsplus.nix @@ -0,0 +1,78 @@ +{ config, pkgs, lib, ntfsplus, ... }: + +# Builds and loads the ntfsplus kernel driver (github:namjaejeon/linux-ntfs), +# a maintained out-of-tree NTFS driver for Linux 6.1+. +# +# The upstream driver is used as-is, with two local patches applied on top +# (see ntfsplus-patches/). This avoids maintaining a fork that would need +# rebasing on every upstream update — patches are plain files that apply +# cleanly regardless of upstream churn. +# +# The ntfsplus flake's nixosModule is NOT used directly. It builds the kernel +# module as a `let` binding inside the module closure — not exposed as a +# package in its flake outputs — so there is nothing in pkgs to override. +# Replicating the module here is the only way to substitute a patched source. +# +# The ntfsplus flake (github:cmspam/ntfsplus-flake) is reused only for: +# - its linux-ntfs source input (ntfsplus.inputs.linux-ntfs) +# - its bundled Makefile (${ntfsplus}/Makefile) +# The flake ships its own Makefile because the upstream repo's Makefile +# has an ifneq KERNELRELEASE guard that breaks the out-of-tree nix build. +# +# The derivation is built inside this module (not via an overlay) so that +# config.boot.kernelPackages.kernel resolves to whatever kernel the host +# declares, with no extra indirection or per-host maintenance. +# +# ntfsplus is passed in via specialArgs in lib/mkNixosSystem.nix. + +let + cfg = config.services.ntfsplus; + + patchedSrc = pkgs.applyPatches { + name = "linux-ntfs-patched"; + src = ntfsplus.inputs.linux-ntfs; + patches = [ + # fsparam_flag → fsparam_bool so windows_names=0/1 is accepted as a + # mount option rather than being treated as a bare flag. + ./ntfsplus-patches/0001-fix-windows_names-option.patch + # Gate the bad-character check behind NVolCheckWindowsNames so that + # the check only runs when windows_names is actually enabled. + ./ntfsplus-patches/0002-gate-bad-character-check-by-windows_names.patch + ]; + }; + + ntfsplus-mod = pkgs.stdenv.mkDerivation { + pname = "ntfsplus-module"; + version = ntfsplus.inputs.linux-ntfs.shortRev or ntfsplus.inputs.linux-ntfs.rev; + src = patchedSrc; + nativeBuildInputs = config.boot.kernelPackages.kernel.moduleBuildDependencies; + preBuild = "cp ${ntfsplus}/Makefile Makefile"; + makeFlags = [ + "KDIR=${config.boot.kernelPackages.kernel.dev}/lib/modules/${config.boot.kernelPackages.kernel.modDirVersion}/build" + "KVERSION=${config.boot.kernelPackages.kernel.modDirVersion}" + "CONFIG_NTFS_FS_POSIX_ACL=y" + ]; + installPhase = '' + mkdir -p $out/lib/modules/${config.boot.kernelPackages.kernel.modDirVersion}/extra + cp ntfs.ko $out/lib/modules/${config.boot.kernelPackages.kernel.modDirVersion}/extra/ + ''; + }; +in +{ + options.services.ntfsplus = { + enable = lib.mkEnableOption "ntfsplus kernel driver and utilities"; + }; + + config = lib.mkIf cfg.enable { + boot.extraModulePackages = [ ntfsplus-mod ]; + boot.kernelModules = [ "ntfs" ]; + boot.extraModprobeConfig = '' + alias fs-ntfs ntfs + alias ntfsplus ntfs + ''; + services.udev.extraRules = '' + SUBSYSTEM=="block", ENV{ID_FS_TYPE}=="ntfs", ENV{ID_FS_TYPE}="ntfs" + ''; + environment.systemPackages = [ pkgs.ntfsprogs-plus ]; + }; +}