Optionally pass Nixpkgs through entry functions (#1409)
The "builtins.fetchTarball" function is not available in some restricted environments such as build jobs of the latest Hydra. Make it possible to pass nixpkgs and nixpkgsStaticLinux when evaulating default.nix and release.nix to avoid importing them internally. This does not change the result of evaulation if no parameters are passed.
This commit is contained in:
parent
58fcc6fe90
commit
48ca2d2424
|
@ -1,13 +1,6 @@
|
|||
let
|
||||
fetchNixpkgs = import ./nix/fetchNixpkgs.nix;
|
||||
|
||||
nixpkgs = fetchNixpkgs {
|
||||
rev = "1d4de0d552ae9aa66a5b8dee5fb0650a4372d148";
|
||||
|
||||
sha256 = "09qx58dp1kbj7cpzp8ahbqfbbab1frb12sh1qng87rybcaz0dz01";
|
||||
|
||||
outputSha256 = "0xpqc1fhkvvv5dv1zmas2j1q27mi7j7dgyjcdh82mlgl1q63i660";
|
||||
};
|
||||
pinned = import ./pinnedNixpkgs.nix; in
|
||||
inherit (pinned) nixpkgs;
|
||||
|
||||
mass = function: names: haskellPackagesNew: haskellPackagesOld:
|
||||
let
|
||||
|
|
|
@ -1,50 +0,0 @@
|
|||
{ rev # The Git revision of nixpkgs to fetch
|
||||
, owner ? "NixOS"
|
||||
, sha256 # The SHA256 of the downloaded data
|
||||
, outputSha256 ? null # The SHA256 fixed-output hash
|
||||
, system ? builtins.currentSystem # This is overridable if necessary
|
||||
}:
|
||||
|
||||
if (0 <= builtins.compareVersions builtins.nixVersion "1.12")
|
||||
|
||||
# In Nix 1.12, we can just give a `sha256` to `builtins.fetchTarball`.
|
||||
then (
|
||||
builtins.fetchTarball {
|
||||
url = "https://github.com/NixOS/nixpkgs/archive/${rev}.tar.gz";
|
||||
sha256 = outputSha256;
|
||||
})
|
||||
|
||||
# This hack should at least work for Nix 1.11
|
||||
else (
|
||||
(rec {
|
||||
tarball = import <nix/fetchurl.nix> {
|
||||
url = "https://github.com/${owner}/nixpkgs/archive/${rev}.tar.gz";
|
||||
inherit sha256;
|
||||
};
|
||||
|
||||
builtin-paths = import <nix/config.nix>;
|
||||
|
||||
script = builtins.toFile "nixpkgs-unpacker" ''
|
||||
"$coreutils/mkdir" "$out"
|
||||
cd "$out"
|
||||
"$gzip" --decompress < "$tarball" | "$tar" -x --strip-components=1
|
||||
'';
|
||||
|
||||
nixpkgs = builtins.derivation ({
|
||||
name = "nixpkgs-${builtins.substring 0 6 rev}";
|
||||
|
||||
builder = builtins.storePath builtin-paths.shell;
|
||||
|
||||
args = [ script ];
|
||||
|
||||
inherit tarball system;
|
||||
|
||||
tar = builtins.storePath builtin-paths.tar;
|
||||
gzip = builtins.storePath builtin-paths.gzip;
|
||||
coreutils = builtins.storePath builtin-paths.coreutils;
|
||||
} // (if null == outputSha256 then { } else {
|
||||
outputHashMode = "recursive";
|
||||
outputHashAlgo = "sha256";
|
||||
outputHash = outputSha256;
|
||||
}));
|
||||
}).nixpkgs)
|
|
@ -0,0 +1,67 @@
|
|||
let
|
||||
fetchNixpkgs =
|
||||
{ rev # The Git revision of nixpkgs to fetch
|
||||
, owner ? "NixOS" # Owner of the Github repository
|
||||
, sha256 # The SHA256 hash of the unpacked archive
|
||||
, system ? builtins.currentSystem # This is overridable if necessary
|
||||
}:
|
||||
|
||||
if (0 <= builtins.compareVersions builtins.nixVersion "1.12")
|
||||
|
||||
# In Nix 1.12, we can just give a `sha256` to `builtins.fetchTarball`.
|
||||
then
|
||||
(builtins.fetchTarball {
|
||||
url = "https://github.com/${owner}/nixpkgs/archive/${rev}.tar.gz";
|
||||
inherit sha256;
|
||||
})
|
||||
|
||||
# This hack should at least work for Nix 1.11
|
||||
else
|
||||
((rec {
|
||||
tarball = import <nix/fetchurl.nix> {
|
||||
url = "https://github.com/${owner}/nixpkgs/archive/${rev}.tar.gz";
|
||||
sha256 = null;
|
||||
};
|
||||
|
||||
builtin-paths = import <nix/config.nix>;
|
||||
|
||||
script = builtins.toFile "nixpkgs-unpacker" ''
|
||||
"$coreutils/mkdir" "$out"
|
||||
cd "$out"
|
||||
"$gzip" --decompress < "$tarball" | "$tar" -x --strip-components=1
|
||||
'';
|
||||
|
||||
nixpkgs = builtins.derivation ({
|
||||
name = "nixpkgs-${builtins.substring 0 6 rev}";
|
||||
|
||||
builder = builtins.storePath builtin-paths.shell;
|
||||
|
||||
args = [ script ];
|
||||
|
||||
inherit tarball system;
|
||||
|
||||
tar = builtins.storePath builtin-paths.tar;
|
||||
gzip = builtins.storePath builtin-paths.gzip;
|
||||
coreutils = builtins.storePath builtin-paths.coreutils;
|
||||
} // (if null == sha256 then
|
||||
{ }
|
||||
else {
|
||||
outputHashMode = "recursive";
|
||||
outputHashAlgo = "sha256";
|
||||
outputHash = sha256;
|
||||
}));
|
||||
}).nixpkgs);
|
||||
in {
|
||||
|
||||
nixpkgs = fetchNixpkgs {
|
||||
rev = "1d4de0d552ae9aa66a5b8dee5fb0650a4372d148";
|
||||
sha256 = "0xpqc1fhkvvv5dv1zmas2j1q27mi7j7dgyjcdh82mlgl1q63i660";
|
||||
};
|
||||
|
||||
nixpkgsStaticLinux = fetchNixpkgs {
|
||||
owner = "nh2";
|
||||
rev = "925aac04f4ca58aceb83beef18cb7dae0715421b";
|
||||
sha256 = "1zr8lscjl2a5cz61f0ibyx55a94v8yyp6sjzjl2gkqjrjbg99abx";
|
||||
};
|
||||
|
||||
}
|
|
@ -1,9 +1,13 @@
|
|||
let
|
||||
pinned = import ./pinnedNixpkgs.nix;
|
||||
|
||||
defaultCompiler = "ghc843";
|
||||
|
||||
in
|
||||
|
||||
{ compiler ? defaultCompiler
|
||||
{ nixpkgs ? pinned.nixpkgs
|
||||
, nixpkgsStaticLinux ? pinned.nixpkgsStaticLinux
|
||||
, compiler ? defaultCompiler
|
||||
, coverage ? false
|
||||
, system ? builtins.currentSystem
|
||||
}:
|
||||
|
@ -17,8 +21,6 @@ let
|
|||
"dhall-nix"
|
||||
];
|
||||
|
||||
fetchNixpkgs = import ./fetchNixpkgs.nix;
|
||||
|
||||
mass = function: names: haskellPackagesNew: haskellPackagesOld:
|
||||
let
|
||||
toNameValue = name: {
|
||||
|
@ -493,16 +495,6 @@ let
|
|||
};
|
||||
};
|
||||
|
||||
|
||||
|
||||
nixpkgs = fetchNixpkgs {
|
||||
rev = "1d4de0d552ae9aa66a5b8dee5fb0650a4372d148";
|
||||
|
||||
sha256 = "09qx58dp1kbj7cpzp8ahbqfbbab1frb12sh1qng87rybcaz0dz01";
|
||||
|
||||
outputSha256 = "0xpqc1fhkvvv5dv1zmas2j1q27mi7j7dgyjcdh82mlgl1q63i660";
|
||||
};
|
||||
|
||||
pkgs = import nixpkgs {
|
||||
inherit system;
|
||||
|
||||
|
@ -600,16 +592,6 @@ let
|
|||
};
|
||||
};
|
||||
|
||||
nixpkgsStaticLinux = fetchNixpkgs {
|
||||
owner = "nh2";
|
||||
|
||||
rev = "925aac04f4ca58aceb83beef18cb7dae0715421b";
|
||||
|
||||
sha256 = "0zkvqzzyf5c742zcl1sqc8009dr6fr1fblz53v8gfl63hzqwj0x4";
|
||||
|
||||
outputSha256 = "1zr8lscjl2a5cz61f0ibyx55a94v8yyp6sjzjl2gkqjrjbg99abx";
|
||||
};
|
||||
|
||||
pkgsStaticLinux = import nixpkgsStaticLinux {
|
||||
config = {};
|
||||
overlays = [ overlayShared overlayStaticLinux ];
|
||||
|
|
28
release.nix
28
release.nix
|
@ -1,23 +1,25 @@
|
|||
{ src ? { rev = ""; }, ... }:
|
||||
let pinned = import ./nix/pinnedNixpkgs.nix;
|
||||
|
||||
in { src ? { rev = ""; }
|
||||
, nixpkgs ? pinned.nixpkgs
|
||||
, nixpkgsStaticLinux ? pinned.nixpkgsStaticLinux
|
||||
}:
|
||||
|
||||
let
|
||||
shared_7_10_3 =
|
||||
import ./nix/shared.nix { compiler = "ghc7103"; };
|
||||
callShared = args:
|
||||
import ./nix/shared.nix ({ inherit nixpkgs nixpkgsStaticLinux; } // args);
|
||||
|
||||
shared_8_6_1 =
|
||||
import ./nix/shared.nix { compiler = "ghc861"; };
|
||||
shared_7_10_3 = callShared { compiler = "ghc7103"; };
|
||||
|
||||
shared_ghcjs =
|
||||
import ./nix/shared.nix { compiler = "ghcjs"; };
|
||||
shared_8_6_1 = callShared { compiler = "ghc861"; };
|
||||
|
||||
shared =
|
||||
import ./nix/shared.nix { };
|
||||
shared_ghcjs = callShared { compiler = "ghcjs"; };
|
||||
|
||||
shared_linux =
|
||||
import ./nix/shared.nix { system = "x86_64-linux"; };
|
||||
shared = callShared { };
|
||||
|
||||
coverage =
|
||||
import ./nix/shared.nix { coverage = true; };
|
||||
shared_linux = callShared { system = "x86_64-linux"; };
|
||||
|
||||
coverage = callShared { coverage = true; };
|
||||
|
||||
in
|
||||
{ dhall = shared.aggregate
|
||||
|
|
Loading…
Reference in New Issue