Merge remote-tracking branch 'origin/develop'

This commit is contained in:
László Vaskó
2020-04-27 01:08:55 +02:00
2 changed files with 59 additions and 53 deletions

View File

@ -5,10 +5,10 @@
"homepage": "",
"owner": "hlissner",
"repo": "doom-emacs",
"rev": "afcdae4fff28ab385da93d28cb819c9cd1769597",
"sha256": "0sg3glhziavrmsf45s4nip8846i67bxdc5b4vw87k4hf3h0jl1if",
"rev": "30dea4bf0c3854f991d02efa73c3d38c5d9a7640",
"sha256": "1kdl10dc91mfxlwac6v16393ysamd2csi2mfw91yr72k82slp898",
"type": "tarball",
"url": "https://github.com/hlissner/doom-emacs/archive/afcdae4fff28ab385da93d28cb819c9cd1769597.tar.gz",
"url": "https://github.com/hlissner/doom-emacs/archive/30dea4bf0c3854f991d02efa73c3d38c5d9a7640.tar.gz",
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
},
"doom-snippets": {
@ -17,10 +17,10 @@
"homepage": "",
"owner": "hlissner",
"repo": "doom-snippets",
"rev": "feaedeb5505dedecf0a971b40ac30a1b7b785e52",
"sha256": "1jwfxx6mlj4zc6lmrk3vrvnsasmaxqnm5pzp9lr60qpf571z90s6",
"rev": "422f683adfbec1b01fe00524690b64dc9e702ae0",
"sha256": "1n1n2hid0cn1dkkivxl5p4c06mvdcnfpyv94f2gw8333bb3hyihc",
"type": "tarball",
"url": "https://github.com/hlissner/doom-snippets/archive/feaedeb5505dedecf0a971b40ac30a1b7b785e52.tar.gz",
"url": "https://github.com/hlissner/doom-snippets/archive/422f683adfbec1b01fe00524690b64dc9e702ae0.tar.gz",
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
},
"emacs-overlay": {
@ -29,10 +29,10 @@
"homepage": "",
"owner": "nix-community",
"repo": "emacs-overlay",
"rev": "edf8dfaea171b245052e110a74d93ef8d5ffc138",
"sha256": "046qadky5vmxrsrj8h5d55dgkl7dwh2kbwrigkgjx77xdhphi5r5",
"rev": "7dbb74ccb0dccc8e0c67b819871932da27e0376d",
"sha256": "1fnhhvdir1ip5a6ggx6vzjzw915la216bwrhmsbkm9hx8l4jhjhi",
"type": "tarball",
"url": "https://github.com/nix-community/emacs-overlay/archive/edf8dfaea171b245052e110a74d93ef8d5ffc138.tar.gz",
"url": "https://github.com/nix-community/emacs-overlay/archive/7dbb74ccb0dccc8e0c67b819871932da27e0376d.tar.gz",
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
},
"emacs-so-long": {
@ -113,10 +113,10 @@
"homepage": "https://code.orgmode.org/bzg/org-mode",
"owner": "emacs-straight",
"repo": "org-mode",
"rev": "c990d43a64ae8df2834367557fc1c709bcab5218",
"sha256": "014l8fifz4acgjighiic3r95iz18n0nrnfm8bs2hv7wpfibkl7mg",
"rev": "14d6f95bec975d882d5d0a047e81c74a1cd89edc",
"sha256": "1yyh7y08qcg9bh8s63i2x623vbdjp8ld9arxvznddabyiff431w8",
"type": "tarball",
"url": "https://github.com/emacs-straight/org-mode/archive/c990d43a64ae8df2834367557fc1c709bcab5218.tar.gz",
"url": "https://github.com/emacs-straight/org-mode/archive/14d6f95bec975d882d5d0a047e81c74a1cd89edc.tar.gz",
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
},
"org-yt": {

View File

@ -6,13 +6,13 @@ let
# The fetchers. fetch_<type> fetches specs of type <type>.
#
fetch_file = spec:
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 = spec:
fetch_tarball = pkgs: spec:
if spec.builtin or true then
builtins_fetchTarball { inherit (spec) url sha256; }
else
@ -43,46 +43,36 @@ let
''
(builtins_fetchurl { inherit (spec) url sha256; });
#
# The sources to fetch.
#
sources = builtins.fromJSON (builtins.readFile ./sources.json);
#
# Various helpers
#
# The set of packages used when specs are fetched using non-builtins.
pkgs =
if hasNixpkgsPath
then
if hasThisAsNixpkgsPath
then import (builtins_fetchTarball { inherit (sources_nixpkgs) url sha256; }) {}
else import <nixpkgs> {}
else
import (builtins_fetchTarball { inherit (sources_nixpkgs) url sha256; }) {};
sources_nixpkgs =
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 sources.nixpkgs
else abort
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.
'';
hasNixpkgsPath = (builtins.tryEval <nixpkgs>).success;
hasThisAsNixpkgsPath =
(builtins.tryEval <nixpkgs>).success && <nixpkgs> == ./.;
# The actual fetching function.
fetch = name: spec:
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 spec
else if spec.type == "tarball" then fetch_tarball spec
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
@ -117,12 +107,28 @@ let
else
fetchurl attrs;
in
# 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 name spec; }
) sources
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); }