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

Update to unstable version by default instead of stable version #198

Closed
selfuryon opened this issue Sep 29, 2023 · 4 comments
Closed

Update to unstable version by default instead of stable version #198

selfuryon opened this issue Sep 29, 2023 · 4 comments

Comments

@selfuryon
Copy link

Hello!
I find out that for some tags nix-update try to update a package to unstable version (by semver) by default.

For example for ethereum.nix project it tries to update lighthouse from 4.5.0 to 4.5.222-exp

$ nix-update --flake lighthouse
$ nix eval --json --impure --expr
let

  inherit (builtins) getFlake stringLength substring;
  currentSystem = builtins.currentSystem;
  flake = getFlake "/home/syakovlev/src/private/ethereum.nix";
  pkg = flake.packages.${currentSystem}."lighthouse" or flake."lighthouse";
  inherit (flake) outPath;
  outPathLen = stringLength outPath;
  sanitizePosition = { file, ... }@pos:
    assert substring 0 outPathLen file != outPath
      -> throw "${file} is not in ${outPath}";
    pos // { file = "/home/syakovlev/src/private/ethereum.nix" + substring outPathLen (stringLength file - outPathLen) file; };

  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
    sanitizePosition (builtins.unsafeGetAttrPos "src" 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;
  npm_deps = pkg.npmDeps.outputHash or null;
  tests = builtins.attrNames (pkg.passthru.tests or {});
  has_update_script = false;
  src_homepage = pkg.src.meta.homepage or null;
  changelog = pkg.meta.changelog or null;
} --extra-experimental-features flakes nix-command
fetch https://github.com/sigp/lighthouse/releases.atom
Update 4.5.0 -> 4.5.222-exp in /.../ethereum.nix/packages/clients/consensus/lighthouse/default.nix
...
@Mic92
Copy link
Owner

Mic92 commented Sep 30, 2023

Currently we use the atom feed to not have to have github api tokens.
However this also means we cannot figure out if a version is an "experimental" one.

You can filter however using regexes like this:

nix-update jq --version-regex 'v(\d+\.\d+\.\d+)'

@Mic92
Copy link
Owner

Mic92 commented Sep 30, 2023

Semver is something that is hard to rely on since projects in general seem not to follow it consistently.

@Mic92
Copy link
Owner

Mic92 commented Sep 30, 2023

You can also put this in your package definition like this:

 passthru.updateScript = nix-update-script {
   extraArgs = [ "--version-regex" "v(.+)" ];
 };

And than do nix-update --use-update-script

@selfuryon
Copy link
Author

Got that, thanks for the explanation!

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

2 participants