Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d2beb68
commit 66e3413
Showing
7 changed files
with
168 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
dotfiles/neovim/plugins.nix: dotfiles/neovim/plugins.json dotfiles/neovim/plugins.py | ||
nix-shell -p python37 --run "python dotfiles/neovim/plugins.py $< > $@" | ||
./nixfmt.sh $@ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
HERE="$(realpath $(dirname $0))" | ||
make | ||
darwin-rebuild $@ -I "darwin-config=$HERE/darwin/default.nix" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
[ | ||
"https://github.com/LnL7/vim-nix#a3eed01f4de995a51dfdd06287e44fcb231f6adf", | ||
"https://github.com/junegunn/fzf.vim#359a80e3a34aacbd5257713b6a88aa085337166f", | ||
"https://github.com/tpope/vim-sensible#67fe033b2b56b6f631a4c7a1179865178665f2a4", | ||
"https://github.com/tpope/vim-surround#fab8621670f71637e9960003af28365129b1dfd0" | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
{ pkgs, ... }: | ||
|
||
{ | ||
|
||
LnL7.vim-nix = pkgs.vimUtils.buildVimPlugin { | ||
name = "vim-nix"; | ||
src = pkgs.fetchFromGitHub { | ||
owner = "LnL7"; | ||
repo = "vim-nix"; | ||
rev = "a3eed01f4de995a51dfdd06287e44fcb231f6adf"; | ||
sha256 = "0pwdfwws1dj3705m00ghw3dvym5zbm00bfsj023gmbp6vr8wn6yi"; | ||
}; | ||
}; | ||
|
||
junegunn."fzf.vim" = pkgs.vimUtils.buildVimPlugin { | ||
name = "fzf.vim"; | ||
src = pkgs.fetchFromGitHub { | ||
owner = "junegunn"; | ||
repo = "fzf.vim"; | ||
rev = "359a80e3a34aacbd5257713b6a88aa085337166f"; | ||
sha256 = "0a01g0gw59m57zizidvm9n89qh8lvj0aq4kyxy27i72ysclp3wsf"; | ||
}; | ||
}; | ||
|
||
tpope.vim-sensible = pkgs.vimUtils.buildVimPlugin { | ||
name = "vim-sensible"; | ||
src = pkgs.fetchFromGitHub { | ||
owner = "tpope"; | ||
repo = "vim-sensible"; | ||
rev = "67fe033b2b56b6f631a4c7a1179865178665f2a4"; | ||
sha256 = "1jhj88n0xj6s6xjx5zs5906y6wwzr855wczk3f5myzs8z8y5cih5"; | ||
}; | ||
}; | ||
|
||
tpope.vim-surround = pkgs.vimUtils.buildVimPlugin { | ||
name = "vim-surround"; | ||
src = pkgs.fetchFromGitHub { | ||
owner = "tpope"; | ||
repo = "vim-surround"; | ||
rev = "fab8621670f71637e9960003af28365129b1dfd0"; | ||
sha256 = "0lkc0isv1cqv34qfia9mjvnp1nzz0qqy3k47z8r3xzb7dxgymkw8"; | ||
}; | ||
}; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
#!/usr/bin/env python | ||
import argparse | ||
import json | ||
import subprocess | ||
import sys | ||
import textwrap | ||
from urllib.parse import urlparse | ||
from urllib.request import urlopen | ||
|
||
def escape(input_): | ||
if '.' in input_: | ||
return '"{}"'.format(input_) | ||
return input_ | ||
|
||
|
||
class GithubPackage: | ||
def __init__(self, url): | ||
self.url = url | ||
self._rev = url.fragment or None | ||
self._sha256 = None | ||
|
||
def __str__(self): | ||
return '{} = {};'.format(self.attr(), self.expression()) | ||
|
||
def owner(self): | ||
return self.url.path.split('/')[1] | ||
|
||
def repo(self): | ||
return self.url.path.split('/')[2] | ||
|
||
def attr(self): | ||
return '{}.{}'.format( | ||
escape(self.owner()), | ||
escape(self.repo()), | ||
) | ||
|
||
def rev(self): | ||
if self._rev is None: | ||
print('determining latest hash for {}'.format(self.attr()), file=sys.stderr) | ||
with urlopen('https://api.github.com/repos/{}/{}/commits'.format(self.owner(), self.repo())) as resp: | ||
self._rev = json.load(resp)[0]["sha"] | ||
|
||
return self._rev | ||
|
||
def sha256(self): | ||
if self._sha256 is None: | ||
print('prefetching sha256 for {}'.format(self.attr()), file=sys.stderr) | ||
self._sha256 = subprocess.check_output([ | ||
'nix-prefetch-url', | ||
'--unpack', | ||
'https://github.com/{}/{}/archive/{}.tar.gz'.format( | ||
self.owner(), | ||
self.repo(), | ||
self.rev(), | ||
), | ||
]).decode('utf-8').strip() | ||
|
||
return self._sha256 | ||
|
||
def expression(self): | ||
return textwrap.dedent('''\ | ||
pkgs.vimUtils.buildVimPlugin { | ||
name = "%s"; | ||
src = pkgs.fetchFromGitHub { | ||
owner = "%s"; | ||
repo = "%s"; | ||
rev = "%s"; | ||
sha256 = "%s"; | ||
}; | ||
} | ||
''') % ( | ||
self.repo(), | ||
self.owner(), | ||
self.repo(), | ||
self.rev(), | ||
self.sha256(), | ||
) | ||
|
||
def main(args): | ||
packages = [] | ||
|
||
for package in json.load(args.packages): | ||
url = urlparse(package) | ||
if 'github.com' in url.netloc: | ||
packages.append(GithubPackage(url)) | ||
else: | ||
print("I don't know how to resolve {}".format(package), file=sys.stderr) | ||
return 1 | ||
|
||
print('{ pkgs, ... }:\n\n{\n') | ||
for package in packages: | ||
print('resolving {}'.format(package.attr()), file=sys.stderr) | ||
print(textwrap.indent(str(package), ' ') + '\n', file=sys.stdout) | ||
print('}') | ||
|
||
if __name__ == '__main__': | ||
parser = argparse.ArgumentParser() | ||
parser.add_argument('packages', type=open) | ||
sys.exit(main(parser.parse_args())) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#!/usr/bin/env bash | ||
set -euo pipefail | ||
nix-shell \ | ||
--pure \ | ||
-p 'import (fetchTarball https://github.com/serokell/nixfmt/archive/e4f31f45799554ff378370256a24f606a3025b0a.tar.gz) {}' \ | ||
--run "nixfmt $@" |