mirror of
https://github.com/Mic92/nix-update.git
synced 2024-09-17 13:27:27 +03:00
respect --override-filename flag for flakes
fixes https://github.com/Mic92/nix-update/issues/238
This commit is contained in:
parent
c20ec18496
commit
8d44ca1d8f
@ -94,11 +94,24 @@ class Package:
|
|||||||
|
|
||||||
|
|
||||||
def eval_expression(
|
def eval_expression(
|
||||||
escaped_import_path: str, attr: str, flake: bool, system: str | None
|
escaped_import_path: str, attr: str, flake: bool, system: str | None, override_filename: str | None
|
||||||
) -> str:
|
) -> str:
|
||||||
system = f'"{system}"' if system else "builtins.currentSystem"
|
system = f'"{system}"' if system else "builtins.currentSystem"
|
||||||
|
|
||||||
if flake:
|
if flake:
|
||||||
|
sanitize_position = (
|
||||||
|
f"""
|
||||||
|
sanitizePosition = {{ file, ... }}@pos:
|
||||||
|
assert substring 0 outPathLen file != outPath
|
||||||
|
-> throw "${{file}} is not in ${{outPath}}";
|
||||||
|
pos // {{ file = {escaped_import_path} + substring outPathLen (stringLength file - outPathLen) file; }};
|
||||||
|
"""
|
||||||
|
if override_filename is None
|
||||||
|
else """
|
||||||
|
sanitizePosition = x: x;
|
||||||
|
"""
|
||||||
|
).strip()
|
||||||
|
|
||||||
let_bindings = f"""
|
let_bindings = f"""
|
||||||
inherit (builtins) getFlake stringLength substring;
|
inherit (builtins) getFlake stringLength substring;
|
||||||
currentSystem = {system};
|
currentSystem = {system};
|
||||||
@ -106,10 +119,7 @@ def eval_expression(
|
|||||||
pkg = flake.packages.${{currentSystem}}.{attr} or flake.{attr};
|
pkg = flake.packages.${{currentSystem}}.{attr} or flake.{attr};
|
||||||
inherit (flake) outPath;
|
inherit (flake) outPath;
|
||||||
outPathLen = stringLength outPath;
|
outPathLen = stringLength outPath;
|
||||||
sanitizePosition = {{ file, ... }}@pos:
|
{sanitize_position}
|
||||||
assert substring 0 outPathLen file != outPath
|
|
||||||
-> throw "${{file}} is not in ${{outPath}}";
|
|
||||||
pos // {{ file = {escaped_import_path} + substring outPathLen (stringLength file - outPathLen) file; }};
|
|
||||||
"""
|
"""
|
||||||
else:
|
else:
|
||||||
let_bindings = f"""
|
let_bindings = f"""
|
||||||
@ -174,7 +184,7 @@ in {{
|
|||||||
|
|
||||||
def eval_attr(opts: Options) -> Package:
|
def eval_attr(opts: Options) -> Package:
|
||||||
expr = eval_expression(
|
expr = eval_expression(
|
||||||
opts.escaped_import_path, opts.escaped_attribute, opts.flake, opts.system
|
opts.escaped_import_path, opts.escaped_attribute, opts.flake, opts.system, opts.override_filename
|
||||||
)
|
)
|
||||||
cmd = [
|
cmd = [
|
||||||
"nix",
|
"nix",
|
||||||
|
Loading…
Reference in New Issue
Block a user