Skip to content

Commit

Permalink
substituteAll: disallow invalid arguments, fix plasma-workspace (#350039
Browse files Browse the repository at this point in the history
)
  • Loading branch information
K900 authored Oct 20, 2024
2 parents 926039f + 05624e4 commit 2a95839
Show file tree
Hide file tree
Showing 12 changed files with 39 additions and 28 deletions.
32 changes: 21 additions & 11 deletions pkgs/build-support/substitute/substitute-all.nix
Original file line number Diff line number Diff line change
@@ -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}.
''
4 changes: 2 additions & 2 deletions pkgs/by-name/is/isc-cron/0000-nixpkgs-specific.diff
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
+
Expand Down
4 changes: 2 additions & 2 deletions pkgs/by-name/is/isc-cron/package.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion pkgs/by-name/lu/luaformatter/fix-lib-paths.patch
Original file line number Diff line number Diff line change
Expand Up @@ -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/
)
Expand Down
3 changes: 2 additions & 1 deletion pkgs/by-name/lu/luaformatter/package.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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;
})
];

Expand Down
4 changes: 2 additions & 2 deletions pkgs/by-name/oh/oh-my-fish/omf-install
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion pkgs/by-name/oh/oh-my-fish/package.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion pkgs/desktops/gnome/extensions/extensionOverrides.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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("\'", "'");
Expand All @@ -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("\'")) {
Expand Down
2 changes: 1 addition & 1 deletion pkgs/development/libraries/libqofono/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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
];
Expand Down
4 changes: 2 additions & 2 deletions pkgs/kde/plasma/plasma-workspace/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions pkgs/kde/plasma/plasma-workspace/dependency-paths.patch
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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

0 comments on commit 2a95839

Please sign in to comment.