From f51148a75bd991fcf9545bb11a0626879795537c Mon Sep 17 00:00:00 2001 From: Jade Lovelace Date: Wed, 22 Apr 2026 13:46:48 +0000 Subject: [PATCH] tidy: delete a bunch of dead code Found ... by edef's harness. There was more dead code it found, which I didn't address because it felt less obviously deletable: - `AutoDestroyCgroup::path()` / `::delegation()` - `TeeSource`, `LambdaSink` - `S3BinaryCacheStore::getS3Stats()` (maybe Hydra? idk) - `fetchers::getBoolAttr()` (technically deletable but it would be inconsistent with the others) Change-Id: I913d2afd61e24136fb506389fc33a1016a6a6964 --- lix/libexpr/flake/flakeref.cc | 20 -------------------- lix/libexpr/flake/flakeref.hh | 6 ------ lix/libexpr/nixexpr.cc | 18 ------------------ lix/libexpr/nixexpr.hh | 14 +++++++++++--- lix/libstore/build/derivation-goal.hh | 4 ---- lix/libstore/build/goal.hh | 25 +------------------------ lix/libstore/build/substitution-goal.hh | 4 ---- lix/libstore/derivations.cc | 6 ------ lix/libstore/derivations.hh | 1 - lix/libstore/nar-accessor.cc | 5 ----- lix/libstore/nar-accessor.hh | 2 -- lix/libutil/processes.hh | 6 ------ 12 files changed, 12 insertions(+), 99 deletions(-) diff --git a/lix/libexpr/flake/flakeref.cc b/lix/libexpr/flake/flakeref.cc index b5c2366c7..f5599e053 100644 --- a/lix/libexpr/flake/flakeref.cc +++ b/lix/libexpr/flake/flakeref.cc @@ -67,16 +67,6 @@ FlakeRef parseFlakeRef( return flakeRef; } -std::optional maybeParseFlakeRef( - const std::string & url, const std::optional & baseDir) -{ - try { - return parseFlakeRef(url, baseDir); - } catch (Error &) { - return {}; - } -} - std::pair parseFlakeRefWithFragment( const std::string & url, const std::optional & baseDir, @@ -234,16 +224,6 @@ std::pair parseFlakeRefWithFragment( } } -std::optional> maybeParseFlakeRefWithFragment( - const std::string & url, const std::optional & baseDir) -{ - try { - return parseFlakeRefWithFragment(url, baseDir); - } catch (Error & e) { - return {}; - } -} - FlakeRef FlakeRef::fromAttrs(const fetchers::Attrs & attrs) { auto attrs2(attrs); diff --git a/lix/libexpr/flake/flakeref.hh b/lix/libexpr/flake/flakeref.hh index 7209f9d5b..068764ed4 100644 --- a/lix/libexpr/flake/flakeref.hh +++ b/lix/libexpr/flake/flakeref.hh @@ -70,18 +70,12 @@ FlakeRef parseFlakeRef( bool allowMissing = false, bool isFlake = true); -std::optional maybeParseFlake( - const std::string & url, const std::optional & baseDir = {}); - std::pair parseFlakeRefWithFragment( const std::string & url, const std::optional & baseDir = {}, bool allowMissing = false, bool isFlake = true); -std::optional> maybeParseFlakeRefWithFragment( - const std::string & url, const std::optional & baseDir = {}); - std::tuple parseFlakeRefWithFragmentAndExtendedOutputsSpec( const std::string & url, const std::optional & baseDir = {}, diff --git a/lix/libexpr/nixexpr.cc b/lix/libexpr/nixexpr.cc index c31e68141..9d2fa08db 100644 --- a/lix/libexpr/nixexpr.cc +++ b/lix/libexpr/nixexpr.cc @@ -99,13 +99,6 @@ JSON ExprVar::toJSON(const SymbolTable & symbols) const return {{"_type", "ExprVar"}, {"value", stringToJSON(symbols[name])}}; } -JSON ExprInheritFrom::toJSON(SymbolTable const & symbols) const -{ - return { - {"_type", "ExprInheritFrom"} - }; -} - JSON ExprSelect::toJSON(const SymbolTable & symbols) const { JSON out = { @@ -747,17 +740,6 @@ void ExprLambda::setName(Symbol name) body->setName(name); } - -std::string ExprLambda::showNamePos(const EvalState & state) const -{ - std::string id(name - ? concatStrings("'", state.ctx.symbols[name], "'") - : "anonymous function"); - return fmt("%1% at %2%", id, state.ctx.positions[pos]); -} - - - /* Position table. */ Pos PosTable::operator[](PosIdx p) const diff --git a/lix/libexpr/nixexpr.hh b/lix/libexpr/nixexpr.hh index a2f5bfbf3..1a29e8fc4 100644 --- a/lix/libexpr/nixexpr.hh +++ b/lix/libexpr/nixexpr.hh @@ -126,7 +126,7 @@ public: std::unique_ptr parsed, Evaluator & es, const std::shared_ptr & env ); - virtual JSON toJSON(const SymbolTable & symbols) const; + virtual JSON toJSON(const SymbolTable & symbols) const = 0; virtual void accept(ExprVisitor & ev, std::unique_ptr & ptr) = 0; virtual Value eval(EvalState & state, Env & env); Value makeThunk(Evaluator & ctx, Env & env); @@ -303,7 +303,11 @@ struct ExprInheritFrom : Expr { } - JSON toJSON(const SymbolTable & symbols) const override; + JSON toJSON(const SymbolTable & symbols) const override + { + abort(); + } + Value eval(EvalState & state, Env & env) override; void accept(ExprVisitor & ev, std::unique_ptr & ptr) override { ev.visit(*this, ptr); } }; @@ -518,7 +522,6 @@ struct ExprLambda : Expr { } void setName(Symbol name) override; - std::string showNamePos(const EvalState & state) const; /** Returns the name of the lambda, * or "anonymous lambda" if it doesn't have one. @@ -657,6 +660,11 @@ struct ExprPos : Expr /* only used to mark thunks as black holes. */ struct ExprBlackHole : Expr { + JSON toJSON(const SymbolTable & symbols) const override + { + abort(); + } + Value eval(EvalState & state, Env & env) override; void accept(ExprVisitor & ev, std::unique_ptr & ptr) override { ev.visit(*this, ptr); } }; diff --git a/lix/libstore/build/derivation-goal.hh b/lix/libstore/build/derivation-goal.hh index 831b7e836..755f3a701 100644 --- a/lix/libstore/build/derivation-goal.hh +++ b/lix/libstore/build/derivation-goal.hh @@ -360,10 +360,6 @@ public: { return false; } - - JobCategory jobCategory() const override { - return JobCategory::Build; - }; }; MakeError(NotDeterministic, BuildError); diff --git a/lix/libstore/build/goal.hh b/lix/libstore/build/goal.hh index 77be12b1c..442834478 100644 --- a/lix/libstore/build/goal.hh +++ b/lix/libstore/build/goal.hh @@ -27,23 +27,6 @@ typedef std::shared_ptr GoalPtr; */ typedef std::set Goals; -/** - * Used as a hint to the worker on how to schedule a particular goal. For example, - * builds are typically CPU- and memory-bound, while substitutions are I/O bound. - * Using this information, the worker might decide to schedule more or fewer goals - * of each category in parallel. - */ -enum struct JobCategory { - /** - * A build of a derivation; it will use CPU and disk resources. - */ - Build, - /** - * A substitution an arbitrary store object; it will use network resources. - */ - Substitution, -}; - struct Goal { typedef enum {ecSuccess, ecFailed, ecNoSubstituters, ecIncompleteClosure} ExitCode; @@ -139,13 +122,7 @@ public: return name; } - virtual void cleanup() { } - - /** - * @brief Hint for the scheduler, which concurrency limit applies. - * @see JobCategory - */ - virtual JobCategory jobCategory() const = 0; + virtual void cleanup() {} }; } diff --git a/lix/libstore/build/substitution-goal.hh b/lix/libstore/build/substitution-goal.hh index 9f2a2d04e..489ebfd03 100644 --- a/lix/libstore/build/substitution-goal.hh +++ b/lix/libstore/build/substitution-goal.hh @@ -90,10 +90,6 @@ public: kj::Promise> referencesValid() noexcept; kj::Promise> tryToRun() noexcept; kj::Promise> finished() noexcept; - - JobCategory jobCategory() const override { - return JobCategory::Substitution; - }; }; } diff --git a/lix/libstore/derivations.cc b/lix/libstore/derivations.cc index ca04385f1..909be6779 100644 --- a/lix/libstore/derivations.cc +++ b/lix/libstore/derivations.cc @@ -744,12 +744,6 @@ WireFormatGenerator serializeDerivation(const Store & store, const BasicDerivati } } -void writeDerivation(Sink & out, const Store & store, const BasicDerivation & drv) -{ - out << serializeDerivation(store, drv); -} - - std::string hashPlaceholder(const OutputNameView outputName) { // FIXME: memoize? diff --git a/lix/libstore/derivations.hh b/lix/libstore/derivations.hh index c3cd429b4..99cd75289 100644 --- a/lix/libstore/derivations.hh +++ b/lix/libstore/derivations.hh @@ -359,7 +359,6 @@ struct Sink; Source & readDerivation(Source & in, const Store & store, BasicDerivation & drv, std::string_view name); WireFormatGenerator serializeDerivation(const Store & store, const BasicDerivation & drv); -void writeDerivation(Sink & out, const Store & store, const BasicDerivation & drv); /** * This creates an opaque and almost certainly unique string diff --git a/lix/libstore/nar-accessor.cc b/lix/libstore/nar-accessor.cc index b6db22a95..e13200a7a 100644 --- a/lix/libstore/nar-accessor.cc +++ b/lix/libstore/nar-accessor.cc @@ -161,11 +161,6 @@ ref makeNarAccessor(std::string && nar) return make_ref(std::move(nar)); } -ref makeNarAccessor(Source & source) -{ - return make_ref(source); -} - ref makeLazyNarAccessor(const std::string & listing, GetNarBytes getNarBytes) { diff --git a/lix/libstore/nar-accessor.hh b/lix/libstore/nar-accessor.hh index ce4023faa..6c43d1f98 100644 --- a/lix/libstore/nar-accessor.hh +++ b/lix/libstore/nar-accessor.hh @@ -18,8 +18,6 @@ struct Source; */ ref makeNarAccessor(std::string && nar); -ref makeNarAccessor(Source & source); - /** * Create a NAR accessor from a NAR listing (in the format produced by * listNar()). The callback getNarBytes(offset, length) is used by the diff --git a/lix/libutil/processes.hh b/lix/libutil/processes.hh index 9d44f93d7..f0160ad6f 100644 --- a/lix/libutil/processes.hh +++ b/lix/libutil/processes.hh @@ -122,11 +122,6 @@ public: int wait(); void waitAndCheck(); - std::optional getStdoutFD() const - { - return childStdout ? std::optional(childStdout->getFD()) : std::nullopt; - } - AsyncFdIoStream * getStdout() const { return childStdout.get(); @@ -160,7 +155,6 @@ public: using RunningProgram::operator bool; using RunningProgram::getStdout; - using RunningProgram::getStdoutFD; using RunningProgram::kill; using RunningProgram::wait;