From abfad3d2958c9e6300a883bd443512c55dfeb1be Mon Sep 17 00:00:00 2001 From: K900 Date: Thu, 24 Apr 2025 12:41:47 +0300 Subject: [PATCH] treewide: substituteAll -> replaceVars/substitute substituteAll is now officially deprecated. --- modules/files.nix | 4 +--- .../command-not-found/command-not-found.nix | 9 ++++----- .../programs/firefox/profiles/search/default.nix | 8 ++++++-- tests/modules/programs/git/git.nix | 14 +++++++++----- tests/modules/programs/tmux/default-shell.nix | 15 +-------------- .../services/emacs/emacs-default-editor.nix | 3 +-- tests/modules/services/emacs/emacs-service-27.nix | 8 ++++++-- ...-service-28-after-graphical-session-target.nix | 8 ++++++-- tests/modules/services/emacs/emacs-service-28.nix | 8 ++++++-- tests/modules/services/emacs/emacs-socket-27.nix | 11 +++++++++-- tests/modules/services/emacs/emacs-socket-28.nix | 8 ++++++-- tests/modules/services/sxhkd/configuration.nix | 3 +-- 12 files changed, 56 insertions(+), 43 deletions(-) diff --git a/modules/files.nix b/modules/files.nix index 0d248dce..9efa0a9d 100644 --- a/modules/files.nix +++ b/modules/files.nix @@ -101,9 +101,7 @@ in storeDir = lib.escapeShellArg builtins.storeDir; - check = pkgs.substituteAll { - src = ./files/check-link-targets.sh; - + check = pkgs.replaceVars ./files/check-link-targets.sh { inherit (config.lib.bash) initHomeManagerLib; inherit forcedPaths storeDir; }; diff --git a/modules/programs/command-not-found/command-not-found.nix b/modules/programs/command-not-found/command-not-found.nix index 75eb8609..fe14ed48 100644 --- a/modules/programs/command-not-found/command-not-found.nix +++ b/modules/programs/command-not-found/command-not-found.nix @@ -8,17 +8,16 @@ }: let cfg = config.programs.command-not-found; - commandNotFound = pkgs.substituteAll { - name = "command-not-found"; - dir = "bin"; - src = ./command-not-found.pl; - isExecutable = true; + cnfScript = pkgs.replaceVars ./command-not-found.pl { inherit (cfg) dbPath; perl = pkgs.perl.withPackages (p: [ p.DBDSQLite p.StringShellQuote ]); }; + commandNotFound = pkgs.runCommand "command-not-found" { } '' + install -Dm555 ${cnfScript} $out/bin/command-not-found + ''; shInit = commandNotFoundHandlerName: '' # This function is called whenever a command is not found. diff --git a/tests/modules/programs/firefox/profiles/search/default.nix b/tests/modules/programs/firefox/profiles/search/default.nix index b5cc89fb..a96ae464 100644 --- a/tests/modules/programs/firefox/profiles/search/default.nix +++ b/tests/modules/programs/firefox/profiles/search/default.nix @@ -14,9 +14,13 @@ let withName = path: - pkgs.substituteAll { + pkgs.substitute { src = path; - name = cfg.wrappedPackageName; + substitutions = [ + "--replace" + "@name@" + cfg.wrappedPackageName + ]; }; in diff --git a/tests/modules/programs/git/git.nix b/tests/modules/programs/git/git.nix index c36f5e1d..ff6b91a1 100644 --- a/tests/modules/programs/git/git.nix +++ b/tests/modules/programs/git/git.nix @@ -11,12 +11,16 @@ let substituteExpected = path: - pkgs.substituteAll { + pkgs.substitute { src = path; - git_include_path = pkgs.writeText "hm_gitconfig" (builtins.readFile ./git-expected-include.conf); - git_named_include_path = pkgs.writeText "hm_gitconfigwork" ( - builtins.readFile ./git-expected-include.conf - ); + substitutions = [ + "--replace" + "@git_include_path@" + (pkgs.writeText "hm_gitconfig" (builtins.readFile ./git-expected-include.conf)) + "--replace" + "@git_named_include_path@" + (pkgs.writeText "hm_gitconfigwork" (builtins.readFile ./git-expected-include.conf)) + ]; }; in diff --git a/tests/modules/programs/tmux/default-shell.nix b/tests/modules/programs/tmux/default-shell.nix index af97f000..bd1bb198 100644 --- a/tests/modules/programs/tmux/default-shell.nix +++ b/tests/modules/programs/tmux/default-shell.nix @@ -1,15 +1,3 @@ -{ pkgs, ... }: -let - - substituteExpected = - path: - pkgs.substituteAll { - src = path; - - sensible_rtp = pkgs.tmuxPlugins.sensible.rtp; - }; - -in { config = { programs.tmux = { @@ -19,8 +7,7 @@ in nmt.script = '' assertFileExists home-files/.config/tmux/tmux.conf - assertFileContent home-files/.config/tmux/tmux.conf \ - ${substituteExpected ./default-shell.conf} + assertFileContent home-files/.config/tmux/tmux.conf ${./default-shell.conf} ''; }; } diff --git a/tests/modules/services/emacs/emacs-default-editor.nix b/tests/modules/services/emacs/emacs-default-editor.nix index f20f4d4f..04490cd5 100644 --- a/tests/modules/services/emacs/emacs-default-editor.nix +++ b/tests/modules/services/emacs/emacs-default-editor.nix @@ -15,9 +15,8 @@ }; nmt.script = "source ${ - pkgs.substituteAll { + pkgs.replaceVars ./emacs-default-editor.sh { inherit (pkgs) coreutils; - src = ./emacs-default-editor.sh; } }"; } diff --git a/tests/modules/services/emacs/emacs-service-27.nix b/tests/modules/services/emacs/emacs-service-27.nix index 33ecd141..f28301a9 100644 --- a/tests/modules/services/emacs/emacs-service-27.nix +++ b/tests/modules/services/emacs/emacs-service-27.nix @@ -29,9 +29,13 @@ assertFileContent \ home-files/.config/systemd/user/emacs.service \ - ${pkgs.substituteAll { - inherit (pkgs) runtimeShell; + ${pkgs.substitute { src = ./emacs-service-emacs.service; + substitutions = [ + "--replace" + "@runtimeShell@" + pkgs.runtimeShell + ]; }} assertFileContent \ diff --git a/tests/modules/services/emacs/emacs-service-28-after-graphical-session-target.nix b/tests/modules/services/emacs/emacs-service-28-after-graphical-session-target.nix index bc93ca3c..f5b3a6ed 100644 --- a/tests/modules/services/emacs/emacs-service-28-after-graphical-session-target.nix +++ b/tests/modules/services/emacs/emacs-service-28-after-graphical-session-target.nix @@ -30,9 +30,13 @@ assertFileContent \ home-files/.config/systemd/user/emacs.service \ - ${pkgs.substituteAll { - inherit (pkgs) runtimeShell; + ${pkgs.substitute { src = ./emacs-service-emacs-after-graphical-session-target.service; + substitutions = [ + "--replace" + "@runtimeShell@" + pkgs.runtimeShell + ]; }} assertFileContent \ diff --git a/tests/modules/services/emacs/emacs-service-28.nix b/tests/modules/services/emacs/emacs-service-28.nix index 10e8d1a4..d41d5d91 100644 --- a/tests/modules/services/emacs/emacs-service-28.nix +++ b/tests/modules/services/emacs/emacs-service-28.nix @@ -30,9 +30,13 @@ assertFileContent \ home-files/.config/systemd/user/emacs.service \ - ${pkgs.substituteAll { - inherit (pkgs) runtimeShell; + ${pkgs.substitute { src = ./emacs-service-emacs.service; + substitutions = [ + "--replace" + "@runtimeShell@" + pkgs.runtimeShell + ]; }} assertFileContent \ diff --git a/tests/modules/services/emacs/emacs-socket-27.nix b/tests/modules/services/emacs/emacs-socket-27.nix index d9a06842..a99e78bb 100644 --- a/tests/modules/services/emacs/emacs-socket-27.nix +++ b/tests/modules/services/emacs/emacs-socket-27.nix @@ -35,9 +35,16 @@ assertFileContent \ home-files/.config/systemd/user/emacs.service \ - ${pkgs.substituteAll { - inherit (pkgs) runtimeShell coreutils; + ${pkgs.substitute { src = ./emacs-socket-27-emacs.service; + substitutions = [ + "--replace" + "@runtimeShell@" + pkgs.runtimeShell + "--replace" + "@coreutils@" + pkgs.coreutils + ]; }} assertFileContent \ diff --git a/tests/modules/services/emacs/emacs-socket-28.nix b/tests/modules/services/emacs/emacs-socket-28.nix index 4d8033dd..1c94971f 100644 --- a/tests/modules/services/emacs/emacs-socket-28.nix +++ b/tests/modules/services/emacs/emacs-socket-28.nix @@ -35,9 +35,13 @@ assertFileContent \ home-files/.config/systemd/user/emacs.service \ - ${pkgs.substituteAll { - inherit (pkgs) runtimeShell coreutils; + ${pkgs.substitute { src = ./emacs-socket-28-emacs.service; + substitutions = [ + "--replace" + "@runtimeShell@" + pkgs.runtimeShell + ]; }} assertFileContent \ diff --git a/tests/modules/services/sxhkd/configuration.nix b/tests/modules/services/sxhkd/configuration.nix index bbef10f6..6358f9b3 100644 --- a/tests/modules/services/sxhkd/configuration.nix +++ b/tests/modules/services/sxhkd/configuration.nix @@ -34,8 +34,7 @@ in assertFileExists $sxhkdrc assertFileContent $sxhkdrc ${ - pkgs.substituteAll { - src = ./sxhkdrc; + pkgs.replaceVars ./sxhkdrc { inherit script; } }