add custom flake+fetchers api
This commit is contained in:
parent
544371e861
commit
0a4cfcce7d
4 changed files with 323 additions and 0 deletions
86
nixide-sys/libnixide-c/nixide_api_fetchers.cc
Normal file
86
nixide-sys/libnixide-c/nixide_api_fetchers.cc
Normal file
|
|
@ -0,0 +1,86 @@
|
|||
#include "nix_api_util_internal.h"
|
||||
#include "nix_api_fetchers_internal.hh"
|
||||
|
||||
#include "nix/fetchers/fetch-settings.hh"
|
||||
|
||||
extern "C" {
|
||||
|
||||
// nix_err nix_fetchers_settings_add_access_token(
|
||||
// nix_c_context * context, nix_fetchers_settings * settings, char * tokenName, char * tokenValue)
|
||||
// {
|
||||
// nix_clear_err(context);
|
||||
// try {
|
||||
// settings->settings->accessTokens.emplace(std::string(tokenName), std::string(tokenValue));
|
||||
// }
|
||||
// NIXC_CATCH_ERRS
|
||||
// }
|
||||
|
||||
// nix_err
|
||||
// nix_fetchers_settings_remove_access_token(nix_c_context * context, nix_fetchers_settings * settings, char *
|
||||
// tokenName)
|
||||
// {
|
||||
// nix_clear_err(context);
|
||||
// try {
|
||||
// settings->settings->accessTokens.erase(std::string(tokenName));
|
||||
// }
|
||||
// NIXC_CATCH_ERRS
|
||||
// }
|
||||
|
||||
nix_err nix_fetchers_settings_set_allow_dirty(nix_c_context * context, nix_fetchers_settings * settings, bool value)
|
||||
{
|
||||
nix_clear_err(context);
|
||||
try {
|
||||
settings->settings->allowDirty = value;
|
||||
}
|
||||
NIXC_CATCH_ERRS
|
||||
}
|
||||
|
||||
nix_err nix_fetchers_settings_set_warn_dirty(nix_c_context * context, nix_fetchers_settings * settings, bool value)
|
||||
{
|
||||
nix_clear_err(context);
|
||||
try {
|
||||
settings->settings->warnDirty = value;
|
||||
}
|
||||
NIXC_CATCH_ERRS
|
||||
}
|
||||
|
||||
nix_err
|
||||
nix_fetchers_settings_set_allow_dirty_locks(nix_c_context * context, nix_fetchers_settings * settings, bool value)
|
||||
{
|
||||
nix_clear_err(context);
|
||||
try {
|
||||
settings->settings->allowDirtyLocks = value;
|
||||
}
|
||||
NIXC_CATCH_ERRS
|
||||
}
|
||||
|
||||
nix_err nix_fetchers_settings_set_trust_tarballs_from_git_forges(
|
||||
nix_c_context * context, nix_fetchers_settings * settings, bool value)
|
||||
{
|
||||
nix_clear_err(context);
|
||||
try {
|
||||
settings->settings->trustTarballsFromGitForges = value;
|
||||
}
|
||||
NIXC_CATCH_ERRS
|
||||
}
|
||||
|
||||
nix_err nix_fetchers_settings_set_global_flake_registry(
|
||||
nix_c_context * context, nix_fetchers_settings * settings, char * registry)
|
||||
{
|
||||
nix_clear_err(context);
|
||||
try {
|
||||
settings->settings->flakeRegistry = registry;
|
||||
}
|
||||
NIXC_CATCH_ERRS
|
||||
}
|
||||
|
||||
nix_err nix_fetchers_settings_set_tarball_ttl(nix_c_context * context, nix_fetchers_settings * settings, uint ttl)
|
||||
{
|
||||
nix_clear_err(context);
|
||||
try {
|
||||
settings->settings->tarballTtl = ttl;
|
||||
}
|
||||
NIXC_CATCH_ERRS
|
||||
}
|
||||
|
||||
} // extern "C"
|
||||
36
nixide-sys/libnixide-c/nixide_api_fetchers.h
Normal file
36
nixide-sys/libnixide-c/nixide_api_fetchers.h
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
#ifndef NIXIDE_API_FETCHERS_H
|
||||
#define NIXIDE_API_FETCHERS_H
|
||||
|
||||
#include "nix_api_fetchers.h"
|
||||
#include <sys/types.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
nix_err nix_fetchers_settings_add_access_token(
|
||||
nix_c_context * context, nix_fetchers_settings * settings, char * tokenName, char * tokenValue);
|
||||
|
||||
nix_err
|
||||
nix_fetchers_settings_remove_access_token(nix_c_context * context, nix_fetchers_settings * settings, char * tokenName);
|
||||
|
||||
nix_err nix_fetchers_settings_set_allow_dirty(nix_c_context * context, nix_fetchers_settings * settings, bool value);
|
||||
|
||||
nix_err nix_fetchers_settings_set_warn_dirty(nix_c_context * context, nix_fetchers_settings * settings, bool value);
|
||||
|
||||
nix_err
|
||||
nix_fetchers_settings_set_allow_dirty_locks(nix_c_context * context, nix_fetchers_settings * settings, bool value);
|
||||
|
||||
nix_err nix_fetchers_settings_set_trust_tarballs_from_git_forges(
|
||||
nix_c_context * context, nix_fetchers_settings * settings, bool value);
|
||||
|
||||
nix_err nix_fetchers_settings_set_global_flake_registry(
|
||||
nix_c_context * context, nix_fetchers_settings * settings, char * registry);
|
||||
|
||||
nix_err nix_fetchers_settings_set_tarball_ttl(nix_c_context * context, nix_fetchers_settings * settings, uint ttl);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif
|
||||
|
||||
#endif // NIXIDE_API_FETCHERS_H
|
||||
154
nixide-sys/libnixide-c/nixide_api_flake.cc
Normal file
154
nixide-sys/libnixide-c/nixide_api_flake.cc
Normal file
|
|
@ -0,0 +1,154 @@
|
|||
// #include <string>
|
||||
|
||||
// #include "nix_api_flake.h"
|
||||
#include "nix_api_flake_internal.hh"
|
||||
// #include "nix_api_util.h"
|
||||
#include "nix_api_util_internal.h"
|
||||
// #include "nix_api_expr_internal.h"
|
||||
// #include "nix_api_fetchers_internal.hh"
|
||||
// #include "nix_api_fetchers.h"
|
||||
|
||||
#include "nix/flake/flake.hh"
|
||||
|
||||
// #include "nixide_api_flake.h"
|
||||
|
||||
extern "C" {
|
||||
|
||||
nix_err nix_flake_lock_flags_set_recreate_lock_file(nix_c_context * context, nix_flake_lock_flags * flags, bool value)
|
||||
{
|
||||
nix_clear_err(context);
|
||||
try {
|
||||
flags->lockFlags->recreateLockFile = value;
|
||||
}
|
||||
NIXC_CATCH_ERRS
|
||||
}
|
||||
|
||||
nix_err nix_flake_lock_flags_set_update_lock_file(nix_c_context * context, nix_flake_lock_flags * flags, bool value)
|
||||
{
|
||||
nix_clear_err(context);
|
||||
try {
|
||||
flags->lockFlags->updateLockFile = value;
|
||||
}
|
||||
NIXC_CATCH_ERRS
|
||||
}
|
||||
|
||||
nix_err nix_flake_lock_flags_set_write_lock_file(nix_c_context * context, nix_flake_lock_flags * flags, bool value)
|
||||
{
|
||||
nix_clear_err(context);
|
||||
try {
|
||||
flags->lockFlags->writeLockFile = value;
|
||||
}
|
||||
NIXC_CATCH_ERRS
|
||||
}
|
||||
|
||||
nix_err nix_flake_lock_flags_set_fail_on_unlocked(nix_c_context * context, nix_flake_lock_flags * flags, bool value)
|
||||
{
|
||||
nix_clear_err(context);
|
||||
try {
|
||||
flags->lockFlags->failOnUnlocked = value;
|
||||
}
|
||||
NIXC_CATCH_ERRS
|
||||
}
|
||||
|
||||
nix_err nix_flake_lock_flags_set_use_registries(nix_c_context * context, nix_flake_lock_flags * flags, bool value)
|
||||
{
|
||||
nix_clear_err(context);
|
||||
try {
|
||||
flags->lockFlags->useRegistries = value;
|
||||
}
|
||||
NIXC_CATCH_ERRS
|
||||
}
|
||||
|
||||
nix_err nix_flake_lock_flags_set_apply_nix_config(nix_c_context * context, nix_flake_lock_flags * flags, bool value)
|
||||
{
|
||||
nix_clear_err(context);
|
||||
try {
|
||||
flags->lockFlags->applyNixConfig = value;
|
||||
}
|
||||
NIXC_CATCH_ERRS
|
||||
}
|
||||
|
||||
nix_err nix_flake_lock_flags_set_allow_unlocked(nix_c_context * context, nix_flake_lock_flags * flags, bool value)
|
||||
{
|
||||
nix_clear_err(context);
|
||||
try {
|
||||
flags->lockFlags->allowUnlocked = value;
|
||||
}
|
||||
NIXC_CATCH_ERRS
|
||||
}
|
||||
|
||||
nix_err nix_flake_lock_flags_set_commit_lock_file(nix_c_context * context, nix_flake_lock_flags * flags, bool value)
|
||||
{
|
||||
nix_clear_err(context);
|
||||
try {
|
||||
flags->lockFlags->commitLockFile = value;
|
||||
}
|
||||
NIXC_CATCH_ERRS
|
||||
}
|
||||
|
||||
nix_err
|
||||
nix_flake_lock_flags_set_reference_lock_file_path(nix_c_context * context, nix_flake_lock_flags * flags, char * path)
|
||||
{
|
||||
nix_clear_err(context);
|
||||
try {
|
||||
auto accessor = nix::getFSSourceAccessor();
|
||||
nix::CanonPath canon(path);
|
||||
flags->lockFlags->referenceLockFilePath = nix::SourcePath(accessor, canon);
|
||||
}
|
||||
NIXC_CATCH_ERRS
|
||||
}
|
||||
|
||||
nix_err
|
||||
nix_flake_lock_flags_set_output_lock_file_path(nix_c_context * context, nix_flake_lock_flags * flags, char * outputPath)
|
||||
{
|
||||
nix_clear_err(context);
|
||||
try {
|
||||
flags->lockFlags->outputLockFilePath = outputPath;
|
||||
}
|
||||
NIXC_CATCH_ERRS
|
||||
}
|
||||
|
||||
nix_err
|
||||
nix_flake_lock_flags_add_input_update(nix_c_context * context, nix_flake_lock_flags * flags, const char * inputPath)
|
||||
{
|
||||
nix_clear_err(context);
|
||||
try {
|
||||
auto path = nix::flake::NonEmptyInputAttrPath::parse(inputPath);
|
||||
if (!path)
|
||||
throw nix::UsageError(
|
||||
"input override path cannot be zero-length; it would refer to the flake itself, not an input");
|
||||
flags->lockFlags->inputUpdates.emplace(std::move(*path));
|
||||
}
|
||||
NIXC_CATCH_ERRS
|
||||
}
|
||||
|
||||
/* nix_flake_settings */
|
||||
nix_err nix_flake_settings_set_use_registries(nix_c_context * context, nix_flake_settings * settings, bool value)
|
||||
{
|
||||
nix_clear_err(context);
|
||||
try {
|
||||
settings->settings->useRegistries = value;
|
||||
}
|
||||
NIXC_CATCH_ERRS
|
||||
}
|
||||
|
||||
nix_err nix_flake_settings_set_accept_flake_config(nix_c_context * context, nix_flake_settings * settings, bool value)
|
||||
{
|
||||
nix_clear_err(context);
|
||||
try {
|
||||
settings->settings->acceptFlakeConfig = value;
|
||||
}
|
||||
NIXC_CATCH_ERRS
|
||||
}
|
||||
|
||||
nix_err
|
||||
nix_flake_settings_set_commit_lock_file_summary(nix_c_context * context, nix_flake_settings * settings, char * summary)
|
||||
{
|
||||
nix_clear_err(context);
|
||||
try {
|
||||
settings->settings->commitLockFileSummary = summary;
|
||||
}
|
||||
NIXC_CATCH_ERRS
|
||||
}
|
||||
|
||||
} // extern "C"
|
||||
47
nixide-sys/libnixide-c/nixide_api_flake.h
Normal file
47
nixide-sys/libnixide-c/nixide_api_flake.h
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
#ifndef NIXIDE_API_FLAKE_H
|
||||
#define NIXIDE_API_FLAKE_H
|
||||
|
||||
#include "nix_api_flake.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
nix_err nix_flake_lock_flags_set_recreate_lock_file(nix_c_context * context, nix_flake_lock_flags * flags, bool value);
|
||||
|
||||
nix_err nix_flake_lock_flags_set_update_lock_file(nix_c_context * context, nix_flake_lock_flags * flags, bool value);
|
||||
|
||||
nix_err nix_flake_lock_flags_set_write_lock_file(nix_c_context * context, nix_flake_lock_flags * flags, bool value);
|
||||
|
||||
nix_err nix_flake_lock_flags_set_fail_on_unlocked(nix_c_context * context, nix_flake_lock_flags * flags, bool value);
|
||||
|
||||
nix_err nix_flake_lock_flags_set_use_registries(nix_c_context * context, nix_flake_lock_flags * flags, bool value);
|
||||
|
||||
nix_err nix_flake_lock_flags_set_apply_nix_config(nix_c_context * context, nix_flake_lock_flags * flags, bool value);
|
||||
|
||||
nix_err nix_flake_lock_flags_set_allow_unlocked(nix_c_context * context, nix_flake_lock_flags * flags, bool value);
|
||||
|
||||
nix_err nix_flake_lock_flags_set_commit_lock_file(nix_c_context * context, nix_flake_lock_flags * flags, bool value);
|
||||
|
||||
nix_err
|
||||
nix_flake_lock_flags_set_reference_lock_file_path(nix_c_context * context, nix_flake_lock_flags * flags, char * path);
|
||||
|
||||
nix_err
|
||||
nix_flake_lock_flags_set_output_lock_file_path(nix_c_context * context, nix_flake_lock_flags * flags, char * path);
|
||||
|
||||
nix_err
|
||||
nix_flake_lock_flags_add_input_update(nix_c_context * context, nix_flake_lock_flags * flags, const char * inputPath);
|
||||
|
||||
/* nix_flake_settings */
|
||||
nix_err nix_flake_settings_set_use_registries(nix_c_context * context, nix_flake_settings * settings, bool value);
|
||||
|
||||
nix_err nix_flake_settings_set_accept_flake_config(nix_c_context * context, nix_flake_settings * settings, bool value);
|
||||
|
||||
nix_err
|
||||
nix_flake_settings_set_commit_lock_file_summary(nix_c_context * context, nix_flake_settings * settings, char * summary);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif
|
||||
|
||||
#endif // NIXIDE_API_FLAKE_H
|
||||
Loading…
Add table
Add a link
Reference in a new issue