From 8e1544c7dea24f691312641f38519a1a165c7d70 Mon Sep 17 00:00:00 2001 From: Elias Graf Date: Thu, 14 May 2026 15:38:14 +0200 Subject: [PATCH] fix(modules.symlinkScript): substitute replace-literal with sd --- modules/symlinkScript/checks/filesToPatch.nix | 78 +++++++++++++------ modules/symlinkScript/module.nix | 4 +- 2 files changed, 55 insertions(+), 27 deletions(-) diff --git a/modules/symlinkScript/checks/filesToPatch.nix b/modules/symlinkScript/checks/filesToPatch.nix index af1fa392..01b9f1ef 100644 --- a/modules/symlinkScript/checks/filesToPatch.nix +++ b/modules/symlinkScript/checks/filesToPatch.nix @@ -7,36 +7,47 @@ let # Create a dummy package with a desktop file that references itself dummyPackage = - (pkgs.runCommand "dummy-app" { } '' - mkdir -p $out/bin - mkdir -p $out/share/applications + (pkgs.runCommand "dummy-app" + { + nativeBuildInputs = [ pkgs.makeBinaryWrapper ]; + } + '' + mkdir -p $out/bin + mkdir -p $out/share/applications - # Create a simple executable - cat > $out/bin/dummy-app <<'EOF' - #!/bin/sh - echo "Hello from dummy app" - EOF - chmod +x $out/bin/dummy-app + # Make a dummy program to have a valid package + makeWrapper ${pkgs.hello}/bin/hello $out/bin/dummy-app - # Create a desktop file that references the package path - cat > $out/share/applications/dummy-app.desktop < $out/share/applications/dummy-app.desktop < "$file" + # Use `sd` which works for both text and binary files + ${pkgs.sd}/bin/sd --fixed-strings "$oldPath" "$newPath" < "$target" > "$file" # Preserve permissions chmod --reference="$target" "$file" fi