robin/ivy
my custom neovim config
git clone https://git.robinwobin.dev/robin/ivy
cd23569
main
1/* 2This file is provided under the MIT licence: 3 4Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 5 6The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 7 8THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 9*/ 10# Generated by npins. Do not modify; will be overwritten regularly 11let 12# Backwards-compatibly make something that previously didn't take any arguments take some 13# The function must return an attrset, and will unfortunately be eagerly evaluated 14# Same thing, but it catches eval errors on the default argument so that one may still call it with other arguments 15mkFunctor = 16fn : 17let 18e = builtins . tryEval ( fn { }); 19in 20( if e . success then e . value else { error = fn { }; }) // { __functor = _self :fn ; }; 21 22# https://github.com/NixOS/nixpkgs/blob/0258808f5744ca980b9a1f24fe0b1e6f0fecee9c/lib/lists.nix#L295 23range = 24first :last :if first > last then [ ] else builtins . genList ( n :first + n ) ( last - first + 1 ); 25 26# https://github.com/NixOS/nixpkgs/blob/0258808f5744ca980b9a1f24fe0b1e6f0fecee9c/lib/strings.nix#L257 27stringToCharacters = s :map ( p :builtins . substring p 1 s ) ( range 0 ( builtins . stringLength s - 1 )); 28 29# https://github.com/NixOS/nixpkgs/blob/0258808f5744ca980b9a1f24fe0b1e6f0fecee9c/lib/strings.nix#L269 30stringAsChars = f :s :concatStrings ( map f ( stringToCharacters s )); 31concatStrings = builtins . concatStringsSep "" ; 32 33# If the environment variable NPINS_OVERRIDE_${name} is set, then use 34# the path directly as opposed to the fetched source. 35# (Taken from Niv for compatibility) 36mayOverride = 37name :path : 38let 39envVarName = "NPINS_OVERRIDE_ ${ saneName } " ; 40saneName = stringAsChars ( c :if ( builtins . match "[a-zA-Z0-9]" c ) == null then "_" else c ) name ; 41ersatz = builtins . getEnv envVarName ; 42in 43if ersatz == "" then 44path 45else 46# this turns the string into an actual Nix path (for both absolute and 47# relative paths) 48builtins . trace "Overriding path of \" ${ name } \" with \" ${ ersatz } \" due to set \" ${ envVarName } \"" ( 49if builtins . substring 0 1 ersatz == "/" then 50/. + ersatz 51else 52/. + builtins . getEnv "PWD" + "/ ${ ersatz } " 53); 54 55mkSource = 56name :spec : 57{ 58pkgs ? null , 59} : 60assert spec ?type ; 61let 62# Unify across builtin and pkgs fetchers. 63# `fetchGit` requires a wrapper because of slight API differences. 64fetchers = 65if pkgs == null then 66{ 67inherit ( builtins ) fetchTarball fetchurl ; 68# Frustratingly, due to flakes and `fetchTree`, `fetchGit` 69# has a different signature than the other builtin 70# fetchers 71fetchGit = args :( builtins . fetchGit args ). outPath ; 72} 73else 74{ 75fetchTarball = 76{ 77url , 78sha256 , 79} : 80pkgs . fetchzip { 81inherit url sha256 ; 82extension = "tar" ; 83}; 84inherit ( pkgs ) fetchurl ; 85fetchGit = 86{ 87url , 88submodules , 89rev , 90name , 91narHash , 92} : 93pkgs . fetchgit { 94inherit url rev name ; 95fetchSubmodules = submodules ; 96hash = narHash ; 97}; 98}; 99 100path = 101if spec . type == "Git" then 102mkGitSource fetchers spec 103else if spec . type == "GitRelease" then 104mkGitSource fetchers spec 105else if spec . type == "PyPi" then 106mkPyPiSource fetchers spec 107else if spec . type == "Channel" then 108mkChannelSource fetchers spec 109else if spec . type == "Url" || spec . type == "MutableUrl" then 110mkUrlSource fetchers spec 111else if spec . type == "Container" then 112mkContainerSource pkgs spec 113else 114builtins . throw "Unknown source type ${ spec . type } " ; 115in 116spec // { outPath = mayOverride name path ; }; 117 118mkGitSource = 119{ 120fetchTarball , 121fetchGit , 122... 123} : 124{ 125repository , 126revision , 127url ? null , 128submodules , 129hash , 130... 131} : 132assert repository ? type ; 133# At the moment, either it is a plain git repository (which has an url), or it is a GitHub/GitLab repository 134# In the latter case, there we will always be an url to the tarball 135if url != null && ! submodules then 136fetchTarball { 137inherit url ; 138sha256 = hash ; 139} 140else 141let 142url = 143if repository . type == "Git" then 144repository . url 145else if repository . type == "GitHub" then 146"https://github.com/ ${ repository . owner } / ${ repository . repo } .git" 147else if repository . type == "GitLab" then 148" ${ repository . server } / ${ repository . repo_path } .git" 149else if repository . type == "Forgejo" then 150" ${ repository . server } / ${ repository . owner } / ${ repository . repo } .git" 151else 152throw "Unrecognized repository type ${ repository . type } " ; 153urlToName = 154url: rev: 155let 156matched = builtins . match "^.*/([^/]*)(\\.git)?$" url ; 157 158short = builtins . substring 0 7 rev ; 159 160appendShort = if ( builtins . match "[a-f0-9]*" rev ) != null then "- ${ short } " else "" ; 161in 162" ${ if matched == null then "source" else builtins . head matched }${ appendShort } " ; 163name = urlToName url revision ; 164in 165fetchGit { 166rev = revision ; 167narHash = hash ; 168 169inherit name submodules url ; 170}; 171 172mkPyPiSource = 173{ fetchurl , ... } : 174{ 175url , 176hash , 177... 178} : 179fetchurl { 180inherit url ; 181sha256 = hash ; 182}; 183 184mkChannelSource = 185{ fetchTarball , ... } : 186{ 187url , 188hash , 189... 190} : 191fetchTarball { 192inherit url ; 193sha256 = hash ; 194}; 195 196mkUrlSource = 197{ 198fetchTarball , 199fetchurl , 200... 201} : 202{ 203url , 204hash , 205unpack , 206... 207} : 208( if unpack then fetchTarball else fetchurl ) { 209inherit url ; 210sha256 = hash ; 211}; 212 213mkContainerSource = 214pkgs: 215{ 216image_name , 217image_tag , 218image_digest , 219hash , 220... 221} @args: 222if pkgs == null then 223builtins . throw "container sources require passing in a Nixpkgs value: https://github.com/andir/npins/blob/master/README.md#using-the-nixpkgs-fetchers" 224else 225pkgs . dockerTools . pullImage ( 226{ 227imageName = image_name ; 228imageDigest = image_digest ; 229finalImageTag = image_tag ; 230hash = hash ; 231} 232// ( if args . arch or null != null then { arch = args . arch ; } else { }) 233); 234 235in 236mkFunctor ( 237{ 238input ? ./sources.json , 239} : 240let 241data = 242if builtins . isPath input then 243# while `readFile` will throw an error anyways if the path doesn't exist, 244# we still need to check beforehand because *our* error can be caught but not the one from the builtin 245# See: <https://git.lix.systems/lix-project/lix/issues/1098> 246if builtins . pathExists input then 247builtins . fromJSON ( builtins . readFile input ) 248else 249throw "Input path ${ toString input } does not exist" 250else if builtins . isAttrs input then 251input 252else 253throw "Unsupported input type ${ builtins . typeOf input } , must be a path or an attrset" ; 254version = data . version ; 255in 256if version == 8 then 257builtins . mapAttrs ( name: spec: mkFunctor ( mkSource name spec )) data . pins 258else 259throw "Unsupported format version ${ toString version } in sources.json. Try running `npins upgrade`" 260)