mirror of
https://github.com/Mic92/nix-update.git
synced 2024-11-03 21:04:49 +03:00
Merge branch 'master' of https://github.com/mic92/nix-update into system
This commit is contained in:
commit
e386585a0e
@ -21,7 +21,7 @@ python3.pkgs.buildPythonApplication rec {
|
||||
echo -e "\x1b[32m## run black\x1b[0m"
|
||||
LC_ALL=en_US.utf-8 black --check . bin/nix-update
|
||||
echo -e "\x1b[32m## run ruff\x1b[0m"
|
||||
ruff .
|
||||
ruff . bin/nix-update
|
||||
echo -e "\x1b[32m## run mypy\x1b[0m"
|
||||
mypy --no-warn-unused-ignores --strict nix_update tests
|
||||
'';
|
||||
|
@ -17,11 +17,11 @@
|
||||
},
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1672350804,
|
||||
"narHash": "sha256-jo6zkiCabUBn3ObuKXHGqqORUMH27gYDIFFfLq5P4wg=",
|
||||
"lastModified": 1672953546,
|
||||
"narHash": "sha256-oz757DnJ1ITvwyTovuwG3l9cX6j9j6/DH9eH+cXFJmc=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "677ed08a50931e38382dbef01cba08a8f7eac8f6",
|
||||
"rev": "a518c77148585023ff56022f09c4b2c418a51ef5",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
@ -1,5 +1,6 @@
|
||||
import json
|
||||
from dataclasses import InitVar, dataclass, field
|
||||
from textwrap import dedent, indent
|
||||
from typing import Any, Dict, List, Optional
|
||||
from urllib.parse import ParseResult, urlparse
|
||||
|
||||
@ -58,23 +59,25 @@ def eval_expression(
|
||||
) -> str:
|
||||
system = f'"{system}"' if system else "builtins.currentSystem"
|
||||
|
||||
let_bindings = (
|
||||
f"""inherit (builtins) getFlake stringLength substring;
|
||||
currentSystem = {system};
|
||||
flake = getFlake "{import_path}";
|
||||
pkg = flake.packages.${{currentSystem}}.{attr} or flake.{attr};
|
||||
inherit (flake) outPath;
|
||||
outPathLen = stringLength outPath;
|
||||
sanitizePosition = {{ file, ... }}@pos:
|
||||
assert substring 0 outPathLen file == outPath;
|
||||
pos // {{ file = "{import_path}" + substring outPathLen (stringLength file - outPathLen) file; }};"""
|
||||
if flake
|
||||
else f"""
|
||||
inputs = if (builtins.functionArgs (import {import_path})) ? overlays then {{ overlays = [ ]; }} else {{ }};
|
||||
system = if (builtins.functionArgs (import {import_path})) ? system then {{ system = {system}; }} else {{ }};
|
||||
pkg = (import {import_path} (inputs // system)).{attr};
|
||||
sanitizePosition = x: x;"""
|
||||
)
|
||||
if flake:
|
||||
let_bindings = f"""
|
||||
inherit (builtins) getFlake stringLength substring;
|
||||
currentSystem = {system};
|
||||
flake = getFlake "{import_path}";
|
||||
pkg = flake.packages.${{currentSystem}}.{attr} or flake.{attr};
|
||||
inherit (flake) outPath;
|
||||
outPathLen = stringLength outPath;
|
||||
sanitizePosition = {{ file, ... }}@pos:
|
||||
assert substring 0 outPathLen file == outPath;
|
||||
pos // {{ file = "{import_path}" + substring outPathLen (stringLength file - outPathLen) file; }};
|
||||
"""
|
||||
else:
|
||||
let_bindings = f"""
|
||||
inputs = if (builtins.functionArgs (import {import_path})) ? overlays then {{ overlays = [ ]; }} else {{ }};
|
||||
system = if (builtins.functionArgs (import {import_path})) ? system then {{ system = {system}; }} else {{ }};
|
||||
pkg = (import {import_path} (inputs // system)).{attr};
|
||||
sanitizePosition = x: x;
|
||||
"""
|
||||
|
||||
has_update_script = (
|
||||
"false" if flake else "pkg.passthru.updateScript or null != null"
|
||||
@ -82,7 +85,7 @@ def eval_expression(
|
||||
|
||||
return f"""
|
||||
let
|
||||
{let_bindings}
|
||||
{indent(dedent(let_bindings), " ")}
|
||||
raw_version_position = sanitizePosition (builtins.unsafeGetAttrPos "version" pkg);
|
||||
|
||||
position = if pkg ? isRubyGem then
|
||||
|
Loading…
Reference in New Issue
Block a user