1
1
Fork 0
mirror of https://github.com/NixOS/nix.git synced 2025-11-30 06:01:00 +01:00

InstallableFlake::toDerivedPaths(): Support paths and store paths

This makes 'nix build' work on paths (which will be copied to the
store) and store paths (returned as is). E.g. the following flake
output attributes can be built using 'nix build .#foo':

  foo = ./src;
  foo = self.outPath;
  foo = builtins.fetchTarball { ... };
  foo = (builtins.fetchTree { .. }).outPath;
  foo = builtins.fetchTree { .. } + "/README.md";
  foo = builtins.storePath /nix/store/...;

Note that this is potentially risky, e.g.

  foo = /.;

will cause Nix to try to copy the entire file system to the store.

What doesn't work yet:

  foo = self;
  foo = builtins.fetchTree { .. };

because we don't handle attrsets with an outPath attribute in it yet,
and

  foo = builtins.storePath /nix/store/.../README.md;

since result symlinks have to point to a store path currently (rather
than a file inside a store path).

Fixes #7417.
This commit is contained in:
Eelco Dolstra 2022-12-15 23:01:15 +01:00
parent 210cd8c565
commit 81a4516397
4 changed files with 104 additions and 4 deletions

View file

@ -66,7 +66,7 @@ struct InputAccessor : public std::enable_shared_from_this<InputAccessor>
StorePath fetchToStore(
ref<Store> store,
const CanonPath & path,
std::string_view name,
std::string_view name = "source",
PathFilter * filter = nullptr,
RepairFlag repair = NoRepair);
@ -151,7 +151,7 @@ struct SourcePath
StorePath fetchToStore(
ref<Store> store,
std::string_view name,
std::string_view name = "source",
PathFilter * filter = nullptr,
RepairFlag repair = NoRepair) const;