From 5746458b7ab7c1f7d50a907ab07b4e9ca4ea65a1 Mon Sep 17 00:00:00 2001 From: Guanran Wang Date: Sat, 16 Dec 2023 20:05:54 +0800 Subject: [PATCH] nixos: overlays: refactor --- .../core/packages/overlays/default.nix | 13 +++++--- .../core/packages/overlays/firefox.nix | 20 ------------ .../core/packages/overlays/nautilus.nix | 31 ++++++++----------- .../core/packages/overlays/prismlauncher.nix | 20 +++++------- .../profiles/core/packages/overlays/sway.nix | 22 ++++++------- 5 files changed, 39 insertions(+), 67 deletions(-) delete mode 100644 nixos/profiles/core/packages/overlays/firefox.nix diff --git a/nixos/profiles/core/packages/overlays/default.nix b/nixos/profiles/core/packages/overlays/default.nix index d8c13ea..1a58ecf 100644 --- a/nixos/profiles/core/packages/overlays/default.nix +++ b/nixos/profiles/core/packages/overlays/default.nix @@ -1,7 +1,12 @@ -_: { +_: let + addPatches = pkg: patches: + pkg.overrideAttrs (old: { + patches = (old.patches or []) ++ patches; + }); +in { nixpkgs.overlays = [ - (import ./nautilus.nix) - (import ./prismlauncher.nix) - (import ./sway.nix) + (import ./nautilus.nix {inherit addPatches;}) + (import ./prismlauncher.nix {inherit addPatches;}) + (import ./sway.nix {inherit addPatches;}) ]; } diff --git a/nixos/profiles/core/packages/overlays/firefox.nix b/nixos/profiles/core/packages/overlays/firefox.nix deleted file mode 100644 index ce0e35e..0000000 --- a/nixos/profiles/core/packages/overlays/firefox.nix +++ /dev/null @@ -1,20 +0,0 @@ -_final: prev: { - firefox-unwrapped = prev.firefox-unwrapped.overrideAttrs (old: { - # Firefox but with .mozilla moved to .config/mozilla - # .patch file from aur/firefox-xdg - # dont actually use this, it take ages to build... =.= - patches = - (old.patches or []) - ++ [ - (prev.fetchgit { - url = "https://aur.archlinux.org/firefox-xdg.git"; - rev = "ab291ab81140867dea4c08e4e1e4e3da0c73e4a6"; - hash = "sha256-6VgCt028qs/Y5kl20qLUYwFI63pItsHPbLimOFIdsyo="; - sparseCheckout = [ - "firefox-xdg-support.diff" - ]; - } - + "/firefox-xdg-support.diff") - ]; - }); -} diff --git a/nixos/profiles/core/packages/overlays/nautilus.nix b/nixos/profiles/core/packages/overlays/nautilus.nix index 8cc8705..56c7133 100644 --- a/nixos/profiles/core/packages/overlays/nautilus.nix +++ b/nixos/profiles/core/packages/overlays/nautilus.nix @@ -1,23 +1,18 @@ -_final: prev: { +{addPatches, ...}: _final: prev: { gnome = prev.gnome // { - # Restore Nautilus's typeahead ability - # .patch file from from aur/nautilus-typeahead - nautilus = prev.gnome.nautilus.overrideAttrs (old: { - patches = - (old.patches or []) - ++ [ - (prev.fetchgit { - url = "https://aur.archlinux.org/nautilus-typeahead.git"; - rev = "26776193230b0d56f714d31d79c5e716ac413a26"; - hash = "sha256-hVWZCQwHzL4j+FcgsEhuumhBkl6d8IIbcYddh08QMJM="; - sparseCheckout = [ - "nautilus-restore-typeahead.patch" - ]; - } - + "/nautilus-restore-typeahead.patch") - ]; - }); + nautilus = addPatches prev.gnome.nautilus [ + # Restore Nautilus's typeahead ability + # https://aur.archlinux.org/packages/nautilus-typeahead + (prev.fetchpatch { + url = let + repo = "nautilus-typeahead"; + file = "nautilus-restore-typeahead.patch"; + commit = "6f75fbb04f6b108324850a0956f4bbdff0b6060b"; + in "https://aur.archlinux.org/cgit/aur.git/plain/${file}?h=${repo}&id=${commit}"; + hash = "sha256-a40vNo2Nw068GBtjVPUz6WAYRtjD0DB2bG/N14vSTxI="; + }) + ]; }; } diff --git a/nixos/profiles/core/packages/overlays/prismlauncher.nix b/nixos/profiles/core/packages/overlays/prismlauncher.nix index 33f3287..604590e 100644 --- a/nixos/profiles/core/packages/overlays/prismlauncher.nix +++ b/nixos/profiles/core/packages/overlays/prismlauncher.nix @@ -1,14 +1,10 @@ -_final: prev: { - prismlauncher = prev.prismlauncher.overrideAttrs (old: { +{addPatches, ...}: _final: prev: { + prismlauncher = addPatches prev.prismlauncher [ # Offline mode for Prism Launcher - # .patch file from some Misterio77's nix-config repo - patches = - (old.patches or []) - ++ [ - (prev.fetchpatch { - url = "https://raw.githubusercontent.com/Misterio77/nix-config/ac1d7bbcafb6be75e94448c7ae7a94d460e3129d/overlays/offline-mode-prism-launcher.diff"; - hash = "sha256-vMcAvhD0Ms4Tvwpzs/YfORc8ki7MNMurdJJ/yswfxFM="; - }) - ]; - }); + # https://github.com/Misterio77/nix-config/blob/main/overlays/offline-mode-prism-launcher.diff + (prev.fetchpatch { + url = "https://raw.githubusercontent.com/Misterio77/nix-config/ac1d7bbcafb6be75e94448c7ae7a94d460e3129d/overlays/offline-mode-prism-launcher.diff"; + hash = "sha256-vMcAvhD0Ms4Tvwpzs/YfORc8ki7MNMurdJJ/yswfxFM="; + }) + ]; } diff --git a/nixos/profiles/core/packages/overlays/sway.nix b/nixos/profiles/core/packages/overlays/sway.nix index 9e9875b..b0799b6 100644 --- a/nixos/profiles/core/packages/overlays/sway.nix +++ b/nixos/profiles/core/packages/overlays/sway.nix @@ -1,14 +1,10 @@ -_final: prev: { - sway-unwrapped = prev.sway-unwrapped.overrideAttrs (old: { - # Add input panel to sway - # .patch file from https://github.com/swaywm/sway/pull/7226 - patches = - (old.patches or []) - ++ [ - (prev.fetchurl { - url = "https://github.com/swaywm/sway/commit/d1c6e44886d1047b3aa6ff6aaac383eadd72f36a.patch"; - sha256 = "sha256-UnNnAgXVBPjhF7ytVpGEStbJK1RQuRIci5PgGEvLp80="; - }) - ]; - }); +{addPatches, ...}: _final: prev: { + sway-unwrapped = addPatches prev.sway-unwrapped [ + # text_input: Implement input-method popups + # https://github.com/swaywm/sway/pull/7226 + (prev.fetchpatch { + url = "https://github.com/swaywm/sway/commit/d1c6e44886d1047b3aa6ff6aaac383eadd72f36a.patch"; + hash = "sha256-LsCoK60FKp3d8qopGtrbCFXofxHT+kOv1e1PiLSyvsA="; + }) + ]; }