Skip to content

Commit f55eb06

Browse files
authored
Merge pull request #12492 from xokdvium/refactor/move-show-man-page-to-nix-cli
Move code related to NIX_MAN_DIR from libstore to nix-cli
2 parents 1f688d6 + b1a38b3 commit f55eb06

File tree

17 files changed

+79
-25
lines changed

17 files changed

+79
-25
lines changed

src/libmain/shared.cc

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -315,20 +315,6 @@ void printVersion(const std::string & programName)
315315
throw Exit();
316316
}
317317

318-
319-
void showManPage(const std::string & name)
320-
{
321-
restoreProcessContext();
322-
setEnv("MANPATH", settings.nixManDir.c_str());
323-
execlp("man", "man", name.c_str(), nullptr);
324-
if (errno == ENOENT) {
325-
// Not SysError because we don't want to suffix the errno, aka No such file or directory.
326-
throw Error("The '%1%' command was not found, but it is needed for '%2%' and some other '%3%' commands' help text. Perhaps you could install the '%1%' command?", "man", name.c_str(), "nix-*");
327-
}
328-
throw SysError("command 'man %1%' failed", name.c_str());
329-
}
330-
331-
332318
int handleExceptions(const std::string & programName, std::function<void()> fun)
333319
{
334320
ReceiveInterrupts receiveInterrupts; // FIXME: need better place for this

src/libmain/shared.hh

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,6 @@ struct LegacyArgs : public MixCommonArgs, public RootArgs
7070
};
7171

7272

73-
/**
74-
* Show the manual page for the specified program.
75-
*/
76-
void showManPage(const std::string & name);
77-
7873
/**
7974
* The constructor of this class starts a pager if standard output is a
8075
* terminal and $PAGER is set. Standard output is redirected to the

src/libstore/globals.cc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@ Settings::Settings()
6565
, nixStateDir(canonPath(getEnvNonEmpty("NIX_STATE_DIR").value_or(NIX_STATE_DIR)))
6666
, nixConfDir(canonPath(getEnvNonEmpty("NIX_CONF_DIR").value_or(NIX_CONF_DIR)))
6767
, nixUserConfFiles(getUserConfigFiles())
68-
, nixManDir(canonPath(NIX_MAN_DIR))
6968
, nixDaemonSocketFile(canonPath(getEnvNonEmpty("NIX_DAEMON_SOCKET_PATH").value_or(nixStateDir + DEFAULT_SOCKET_PATH)))
7069
{
7170
#ifndef _WIN32

src/libstore/globals.hh

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -84,11 +84,6 @@ public:
8484
*/
8585
std::vector<Path> nixUserConfFiles;
8686

87-
/**
88-
* The directory where the man pages are stored.
89-
*/
90-
Path nixManDir;
91-
9287
/**
9388
* File name of the socket the daemon listens to.
9489
*/

src/nix-build/nix-build.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
#include "users.hh"
2929
#include "network-proxy.hh"
3030
#include "compatibility-settings.hh"
31+
#include "man-pages.hh"
3132

3233
using namespace nix;
3334
using namespace std::string_literals;

src/nix-channel/nix-channel.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#include "users.hh"
99
#include "tarball.hh"
1010
#include "self-exe.hh"
11+
#include "man-pages.hh"
1112

1213
#include <fcntl.h>
1314
#include <regex>

src/nix-collect-garbage/nix-collect-garbage.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#include "shared.hh"
88
#include "globals.hh"
99
#include "legacy.hh"
10+
#include "man-pages.hh"
1011

1112
#include <iostream>
1213
#include <cerrno>

src/nix-copy-closure/nix-copy-closure.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#include "realisation.hh"
33
#include "store-api.hh"
44
#include "legacy.hh"
5+
#include "man-pages.hh"
56

67
using namespace nix;
78

src/nix-env/nix-env.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#include "legacy.hh"
1818
#include "eval-settings.hh" // for defexpr
1919
#include "terminal.hh"
20+
#include "man-pages.hh"
2021

2122
#include <cerrno>
2223
#include <ctime>

src/nix-instantiate/nix-instantiate.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include "local-fs-store.hh"
1313
#include "common-eval-args.hh"
1414
#include "legacy.hh"
15+
#include "man-pages.hh"
1516

1617
#include <map>
1718
#include <iostream>

0 commit comments

Comments
 (0)