aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--default.nix41
-rwxr-xr-xfetch_version108
-rw-r--r--fetched/ledger.json15
-rw-r--r--fetched/vit.json15
4 files changed, 179 insertions, 0 deletions
diff --git a/default.nix b/default.nix
new file mode 100644
index 0000000..1b9b4b0
--- /dev/null
+++ b/default.nix
@@ -0,0 +1,41 @@
1with import <nixpkgs> {};
2let
3 nixpkgs = import <nixpkgs> {};
4 fetchedGithub = path:
5 let
6 json = lib.importJSON path;
7 in rec {
8 version = json.tag;
9 name = "${json.meta.name}-${version}";
10 src = fetchFromGitHub json.github;
11 };
12
13 ledger = (nixpkgs.ledger.override { boost = boost166; }).overrideAttrs (oldAttrs:
14 fetchedGithub ./fetched/ledger.json // {
15 postInstall = "";
16 }
17 );
18
19 taskwarrior = nixpkgs.taskwarrior.overrideAttrs (oldAttrs: rec {
20 postInstall = ''${oldAttrs.postInstall}
21 mkdir -p "$out/share/vim/vimfiles/ftdetect"
22 mkdir -p "$out/share/vim/vimfiles/syntax"
23 ln -s "../../../../share/doc/task/scripts/vim/ftdetect/task.vim" "$out/share/vim/vimfiles/ftdetect/"
24 ln -s "../../../../share/doc/task/scripts/vim/syntax/taskrc.vim" "$out/share/vim/vimfiles/syntax/"
25 ln -s "../../../../share/doc/task/scripts/vim/syntax/taskdata.vim" "$out/share/vim/vimfiles/syntax/"
26 ln -s "../../../../share/doc/task/scripts/vim/syntax/taskedit.vim" "$out/share/vim/vimfiles/syntax/"
27 '';
28 });
29
30 vit = (nixpkgs.vit.override { inherit taskwarrior; }).overrideAttrs (oldAttrs:
31 fetchedGithub ./fetched/vit.json // {
32 buildInputs = oldAttrs.buildInputs ++ [perlPackages.TryTiny perlPackages.TextCharWidth];
33 }
34 );
35
36 #weechat = callPackage nixpkgs.weechat { guileSupport = false; luaSupport = false; rubySupport = false; tclSupport = false; };
37in
38 {
39 inherit ledger;
40 inherit taskwarrior vit;
41 }
diff --git a/fetch_version b/fetch_version
new file mode 100755
index 0000000..db0af1b
--- /dev/null
+++ b/fetch_version
@@ -0,0 +1,108 @@
1#!/bin/bash
2
3usage() {
4 echo "$0 file.json"
5 echo "$0 [-n|--name name] [-b|--branch branch] [-h|--help] (-u|--url) url"
6 exit
7}
8
9branch="master"
10while [[ $# -gt 0 ]]; do
11 a="$1"
12 shift
13 case "$a" in
14 *.json)
15 file=$a
16 content=$(cat $a)
17 name="$(echo "$content" | jq -r ".meta.name")"
18 url="$(echo "$content" | jq -r ".meta.url")"
19 branch="$(echo "$content" | jq -r ".meta.branch")"
20 ;;
21 -n|--name)
22 name=$1
23 shift
24 ;;
25 -u|--url)
26 url=$1
27 shift
28 ;;
29 -b|--branch)
30 branch=$1
31 shift
32 ;;
33 -h|--help)
34 usage
35 ;;
36 esac
37done
38if [ -z "$url" ]; then
39 usage
40fi
41if [ -z "$name" ]; then
42 name=$(echo "$url" | cut -d"/" -f5)
43fi
44if [ -z "$file" ]; then
45 file=$name.json
46fi
47
48# function fetch_ledger () {
49# pushd $HOME/projets/ledger >/dev/null 2>/dev/null
50# git fetch origin
51# tag="$(git describe origin/next | sed -e "s/^v//")"
52# rev="$(git show-ref -s refs/remotes/origin/next)"
53# sha="$(nix-prefetch-url --unpack file://<(git archive --format=tar.gz HEAD) 2>/dev/null)"
54# popd >/dev/null 2>/dev/null
55# }
56
57# awk_describe='BEGIN {
58# FS = "[ /^]+"
59# while ("git ls-remote " ARGV[1] "| sort -Vk2" | getline) {
60# if (!sha)
61# sha = substr($0, 1, 7)
62# tag = $3
63# }
64# while ("curl -s " ARGV[1] "/releases/tag/" tag | getline)
65# if ($3 ~ "commits")
66# com = $2
67# printf com ? "%s-%s-g%s\n" : "%s\n", tag, com, sha
68# }'
69
70function fetch_github () {
71 rev="$(git ls-remote --refs $url refs/heads/$branch | head -n1 | cut -f1)"
72 sha="$(nix-prefetch-url --unpack $url/archive/$branch.tar.gz)"
73 # Différent du git-describe et github-spécifique
74 #tag=$(echo "$awk_describe" | awk -f - $url | sed -e "s/^v//")
75 tag=${rev:0:7}-$branch
76}
77
78fetch_github 2>/dev/null
79
80owner=$(echo "$url" | cut -d"/" -f4)
81repo=$(echo "$url" | cut -d"/" -f5)
82
83F='{
84 "tag": $tag,
85 "meta": {
86 "name": $name,
87 "url": $url,
88 "branch": $branch
89 },
90 "github": {
91 "owner": $owner,
92 "repo": $repo,
93 "rev": $rev,
94 "sha256": $sha,
95 "fetchSubmodules": true
96 }
97}'
98
99jq -n \
100 --arg name "$name" \
101 --arg owner "$owner" \
102 --arg repo "$repo" \
103 --arg tag "$tag" \
104 --arg rev "$rev" \
105 --arg url "$url" \
106 --arg branch "$branch" \
107 --arg sha "$sha" \
108 "$F" > $file
diff --git a/fetched/ledger.json b/fetched/ledger.json
new file mode 100644
index 0000000..6ea613b
--- /dev/null
+++ b/fetched/ledger.json
@@ -0,0 +1,15 @@
1{
2 "tag": "7567fb7-next",
3 "meta": {
4 "name": "ledger",
5 "url": "https://github.com/ledger/ledger",
6 "branch": "next"
7 },
8 "github": {
9 "owner": "ledger",
10 "repo": "ledger",
11 "rev": "7567fb7595c9937088abec6caaf7b59f8e2e772a",
12 "sha256": "07482bvd0mnvaad116cjlmg3ls6bg0ksy23gc99lmyz35nbf25v1",
13 "fetchSubmodules": true
14 }
15}
diff --git a/fetched/vit.json b/fetched/vit.json
new file mode 100644
index 0000000..d062f68
--- /dev/null
+++ b/fetched/vit.json
@@ -0,0 +1,15 @@
1{
2 "tag": "dbacada-1.3",
3 "meta": {
4 "name": "vit",
5 "url": "https://github.com/scottkosty/vit",
6 "branch": "1.3"
7 },
8 "github": {
9 "owner": "scottkosty",
10 "repo": "vit",
11 "rev": "dbacada5867b238fdf35dbf00a3ca0daf7703038",
12 "sha256": "1wlk62cv6dc0dqv8265xcx2l7ydzg40xf6l4qbrf6h5156ncc90l",
13 "fetchSubmodules": true
14 }
15}