From ed8c856ebfc87f211e60c1699e091c39540e93b1 Mon Sep 17 00:00:00 2001 From: K900 Date: Sun, 20 Oct 2024 18:30:58 +0300 Subject: [PATCH 1/7] kdePackages.plasma-workspace: fix substituteAll usage --- pkgs/kde/plasma/plasma-workspace/default.nix | 4 ++-- pkgs/kde/plasma/plasma-workspace/dependency-paths.patch | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/pkgs/kde/plasma/plasma-workspace/default.nix b/pkgs/kde/plasma/plasma-workspace/default.nix index 2dd596efffa5..6225f7c3b77c 100644 --- a/pkgs/kde/plasma/plasma-workspace/default.nix +++ b/pkgs/kde/plasma/plasma-workspace/default.nix @@ -24,8 +24,8 @@ mkKdeDerivation { patches = [ (substituteAll { src = ./dependency-paths.patch; - dbus-send = lib.getExe' dbus "dbus-send"; - fc-match = lib.getExe' fontconfig "fc-match"; + dbusSend = lib.getExe' dbus "dbus-send"; + fcMatch = lib.getExe' fontconfig "fc-match"; lsof = lib.getExe lsof; qdbus = lib.getExe' qttools "qdbus"; xmessage = lib.getExe xorg.xmessage; diff --git a/pkgs/kde/plasma/plasma-workspace/dependency-paths.patch b/pkgs/kde/plasma/plasma-workspace/dependency-paths.patch index d84e6dda7278..561655dde280 100644 --- a/pkgs/kde/plasma/plasma-workspace/dependency-paths.patch +++ b/pkgs/kde/plasma/plasma-workspace/dependency-paths.patch @@ -46,7 +46,7 @@ index f5034455c9..8ea57813a1 100644 connect(m_proc, &QProcess::readyReadStandardOutput, this, &CFcQuery::data); - m_proc->start(u"fc-match"_s, args); -+ m_proc->start(u"@fc-match@"_s, args); ++ m_proc->start(u"@fcMatch@"_s, args); } void CFcQuery::procExited() @@ -143,5 +143,5 @@ index 1e903130a9..1d807a8526 100644 [Service] Type=oneshot -ExecStart=dbus-send --session --reply-timeout=1 --type=method_call --dest=org.kde.KSplash /KSplash org.kde.KSplash.setStage string:ready -+ExecStart=@dbus-send@ --session --reply-timeout=1 --type=method_call --dest=org.kde.KSplash /KSplash org.kde.KSplash.setStage string:ready ++ExecStart=@dbusSend@ --session --reply-timeout=1 --type=method_call --dest=org.kde.KSplash /KSplash org.kde.KSplash.setStage string:ready Slice=session.slice From 8a9b8cd39e28342b0f051ec139f96b3ab2df7233 Mon Sep 17 00:00:00 2001 From: K900 Date: Sun, 20 Oct 2024 18:45:02 +0300 Subject: [PATCH 2/7] isc-cron: fix substituteAll usage --- pkgs/by-name/is/isc-cron/0000-nixpkgs-specific.diff | 4 ++-- pkgs/by-name/is/isc-cron/package.nix | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/pkgs/by-name/is/isc-cron/0000-nixpkgs-specific.diff b/pkgs/by-name/is/isc-cron/0000-nixpkgs-specific.diff index 0bf0a9bd6177..9bf9f89ddee2 100644 --- a/pkgs/by-name/is/isc-cron/0000-nixpkgs-specific.diff +++ b/pkgs/by-name/is/isc-cron/0000-nixpkgs-specific.diff @@ -35,10 +35,10 @@ diff -Naur cron-old/pathnames.h cron-new/pathnames.h +#define _PATH_SENDMAIL "@sendmailPath@" + +#undef _PATH_VI -+#define _PATH_VI "@VIPATH@" ++#define _PATH_VI "@viPath@" + +#undef _PATH_DEFPATH -+#define _PATH_DEFPATH "@DEFPATH@" ++#define _PATH_DEFPATH "@defPath@" + +/* Nixpkgs-specific patch end */ + diff --git a/pkgs/by-name/is/isc-cron/package.nix b/pkgs/by-name/is/isc-cron/package.nix index b52086fca473..61633c6c9c88 100644 --- a/pkgs/by-name/is/isc-cron/package.nix +++ b/pkgs/by-name/is/isc-cron/package.nix @@ -20,8 +20,8 @@ stdenv.mkDerivation (finalAttrs: { (substituteAll { src = ./0000-nixpkgs-specific.diff; inherit sendmailPath; - VIPATH = lib.getExe' vim "vim"; - DEFPATH = lib.concatStringsSep ":" [ + viPath = lib.getExe' vim "vim"; + defPath = lib.concatStringsSep ":" [ "/run/wrappers/bin" "/nix/var/nix/profiles/default/bin" "/run/current-system/sw/bin" From 359cf4b159beb299ad6663bd1c44a3e866e9713d Mon Sep 17 00:00:00 2001 From: K900 Date: Sun, 20 Oct 2024 18:51:21 +0300 Subject: [PATCH 3/7] luaformatter: fix substituteAll usage --- pkgs/by-name/lu/luaformatter/fix-lib-paths.patch | 2 +- pkgs/by-name/lu/luaformatter/package.nix | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/pkgs/by-name/lu/luaformatter/fix-lib-paths.patch b/pkgs/by-name/lu/luaformatter/fix-lib-paths.patch index 610a313ca27c..c2931c17628c 100644 --- a/pkgs/by-name/lu/luaformatter/fix-lib-paths.patch +++ b/pkgs/by-name/lu/luaformatter/fix-lib-paths.patch @@ -12,7 +12,7 @@ index 4a21b94..0ac7911 100644 - ${PROJECT_SOURCE_DIR}/third_party/antlr4/runtime/Cpp/runtime/src + @libargs@/include + @catch2@/include -+ @yaml-cpp@/include ++ @yamlCpp@/include + @antlr4RuntimeCpp@/include/antlr4-runtime ${PROJECT_SOURCE_DIR}/src/ ) diff --git a/pkgs/by-name/lu/luaformatter/package.nix b/pkgs/by-name/lu/luaformatter/package.nix index 963d00991bc5..06bb68264588 100644 --- a/pkgs/by-name/lu/luaformatter/package.nix +++ b/pkgs/by-name/lu/luaformatter/package.nix @@ -27,7 +27,8 @@ stdenv.mkDerivation rec { (substituteAll { src = ./fix-lib-paths.patch; antlr4RuntimeCpp = antlr4.runtime.cpp.dev; - inherit libargs catch2 yaml-cpp; + yamlCpp = yaml-cpp; + inherit libargs catch2; }) ]; From 3c7d6adcc82b40d251b5217921019a28e71a4a74 Mon Sep 17 00:00:00 2001 From: K900 Date: Sun, 20 Oct 2024 18:51:44 +0300 Subject: [PATCH 4/7] oh-my-fish: fix substituteAll usage --- pkgs/by-name/oh/oh-my-fish/omf-install | 4 ++-- pkgs/by-name/oh/oh-my-fish/package.nix | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/pkgs/by-name/oh/oh-my-fish/omf-install b/pkgs/by-name/oh/oh-my-fish/omf-install index 0b8be218e38a..36cc440e13a0 100644 --- a/pkgs/by-name/oh/oh-my-fish/omf-install +++ b/pkgs/by-name/oh/oh-my-fish/omf-install @@ -1,6 +1,6 @@ #!@runtimeShell@ @fish@/bin/fish \ - @OMF@/share/oh-my-fish/bin/install \ + @omf@/share/oh-my-fish/bin/install \ --noninteractive \ - --offline=@OMF@/share/oh-my-fish + --offline=@omf@/share/oh-my-fish diff --git a/pkgs/by-name/oh/oh-my-fish/package.nix b/pkgs/by-name/oh/oh-my-fish/package.nix index d18465609d91..019979bf9f39 100644 --- a/pkgs/by-name/oh/oh-my-fish/package.nix +++ b/pkgs/by-name/oh/oh-my-fish/package.nix @@ -39,7 +39,7 @@ stdenv.mkDerivation (finalAttrs: { cp -v ${substituteAll { name = "omf-install"; src = ./omf-install; - OMF = placeholder "out"; + omf = placeholder "out"; inherit fish runtimeShell; }} $out/bin/omf-install From 1f0044428f5ae1c58504e07aed930095c18410dc Mon Sep 17 00:00:00 2001 From: K900 Date: Sun, 20 Oct 2024 18:51:57 +0300 Subject: [PATCH 5/7] libsForQt5.libqofono: fix substituteAll usage --- ...01-NixOS-provide-mobile-broadband-provider-info-path.patch | 4 ++-- pkgs/development/libraries/libqofono/default.nix | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/pkgs/development/libraries/libqofono/0001-NixOS-provide-mobile-broadband-provider-info-path.patch b/pkgs/development/libraries/libqofono/0001-NixOS-provide-mobile-broadband-provider-info-path.patch index 94b4c61befe5..825c9e0c3825 100644 --- a/pkgs/development/libraries/libqofono/0001-NixOS-provide-mobile-broadband-provider-info-path.patch +++ b/pkgs/development/libraries/libqofono/0001-NixOS-provide-mobile-broadband-provider-info-path.patch @@ -16,7 +16,7 @@ index b5877ed..455167c 100644 QString provider = providerString; - query.setFocus(QUrl("/usr/share/mobile-broadband-provider-info/serviceproviders.xml")); -+ query.setFocus(QUrl("@mobile-broadband-provider-info@/share/mobile-broadband-provider-info/serviceproviders.xml")); ++ query.setFocus(QUrl("@mobileBroadbandProviderInfo@/share/mobile-broadband-provider-info/serviceproviders.xml")); if (provider.contains("\'")) { provider = provider.replace("\'", "'"); @@ -25,7 +25,7 @@ index b5877ed..455167c 100644 #ifdef QOFONO_PROVISIONING QXmlQuery query; - query.setFocus(QUrl("/usr/share/mobile-broadband-provider-info/serviceproviders.xml")); -+ query.setFocus(QUrl("@mobile-broadband-provider-info@/share/mobile-broadband-provider-info/serviceproviders.xml")); ++ query.setFocus(QUrl("@mobileBroadbandProviderInfo@/share/mobile-broadband-provider-info/serviceproviders.xml")); QString providerStr = provider; if (providerStr.contains("\'")) { diff --git a/pkgs/development/libraries/libqofono/default.nix b/pkgs/development/libraries/libqofono/default.nix index a7d7868f30b3..f337de228a3e 100644 --- a/pkgs/development/libraries/libqofono/default.nix +++ b/pkgs/development/libraries/libqofono/default.nix @@ -23,7 +23,7 @@ mkDerivation rec { patches = [ (substituteAll { src = ./0001-NixOS-provide-mobile-broadband-provider-info-path.patch; - inherit mobile-broadband-provider-info; + mobileBroadbandProviderInfo = mobile-broadband-provider-info; }) ./0001-NixOS-Skip-tests-they-re-shock-full-of-hardcoded-FHS.patch ]; From c46a2c35ab346bdb9015b780a77229b972d7a841 Mon Sep 17 00:00:00 2001 From: K900 Date: Sun, 20 Oct 2024 18:52:20 +0300 Subject: [PATCH 6/7] gnomeExtensions.gtk4-desktop-icons-ng-ding: fix substituteAll usage --- pkgs/desktops/gnome/extensions/extensionOverrides.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/desktops/gnome/extensions/extensionOverrides.nix b/pkgs/desktops/gnome/extensions/extensionOverrides.nix index ca96a3831325..e45aa28bd526 100644 --- a/pkgs/desktops/gnome/extensions/extensionOverrides.nix +++ b/pkgs/desktops/gnome/extensions/extensionOverrides.nix @@ -103,7 +103,7 @@ super: lib.trivial.pipe super [ nativeBuildInputs = [ wrapGAppsHook3 ]; patches = [ (substituteAll { - inherit gjs util-linux xdg-utils; + inherit gjs; util_linux = util-linux; xdg_utils = xdg-utils; src = ./extensionOverridesPatches/gtk4-ding_at_smedius.gitlab.com.patch; From 05624e48e28d1243aed7b0282f0cfdd9d988a8fd Mon Sep 17 00:00:00 2001 From: K900 Date: Sun, 20 Oct 2024 18:31:12 +0300 Subject: [PATCH 7/7] substituteAll: validate arguments So no one can repeat my mistakes. --- .../substitute/substitute-all.nix | 32 ++++++++++++------- 1 file changed, 21 insertions(+), 11 deletions(-) diff --git a/pkgs/build-support/substitute/substitute-all.nix b/pkgs/build-support/substitute/substitute-all.nix index f49d56041f7e..c6fc688d50e6 100644 --- a/pkgs/build-support/substitute/substitute-all.nix +++ b/pkgs/build-support/substitute/substitute-all.nix @@ -1,12 +1,22 @@ -{ stdenvNoCC }: - -args: - +{ lib, stdenvNoCC }: # see the substituteAll in the nixpkgs documentation for usage and constraints -stdenvNoCC.mkDerivation ({ - name = if args ? name then args.name else baseNameOf (toString args.src); - builder = ./substitute-all.sh; - inherit (args) src; - preferLocalBuild = true; - allowSubstitutes = false; -} // args) +args: +let + # keep this in sync with substituteAll + isInvalidArgName = x: builtins.match "^[a-z][a-zA-Z0-9_]*$" x == null; + invalidArgs = builtins.filter isInvalidArgName (builtins.attrNames args); +in + if invalidArgs == [] then + stdenvNoCC.mkDerivation ({ + name = if args ? name then args.name else baseNameOf (toString args.src); + builder = ./substitute-all.sh; + inherit (args) src; + preferLocalBuild = true; + allowSubstitutes = false; + } // args) + else throw '' + Argument names for `pkgs.substituteAll` must: + - start with a lower case ASCII letter + - only contain ASCII letters, digits and underscores + Found invalid argument names: ${lib.concatStringsSep ", " invalidArgs}. + ''