mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-23 14:36:16 +02:00
Automated lockfile updating with nix build
This commit is contained in:
parent
87033f2c4e
commit
4bf3a8226b
3 changed files with 24 additions and 6 deletions
|
@ -11,7 +11,7 @@ struct CmdBuild : MixDryRun, InstallablesCommand
|
||||||
{
|
{
|
||||||
Path outLink = "result";
|
Path outLink = "result";
|
||||||
|
|
||||||
std::optional<std::string> gitRepo = std::nullopt;
|
bool update = true;
|
||||||
|
|
||||||
CmdBuild()
|
CmdBuild()
|
||||||
{
|
{
|
||||||
|
@ -28,9 +28,9 @@ struct CmdBuild : MixDryRun, InstallablesCommand
|
||||||
.set(&outLink, Path(""));
|
.set(&outLink, Path(""));
|
||||||
|
|
||||||
mkFlag()
|
mkFlag()
|
||||||
.longName("update-lock-file")
|
.longName("no-update")
|
||||||
.description("update the lock file")
|
.description("don't update the lock files")
|
||||||
.dest(&gitRepo);
|
.set(&update, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string name() override
|
std::string name() override
|
||||||
|
@ -78,8 +78,12 @@ struct CmdBuild : MixDryRun, InstallablesCommand
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (gitRepo)
|
if (update)
|
||||||
updateLockFile(*evalState, *gitRepo);
|
for (auto installable : installables) {
|
||||||
|
auto flakeUri = installable->installableToFlakeUri();
|
||||||
|
if (flakeUri)
|
||||||
|
updateLockFile(*evalState, *flakeUri);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
#include "args.hh"
|
#include "args.hh"
|
||||||
#include "common-eval-args.hh"
|
#include "common-eval-args.hh"
|
||||||
|
#include <optional>
|
||||||
|
|
||||||
namespace nix {
|
namespace nix {
|
||||||
|
|
||||||
|
@ -65,6 +66,11 @@ struct Installable
|
||||||
|
|
||||||
Buildable toBuildable();
|
Buildable toBuildable();
|
||||||
|
|
||||||
|
virtual std::optional<std::string> installableToFlakeUri()
|
||||||
|
{
|
||||||
|
return std::nullopt;
|
||||||
|
}
|
||||||
|
|
||||||
virtual Value * toValue(EvalState & state)
|
virtual Value * toValue(EvalState & state)
|
||||||
{
|
{
|
||||||
throw Error("argument '%s' cannot be evaluated", what());
|
throw Error("argument '%s' cannot be evaluated", what());
|
||||||
|
|
|
@ -176,6 +176,14 @@ struct InstallableFlake : InstallableValue
|
||||||
state.forceValue(*v);
|
state.forceValue(*v);
|
||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::optional<std::string> installableToFlakeUri() override
|
||||||
|
{
|
||||||
|
if (std::get_if<FlakeRef::IsPath>(&flakeRef.data))
|
||||||
|
return flakeRef.to_string();
|
||||||
|
else
|
||||||
|
return std::nullopt;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// FIXME: extend
|
// FIXME: extend
|
||||||
|
|
Loading…
Reference in a new issue