Skip to content

Commit

Permalink
t
Browse files Browse the repository at this point in the history
  • Loading branch information
jpverde committed Jun 27, 2023
1 parent 01b40ff commit b47f483
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 18 deletions.
18 changes: 3 additions & 15 deletions src/cli/main/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,16 +267,9 @@ def _clone_src_cache_refresh(head: str, cache_key: str) -> None:
shutil.copytree(head, cached)


def _get_attr_paths(head: str) -> str:
rel_paths: list[str] = glob("**/main.nix", root_dir=head, recursive=True)
abs_paths: list[str] = [f"/{path}" for path in rel_paths]
return json.dumps({"attrs": abs_paths}, separators=(",", ":"))


def _nix_build(
*,
attr: str,
attr_paths: str,
cache: Optional[List[Dict[str, str]]],
head: str,
out: str = "",
Expand Down Expand Up @@ -308,7 +301,6 @@ def _nix_build(
*_if(not NIX_STABLE, "build"),
*_if(NIX_STABLE, "--argstr", "makesSrc", __MAKES_SRC__),
*_if(NIX_STABLE, "--argstr", "projectSrc", head),
*["--argstr", "attrPaths", attr_paths],
*_if(NIX_STABLE, "--attr", attr),
*["--option", "cores", "0"],
*_if(not NIX_STABLE, "--impure"),
Expand Down Expand Up @@ -411,7 +403,7 @@ class Config(NamedTuple):
cache: List[Dict[str, str]]


def _get_config(head: str, attr_paths: str) -> Config:
def _get_config(head: str) -> Config:
CON.out()
CON.rule("Building project configuration")
CON.out()
Expand All @@ -421,7 +413,6 @@ def _get_config(head: str, attr_paths: str) -> Config:
attr="config.configAsJson"
if NIX_STABLE
else f'{head}#__makes__."config:configAsJson"',
attr_paths=attr_paths,
cache=None,
head=head,
out=out,
Expand Down Expand Up @@ -578,8 +569,7 @@ def cli(args: List[str]) -> None:
_help_and_exit_base()

head: str = _get_head(src)
attr_paths: str = _get_attr_paths(head)
config: Config = _get_config(head, attr_paths)
config: Config = _get_config(head)

args, attr = _cli_get_args_and_attr(args, config.attrs, src)

Expand All @@ -588,7 +578,7 @@ def cli(args: List[str]) -> None:
MAKES_DIR,
f"provenance{attr.replace('/', '-')}.json",
)
code = _cli_build(attr, attr_paths, config, head, out, src)
code = _cli_build(attr, config, head, out, src)

if code == 0:
write_provenance(args, head, out, provenance, src)
Expand Down Expand Up @@ -616,7 +606,6 @@ def _cli_get_args_and_attr(

def _cli_build( # pylint: disable=too-many-arguments
attr: str,
attr_paths: str,
config: Config,
head: str,
out: str,
Expand All @@ -637,7 +626,6 @@ def _cli_build( # pylint: disable=too-many-arguments
attr=f'config.outputs."{attr}"'
if NIX_STABLE
else f'{head}#__makes__."config:outputs:{attr}"',
attr_paths=attr_paths,
cache=config.cache,
head=head,
out=out,
Expand Down
13 changes: 10 additions & 3 deletions src/evaluator/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@
# You better avoid changing this function signature...
# Ask a maintainer first.
{
# JSON String containing complete list of main.nix files found within projectSrc
attrPaths,
# flake inputs to inject, if any
flakeInputs ? {},
# Source code of makes, can be overriden by the user.
Expand All @@ -35,6 +33,15 @@
then import makesLockNixPath
else {};

makesExtendsPath = projectSrc + "/makes-extends.nix";
makesExtendsNix =
if builtins.pathExists makesExtendsPath
then import makesExtendsNix
else {};
makesExtendsPaths =
nixpkgs.lib.attrsets.catAttrs "path"
(nixpkgs.lib.attrsets.getAttrFromPath ["makesExtends"] makesExtendsNix);

makesSrcOverriden =
if makesLockNix ? "makesSrc"
then makesLockNix.makesSrc
Expand All @@ -58,7 +65,7 @@
"${makesSrcOverriden}/src/evaluator/modules/default.nix"
makesNix
];
specialArgs = args // {inherit attrPaths;};
specialArgs = args // {inherit makesExtendsPaths;};
};
in
result

0 comments on commit b47f483

Please sign in to comment.