niv icon indicating copy to clipboard operation
niv copied to clipboard

Add example for fetching a particular version

Open nmattia opened this issue 5 years ago • 9 comments

$ niv add foo/bar -a rev=v10.0

nmattia avatar Feb 12 '20 15:02 nmattia

If we add a specific revision, is the default that this version will remain non-updated upon call to niv update?

mjlbach avatar Feb 17 '20 18:02 mjlbach

wondering if its worth adding a new flag just for revision (e.g. niv add foo/bar -rev v10.0)

rencire avatar Feb 17 '20 23:02 rencire

@rencire definitely, see https://github.com/nmattia/niv/pull/138 by @michaelpj .

I realized it's very uncommon for people to use -r foo to change/set the repo, so maybe we could recycle this one for the rev.

If we add a specific revision, is the default that this version will remain non-updated upon call to niv update?

If you set the rev then it won't be updated during that update call. But it will get updated in subsequent calls. I think @knl and @zimbatm were looking for a point to point to a particular version as well: https://github.com/nmattia/niv/issues/141

nmattia avatar Feb 18 '20 09:02 nmattia

Does this actually work? I tried to update my nixpkgs pin with

niv update nixpkgs -a rev=abcde

and the change was not reflected in the sources.json file.

mpickering avatar Mar 22 '20 15:03 mpickering

You probably want to use niv modify: niv update updates the revision from the specified branch, which will overwrite what you set!

(This is a bit confusing, I think it's easy to confuse "update based on user input" vs "update based on remote source"!)

michaelpj avatar Mar 22 '20 15:03 michaelpj

My version of niv doesn't seem to have a modify command.. perhaps it is extremely old. Time to upgrade.

mpickering avatar Mar 22 '20 15:03 mpickering

niv update nixpkgs -a rev=abcde

regardless of your version, this should update the rev... can you share the nixpkgs entry?

nmattia avatar Mar 23 '20 10:03 nmattia

I don't think it will, this is one of the reasons I asked for modify in the first place!

What happens is:

  • rev gets set to what you asked for.
  • update goes and fetches the latest rev from the branch in the spec, and overwrites whatever you supplied in the first step.

michaelpj avatar Mar 23 '20 11:03 michaelpj

No, specifying attributes should lock that particular attribute in the update. If the attribute gets updated, it's definitely a bug!

nmattia avatar Mar 23 '20 12:03 nmattia