mirror of
https://github.com/ilyakooo0/haskell.nix.git
synced 2024-09-11 06:55:40 +03:00
Add niv sources at haskell-nix.sources (#622)
This commit is contained in:
parent
66e40b0860
commit
74915fa817
@ -2,10 +2,9 @@ let haskellNix = {
|
||||
checkMaterialization ? false, # Allows us to easily switch on materialization checking
|
||||
defaultCompilerNixName ? null, # Quick way to override the default compiler e.g. "ghc883"
|
||||
system ? builtins.currentSystem,
|
||||
... }: rec {
|
||||
sources = {
|
||||
inherit (import ./nixpkgs/default.nix) nixpkgs-1909 nixpkgs-2003 nixpkgs-default;
|
||||
};
|
||||
sourcesOverride ? {},
|
||||
... }@args: rec {
|
||||
sources = (import ./nix/sources.nix) // sourcesOverride;
|
||||
|
||||
config = import ./config.nix;
|
||||
overlays = [ allOverlays.combined ] ++ (
|
||||
@ -29,7 +28,7 @@ let haskellNix = {
|
||||
)]
|
||||
else []
|
||||
);
|
||||
allOverlays = import ./overlays;
|
||||
allOverlays = import ./overlays args;
|
||||
nixpkgsArgs = { inherit config overlays system; };
|
||||
pkgs = import sources.nixpkgs-default nixpkgsArgs;
|
||||
};
|
||||
|
50
nix/sources.json
Normal file
50
nix/sources.json
Normal file
@ -0,0 +1,50 @@
|
||||
{
|
||||
"niv": {
|
||||
"branch": "master",
|
||||
"description": "Easy dependency management for Nix projects",
|
||||
"homepage": "https://github.com/nmattia/niv",
|
||||
"owner": "nmattia",
|
||||
"repo": "niv",
|
||||
"rev": "f73bf8d584148677b01859677a63191c31911eae",
|
||||
"sha256": "0jlmrx633jvqrqlyhlzpvdrnim128gc81q5psz2lpp2af8p8q9qs",
|
||||
"type": "tarball",
|
||||
"url": "https://github.com/nmattia/niv/archive/f73bf8d584148677b01859677a63191c31911eae.tar.gz",
|
||||
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
|
||||
},
|
||||
"nixpkgs-1909": {
|
||||
"branch": "nixpkgs-19.09-darwin",
|
||||
"description": "Nix Packages collection",
|
||||
"homepage": null,
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "9237a09d8edbae9951a67e9a3434a07ef94035b7",
|
||||
"sha256": "05bizymljzzd665bpsjbhxamcgzq7bkjjzjfapkl2nicy774ak4x",
|
||||
"type": "tarball",
|
||||
"url": "https://github.com/NixOS/nixpkgs/archive/9237a09d8edbae9951a67e9a3434a07ef94035b7.tar.gz",
|
||||
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
|
||||
},
|
||||
"nixpkgs-2003": {
|
||||
"branch": "nixpkgs-20.03-darwin",
|
||||
"description": "Nix Packages collection",
|
||||
"homepage": null,
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "cac363c661817666e43d047addfaa722610d425f",
|
||||
"sha256": "0fi8hgddy8qh2jrsa40jw7jxnr5lrhq2ji6a2xbndllivhzc31kf",
|
||||
"type": "tarball",
|
||||
"url": "https://github.com/NixOS/nixpkgs/archive/cac363c661817666e43d047addfaa722610d425f.tar.gz",
|
||||
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
|
||||
},
|
||||
"nixpkgs-default": {
|
||||
"branch": "nixpkgs-20.03-darwin",
|
||||
"description": "Nix Packages collection",
|
||||
"homepage": null,
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "cac363c661817666e43d047addfaa722610d425f",
|
||||
"sha256": "0fi8hgddy8qh2jrsa40jw7jxnr5lrhq2ji6a2xbndllivhzc31kf",
|
||||
"type": "tarball",
|
||||
"url": "https://github.com/NixOS/nixpkgs/archive/cac363c661817666e43d047addfaa722610d425f.tar.gz",
|
||||
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
|
||||
}
|
||||
}
|
134
nix/sources.nix
Normal file
134
nix/sources.nix
Normal file
@ -0,0 +1,134 @@
|
||||
# This file has been generated by Niv.
|
||||
|
||||
let
|
||||
|
||||
#
|
||||
# The fetchers. fetch_<type> fetches specs of type <type>.
|
||||
#
|
||||
|
||||
fetch_file = pkgs: spec:
|
||||
if spec.builtin or true then
|
||||
builtins_fetchurl { inherit (spec) url sha256; }
|
||||
else
|
||||
pkgs.fetchurl { inherit (spec) url sha256; };
|
||||
|
||||
fetch_tarball = pkgs: spec:
|
||||
if spec.builtin or true then
|
||||
builtins_fetchTarball { inherit (spec) url sha256; }
|
||||
else
|
||||
pkgs.fetchzip { inherit (spec) url sha256; };
|
||||
|
||||
fetch_git = spec:
|
||||
builtins.fetchGit { url = spec.repo; inherit (spec) rev ref; };
|
||||
|
||||
fetch_builtin-tarball = spec:
|
||||
builtins.trace
|
||||
''
|
||||
WARNING:
|
||||
The niv type "builtin-tarball" will soon be deprecated. You should
|
||||
instead use `builtin = true`.
|
||||
|
||||
$ niv modify <package> -a type=tarball -a builtin=true
|
||||
''
|
||||
builtins_fetchTarball { inherit (spec) url sha256; };
|
||||
|
||||
fetch_builtin-url = spec:
|
||||
builtins.trace
|
||||
''
|
||||
WARNING:
|
||||
The niv type "builtin-url" will soon be deprecated. You should
|
||||
instead use `builtin = true`.
|
||||
|
||||
$ niv modify <package> -a type=file -a builtin=true
|
||||
''
|
||||
(builtins_fetchurl { inherit (spec) url sha256; });
|
||||
|
||||
#
|
||||
# Various helpers
|
||||
#
|
||||
|
||||
# The set of packages used when specs are fetched using non-builtins.
|
||||
mkPkgs = sources:
|
||||
let
|
||||
sourcesNixpkgs =
|
||||
import (builtins_fetchTarball { inherit (sources.nixpkgs) url sha256; }) {};
|
||||
hasNixpkgsPath = builtins.any (x: x.prefix == "nixpkgs") builtins.nixPath;
|
||||
hasThisAsNixpkgsPath = <nixpkgs> == ./.;
|
||||
in
|
||||
if builtins.hasAttr "nixpkgs" sources
|
||||
then sourcesNixpkgs
|
||||
else if hasNixpkgsPath && ! hasThisAsNixpkgsPath then
|
||||
import <nixpkgs> {}
|
||||
else
|
||||
abort
|
||||
''
|
||||
Please specify either <nixpkgs> (through -I or NIX_PATH=nixpkgs=...) or
|
||||
add a package called "nixpkgs" to your sources.json.
|
||||
'';
|
||||
|
||||
# The actual fetching function.
|
||||
fetch = pkgs: name: spec:
|
||||
|
||||
if ! builtins.hasAttr "type" spec then
|
||||
abort "ERROR: niv spec ${name} does not have a 'type' attribute"
|
||||
else if spec.type == "file" then fetch_file pkgs spec
|
||||
else if spec.type == "tarball" then fetch_tarball pkgs spec
|
||||
else if spec.type == "git" then fetch_git spec
|
||||
else if spec.type == "builtin-tarball" then fetch_builtin-tarball spec
|
||||
else if spec.type == "builtin-url" then fetch_builtin-url spec
|
||||
else
|
||||
abort "ERROR: niv spec ${name} has unknown type ${builtins.toJSON spec.type}";
|
||||
|
||||
# Ports of functions for older nix versions
|
||||
|
||||
# a Nix version of mapAttrs if the built-in doesn't exist
|
||||
mapAttrs = builtins.mapAttrs or (
|
||||
f: set: with builtins;
|
||||
listToAttrs (map (attr: { name = attr; value = f attr set.${attr}; }) (attrNames set))
|
||||
);
|
||||
|
||||
# fetchTarball version that is compatible between all the versions of Nix
|
||||
builtins_fetchTarball = { url, sha256 }@attrs:
|
||||
let
|
||||
inherit (builtins) lessThan nixVersion fetchTarball;
|
||||
in
|
||||
if lessThan nixVersion "1.12" then
|
||||
fetchTarball { inherit url; }
|
||||
else
|
||||
fetchTarball attrs;
|
||||
|
||||
# fetchurl version that is compatible between all the versions of Nix
|
||||
builtins_fetchurl = { url, sha256 }@attrs:
|
||||
let
|
||||
inherit (builtins) lessThan nixVersion fetchurl;
|
||||
in
|
||||
if lessThan nixVersion "1.12" then
|
||||
fetchurl { inherit url; }
|
||||
else
|
||||
fetchurl attrs;
|
||||
|
||||
# Create the final "sources" from the config
|
||||
mkSources = config:
|
||||
mapAttrs (
|
||||
name: spec:
|
||||
if builtins.hasAttr "outPath" spec
|
||||
then abort
|
||||
"The values in sources.json should not have an 'outPath' attribute"
|
||||
else
|
||||
spec // { outPath = fetch config.pkgs name spec; }
|
||||
) config.sources;
|
||||
|
||||
# The "config" used by the fetchers
|
||||
mkConfig =
|
||||
{ sourcesFile ? ./sources.json
|
||||
, sources ? builtins.fromJSON (builtins.readFile sourcesFile)
|
||||
, pkgs ? mkPkgs sources
|
||||
}: rec {
|
||||
# The sources, i.e. the attribute set of spec name to spec
|
||||
inherit sources;
|
||||
|
||||
# The "pkgs" (evaluated nixpkgs) to use for e.g. non-builtin fetchers
|
||||
inherit pkgs;
|
||||
};
|
||||
in
|
||||
mkSources (mkConfig {}) // { __functor = _: settings: mkSources (mkConfig settings); }
|
@ -1,16 +1,4 @@
|
||||
# see ../docs/dev/nixpkgs-pin.md
|
||||
let
|
||||
fetch = jsonFile:
|
||||
with builtins;
|
||||
let spec = fromJSON (readFile jsonFile);
|
||||
in fetchTarball {
|
||||
name = "nixpkgs";
|
||||
inherit (spec) sha256;
|
||||
url = "${spec.url}/archive/${spec.rev}.tar.gz";
|
||||
};
|
||||
in
|
||||
# This file is for backwards compatibility only
|
||||
{
|
||||
nixpkgs-2003 = fetch (./. + "/release-20.03.json");
|
||||
nixpkgs-1909 = fetch (./. + "/release-19.09.json");
|
||||
nixpkgs-default = fetch (./. + "/github.json");
|
||||
inherit (import ../nix/sources.nix) nixpkgs-2003 nixpkgs-1909 nixpkgs-default;
|
||||
}
|
||||
|
@ -1,9 +0,0 @@
|
||||
{
|
||||
"url": "https://github.com/NixOS/nixpkgs",
|
||||
"rev": "cac363c661817666e43d047addfaa722610d425f",
|
||||
"date": "2020-03-24T13:44:58+01:00",
|
||||
"sha256": "0fi8hgddy8qh2jrsa40jw7jxnr5lrhq2ji6a2xbndllivhzc31kf",
|
||||
"fetchSubmodules": false,
|
||||
"deepClone": false,
|
||||
"leaveDotGit": false
|
||||
}
|
@ -1,9 +0,0 @@
|
||||
{
|
||||
"url": "https://github.com/NixOS/nixpkgs",
|
||||
"rev": "9237a09d8edbae9951a67e9a3434a07ef94035b7",
|
||||
"date": "2020-04-19T11:10:38+05:30",
|
||||
"sha256": "05bizymljzzd665bpsjbhxamcgzq7bkjjzjfapkl2nicy774ak4x",
|
||||
"fetchSubmodules": false,
|
||||
"deepClone": false,
|
||||
"leaveDotGit": false
|
||||
}
|
@ -1,9 +0,0 @@
|
||||
{
|
||||
"url": "https://github.com/NixOS/nixpkgs",
|
||||
"rev": "cac363c661817666e43d047addfaa722610d425f",
|
||||
"date": "2020-03-24T13:44:58+01:00",
|
||||
"sha256": "0fi8hgddy8qh2jrsa40jw7jxnr5lrhq2ji6a2xbndllivhzc31kf",
|
||||
"fetchSubmodules": false,
|
||||
"deepClone": false,
|
||||
"leaveDotGit": false
|
||||
}
|
@ -1,9 +1,11 @@
|
||||
args:
|
||||
|
||||
let
|
||||
overlays = {
|
||||
wine = import ./wine.nix;
|
||||
#ghcjs = import ./ghcjs-asterius-triple.nix;
|
||||
#python = import ./python.nix;
|
||||
haskell = import ./haskell.nix;
|
||||
haskell = import ./haskell.nix args;
|
||||
hackage-quirks = import ./hackage-quirks.nix;
|
||||
bootstrap = import ./bootstrap.nix;
|
||||
ghc = import ./ghc.nix;
|
||||
|
@ -1,3 +1,5 @@
|
||||
{ sourcesOverride ? {}
|
||||
, ... }:
|
||||
# The haskell.nix infrastructure
|
||||
#
|
||||
# for hygenic reasons we'll use haskell-nix as a prefix.
|
||||
@ -10,6 +12,26 @@ final: prev: {
|
||||
# overlays.
|
||||
defaultModules = [];
|
||||
|
||||
# Niv based source pins. See https://github.com/nmattia/niv#niv
|
||||
# for details on how to update this using the niv tool
|
||||
# or edit nix/sources.json manually if you prefer.
|
||||
sources = {
|
||||
# Hackage and stackage still updated by scripts
|
||||
# that predate our use of niv. We have moved them
|
||||
# here though so that you can still use the
|
||||
# sourcesOverride arg or `niv add` to replace them.
|
||||
hackage = fetchExternal {
|
||||
name = "hackage-exprs-source";
|
||||
specJSON = hackageSourceJSON;
|
||||
override = "hackage";
|
||||
};
|
||||
stackage = fetchExternal {
|
||||
name = "stackage-snapshot-source";
|
||||
specJSON = stackageSourceJSON;
|
||||
override = "stackage";
|
||||
};
|
||||
} // (import ../nix/sources.nix) // sourcesOverride;
|
||||
|
||||
# We provide a `callPackage` function to consumers for
|
||||
# convenience. We will however refrain from using it
|
||||
# here and be explicit about imports and dependencies.
|
||||
@ -37,11 +59,7 @@ final: prev: {
|
||||
cleanSourceHaskell;
|
||||
|
||||
# All packages from Hackage as Nix expressions
|
||||
hackageSrc = fetchExternal {
|
||||
name = "hackage-exprs-source";
|
||||
specJSON = hackageSourceJSON;
|
||||
override = "hackage";
|
||||
};
|
||||
hackageSrc = sources.hackage;
|
||||
hackage = import hackageSrc;
|
||||
|
||||
# Contains the hashes of the cabal 01-index.tar.gz for given
|
||||
@ -49,12 +67,7 @@ final: prev: {
|
||||
indexStateHashesPath = hackageSrc + "/index-state-hashes.nix";
|
||||
|
||||
# The set of all Stackage snapshots
|
||||
stackageSrc = fetchExternal {
|
||||
name = "stackage-snapshot-source";
|
||||
specJSON = stackageSourceJSON;
|
||||
override = "stackage";
|
||||
};
|
||||
|
||||
stackageSrc = sources.stackage;
|
||||
stackage = import stackageSrc;
|
||||
|
||||
# Utility functions for working with the component builder.
|
||||
|
Loading…
Reference in New Issue
Block a user