Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Empties package file when updating to the same version #295

Open
l0b0 opened this issue Oct 31, 2024 · 0 comments
Open

Empties package file when updating to the same version #295

l0b0 opened this issue Oct 31, 2024 · 0 comments

Comments

@l0b0
Copy link

l0b0 commented Oct 31, 2024

To reproduce:

  1. Check out daggerfall-unity: init at 1.1.1 NixOS/nixpkgs#350177
  2. nix-update '--version-regex=^v(\d+(\.\d+)*)$' daggerfall-unity

Console session:

❯ nix-update '--version-regex=^v(\d+(\.\d+)*)$' daggerfall-unity
$ nix eval --json --impure --expr 
let
  
  pkgs = import "/home/victor/nixpkgs";
  args =  builtins.functionArgs pkgs;
  inputs = (if args ? system then { system = builtins.currentSystem; } else {}) //
           (if args ? overlays then { overlays = [ ]; } else {});
  pkg = (pkgs inputs)."daggerfall-unity";
  sanitizePosition = x: x;

  positionFromMeta = pkg: let
    parts = builtins.match "(.*):([0-9]+)" pkg.meta.position;
  in {
    file = builtins.elemAt parts 0;
    line = builtins.fromJSON (builtins.elemAt parts 1);
  };

  raw_version_position = sanitizePosition (builtins.unsafeGetAttrPos "version" pkg);

  position = if pkg ? isRubyGem then
    raw_version_position
  else if pkg ? isPhpExtension then
    raw_version_position
  else if (builtins.unsafeGetAttrPos "src" pkg) != null then
    sanitizePosition (builtins.unsafeGetAttrPos "src" pkg)
  else
    sanitizePosition (positionFromMeta pkg);
in {
  name = pkg.name;
  old_version = pkg.version or (builtins.parseDrvName pkg.name).version;
  inherit raw_version_position;
  filename = position.file;
  line = position.line;
  urls = pkg.src.urls or null;
  url = pkg.src.url or null;
  rev = pkg.src.rev or null;
  hash = pkg.src.outputHash or null;
  go_modules = pkg.goModules.outputHash or null;
  go_modules_old = pkg.go-modules.outputHash or null;
  cargo_deps = pkg.cargoDeps.outputHash or null;
  raw_cargo_lock =
    if pkg ? cargoDeps.lockFile then
      let
        inherit (pkg.cargoDeps) lockFile;
        res = builtins.tryEval (sanitizePosition {
          file = toString lockFile;
        });
      in
      if res.success then res.value.file else false
    else
      null;
  composer_deps = pkg.composerRepository.outputHash or null;
  npm_deps = pkg.npmDeps.outputHash or null;
  pnpm_deps = pkg.pnpmDeps.outputHash or null;
  yarn_deps = pkg.offlineCache.outputHash or null;
  maven_deps = pkg.fetchedMavenDeps.outputHash or null;
  mix_deps = pkg.mixFodDeps.outputHash or null;
  tests = builtins.attrNames (pkg.passthru.tests or {});
  has_update_script = pkg.passthru.updateScript or null != null;
  src_homepage = pkg.src.meta.homepage or null;
  changelog = pkg.meta.changelog or null;
  maintainers = pkg.meta.maintainers or null;
} --extra-experimental-features flakes nix-command
fetch https://github.com/Interkarma/daggerfall-unity/releases.atom
$ git diff --color=never --word-diff=porcelain -- /home/victor/nixpkgs/pkgs/by-name/da/daggerfall-unity/package.nix
Update 1.1.1 -> 1.1.1 in /home/victor/nixpkgs/pkgs/by-name/da/daggerfall-unity/package.nix
Traceback (most recent call last):
  File "/nix/store/zgz97bjlbcjbnik6p69wiyblxpn03jv0-nix-update-1.5.2/bin/.nix-update-wrapped", line 9, in <module>
    sys.exit(main())
             ^^^^^^
  File "/nix/store/zgz97bjlbcjbnik6p69wiyblxpn03jv0-nix-update-1.5.2/lib/python3.12/site-packages/nix_update/__init__.py", line 311, in main
    package = update(options)
              ^^^^^^^^^^^^^^^
  File "/nix/store/zgz97bjlbcjbnik6p69wiyblxpn03jv0-nix-update-1.5.2/lib/python3.12/site-packages/nix_update/update.py", line 449, in update
    update_hash = update_version(
                  ^^^^^^^^^^^^^^^
  File "/nix/store/zgz97bjlbcjbnik6p69wiyblxpn03jv0-nix-update-1.5.2/lib/python3.12/site-packages/nix_update/update.py", line 422, in update_version
    return replace_version(package)
           ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/nix/store/zgz97bjlbcjbnik6p69wiyblxpn03jv0-nix-update-1.5.2/lib/python3.12/site-packages/nix_update/update.py", line 41, in replace_version
    line = line.replace(package.rev, package.new_version.rev)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: replace() argument 1 must be str, not None
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant