mirror of
https://github.com/NixOS/nix
synced 2025-06-25 10:41:16 +02:00
Move call-flake.nix to nix-flake
As suggested by Ericson2314 in review https://github.com/NixOS/nix/pull/12759#issuecomment-2755352343
This commit is contained in:
parent
6fc9651d57
commit
0c75581d8b
7 changed files with 34 additions and 10 deletions
|
@ -288,10 +288,6 @@ EvalState::EvalState(
|
||||||
CanonPath("derivation-internal.nix"),
|
CanonPath("derivation-internal.nix"),
|
||||||
#include "primops/derivation.nix.gen.hh"
|
#include "primops/derivation.nix.gen.hh"
|
||||||
)}
|
)}
|
||||||
, callFlakeInternal{internalFS->addFile(
|
|
||||||
CanonPath("call-flake.nix"),
|
|
||||||
#include "call-flake.nix.gen.hh"
|
|
||||||
)}
|
|
||||||
, store(store)
|
, store(store)
|
||||||
, buildStore(buildStore ? buildStore : store)
|
, buildStore(buildStore ? buildStore : store)
|
||||||
, debugRepl(nullptr)
|
, debugRepl(nullptr)
|
||||||
|
|
|
@ -274,14 +274,12 @@ public:
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* In-memory filesystem for internal, non-user-callable Nix
|
* In-memory filesystem for internal, non-user-callable Nix
|
||||||
* expressions like call-flake.nix.
|
* expressions like `derivation.nix`.
|
||||||
*/
|
*/
|
||||||
const ref<MemorySourceAccessor> internalFS;
|
const ref<MemorySourceAccessor> internalFS;
|
||||||
|
|
||||||
const SourcePath derivationInternal;
|
const SourcePath derivationInternal;
|
||||||
|
|
||||||
const SourcePath callFlakeInternal;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Store used to materialise .drv files.
|
* Store used to materialise .drv files.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -126,7 +126,6 @@ generated_headers = []
|
||||||
foreach header : [
|
foreach header : [
|
||||||
'imported-drv-to-derivation.nix',
|
'imported-drv-to-derivation.nix',
|
||||||
'fetchurl.nix',
|
'fetchurl.nix',
|
||||||
'call-flake.nix',
|
|
||||||
]
|
]
|
||||||
generated_headers += gen_header.process(header)
|
generated_headers += gen_header.process(header)
|
||||||
endforeach
|
endforeach
|
||||||
|
|
|
@ -16,6 +16,8 @@
|
||||||
|
|
||||||
#include <nlohmann/json.hpp>
|
#include <nlohmann/json.hpp>
|
||||||
|
|
||||||
|
#include "memory-source-accessor.hh"
|
||||||
|
|
||||||
namespace nix {
|
namespace nix {
|
||||||
|
|
||||||
using namespace flake;
|
using namespace flake;
|
||||||
|
@ -921,6 +923,25 @@ LockedFlake lockFlake(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static ref<SourceAccessor> makeInternalFS() {
|
||||||
|
auto internalFS = make_ref<MemorySourceAccessor>(MemorySourceAccessor {});
|
||||||
|
internalFS->setPathDisplay("«flakes-internal»", "");
|
||||||
|
internalFS->addFile(
|
||||||
|
CanonPath("call-flake.nix"),
|
||||||
|
#include "call-flake.nix.gen.hh"
|
||||||
|
);
|
||||||
|
return internalFS;
|
||||||
|
}
|
||||||
|
|
||||||
|
static auto internalFS = makeInternalFS();
|
||||||
|
|
||||||
|
static Value * requireInternalFile(EvalState & state, CanonPath path) {
|
||||||
|
SourcePath p {internalFS, path};
|
||||||
|
auto v = state.allocValue();
|
||||||
|
state.evalFile(p, *v); // has caching
|
||||||
|
return v;
|
||||||
|
}
|
||||||
|
|
||||||
void callFlake(EvalState & state,
|
void callFlake(EvalState & state,
|
||||||
const LockedFlake & lockedFlake,
|
const LockedFlake & lockedFlake,
|
||||||
Value & vRes)
|
Value & vRes)
|
||||||
|
@ -960,8 +981,7 @@ void callFlake(EvalState & state,
|
||||||
|
|
||||||
auto & vOverrides = state.allocValue()->mkAttrs(overrides);
|
auto & vOverrides = state.allocValue()->mkAttrs(overrides);
|
||||||
|
|
||||||
auto vCallFlake = state.allocValue();
|
Value * vCallFlake = requireInternalFile(state, CanonPath("call-flake.nix"));
|
||||||
state.evalFile(state.callFlakeInternal, *vCallFlake);
|
|
||||||
|
|
||||||
auto vLocks = state.allocValue();
|
auto vLocks = state.allocValue();
|
||||||
vLocks->mkString(lockFileStr);
|
vLocks->mkString(lockFileStr);
|
||||||
|
|
|
@ -39,6 +39,15 @@ add_project_arguments(
|
||||||
|
|
||||||
subdir('nix-meson-build-support/common')
|
subdir('nix-meson-build-support/common')
|
||||||
|
|
||||||
|
subdir('nix-meson-build-support/generate-header')
|
||||||
|
|
||||||
|
generated_headers = []
|
||||||
|
foreach header : [
|
||||||
|
'call-flake.nix',
|
||||||
|
]
|
||||||
|
generated_headers += gen_header.process(header)
|
||||||
|
endforeach
|
||||||
|
|
||||||
sources = files(
|
sources = files(
|
||||||
'flake/config.cc',
|
'flake/config.cc',
|
||||||
'flake/flake.cc',
|
'flake/flake.cc',
|
||||||
|
@ -62,6 +71,7 @@ headers = files(
|
||||||
this_library = library(
|
this_library = library(
|
||||||
'nixflake',
|
'nixflake',
|
||||||
sources,
|
sources,
|
||||||
|
generated_headers,
|
||||||
dependencies : deps_public + deps_private + deps_other,
|
dependencies : deps_public + deps_private + deps_other,
|
||||||
prelink : true, # For C++ static initializers
|
prelink : true, # For C++ static initializers
|
||||||
install : true,
|
install : true,
|
||||||
|
|
|
@ -28,6 +28,7 @@ mkMesonLibrary (finalAttrs: {
|
||||||
../../.version
|
../../.version
|
||||||
./.version
|
./.version
|
||||||
./meson.build
|
./meson.build
|
||||||
|
./call-flake.nix
|
||||||
(fileset.fileFilter (file: file.hasExt "cc") ./.)
|
(fileset.fileFilter (file: file.hasExt "cc") ./.)
|
||||||
(fileset.fileFilter (file: file.hasExt "hh") ./.)
|
(fileset.fileFilter (file: file.hasExt "hh") ./.)
|
||||||
];
|
];
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue