[Nix-dev] Fetching variable and unpredictable URL download link

Berno Strik dutchman55 at gmx.com
Mon Mar 2 10:48:39 CET 2015


Op Sun, 1 Mar 2015 20:36:54 -0300
Anderson Torres <torres.anderson.85 at gmail.com> schreef:

> 2015-03-01 15:16 GMT-03:00 Berno Strik <dutchman55 at gmx.com>:
> > Op Sun, 1 Mar 2015 12:21:04 -0300
> > Anderson Torres <torres.anderson.85 at gmail.com> schreef:
> >
> >> Hello, Nixers!
> >>
> >> How can I "fetchurl" a variable url?
> >>
> >> When I download a dockapp from Windowmaker site, like
> >>
> >> "http://windowmaker.org/dockapps/?download=wmSMPmon-3.1.tar.gz",
> >>
> >> it in fact downloads something like "wmSMPmon-${a long string of
> >> chars, like a checksum}.tar.gz". And the long string is
> >> unpredictable.
> >>
> >> And when I run nix-prefetch-url
> >> "http://windowmaker.org/dockapps/?download=wmSMPmon-3.1.tar.gz"
> >> more than once, it just outputs different hashes:
> >>
> >> > nix-prefetch-url
> >> > http://windowmaker.org/dockapps/\?download\=wmSMPmon-3.1.tar.gz
> >>   % Total    % Received % Xferd  Average Speed   Time    Time
> >> Time  Current Dload  Upload   Total   Spent    Left  Speed
> >>   0     0    0     0    0     0      0      0 --:--:--  0:00:01
> >> --:--:--     0 100 24113    0 24113    0     0   3809      0
> >> --:--:--  0:00:06 --:--:--  5139 path is
> >> ‘/nix/store/lqri8zgmwz3mbf3q07kp62zl81bc6fpq-?download=wmSMPmon-3.1.tar.gz’
> >> 104bcfj4j0vlnr4v1fzahgj9amccn1aq7rjcpy1jyqnq6lbrmc3g
> >>
> >> > nix-prefetch-url
> >> > http://windowmaker.org/dockapps/\?download\=wmSMPmon-3.1.tar.gz
> >>   % Total    % Received % Xferd  Average Speed   Time    Time
> >> Time  Current Dload  Upload   Total   Spent    Left  Speed
> >>   0     0    0     0    0     0      0      0 --:--:-- --:--:--
> >> --:--:--     0 100 24110    0 24110    0     0   3193      0
> >> --:--:--  0:00:07 --:--:--  3985 path is
> >> ‘/nix/store/f2b7rksjfh6ajddjhx09xb0jzc04jxg9-?download=wmSMPmon-3.1.tar.gz’
> >> 1s01whvf51jrwdmrk3bdgysaa2rzmh56c9p0kv3ydxijaagvqi2x
> >>
> >> How can I download it?
> >
> > Use the following code:
> >
> >   src = fetchgit {
> >      url = git://repo.or.cz/dockapps.git;
> >      rev = "38c74350b02f35824554ce0c4f0f251d71762040";
> >      sha256 =
> > "0g9cwhlqg065fbhav4g4n16a4cqkk9jykl3y0zwbn5whhacfqyhl"; };
> >
> > Explanation:
> >
> > When you download a dockapp from Windowmaker site you are
> > redirected to a git repo site where you get a snapshot out of it.
> > The id of the snapshot is the long hexadecimal string you are
> > getting. The above code does a checkout of the whole dockapp-git
> > directory. The only thing you have left to do is point to the
> > directory where your actual dockapp is:
> >
> > postUnpack = "sourceRoot=\${sourceRoot}/dockapp-dir";
> >
> 
> So you are just saying we need to download all dockapps and build one
> by one?
> 
> It appears to be better handled with a "multiple-output derivation"! I
> will do some research on Nix docs about it.
> 
Yes this seemes the only solution if you want a stable checksum.
The rev = "38c74350b02f35824554ce0c4f0f251d71762040" points to a very
recent commit of the dockapp-git and this should always provide the
same checksum.

> >> _______________________________________________
> >> nix-dev mailing list
> >> nix-dev at lists.science.uu.nl
> >> http://lists.science.uu.nl/mailman/listinfo/nix-dev
> >
> _______________________________________________
> nix-dev mailing list
> nix-dev at lists.science.uu.nl
> http://lists.science.uu.nl/mailman/listinfo/nix-dev



More information about the nix-dev mailing list