From 8bf10a4fc6f03a1aa6b62395908f0b684ec57d06 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A1szl=C3=B3=20Vask=C3=B3?= Date: Wed, 19 Feb 2020 23:48:39 +0100 Subject: [PATCH] Updating sources using `niv` to track versions It is nice tool for the job I have not yet known about --- default.nix | 24 +++---- derivations.json | 52 ---------------- derivations.lock | 158 ----------------------------------------------- nix/sources.json | 158 +++++++++++++++++++++++++++++++++++++++++++++++ nix/sources.nix | 128 ++++++++++++++++++++++++++++++++++++++ 5 files changed, 296 insertions(+), 224 deletions(-) delete mode 100644 derivations.json delete mode 100644 derivations.lock create mode 100644 nix/sources.json create mode 100644 nix/sources.nix diff --git a/default.nix b/default.nix index 201dcda..d9faa5b 100644 --- a/default.nix +++ b/default.nix @@ -53,12 +53,10 @@ , writeTextDir }: let - lock = pkgs.callPackage - "${builtins.fetchTarball https://github.com/vlaci/nix-lock/archive/develop.tar.gz}/lock.nix" { - path = ./derivations.lock; - overrides = dependencyOverrides; - }; - + sources = import ./nix/sources.nix; + lock = p: if dependencyOverrides ? p + then dependencyOverrides.${p} + else sources.${p}; # Packages we need to get the default doom configuration run overrides = self: super: { evil-escape = super.evil-escape.overrideAttrs (esuper: { @@ -67,7 +65,7 @@ let straightBuild = { pname, ... }@args: self.trivialBuild ({ ename = pname; version = "1"; - src = lock.get pname; + src = lock pname; buildPhase = ":"; } // args); doom-snippets = self.straightBuild { @@ -105,19 +103,17 @@ let pname = "php-extras"; }; rotate-text = self.straightBuild { - pname = "rotate-text"; - ename = "rotate-text.el"; + pname = "rotate-text.el"; }; so-long = self.straightBuild { - pname = "so-long"; - ename = "emacs-so-long"; + pname = "emacs-so-long"; }; }; # Stage 1: prepare source for byte-compilation doomSrc = stdenv.mkDerivation { name = "doom-src"; - src = lock.get "doom-emacs"; + src = lock "doom-emacs"; phases = ["unpackPhase" "patchPhase" "installPhase"]; patches = [ (substituteAll { @@ -132,12 +128,12 @@ let }; # Bundled version of `emacs-overlay` - emacs-overlay = import (lock.get "emacs-overlay") pkgs pkgs; + emacs-overlay = import (lock "emacs-overlay") pkgs pkgs; # Stage 2: install dependencies and byte-compile prepared source doomLocal = let - straight-env = pkgs.callPackage (lock.get "nix-straight.el") { + straight-env = pkgs.callPackage (lock "nix-straight.el") { emacsPackages = if bundledPackages then let diff --git a/derivations.json b/derivations.json deleted file mode 100644 index 8e92675..0000000 --- a/derivations.json +++ /dev/null @@ -1,52 +0,0 @@ -{ - "doom-emacs": { - "repo": "doom-emacs", - "owner": "hlissner", - "rev": "develop" - }, - "nix-straight.el": { - "owner": "vlaci", - "repo": "nix-straight.el", - "rev": "v1.2.0" - }, - "doom-snippets": { - "owner": "hlissner", - "repo": "doom-snippets" - }, - "evil-markdown": { - "owner": "Somelauw", - "repo": "evil-markdown" - }, - "evil-org-mode": { - "owner": "hlissner", - "repo": "evil-org-mode" - }, - "evil-quick-diff": { - "owner": "rgrinberg", - "repo": "evil-quick-diff" - }, - "org-mode": { - "owner": "emacs-straight", - "repo": "org-mode" - }, - "org-yt": { - "owner": "TobiasZawada", - "repo": "org-yt" - }, - "php-extras": { - "owner": "arnested", - "repo": "php-extras" - }, - "rotate-text": { - "owner": "debug-ito", - "repo": "rotate-text.el" - }, - "so-long": { - "owner": "hlissner", - "repo": "emacs-so-long" - }, - "emacs-overlay": { - "owner": "nix-community", - "repo": "emacs-overlay" - } -} diff --git a/derivations.lock b/derivations.lock deleted file mode 100644 index fb5d75d..0000000 --- a/derivations.lock +++ /dev/null @@ -1,158 +0,0 @@ -{ - "doom-emacs": { - "fetcher": "fetchFromGitHub", - "args": { - "owner": "hlissner", - "repo": "doom-emacs", - "rev": "b0978a4526cfd78bb18e5279909c19bee97e9878", - "sha256": "0ydjzp87zcz4bfnqcqs0fyxdbv4273h21ir1sjny2lln3d3w7zzw" - }, - "meta": { - "updated": "2020-02-15T09:39:33+00:00", - "rev": "b0978a4526cfd78bb18e5279909c19bee97e9878" - } - }, - "nix-straight.el": { - "fetcher": "fetchFromGitHub", - "args": { - "owner": "vlaci", - "repo": "nix-straight.el", - "rev": "446f3d70f1816305130f307c0cf2bc8db77ed698", - "sha256": "1p4yp46kwhii8w9yf882fca9r3addn91wg6f4mv62wnkfm0i6q0f" - }, - "meta": { - "updated": "2020-01-25T18:43:31+00:00", - "rev": "446f3d70f1816305130f307c0cf2bc8db77ed698" - } - }, - "org-yt": { - "fetcher": "fetchFromGitHub", - "args": { - "owner": "TobiasZawada", - "repo": "org-yt", - "rev": "40cc1ac76d741055cbefa13860d9f070a7ade001", - "sha256": "0jsm3azb7lwikvc53z4p91av8qvda9s15wij153spkgjp83kld3p" - }, - "meta": { - "updated": "2019-10-25T22:28:27+00:00", - "rev": "40cc1ac76d741055cbefa13860d9f070a7ade001" - } - }, - "emacs-overlay": { - "fetcher": "fetchFromGitHub", - "args": { - "owner": "nix-community", - "repo": "emacs-overlay", - "rev": "af3182aa950a3c591df7d2007fedf658c6cbc687", - "sha256": "09yqs9h4zwcshhkvzdzlkixs1mprdrmknh05kqv7c3pq1ir0daiz" - }, - "meta": { - "updated": "2020-02-15T09:39:40+00:00", - "rev": "af3182aa950a3c591df7d2007fedf658c6cbc687" - } - }, - "evil-markdown": { - "fetcher": "fetchFromGitHub", - "args": { - "owner": "Somelauw", - "repo": "evil-markdown", - "rev": "46cd81b37991c4325fc24015a610f832b0ff995d", - "sha256": "0mad8sp5y9vyk28595qygspnyh8bfmb1fbxjlw70qwc1kdn822n4" - }, - "meta": { - "updated": "2019-11-23T14:33:01+00:00", - "rev": "46cd81b37991c4325fc24015a610f832b0ff995d" - } - }, - "php-extras": { - "fetcher": "fetchFromGitHub", - "args": { - "owner": "arnested", - "repo": "php-extras", - "rev": "81ebd7c1a8c8d02b2775d4cdbf73653feb608a7c", - "sha256": "181dg1z00qagwb9qd45fpcrya32mdgj8dnkpnfv52lqmi94vvzg0" - }, - "meta": { - "updated": "2019-11-23T14:33:03+00:00", - "rev": "81ebd7c1a8c8d02b2775d4cdbf73653feb608a7c" - } - }, - "so-long": { - "fetcher": "fetchFromGitHub", - "args": { - "owner": "hlissner", - "repo": "emacs-so-long", - "rev": "ed666b0716f60e8988c455804de24b55919e71ca", - "sha256": "0bc6nrdrvj422g15zqn00vs7ga9bq5c3hdg7ml1kls8rxp6bk1n4" - }, - "meta": { - "updated": "2019-12-21T13:21:48+00:00", - "rev": "ed666b0716f60e8988c455804de24b55919e71ca" - } - }, - "evil-quick-diff": { - "fetcher": "fetchFromGitHub", - "args": { - "owner": "rgrinberg", - "repo": "evil-quick-diff", - "rev": "69c883720b30a892c63bc89f49d4f0e8b8028908", - "sha256": "15cww264lhddxh0d2ca5qd5nq5pda8hs4nj8mcpb5xlnmkayav50" - }, - "meta": { - "updated": "2019-12-01T14:49:48+00:00", - "rev": "69c883720b30a892c63bc89f49d4f0e8b8028908" - } - }, - "evil-org-mode": { - "fetcher": "fetchFromGitHub", - "args": { - "owner": "hlissner", - "repo": "evil-org-mode", - "rev": "4d44e9bbdc3ae35d0050ca298886710f6531f434", - "sha256": "0kp19q58rqi2x31g5fqqy5rzw7ymxsa9iaxj3f9rya9zyyma6g59" - }, - "meta": { - "updated": "2020-01-07T11:56:38+00:00", - "rev": "4d44e9bbdc3ae35d0050ca298886710f6531f434" - } - }, - "org-mode": { - "fetcher": "fetchFromGitHub", - "args": { - "owner": "emacs-straight", - "repo": "org-mode", - "rev": "e361c640435af947fab201c1fe60f25843edb5e9", - "sha256": "15hbrsz45zhvh09qsijmw9x38zzaiymsmczafyfql68ar2s1slgj" - }, - "meta": { - "updated": "2020-02-15T09:39:37+00:00", - "rev": "e361c640435af947fab201c1fe60f25843edb5e9" - } - }, - "doom-snippets": { - "fetcher": "fetchFromGitHub", - "args": { - "owner": "hlissner", - "repo": "doom-snippets", - "rev": "4a0e675e1a4713dc8b3c020b30cad18ef4d7401d", - "sha256": "0b3vdwm9brnjgivxd3icz5znjhjhzqkd38nn9qamk4n09d7h2nd7" - }, - "meta": { - "updated": "2020-02-15T09:48:50+00:00", - "rev": "4a0e675e1a4713dc8b3c020b30cad18ef4d7401d" - } - }, - "rotate-text": { - "fetcher": "fetchFromGitHub", - "args": { - "owner": "debug-ito", - "repo": "rotate-text.el", - "rev": "48f193697db996855aee1ad2bc99b38c6646fe76", - "sha256": "02fkv45nbbqrv12czlinpr8qpsd7yjdhr628hl58n42w560qxrs8" - }, - "meta": { - "updated": "2020-02-15T09:48:53+00:00", - "rev": "48f193697db996855aee1ad2bc99b38c6646fe76" - } - } -} diff --git a/nix/sources.json b/nix/sources.json new file mode 100644 index 0000000..cc38ff4 --- /dev/null +++ b/nix/sources.json @@ -0,0 +1,158 @@ +{ + "doom-emacs": { + "branch": "develop", + "description": "An Emacs configuration for the stubborn martian vimmer", + "homepage": "", + "owner": "hlissner", + "repo": "doom-emacs", + "rev": "f645675e4c03c613c76e36230594e4b0ea7fbaeb", + "sha256": "1payhw79x90ms3ahr09qkzagg0dg40js5fsdr8wwyf0si8nl9awr", + "type": "tarball", + "url": "https://github.com/hlissner/doom-emacs/archive/f645675e4c03c613c76e36230594e4b0ea7fbaeb.tar.gz", + "url_template": "https://github.com///archive/.tar.gz" + }, + "doom-snippets": { + "branch": "master", + "description": "The Doom Emacs snippets library", + "homepage": "", + "owner": "hlissner", + "repo": "doom-snippets", + "rev": "1449fdaf9a3755c16c6b5b7c0de36b9de520afed", + "sha256": "0mbjdgn602bgnx2mi5925m4ss4y95ywh7jk1qnka74zpa34dfgnq", + "type": "tarball", + "url": "https://github.com/hlissner/doom-snippets/archive/1449fdaf9a3755c16c6b5b7c0de36b9de520afed.tar.gz", + "url_template": "https://github.com///archive/.tar.gz" + }, + "emacs-overlay": { + "branch": "master", + "description": "Bleeding edge emacs overlay [maintainer=@adisbladis] ", + "homepage": "", + "owner": "nix-community", + "repo": "emacs-overlay", + "rev": "34b22694b4859416d5b84dbfc423e4444dc52a62", + "sha256": "0yawmp08md1mzzvixhyn9lkv7jkwya8xd76pskbp1k1czqlsn5p9", + "type": "tarball", + "url": "https://github.com/nix-community/emacs-overlay/archive/34b22694b4859416d5b84dbfc423e4444dc52a62.tar.gz", + "url_template": "https://github.com///archive/.tar.gz" + }, + "emacs-so-long": { + "branch": "master", + "description": "A mirror of the so-long package (until it's on ELPA)", + "homepage": "https://git.savannah.gnu.org/git/so-long.git/", + "owner": "hlissner", + "repo": "emacs-so-long", + "rev": "ed666b0716f60e8988c455804de24b55919e71ca", + "sha256": "0bc6nrdrvj422g15zqn00vs7ga9bq5c3hdg7ml1kls8rxp6bk1n4", + "type": "tarball", + "url": "https://github.com/hlissner/emacs-so-long/archive/ed666b0716f60e8988c455804de24b55919e71ca.tar.gz", + "url_template": "https://github.com///archive/.tar.gz" + }, + "evil-markdown": { + "branch": "master", + "description": "Integrates emacs evil and markdown", + "homepage": null, + "owner": "Somelauw", + "repo": "evil-markdown", + "rev": "46cd81b37991c4325fc24015a610f832b0ff995d", + "sha256": "0mad8sp5y9vyk28595qygspnyh8bfmb1fbxjlw70qwc1kdn822n4", + "type": "tarball", + "url": "https://github.com/Somelauw/evil-markdown/archive/46cd81b37991c4325fc24015a610f832b0ff995d.tar.gz", + "url_template": "https://github.com///archive/.tar.gz" + }, + "evil-org-mode": { + "branch": "master", + "description": "Supplemental evil-mode keybindings to emacs org-mode", + "homepage": null, + "owner": "hlissner", + "repo": "evil-org-mode", + "rev": "4d44e9bbdc3ae35d0050ca298886710f6531f434", + "sha256": "0kp19q58rqi2x31g5fqqy5rzw7ymxsa9iaxj3f9rya9zyyma6g59", + "type": "tarball", + "url": "https://github.com/hlissner/evil-org-mode/archive/4d44e9bbdc3ae35d0050ca298886710f6531f434.tar.gz", + "url_template": "https://github.com///archive/.tar.gz" + }, + "evil-quick-diff": { + "branch": "master", + "description": "linediff.vim for evil", + "homepage": null, + "owner": "rgrinberg", + "repo": "evil-quick-diff", + "rev": "69c883720b30a892c63bc89f49d4f0e8b8028908", + "sha256": "15cww264lhddxh0d2ca5qd5nq5pda8hs4nj8mcpb5xlnmkayav50", + "type": "tarball", + "url": "https://github.com/rgrinberg/evil-quick-diff/archive/69c883720b30a892c63bc89f49d4f0e8b8028908.tar.gz", + "url_template": "https://github.com///archive/.tar.gz" + }, + "nix-straight.el": { + "branch": "v1.2.0", + "description": null, + "homepage": null, + "owner": "vlaci", + "repo": "nix-straight.el", + "rev": "446f3d70f1816305130f307c0cf2bc8db77ed698", + "sha256": "1p4yp46kwhii8w9yf882fca9r3addn91wg6f4mv62wnkfm0i6q0f", + "type": "tarball", + "url": "https://github.com/vlaci/nix-straight.el/archive/446f3d70f1816305130f307c0cf2bc8db77ed698.tar.gz", + "url_template": "https://github.com///archive/.tar.gz" + }, + "nixpkgs": { + "branch": "nixos-19.09", + "description": "A read-only mirror of NixOS/nixpkgs tracking the released channels. Send issues and PRs to", + "homepage": "https://github.com/NixOS/nixpkgs", + "owner": "NixOS", + "repo": "nixpkgs-channels", + "rev": "8731aaaf8b30888bc24994096db830993090d7c4", + "sha256": "1hcc89rxi47nb0mpk05nl9rbbb04kfw97xfydhpmmgh57yrp3zqa", + "type": "tarball", + "url": "https://github.com/NixOS/nixpkgs-channels/archive/8731aaaf8b30888bc24994096db830993090d7c4.tar.gz", + "url_template": "https://github.com///archive/.tar.gz" + }, + "org-mode": { + "branch": "master", + "description": "Mirror of org-mode from orgmode.org", + "homepage": "https://code.orgmode.org/bzg/org-mode", + "owner": "emacs-straight", + "repo": "org-mode", + "rev": "bc75b75d9f15da387adf47b6d53a21fae09670b0", + "sha256": "1sjy57zv4638r0ysz58jrckslz3mc5myi3lvj9lzax2klxndrv6s", + "type": "tarball", + "url": "https://github.com/emacs-straight/org-mode/archive/bc75b75d9f15da387adf47b6d53a21fae09670b0.tar.gz", + "url_template": "https://github.com///archive/.tar.gz" + }, + "org-yt": { + "branch": "master", + "description": "Youtube links in org-mode, see https://emacs.stackexchange.com/questions/38098/org-mode-custom-youtube-link-syntax", + "homepage": null, + "owner": "TobiasZawada", + "repo": "org-yt", + "rev": "40cc1ac76d741055cbefa13860d9f070a7ade001", + "sha256": "0jsm3azb7lwikvc53z4p91av8qvda9s15wij153spkgjp83kld3p", + "type": "tarball", + "url": "https://github.com/TobiasZawada/org-yt/archive/40cc1ac76d741055cbefa13860d9f070a7ade001.tar.gz", + "url_template": "https://github.com///archive/.tar.gz" + }, + "php-extras": { + "branch": "develop", + "description": "Extra features for Emacs `php-mode'.", + "homepage": "http://marmalade-repo.org/packages/php-extras", + "owner": "arnested", + "repo": "php-extras", + "rev": "d410c5af663c30c01d461ac476d1cbfbacb49367", + "sha256": "0mcgwisnqplav0ga8xqqw72523iv841wp2cyw7d4lkzgpiav51dg", + "type": "tarball", + "url": "https://github.com/arnested/php-extras/archive/d410c5af663c30c01d461ac476d1cbfbacb49367.tar.gz", + "url_template": "https://github.com///archive/.tar.gz" + }, + "rotate-text.el": { + "branch": "master", + "description": "Emacs: cycle through words, symbols and patterns", + "homepage": "http://nschum.de/src/emacs/rotate-text/", + "owner": "debug-ito", + "repo": "rotate-text.el", + "rev": "48f193697db996855aee1ad2bc99b38c6646fe76", + "sha256": "02fkv45nbbqrv12czlinpr8qpsd7yjdhr628hl58n42w560qxrs8", + "type": "tarball", + "url": "https://github.com/debug-ito/rotate-text.el/archive/48f193697db996855aee1ad2bc99b38c6646fe76.tar.gz", + "url_template": "https://github.com///archive/.tar.gz" + } +} diff --git a/nix/sources.nix b/nix/sources.nix new file mode 100644 index 0000000..4c0351c --- /dev/null +++ b/nix/sources.nix @@ -0,0 +1,128 @@ +# This file has been generated by Niv. + +let + + # + # The fetchers. fetch_ fetches specs of type . + # + + fetch_file = spec: + if spec.builtin or true then + builtins_fetchurl { inherit (spec) url sha256; } + else + pkgs.fetchurl { inherit (spec) url sha256; }; + + fetch_tarball = 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 -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 -a type=file -a builtin=true + '' + (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 {} + else + import (builtins_fetchTarball { inherit (sources_nixpkgs) url sha256; }) {}; + + sources_nixpkgs = + if builtins.hasAttr "nixpkgs" sources + then sources.nixpkgs + else abort + '' + Please specify either (through -I or NIX_PATH=nixpkgs=...) or + add a package called "nixpkgs" to your sources.json. + ''; + + hasNixpkgsPath = (builtins.tryEval ).success; + hasThisAsNixpkgsPath = + (builtins.tryEval ).success && == ./.; + + # The actual fetching function. + fetch = 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 == "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; + +in +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