about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--src/libexpr/primops.cc13
-rw-r--r--src/libstore/build.cc7
-rw-r--r--src/libstore/local-store.cc4
-rw-r--r--src/libstore/profiles.cc3
-rw-r--r--src/libutil/util.hh9
-rw-r--r--src/nix-daemon/nix-daemon.cc4
-rw-r--r--src/nix-env/nix-env.cc6
-rw-r--r--src/nix-env/user-env.cc4
-rw-r--r--src/nix-store/nix-store.cc8
9 files changed, 23 insertions, 35 deletions
diff --git a/src/libexpr/primops.cc b/src/libexpr/primops.cc
index c2852629a015..d7245fca52e1 100644
--- a/src/libexpr/primops.cc
+++ b/src/libexpr/primops.cc
@@ -87,7 +87,7 @@ static void prim_scopedImport(EvalState & state, const Pos & pos, Value * * args
         Value & w = *state.allocValue();
         state.mkAttrs(w, 3 + drv.outputs.size());
         Value * v2 = state.allocAttr(w, state.sDrvPath);
-        mkString(*v2, path, singleton<PathSet>("=" + path));
+        mkString(*v2, path, {"=" + path});
         v2 = state.allocAttr(w, state.sName);
         mkString(*v2, drv.env["name"]);
         Value * outputsVal =
@@ -97,8 +97,7 @@ static void prim_scopedImport(EvalState & state, const Pos & pos, Value * * args
 
         for (const auto & o : drv.outputs) {
             v2 = state.allocAttr(w, state.symbols.create(o.first));
-            mkString(*v2, o.second.path,
-                singleton<PathSet>("!" + o.first + "!" + path));
+            mkString(*v2, o.second.path, {"!" + o.first + "!" + path});
             outputsVal->listElems()[outputs_index] = state.allocValue();
             mkString(*(outputsVal->listElems()[outputs_index++]), o.first);
         }
@@ -665,10 +664,10 @@ static void prim_derivationStrict(EvalState & state, const Pos & pos, Value * *
     drvHashes[drvPath] = hashDerivationModulo(*state.store, drv);
 
     state.mkAttrs(v, 1 + drv.outputs.size());
-    mkString(*state.allocAttr(v, state.sDrvPath), drvPath, singleton<PathSet>("=" + drvPath));
+    mkString(*state.allocAttr(v, state.sDrvPath), drvPath, {"=" + drvPath});
     for (auto & i : drv.outputs) {
         mkString(*state.allocAttr(v, state.symbols.create(i.first)),
-            i.second.path, singleton<PathSet>("!" + i.first + "!" + drvPath));
+            i.second.path, {"!" + i.first + "!" + drvPath});
     }
     v.attrs->sort();
 }
@@ -905,7 +904,7 @@ static void prim_toFile(EvalState & state, const Pos & pos, Value * * args, Valu
        result, since `storePath' itself has references to the paths
        used in args[1]. */
 
-    mkString(v, storePath, singleton<PathSet>(storePath));
+    mkString(v, storePath, {storePath});
 }
 
 
@@ -967,7 +966,7 @@ static void prim_filterSource(EvalState & state, const Pos & pos, Value * * args
         ? computeStorePathForPath(path, true, htSHA256, filter).first
         : state.store->addToStore(baseNameOf(path), path, true, htSHA256, filter, state.repair);
 
-    mkString(v, dstPath, singleton<PathSet>(dstPath));
+    mkString(v, dstPath, {dstPath});
 }
 
 
diff --git a/src/libstore/build.cc b/src/libstore/build.cc
index e6ec7886f3cd..81c79435ef8b 100644
--- a/src/libstore/build.cc
+++ b/src/libstore/build.cc
@@ -2145,8 +2145,7 @@ void DerivationGoal::startBuilder()
     /* parent */
     pid.setSeparatePG(true);
     builderOut.writeSide.close();
-    worker.childStarted(shared_from_this(),
-        singleton<set<int> >(builderOut.readSide), true, true);
+    worker.childStarted(shared_from_this(), {builderOut.readSide}, true, true);
 
     /* Check if setting up the build environment failed. */
     while (true) {
@@ -3698,7 +3697,7 @@ void LocalStore::ensurePath(const Path & path)
 
     Worker worker(*this);
     GoalPtr goal = worker.makeSubstitutionGoal(path);
-    Goals goals = singleton<Goals>(goal);
+    Goals goals = {goal};
 
     worker.run(goals);
 
@@ -3711,7 +3710,7 @@ void LocalStore::repairPath(const Path & path)
 {
     Worker worker(*this);
     GoalPtr goal = worker.makeSubstitutionGoal(path, true);
-    Goals goals = singleton<Goals>(goal);
+    Goals goals = {goal};
 
     worker.run(goals);
 
diff --git a/src/libstore/local-store.cc b/src/libstore/local-store.cc
index ff434d058992..6f33c1e810bb 100644
--- a/src/libstore/local-store.cc
+++ b/src/libstore/local-store.cc
@@ -949,7 +949,7 @@ Path LocalStore::addToStoreFromDump(const string & dump, const string & name,
         /* The first check above is an optimisation to prevent
            unnecessary lock acquisition. */
 
-        PathLocks outputLock(singleton<PathSet, Path>(dstPath));
+        PathLocks outputLock({dstPath});
 
         if (repair || !isValidPath(dstPath)) {
 
@@ -1018,7 +1018,7 @@ Path LocalStore::addTextToStore(const string & name, const string & s,
 
     if (repair || !isValidPath(dstPath)) {
 
-        PathLocks outputLock(singleton<PathSet, Path>(dstPath));
+        PathLocks outputLock({dstPath});
 
         if (repair || !isValidPath(dstPath)) {
 
diff --git a/src/libstore/profiles.cc b/src/libstore/profiles.cc
index cc83a838eddc..18e3bcbec4a3 100644
--- a/src/libstore/profiles.cc
+++ b/src/libstore/profiles.cc
@@ -222,8 +222,7 @@ void switchLink(Path link, Path target)
 
 void lockProfile(PathLocks & lock, const Path & profile)
 {
-    lock.lockPaths(singleton<PathSet>(profile),
-        (format("waiting for lock on profile ‘%1%’") % profile).str());
+    lock.lockPaths({profile}, (format("waiting for lock on profile ‘%1%’") % profile).str());
     lock.setDeletion(true);
 }
 
diff --git a/src/libutil/util.hh b/src/libutil/util.hh
index f3f0f92a0aaa..ab43637a574c 100644
--- a/src/libutil/util.hh
+++ b/src/libutil/util.hh
@@ -117,15 +117,6 @@ void createSymlink(const Path & target, const Path & link);
 void replaceSymlink(const Path & target, const Path & link);
 
 
-template<class T, class A>
-T singleton(const A & a)
-{
-    T t;
-    t.insert(a);
-    return t;
-}
-
-
 /* Wrappers arount read()/write() that read/write exactly the
    requested number of bytes. */
 void readFull(int fd, unsigned char * buf, size_t count);
diff --git a/src/nix-daemon/nix-daemon.cc b/src/nix-daemon/nix-daemon.cc
index bc05b85f4923..9757086c650e 100644
--- a/src/nix-daemon/nix-daemon.cc
+++ b/src/nix-daemon/nix-daemon.cc
@@ -195,7 +195,7 @@ static void performOp(ref<LocalStore> store, bool trusted, unsigned int clientVe
     case wopHasSubstitutes: {
         Path path = readStorePath(from);
         startWork();
-        PathSet res = store->querySubstitutablePaths(singleton<PathSet>(path));
+        PathSet res = store->querySubstitutablePaths({path});
         stopWork();
         to << (res.find(path) != res.end());
         break;
@@ -472,7 +472,7 @@ static void performOp(ref<LocalStore> store, bool trusted, unsigned int clientVe
         Path path = absPath(readString(from));
         startWork();
         SubstitutablePathInfos infos;
-        store->querySubstitutablePathInfos(singleton<PathSet>(path), infos);
+        store->querySubstitutablePathInfos({path}, infos);
         stopWork();
         SubstitutablePathInfos::iterator i = infos.find(path);
         if (i == infos.end())
diff --git a/src/nix-env/nix-env.cc b/src/nix-env/nix-env.cc
index 6bc8d79bc1bb..6b6c245d3637 100644
--- a/src/nix-env/nix-env.cc
+++ b/src/nix-env/nix-env.cc
@@ -224,7 +224,7 @@ static bool isPrebuilt(EvalState & state, DrvInfo & elem)
 {
     Path path = elem.queryOutPath();
     if (state.store->isValidPath(path)) return true;
-    PathSet ps = state.store->querySubstitutablePaths(singleton<PathSet>(path));
+    PathSet ps = state.store->querySubstitutablePaths({path});
     return ps.find(path) != ps.end();
 }
 
@@ -710,13 +710,13 @@ static void opSet(Globals & globals, Strings opFlags, Strings opArgs)
         drv.name = globals.forceName;
 
     if (drv.queryDrvPath() != "") {
-        PathSet paths = singleton<PathSet>(drv.queryDrvPath());
+        PathSet paths = {drv.queryDrvPath()};
         printMissing(globals.state->store, paths);
         if (globals.dryRun) return;
         globals.state->store->buildPaths(paths, globals.state->repair ? bmRepair : bmNormal);
     }
     else {
-        printMissing(globals.state->store, singleton<PathSet>(drv.queryOutPath()));
+        printMissing(globals.state->store, {drv.queryOutPath()});
         if (globals.dryRun) return;
         globals.state->store->ensurePath(drv.queryOutPath());
     }
diff --git a/src/nix-env/user-env.cc b/src/nix-env/user-env.cc
index e378d8196258..ca27a7248107 100644
--- a/src/nix-env/user-env.cc
+++ b/src/nix-env/user-env.cc
@@ -112,7 +112,7 @@ bool createUserEnv(EvalState & state, DrvInfos & elems,
     Value args, topLevel;
     state.mkAttrs(args, 3);
     mkString(*state.allocAttr(args, state.symbols.create("manifest")),
-        manifestFile, singleton<PathSet>(manifestFile));
+        manifestFile, {manifestFile});
     args.attrs->push_back(Attr(state.symbols.create("derivations"), &manifest));
     args.attrs->sort();
     mkApp(topLevel, envBuilder, args);
@@ -128,7 +128,7 @@ bool createUserEnv(EvalState & state, DrvInfos & elems,
 
     /* Realise the resulting store expression. */
     debug("building user environment");
-    state.store->buildPaths(singleton<PathSet>(topLevelDrv), state.repair ? bmRepair : bmNormal);
+    state.store->buildPaths({topLevelDrv}, state.repair ? bmRepair : bmNormal);
 
     /* Switch the current user environment to the output path. */
     PathLocks lock;
diff --git a/src/nix-store/nix-store.cc b/src/nix-store/nix-store.cc
index 9bb1ac50a607..0038fff036a1 100644
--- a/src/nix-store/nix-store.cc
+++ b/src/nix-store/nix-store.cc
@@ -64,7 +64,7 @@ static PathSet realisePath(Path path, bool build = true)
     DrvPathWithOutputs p = parseDrvPathWithOutputs(path);
 
     if (isDerivation(p.first)) {
-        if (build) store->buildPaths(singleton<PathSet>(path));
+        if (build) store->buildPaths({path});
         Derivation drv = store->derivationFromPath(p.first);
         rootNr++;
 
@@ -101,7 +101,7 @@ static PathSet realisePath(Path path, bool build = true)
             if (rootNr > 1) rootName += "-" + std::to_string(rootNr);
             path = store->addPermRoot(path, rootName, indirectRoot);
         }
-        return singleton<PathSet>(path);
+        return {path};
     }
 }
 
@@ -222,7 +222,7 @@ static PathSet maybeUseOutputs(const Path & storePath, bool useOutput, bool forc
             outputs.insert(i.second.path);
         return outputs;
     }
-    else return singleton<PathSet>(storePath);
+    else return {storePath};
 }
 
 
@@ -537,7 +537,7 @@ static void opDumpDB(Strings opFlags, Strings opArgs)
         throw UsageError("no arguments expected");
     PathSet validPaths = store->queryAllValidPaths();
     for (auto & i : validPaths)
-        cout << store->makeValidityRegistration(singleton<PathSet>(i), true, true);
+        cout << store->makeValidityRegistration({i}, true, true);
 }