From d9b73bfd43ff31590a16c05fb87112c6f56cee62 Mon Sep 17 00:00:00 2001 From: LavaDesu Date: Sat, 26 Jun 2021 23:48:15 +0700 Subject: [PATCH] refactoring - overlays/{linux,wine-osu}.nix -> packages/{linux-lava,wine-osu}/ - overlays/misc/ -> overlays/patches/ - overlays/misc/0001...patch -> packages/linux-lava/si...patch - overlays/misc/wine/ -> packages/wine-osu/patches/ - flake.nix: - overlays are dynamically read from overlays/ - define custom packages separately - packages/* - now imported using callPackage --- flake.nix | 53 +++---- hosts/winter/kernel.nix | 2 +- overlays/linux.nix | 126 ----------------- overlays/{misc => patches}/startx.patch | 0 overlays/{misc => patches}/transcrypt.patch | 0 overlays/transcrypt.nix | 2 +- overlays/wine-osu.nix | 45 ------ overlays/xinit.nix | 2 +- packages/linux-lava/default.nix | 129 ++++++++++++++++++ .../linux-lava/si-manual-clocking.patch | 0 packages/wine-osu/default.nix | 51 +++++++ .../0001-Revert-to-5.14-winepulse.drv.patch | 0 .../patches}/0002-5.14-Latency-Fix.patch | 0 ...h-from-invalid-context-in-Initialize.patch | 0 ...he-last-used-locale-sortguid-mapping.patch | 0 15 files changed, 210 insertions(+), 200 deletions(-) delete mode 100644 overlays/linux.nix rename overlays/{misc => patches}/startx.patch (100%) rename overlays/{misc => patches}/transcrypt.patch (100%) delete mode 100644 overlays/wine-osu.nix create mode 100644 packages/linux-lava/default.nix rename overlays/misc/0001-Lava-s-amdgpu-patches.patch => packages/linux-lava/si-manual-clocking.patch (100%) create mode 100644 packages/wine-osu/default.nix rename {overlays/misc/wine => packages/wine-osu/patches}/0001-Revert-to-5.14-winepulse.drv.patch (100%) rename {overlays/misc/wine => packages/wine-osu/patches}/0002-5.14-Latency-Fix.patch (100%) rename {overlays/misc/wine => packages/wine-osu/patches}/0003-secur32-Fix-crash-from-invalid-context-in-Initialize.patch (100%) rename {overlays/misc/wine => packages/wine-osu/patches}/0004-kernelbase-Cache-last-used-locale-sortguid-mapping.patch (100%) diff --git a/flake.nix b/flake.nix index 2995406..f1585df 100644 --- a/flake.nix +++ b/flake.nix @@ -9,6 +9,26 @@ outputs = inputs: with inputs; let + getPaths = root: builtins.map + (path: root + ("/" + path)) # Prepends root path + (builtins.attrNames (builtins.readDir root)); # Reads root path + + customPackages = pkgs: + let + callPackage = pkgs.callPackage; + in { + linux-lava = callPackage ./packages/linux-lava {}; + wine-osu = callPackage ./packages/wine-osu { inherit getPaths; }; + }; + + overlays = (builtins.map + (path: import path) # Imports path + (builtins.filter + (path: nixpkgs.lib.hasSuffix ".nix" path) # Checks file extension + (getPaths ./overlays) + ) + ) ++ [(self: super: customPackages super)]; + revCount = "297098"; base = { config, ... }: { system = { @@ -19,23 +39,14 @@ }; }; nix.registry.nixpkgs.flake = nixpkgs; - nixpkgs.overlays = builtins.attrValues overlays; + nixpkgs.overlays = overlays; }; + hm-base = { - home-manager.useGlobalPkgs = true; - home-manager.useUserPackages = true; - }; - overlays = { - discord = import ./overlays/discord.nix; - linux = import ./overlays/linux.nix; - material-icons = import ./overlays/material-icons.nix; - mps-youtube = import ./overlays/mps-youtube.nix; - picom = import ./overlays/picom.nix; - polybar = import ./overlays/polybar.nix; - transcrypt = import ./overlays/transcrypt.nix; - winetricks = import ./overlays/winetricks.nix; - wine-osu = import ./overlays/wine-osu.nix; - xinit = import ./overlays/xinit.nix; + home-manager = { + useGlobalPkgs = true; + useUserPackages = true; + }; }; in { @@ -48,17 +59,7 @@ ./hosts/winter secrets.nixosModules.winter ]; - specialArgs = { inherit overlays; }; }; - - packages.x86_64-linux = - let - pkgs = import nixpkgs { - overlays = builtins.attrValues overlays; - system = "x86_64-linux"; - }; - in { - inherit (pkgs) linux-lava wine-osu; - }; + packages.x86_64-linux = customPackages nixpkgs.legacyPackages.x86_64-linux; }; } diff --git a/hosts/winter/kernel.nix b/hosts/winter/kernel.nix index 320a9c7..68f2cf6 100644 --- a/hosts/winter/kernel.nix +++ b/hosts/winter/kernel.nix @@ -1,4 +1,4 @@ -{ config, pkgs, ...}: { +{ config, pkgs, ... }: { powerManagement.cpuFreqGovernor = "ondemand"; boot = { loader = { diff --git a/overlays/linux.nix b/overlays/linux.nix deleted file mode 100644 index eceadd3..0000000 --- a/overlays/linux.nix +++ /dev/null @@ -1,126 +0,0 @@ -self: super: { - linux-lava = super.buildLinux ( - let - major = "5"; - minor = "12"; - patch = "13"; - tkg = "2da317c20ed6f70085b195639b9aad2cacf31ab5"; - - mm = "${major}.${minor}"; - mmp = "${major}.${minor}.${patch}"; - - kernelUrl = name: sha256: builtins.fetchurl { - inherit sha256; - url = "https://cdn.kernel.org/pub/linux/kernel/v${major}.x/${name}.xz"; - }; - - tkgPatch = name: sha256: { - inherit name; - patch = builtins.fetchurl { - inherit sha256; - url = "https://raw.githubusercontent.com/Frogging-Family/linux-tkg/${tkg}/linux-tkg-patches/${mm}/${name}.patch"; - }; - }; - in { - version = "${mmp}-tkg-Lava"; - isZen = true; - # TODO: - # some stuff is set in pkgs/os-specific/linux/kernel/common-config.nix - # but i have no idea how to change it - structuredExtraConfig = with super.lib.kernel; builtins.mapAttrs (_: value: super.lib.mkForce value) { - LOCALVERSION = freeform "-tkg-Lava"; - ZENIFY = yes; - FUTEX2 = yes; - MHASWELL = yes; - WINESYNC = module; - - # timers - HZ_PERIODIC = no; - NO_HZ = yes; - NO_HZ_COMMON = yes; - NO_HZ_FULL = yes; - NO_HZ_IDLE = no; - CONTEXT_TRACKING = yes; - CONTEXT_TRACKING_FORCE = yes; - # HZ_100 = yes; - HZ_1000 = yes; - HZ_1000_NODEF = yes; - - # preempt - PREEMPT = yes; - PREEMPT_COUNT = yes; - PREEMPT_VOLUNTARY = no; - PREEMPTION = yes; - PREEMPT_DYNAMIC = yes; - - # scheduler - # SCHED_ALT = yes; - # SCHED_PDS = yes; - CACULE_SCHED = yes; - - # cacule stuff - SCHED_AUTOGROUP = yes; - BSD_PROCESS_ACCT = no; - TASK_XACCT = no; - CGROUP_CPUACCT = no; - CGROUP_DEBUG = no; - - # disable numa - NUMA = no; - AMD_NUMA = no; - X86_64_ACPI_NUMA = no; - NODES_SPAN_OTHER_NODES = no; - NUMA_EMU = no; - NEED_MULTIPLE_NODES = no; - USE_PERCPU_NUMA_NODE_ID = no; - ACPI_NUMA = no; - - # disable misc debugging - SLUB_DEBUG = no; - PM_DEBUG = no; - PM_ADVANCED_DEBUG = no; - PM_SLEEP_DEBUG = no; - ACPI_DEBUG = no; - SCHED_DEBUG = no; - LATENCYTOP = no; - DEBUG_PREEMPT = no; - }; - ignoreConfigErrors = true; - - src = kernelUrl "linux-${mm}.tar" "0rn3z942vjc7bixjw066rm6kcr0x0wzgxqfq1f6xd113pzrgc3bx"; - kernelPatches = [ - # Kernel version patch - { - name = "patch-${patch}"; - patch = kernelUrl "patch-${mmp}" "17d38hns5qfbw1pajpa5y38v86r49nqnw7a3pwsay5fapj69z8w4"; - } - - # AMD SI manual clocking - { - name = "amd"; - patch = ./misc/0001-Lava-s-amdgpu-patches.patch; - } - - # Graysky gcc patches - { - name = "graysky-gcc"; - patch = builtins.fetchurl { - url = "https://raw.githubusercontent.com/graysky2/kernel_gcc_patch/d2e7942c19ee568638d3795cf52db5274a90ce0a/more-uarches-for-kernel-5.8+.patch"; - sha256 = "16jbknjlg12jxbj8cjkk01djvr01n9zz7qlzxppcqizmz55vk0wh"; - }; - } - - # TK-Glitch patches - ( tkgPatch "0002-clear-patches" "1h1gx6rq2c961d36z1szqv9xpq1xgz2bhqjsyb03jjdrdzlcv9rm" ) - ( tkgPatch "0003-cacule-${mm}" "1rgdk1x514xsjwcjjcdmggbaj6biql5p41skn98ysqbjaw7k22ib" ) - ( tkgPatch "0003-glitched-base" "1dg177i3y54z5nadc5678hm67angram2vlr314mpxv3jgsh7vj8s" ) - ( tkgPatch "0003-glitched-cfs" "1cm4s72pymxnh37da84qrzvrwbbwagk46m1xsk99ir7cjb1l1zay" ) - # ( tkgPatch "0005-glitched-pds" "0833awp8n9ngyl5spx8znwyw1lj3nacp8vg7ffysw0j5r8akv9pw" ) - ( tkgPatch "0007-v${mm}-fsync" "0mplwdglw58bmkkxix4ccwgax3r02gahax9042dx33mybdnbl0mk" ) - ( tkgPatch "0007-v${mm}-futex2_interface" "1j29zyx2s85scfhbprgb9cs11rp50glbzczl4plphli8wds342pw" ) - ( tkgPatch "0007-v${mm}-winesync" "1av2k86ns0zc3lmgbfdch1z2a808brp2jvsfl4cwwlwwb51qzipp" ) - # ( tkgPatch "0009-prjc_v${mm}-r1" "1z731jiwyc7z4d5hzd6szrxnvw0iygbqx82y2anzm32n22731dqv" ) - ( tkgPatch "0012-misc-additions" "092ws9v1snk61i6x3gbqm5m803zd81wykkdxizn7knvy2r611cbz") - ]; - }); -} diff --git a/overlays/misc/startx.patch b/overlays/patches/startx.patch similarity index 100% rename from overlays/misc/startx.patch rename to overlays/patches/startx.patch diff --git a/overlays/misc/transcrypt.patch b/overlays/patches/transcrypt.patch similarity index 100% rename from overlays/misc/transcrypt.patch rename to overlays/patches/transcrypt.patch diff --git a/overlays/transcrypt.nix b/overlays/transcrypt.nix index 85f350f..cce969a 100644 --- a/overlays/transcrypt.nix +++ b/overlays/transcrypt.nix @@ -2,7 +2,7 @@ self: super: { transcrypt = super.transcrypt.overrideAttrs(o: rec { version = "2.1.0"; - patches = [ ./misc/transcrypt.patch ]; + patches = [ ./patches/transcrypt.patch ]; src = super.fetchFromGitHub { owner = "elasticdog"; repo = "transcrypt"; diff --git a/overlays/wine-osu.nix b/overlays/wine-osu.nix deleted file mode 100644 index 78be721..0000000 --- a/overlays/wine-osu.nix +++ /dev/null @@ -1,45 +0,0 @@ -self: super: { - wine-osu = (super.wineStaging.overrideDerivation(o: { - patches = (o.patches or []) ++ builtins.map (e: ./misc/wine + ("/" + e)) (builtins.attrNames (builtins.readDir ./misc/wine)); - })).override { - wineRelease = "staging"; - wineBuild = "wineWow"; - - pngSupport = true; - jpegSupport = true; - tiffSupport = true; - gettextSupport = true; - fontconfigSupport = true; - alsaSupport = true; - gtkSupport = true; - openglSupport = true; - tlsSupport = true; - gstreamerSupport = true; - #cupsSupport = true; - colorManagementSupport = true; - dbusSupport = true; - mpg123Support = true; - #openalSupport = true; - #openclSupport = true; - #cairoSupport = true; - #odbcSupport = true; - netapiSupport = true; - cursesSupport = true; - vaSupport = true; - pcapSupport = true; - #v4lSupport = true; - #saneSupport = true; - gsmSupport = true; - #gphoto2Support = true; - #ldapSupport = true; - pulseaudioSupport = true; - udevSupport = true; - xineramaSupport = true; - xmlSupport = true; - vulkanSupport = true; - sdlSupport = true; - faudioSupport = true; - vkd3dSupport = true; - mingwSupport = true; - }; -} diff --git a/overlays/xinit.nix b/overlays/xinit.nix index f89ce59..f9e13c7 100644 --- a/overlays/xinit.nix +++ b/overlays/xinit.nix @@ -4,7 +4,7 @@ self: super: { # Some info: # - Make startx use $XAUTHORITY as server auth files instead of .serverauth.$$ # - Make startx respect $XINITRC and $XSERVERRC - patches = o.patches ++ [ ./misc/startx.patch ]; + patches = o.patches ++ [ ./patches/startx.patch ]; }); }; } diff --git a/packages/linux-lava/default.nix b/packages/linux-lava/default.nix new file mode 100644 index 0000000..f57ea08 --- /dev/null +++ b/packages/linux-lava/default.nix @@ -0,0 +1,129 @@ +{ + buildLinux, + kernelPatches, + lib, + ... +} @ args: +let + major = "5"; + minor = "12"; + patch = "13"; + tkg = "2da317c20ed6f70085b195639b9aad2cacf31ab5"; + + mm = "${major}.${minor}"; + mmp = "${major}.${minor}.${patch}"; + + kernelUrl = name: sha256: builtins.fetchurl { + inherit sha256; + url = "https://cdn.kernel.org/pub/linux/kernel/v${major}.x/${name}.xz"; + }; + + tkgPatch = name: sha256: { + inherit name; + patch = builtins.fetchurl { + inherit sha256; + url = "https://raw.githubusercontent.com/Frogging-Family/linux-tkg/${tkg}/linux-tkg-patches/${mm}/${name}.patch"; + }; + }; +in buildLinux (args // { + version = "${mmp}-tkg-Lava"; + isZen = true; + # TODO: + # some stuff is set in pkgs/os-specific/linux/kernel/common-config.nix + # but i have no idea how to change it + structuredExtraConfig = with lib.kernel; builtins.mapAttrs (_: value: lib.mkForce value) { + LOCALVERSION = freeform "-tkg-Lava"; + ZENIFY = yes; + FUTEX2 = yes; + MHASWELL = yes; + WINESYNC = module; + + # timers + HZ_PERIODIC = no; + NO_HZ = yes; + NO_HZ_COMMON = yes; + NO_HZ_FULL = yes; + NO_HZ_IDLE = no; + CONTEXT_TRACKING = yes; + CONTEXT_TRACKING_FORCE = yes; + # HZ_100 = yes; + HZ_1000 = yes; + HZ_1000_NODEF = yes; + + # preempt + PREEMPT = yes; + PREEMPT_COUNT = yes; + PREEMPT_VOLUNTARY = no; + PREEMPTION = yes; + PREEMPT_DYNAMIC = yes; + + # scheduler + # SCHED_ALT = yes; + # SCHED_PDS = yes; + CACULE_SCHED = yes; + + # cacule stuff + SCHED_AUTOGROUP = yes; + BSD_PROCESS_ACCT = no; + TASK_XACCT = no; + CGROUP_CPUACCT = no; + CGROUP_DEBUG = no; + + # disable numa + NUMA = no; + AMD_NUMA = no; + X86_64_ACPI_NUMA = no; + NODES_SPAN_OTHER_NODES = no; + NUMA_EMU = no; + NEED_MULTIPLE_NODES = no; + USE_PERCPU_NUMA_NODE_ID = no; + ACPI_NUMA = no; + + # disable misc debugging + SLUB_DEBUG = no; + PM_DEBUG = no; + PM_ADVANCED_DEBUG = no; + PM_SLEEP_DEBUG = no; + ACPI_DEBUG = no; + SCHED_DEBUG = no; + LATENCYTOP = no; + DEBUG_PREEMPT = no; + }; + ignoreConfigErrors = true; + + src = kernelUrl "linux-${mm}.tar" "0rn3z942vjc7bixjw066rm6kcr0x0wzgxqfq1f6xd113pzrgc3bx"; + kernelPatches = [ + # Kernel version patch + { + name = "patch-${patch}"; + patch = kernelUrl "patch-${mmp}" "17d38hns5qfbw1pajpa5y38v86r49nqnw7a3pwsay5fapj69z8w4"; + } + + # AMD SI manual clocking + { + name = "si-clock"; + patch = ./si-manual-clocking.patch; + } + + # Graysky gcc patches + { + name = "graysky-gcc"; + patch = builtins.fetchurl { + url = "https://raw.githubusercontent.com/graysky2/kernel_gcc_patch/d2e7942c19ee568638d3795cf52db5274a90ce0a/more-uarches-for-kernel-5.8+.patch"; + sha256 = "16jbknjlg12jxbj8cjkk01djvr01n9zz7qlzxppcqizmz55vk0wh"; + }; + } + + # TK-Glitch patches + ( tkgPatch "0002-clear-patches" "1h1gx6rq2c961d36z1szqv9xpq1xgz2bhqjsyb03jjdrdzlcv9rm" ) + ( tkgPatch "0003-cacule-${mm}" "1rgdk1x514xsjwcjjcdmggbaj6biql5p41skn98ysqbjaw7k22ib" ) + ( tkgPatch "0003-glitched-base" "1dg177i3y54z5nadc5678hm67angram2vlr314mpxv3jgsh7vj8s" ) + ( tkgPatch "0003-glitched-cfs" "1cm4s72pymxnh37da84qrzvrwbbwagk46m1xsk99ir7cjb1l1zay" ) + # ( tkgPatch "0005-glitched-pds" "0833awp8n9ngyl5spx8znwyw1lj3nacp8vg7ffysw0j5r8akv9pw" ) + ( tkgPatch "0007-v${mm}-fsync" "0mplwdglw58bmkkxix4ccwgax3r02gahax9042dx33mybdnbl0mk" ) + ( tkgPatch "0007-v${mm}-futex2_interface" "1j29zyx2s85scfhbprgb9cs11rp50glbzczl4plphli8wds342pw" ) + ( tkgPatch "0007-v${mm}-winesync" "1av2k86ns0zc3lmgbfdch1z2a808brp2jvsfl4cwwlwwb51qzipp" ) + # ( tkgPatch "0009-prjc_v${mm}-r1" "1z731jiwyc7z4d5hzd6szrxnvw0iygbqx82y2anzm32n22731dqv" ) + ( tkgPatch "0012-misc-additions" "092ws9v1snk61i6x3gbqm5m803zd81wykkdxizn7knvy2r611cbz") + ]; +} // (args.argsOverride or {})) diff --git a/overlays/misc/0001-Lava-s-amdgpu-patches.patch b/packages/linux-lava/si-manual-clocking.patch similarity index 100% rename from overlays/misc/0001-Lava-s-amdgpu-patches.patch rename to packages/linux-lava/si-manual-clocking.patch diff --git a/packages/wine-osu/default.nix b/packages/wine-osu/default.nix new file mode 100644 index 0000000..955fd00 --- /dev/null +++ b/packages/wine-osu/default.nix @@ -0,0 +1,51 @@ +{ + getPaths, + winePackages, + wineUnstable, + wineStaging, + ... +}: +# TODO: Use winePackages.callPackage +(wineStaging.overrideDerivation(o: { + patches = (o.patches or []) ++ getPaths ./patches; +})).override { + wineRelease = "staging"; + wineBuild = "wineWow"; + + pngSupport = true; + jpegSupport = true; + tiffSupport = true; + gettextSupport = true; + fontconfigSupport = true; + alsaSupport = true; + gtkSupport = true; + openglSupport = true; + tlsSupport = true; + gstreamerSupport = true; + #cupsSupport = true; + colorManagementSupport = true; + dbusSupport = true; + mpg123Support = true; + #openalSupport = true; + #openclSupport = true; + #cairoSupport = true; + #odbcSupport = true; + netapiSupport = true; + cursesSupport = true; + vaSupport = true; + pcapSupport = true; + #v4lSupport = true; + #saneSupport = true; + gsmSupport = true; + #gphoto2Support = true; + #ldapSupport = true; + pulseaudioSupport = true; + udevSupport = true; + xineramaSupport = true; + xmlSupport = true; + vulkanSupport = true; + sdlSupport = true; + faudioSupport = true; + vkd3dSupport = true; + mingwSupport = true; +} diff --git a/overlays/misc/wine/0001-Revert-to-5.14-winepulse.drv.patch b/packages/wine-osu/patches/0001-Revert-to-5.14-winepulse.drv.patch similarity index 100% rename from overlays/misc/wine/0001-Revert-to-5.14-winepulse.drv.patch rename to packages/wine-osu/patches/0001-Revert-to-5.14-winepulse.drv.patch diff --git a/overlays/misc/wine/0002-5.14-Latency-Fix.patch b/packages/wine-osu/patches/0002-5.14-Latency-Fix.patch similarity index 100% rename from overlays/misc/wine/0002-5.14-Latency-Fix.patch rename to packages/wine-osu/patches/0002-5.14-Latency-Fix.patch diff --git a/overlays/misc/wine/0003-secur32-Fix-crash-from-invalid-context-in-Initialize.patch b/packages/wine-osu/patches/0003-secur32-Fix-crash-from-invalid-context-in-Initialize.patch similarity index 100% rename from overlays/misc/wine/0003-secur32-Fix-crash-from-invalid-context-in-Initialize.patch rename to packages/wine-osu/patches/0003-secur32-Fix-crash-from-invalid-context-in-Initialize.patch diff --git a/overlays/misc/wine/0004-kernelbase-Cache-last-used-locale-sortguid-mapping.patch b/packages/wine-osu/patches/0004-kernelbase-Cache-last-used-locale-sortguid-mapping.patch similarity index 100% rename from overlays/misc/wine/0004-kernelbase-Cache-last-used-locale-sortguid-mapping.patch rename to packages/wine-osu/patches/0004-kernelbase-Cache-last-used-locale-sortguid-mapping.patch