nur-packages

My NUR packages
git clone git://git.sikmir.ru/nur-packages
Log | Files | Refs | README | LICENSE

commit 1bc360fd14553a5645e11ea5d5fa66545237ec29
parent 8c818af8a89047df08988c4fda04251d214e325d
Author: Nikolay Korotkiy <sikmir@gmail.com>
Date:   Sat,  2 Jan 2021 02:35:29 +0300

Up

Diffstat:
Mnix/sources.json | 64++++++++++++++++++++++++++++++++--------------------------------
Mnix/sources.nix | 181+++++++++++++++++++++++++++++++++++++++++++++++--------------------------------
2 files changed, 141 insertions(+), 104 deletions(-)

diff --git a/nix/sources.json b/nix/sources.json @@ -44,15 +44,15 @@ "cheetah3": { "branch": "master", "builtin": false, - "date": "2020-12-14T17:50:07Z", + "date": "2021-01-01T22:01:06Z", "description": "Cheetah3 is a free (MIT) and open source template engine for Python", "homepage": "https://cheetahtemplate.org/", "owner": "CheetahTemplate3", "repo": "cheetah3", - "rev": "089e45aadb92d6cd24ccdc8e9a2accac1f7223ba", - "sha256": "1aq1qkfyx1kdra8a8xysv11frwzis2yfa5y9li90rqg48p80izxi", + "rev": "50804e70261bc9476c8a498985fd93b931b18ae6", + "sha256": "0fq6inzr04zbsqmbzj8khr1l8whab61xpzvdp3lchz0lkwms8ppn", "type": "tarball", - "url": "https://github.com/CheetahTemplate3/cheetah3/archive/089e45aadb92d6cd24ccdc8e9a2accac1f7223ba.tar.gz", + "url": "https://github.com/CheetahTemplate3/cheetah3/archive/50804e70261bc9476c8a498985fd93b931b18ae6.tar.gz", "url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz" }, "csvquote": { @@ -170,15 +170,15 @@ "embox": { "branch": "master", "builtin": false, - "date": "2020-12-29T17:58:24Z", + "date": "2020-12-31T08:57:22Z", "description": "Modular and configurable OS for embedded applications", "homepage": "http://embox.github.io", "owner": "embox", "repo": "embox", - "rev": "68eb38c57473eaa12a295bffe15115cea2cb363e", - "sha256": "0d1c4sv9jfwivxbp29b7szrp5jirb4hsp118ssxngbvkvbhdm60c", + "rev": "df47a5a853928315904670fd8e03c88e97602823", + "sha256": "0lvlmw60ab3n48cqb857phsvw9mpc5qfva4dw7wyilgs635x567c", "type": "tarball", - "url": "https://github.com/embox/embox/archive/68eb38c57473eaa12a295bffe15115cea2cb363e.tar.gz", + "url": "https://github.com/embox/embox/archive/df47a5a853928315904670fd8e03c88e97602823.tar.gz", "url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz" }, "foma": { @@ -239,27 +239,27 @@ }, "geofabrik-estonia": { "builtin": false, - "sha256": "16l4n89fzh6g8rcjn1n6g18xjvycbvsmvcvbfnhhz7sbsg3drfi3", + "sha256": "0xhb0yg6hf09zdyhw59gsky6fdx5x7jfch3i6gp66vqzmxc951wr", "type": "file", - "url": "https://download.geofabrik.de/europe/estonia-201228.osm.pbf", + "url": "https://download.geofabrik.de/europe/estonia-201231.osm.pbf", "url_template": "https://download.geofabrik.de/europe/estonia-<version>.osm.pbf", - "version": "201228" + "version": "201231" }, "geofabrik-finland": { "builtin": false, - "sha256": "10jzcc551f5p8gvmnp2vyb9kql4vxmcifkpzvpkvw1vdx3xhb782", + "sha256": "0s3wvndspnl0p918j8qgnihr4y61ylb2zs7cznmghrwd6kk0ic3d", "type": "file", - "url": "https://download.geofabrik.de/europe/finland-201228.osm.pbf", + "url": "https://download.geofabrik.de/europe/finland-201231.osm.pbf", "url_template": "https://download.geofabrik.de/europe/finland-<version>.osm.pbf", - "version": "201228" + "version": "201231" }, "geofabrik-russia-nwfd": { "builtin": false, - "sha256": "18rc0413v1p67wzphp0v92hr3dvdfkmclyjkgh7bsxhc3dajfh78", + "sha256": "06jicr6xix1dgmbvy39ijly3sqnq7xhbq81ja066cm0jlwf31na6", "type": "file", - "url": "https://download.geofabrik.de/russia/northwestern-fed-district-201228.osm.pbf", + "url": "https://download.geofabrik.de/russia/northwestern-fed-district-201231.osm.pbf", "url_template": "https://download.geofabrik.de/russia/northwestern-fed-district-<version>.osm.pbf", - "version": "201228" + "version": "201231" }, "gimgtools": { "branch": "master", @@ -377,15 +377,15 @@ "branch": "master", "builtin": false, "changelog": "https://build.opensuse.org/package/view_file/home:tumic:GPXSee/gpxsee/gpxsee.changes", - "date": "2020-12-30T08:26:26Z", + "date": "2021-01-01T11:52:00Z", "description": "GPS log file viewer and analyzer", "homepage": "https://www.gpxsee.org", "owner": "tumic0", "repo": "GPXSee", - "rev": "7e39a34d0ea189bfd1220b981632f14c0b63741f", - "sha256": "08lyc99c2ipigmmyg2ag5ka378xlakbggq2359910wz5pyyidv13", + "rev": "4cb369d2f3528c7ddff3f079393b0d2c18518bb0", + "sha256": "0qm46am1kxd664rvdx52cqmqf3a35dhb7lagfy77mhb71nnpvhj1", "type": "tarball", - "url": "https://github.com/tumic0/GPXSee/archive/7e39a34d0ea189bfd1220b981632f14c0b63741f.tar.gz", + "url": "https://github.com/tumic0/GPXSee/archive/4cb369d2f3528c7ddff3f079393b0d2c18518bb0.tar.gz", "url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz" }, "gpxsee-maps": { @@ -629,15 +629,15 @@ "mapper": { "branch": "master", "builtin": false, - "date": "2020-12-30T05:53:02Z", + "date": "2021-01-01T15:37:39Z", "description": "OpenOrienteering Mapper is a software for creating maps for the orienteering sport", "homepage": "https://www.openorienteering.org/apps/mapper/", "owner": "OpenOrienteering", "repo": "mapper", - "rev": "ca4f2946603862af3a9c5cc211a15ee4058a980b", - "sha256": "0hh9rmy27d1l9v78h6kss2gacc1x3mkv80fsdx6dc2zgjyxwi7nh", + "rev": "d6ed6b3f0bb60836b5a73eb41b5ec8dfd0707094", + "sha256": "1vx7ii87qrn9m3mx72xzs90l0xqzrhwgipdb7z4zdvvwlfgkjly9", "type": "tarball", - "url": "https://github.com/OpenOrienteering/mapper/archive/ca4f2946603862af3a9c5cc211a15ee4058a980b.tar.gz", + "url": "https://github.com/OpenOrienteering/mapper/archive/d6ed6b3f0bb60836b5a73eb41b5ec8dfd0707094.tar.gz", "url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz" }, "maprec": { @@ -673,11 +673,11 @@ "description": "Ежедневная сборка карт из данных OpenStreetMap для навигационных приборов и приложений Garmin", "homepage": "https://maptourist.org", "region": "szfo", - "sha256": "15rkvzpd5h6v9nh0b8n39f8qs6i4a6hiq3jz96as3x8rwkngg04q", + "sha256": "1glvaqkrfsrdj84nca1wkvdpw5n02fry7fr4ixijzwr2xxkscq0l", "type": "file", - "url": "https://maptourist.org/osm-garmin/archive/OSM-MapTourist-szfo-RU_2020-12-29.zip", + "url": "https://maptourist.org/osm-garmin/archive/OSM-MapTourist-szfo-RU_2021-01-01.zip", "url_template": "https://maptourist.org/osm-garmin/archive/OSM-MapTourist-<region>-RU_<version>.zip", - "version": "2020-12-29" + "version": "2021-01-01" }, "mercantile": { "branch": "master", @@ -860,15 +860,15 @@ "py-staticmaps": { "branch": "master", "builtin": false, - "date": "2020-11-28T13:45:19Z", + "date": "2020-12-31T10:49:07Z", "description": "A python module to create static map images with markers, geodesic lines, etc.", "homepage": "https://github.com/flopp/py-staticmaps", "owner": "flopp", "repo": "py-staticmaps", - "rev": "cbe706fd266137cdf8a412f6ca54c02e4bc89fa6", - "sha256": "0ff5wnrw7pfs80092r2iddacb3vi9a64s7j9im177897s55204fq", + "rev": "49d2a81d7a7a778eca4527868cf27e9298c5e7c8", + "sha256": "17707jc35xbbgn7bnmbfizpcn46hc51nbcz3rjvsizabl8bj8bk5", "type": "tarball", - "url": "https://github.com/flopp/py-staticmaps/archive/cbe706fd266137cdf8a412f6ca54c02e4bc89fa6.tar.gz", + "url": "https://github.com/flopp/py-staticmaps/archive/49d2a81d7a7a778eca4527868cf27e9298c5e7c8.tar.gz", "url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz" }, "pyephem": { diff --git a/nix/sources.nix b/nix/sources.nix @@ -1,82 +1,105 @@ # 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_file = pkgs: name: spec: + let + name' = sanitizeName name + "-src"; + in + if spec.builtin or true then + builtins_fetchurl { inherit (spec) url sha256; name = name'; } + else + pkgs.fetchurl { inherit (spec) url sha256; name = name'; }; - fetch_git = spec: - builtins.fetchGit { url = spec.repo; inherit (spec) rev ref; }; + fetch_tarball = pkgs: name: spec: + let + name' = sanitizeName name + "-src"; + in + if spec.builtin or true then + builtins_fetchTarball { name = name'; inherit (spec) url sha256; } + else + pkgs.fetchzip { name = name'; inherit (spec) url sha256; }; - fetch_builtin-tarball = spec: - builtins.trace - '' - WARNING: - The niv type "builtin-tarball" will soon be deprecated. You should - instead use `builtin = true`. + fetch_git = name: spec: + let + ref = + if spec ? ref then spec.ref else + if spec ? branch then "refs/heads/${spec.branch}" else + if spec ? tag then "refs/tags/${spec.tag}" else + abort "In git source '${name}': Please specify `ref`, `tag` or `branch`!"; + in + builtins.fetchGit { url = spec.repo; inherit (spec) rev; inherit ref; }; - $ niv modify <package> -a type=tarball -a builtin=true - '' - builtins_fetchTarball { inherit (spec) url sha256; }; + fetch_local = spec: spec.path; - fetch_builtin-url = spec: - builtins.trace - '' - WARNING: - The niv type "builtin-url" will soon be deprecated. You should - instead use `builtin = true`. + fetch_builtin-tarball = name: throw + ''[${name}] The niv type "builtin-tarball" is deprecated. You should instead use `builtin = true`. + $ niv modify ${name} -a type=tarball -a builtin=true''; - $ niv modify <package> -a type=file -a builtin=true - '' - (builtins_fetchurl { inherit (spec) url sha256; }); + fetch_builtin-url = name: throw + ''[${name}] The niv type "builtin-url" will soon be deprecated. You should instead use `builtin = true`. + $ niv modify ${name} -a type=file -a builtin=true''; # # Various helpers # + # https://github.com/NixOS/nixpkgs/pull/83241/files#diff-c6f540a4f3bfa4b0e8b6bafd4cd54e8bR695 + sanitizeName = name: + ( + concatMapStrings (s: if builtins.isList s then "-" else s) + ( + builtins.split "[^[:alnum:]+._?=-]+" + ((x: builtins.elemAt (builtins.match "\\.*(.*)" x) 0) name) + ) + ); + # The set of packages used when specs are fetched using non-builtins. - mkPkgs = sources: + mkPkgs = sources: system: let sourcesNixpkgs = - import (builtins_fetchTarball { inherit (sources.nixpkgs) url sha256; }) { }; + import (builtins_fetchTarball { inherit (sources.nixpkgs) url sha256; }) { inherit system; }; 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. - ''; + 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 if spec.type == "file" then fetch_file pkgs name spec + else if spec.type == "tarball" then fetch_tarball pkgs name spec + else if spec.type == "git" then fetch_git name spec + else if spec.type == "local" then fetch_local spec + else if spec.type == "builtin-tarball" then fetch_builtin-tarball name + else if spec.type == "builtin-url" then fetch_builtin-url name else abort "ERROR: niv spec ${name} has unknown type ${builtins.toJSON spec.type}"; + # If the environment variable NIV_OVERRIDE_${name} is set, then use + # the path directly as opposed to the fetched source. + replace = name: drv: + let + saneName = stringAsChars (c: if isNull (builtins.match "[a-zA-Z0-9]" c) then "_" else c) name; + ersatz = builtins.getEnv "NIV_OVERRIDE_${saneName}"; + in + if ersatz == "" then drv else ersatz; + # Ports of functions for older nix versions # a Nix version of mapAttrs if the built-in doesn't exist @@ -85,44 +108,57 @@ let listToAttrs (map (attr: { name = attr; value = f attr set.${attr}; }) (attrNames set)) ); + # https://github.com/NixOS/nixpkgs/blob/0258808f5744ca980b9a1f24fe0b1e6f0fecee9c/lib/lists.nix#L295 + range = first: last: if first > last then [] else builtins.genList (n: first + n) (last - first + 1); + + # https://github.com/NixOS/nixpkgs/blob/0258808f5744ca980b9a1f24fe0b1e6f0fecee9c/lib/strings.nix#L257 + stringToCharacters = s: map (p: builtins.substring p 1 s) (range 0 (builtins.stringLength s - 1)); + + # https://github.com/NixOS/nixpkgs/blob/0258808f5744ca980b9a1f24fe0b1e6f0fecee9c/lib/strings.nix#L269 + stringAsChars = f: s: concatStrings (map f (stringToCharacters s)); + concatMapStrings = f: list: concatStrings (map f list); + concatStrings = builtins.concatStringsSep ""; + + # https://github.com/NixOS/nixpkgs/blob/8a9f58a375c401b96da862d969f66429def1d118/lib/attrsets.nix#L331 + optionalAttrs = cond: as: if cond then as else {}; + # fetchTarball version that is compatible between all the versions of Nix - builtins_fetchTarball = { url, sha256 }@attrs: + builtins_fetchTarball = { url, name ? null, sha256 }@attrs: let inherit (builtins) lessThan nixVersion fetchTarball; in - if lessThan nixVersion "1.12" then - fetchTarball { inherit url; } - else - fetchTarball attrs; + if lessThan nixVersion "1.12" then + fetchTarball ({ inherit url; } // (optionalAttrs (!isNull name) { inherit name; })) + else + fetchTarball attrs; # fetchurl version that is compatible between all the versions of Nix - builtins_fetchurl = { url, sha256 }@attrs: + builtins_fetchurl = { url, name ? null, sha256 }@attrs: let inherit (builtins) lessThan nixVersion fetchurl; in - if lessThan nixVersion "1.12" then - fetchurl { inherit url; } - else - fetchurl attrs; + if lessThan nixVersion "1.12" then + fetchurl ({ inherit url; } // (optionalAttrs (!isNull name) { inherit name; })) + 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; + mapAttrs ( + name: spec: + if builtins.hasAttr "outPath" spec + then abort + "The values in sources.json should not have an 'outPath' attribute" + else + spec // { outPath = replace name (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 + { sourcesFile ? if builtins.pathExists ./sources.json then ./sources.json else null + , sources ? if isNull sourcesFile then {} else builtins.fromJSON (builtins.readFile sourcesFile) + , system ? builtins.currentSystem + , pkgs ? mkPkgs sources system }: rec { # The sources, i.e. the attribute set of spec name to spec inherit sources; @@ -130,5 +166,6 @@ let # The "pkgs" (evaluated nixpkgs) to use for e.g. non-builtin fetchers inherit pkgs; }; + in -mkSources (mkConfig { }) // { __functor = _: settings: mkSources (mkConfig settings); } +mkSources (mkConfig {}) // { __functor = _: settings: mkSources (mkConfig settings); }