aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEelco Dolstra <e.dolstra@tudelft.nl>2010-04-19 10:47:56 +0000
committerEelco Dolstra <e.dolstra@tudelft.nl>2010-04-19 10:47:56 +0000
commitb7ff69eb7c3f97c33ec18c51ab87b7f3dd967052 (patch)
tree62b3bb7591e2e76315b93510dc62fa2baa9dce9b
parent5c31995bb8adb9189152ebd4f3c41ca9e8049749 (diff)
* Refactoring: move the user environment stuff into its own module.
-rw-r--r--src/nix-env/Makefile.am3
-rw-r--r--src/nix-env/nix-env.cc20
-rw-r--r--src/nix-env/user-env.cc28
-rw-r--r--src/nix-env/user-env.hh16
4 files changed, 47 insertions, 20 deletions
diff --git a/src/nix-env/Makefile.am b/src/nix-env/Makefile.am
index 900524f76..9b0d99513 100644
--- a/src/nix-env/Makefile.am
+++ b/src/nix-env/Makefile.am
@@ -1,6 +1,7 @@
bin_PROGRAMS = nix-env
-nix_env_SOURCES = nix-env.cc profiles.cc profiles.hh help.txt
+nix_env_SOURCES = nix-env.cc profiles.cc user-env.cc profiles.hh help.txt
+
nix_env_LDADD = ../libmain/libmain.la ../libexpr/libexpr.la \
../libstore/libstore.la ../libutil/libutil.la \
../boost/format/libformat.la ${aterm_lib} @ADDITIONAL_NETWORK_LIBS@
diff --git a/src/nix-env/nix-env.cc b/src/nix-env/nix-env.cc
index 306b9507d..e298c4003 100644
--- a/src/nix-env/nix-env.cc
+++ b/src/nix-env/nix-env.cc
@@ -12,6 +12,7 @@
#include "common-opts.hh"
#include "xml-writer.hh"
#include "store-api.hh"
+#include "user-env.hh"
#include "util.hh"
#include <cerrno>
@@ -192,25 +193,6 @@ static Path getDefNixExprPath()
}
-static DrvInfos queryInstalled(EvalState & state, const Path & userEnv)
-{
- Path path = userEnv + "/manifest";
-
- if (!pathExists(path))
- return DrvInfos(); /* not an error, assume nothing installed */
-
- throw Error("not implemented");
-#if 0
- Expr e = ATreadFromNamedFile(path.c_str());
- if (!e) throw Error(format("cannot read Nix expression from `%1%'") % path);
-
- DrvInfos elems;
- // !!! getDerivations(state, e, "", ATermMap(1), elems);
- return elems;
-#endif
-}
-
-
/* Ensure exclusive access to a profile. Any command that modifies
the profile first acquires this lock. */
static void lockProfile(PathLocks & lock, const Path & profile)
diff --git a/src/nix-env/user-env.cc b/src/nix-env/user-env.cc
new file mode 100644
index 000000000..0e1fce650
--- /dev/null
+++ b/src/nix-env/user-env.cc
@@ -0,0 +1,28 @@
+#include "util.hh"
+#include "get-drvs.hh"
+
+
+namespace nix {
+
+
+DrvInfos queryInstalled(EvalState & state, const Path & userEnv)
+{
+ Path path = userEnv + "/manifest";
+
+ if (!pathExists(path))
+ return DrvInfos(); /* not an error, assume nothing installed */
+
+ throw Error("not implemented");
+#if 0
+ Expr e = ATreadFromNamedFile(path.c_str());
+ if (!e) throw Error(format("cannot read Nix expression from `%1%'") % path);
+
+ DrvInfos elems;
+ // !!! getDerivations(state, e, "", ATermMap(1), elems);
+ return elems;
+#endif
+}
+
+
+}
+
diff --git a/src/nix-env/user-env.hh b/src/nix-env/user-env.hh
new file mode 100644
index 000000000..6675014f1
--- /dev/null
+++ b/src/nix-env/user-env.hh
@@ -0,0 +1,16 @@
+#ifndef __USER_ENV_H
+#define __USER_ENV_H
+
+#include "get-drvs.hh"
+
+namespace nix {
+
+DrvInfos queryInstalled(EvalState & state, const Path & userEnv);
+
+}
+
+#endif /* !__USER_ENV_H */
+
+
+
+