From d74acf195427c9d28a0beaa070d0320b185489d7 Mon Sep 17 00:00:00 2001 From: Graham Christensen Date: Wed, 23 Apr 2025 20:54:53 -0400 Subject: [PATCH] Hide the "dirty" notice when running nix develop In the common case, nix develop is running against a dirty checkout of a project. This patch removes the warning about a dirty tree on nix develop only. Close FH-736 --- src/libcmd/include/nix/cmd/command.hh | 2 ++ src/libcmd/installables.cc | 5 +++++ src/nix/develop.cc | 6 ++++++ 3 files changed, 13 insertions(+) diff --git a/src/libcmd/include/nix/cmd/command.hh b/src/libcmd/include/nix/cmd/command.hh index 6b6418f51..11981a769 100644 --- a/src/libcmd/include/nix/cmd/command.hh +++ b/src/libcmd/include/nix/cmd/command.hh @@ -214,6 +214,8 @@ struct InstallableCommand : virtual Args, SourceExprCommand { InstallableCommand(); + virtual void preRun(ref store); + virtual void run(ref store, ref installable) = 0; void run(ref store) override; diff --git a/src/libcmd/installables.cc b/src/libcmd/installables.cc index edfe8c15a..1047f94f1 100644 --- a/src/libcmd/installables.cc +++ b/src/libcmd/installables.cc @@ -903,8 +903,13 @@ InstallableCommand::InstallableCommand() }); } +void InstallableCommand::preRun(ref store) +{ +} + void InstallableCommand::run(ref store) { + preRun(store); auto installable = parseInstallable(store, _installable); run(store, std::move(installable)); } diff --git a/src/nix/develop.cc b/src/nix/develop.cc index 00572697a..02947ff41 100644 --- a/src/nix/develop.cc +++ b/src/nix/develop.cc @@ -1,5 +1,6 @@ #include "nix/util/config-global.hh" #include "nix/expr/eval.hh" +#include "nix/fetchers/fetch-settings.hh" #include "nix/cmd/installable-flake.hh" #include "nix/cmd/command-installable-value.hh" #include "nix/main/common-args.hh" @@ -583,6 +584,11 @@ struct CmdDevelop : Common, MixEnvironment ; } + void preRun(ref store) override + { + fetchSettings.warnDirty = false; + } + void run(ref store, ref installable) override { auto [buildEnvironment, gcroot] = getBuildEnvironment(store, installable);