forked from vkleen/machines
-
Notifications
You must be signed in to change notification settings - Fork 0
/
fetch-nixpkgs.nix
29 lines (29 loc) · 948 Bytes
/
fetch-nixpkgs.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
{ override-rev ? null, override-json ? ./nixpkgs-src.json }:
let
spec = builtins.fromJSON (builtins.readFile override-json) // {
${if override-rev != null then "rev" else null} = override-rev;
};
src = let url = "https://github.com/${spec.owner}/${spec.repo}/archive/${spec.rev}.tar.gz";
in if override-rev == null
then import <nix/fetchurl.nix> {
inherit url;
inherit (spec) hash;
}
else builtins.fetchurl url;
nixcfg = import <nix/config.nix>;
in builtins.derivation {
system = builtins.currentSystem;
name = "nixpkgs-unpacked";
builder = builtins.storePath nixcfg.shell;
inherit src;
args = [
(builtins.toFile "builder" ''
$coreutils/mkdir $out
cd $out
$gzip -d < $src | $tar -x --strip-components=1
'')
];
coreutils = builtins.storePath nixcfg.coreutils;
tar = builtins.storePath nixcfg.tar;
gzip = builtins.storePath nixcfg.gzip;
}