]> git.immae.eu Git - perso/Immae/Config/Nix.git/commitdiff
Initial commit
authorIsmaël Bouya <ismael.bouya@normalesup.org>
Thu, 13 Dec 2018 20:25:24 +0000 (21:25 +0100)
committerIsmaël Bouya <ismael.bouya@normalesup.org>
Thu, 13 Dec 2018 20:26:23 +0000 (21:26 +0100)
default.nix [new file with mode: 0644]
fetch_version [new file with mode: 0755]
fetched/ledger.json [new file with mode: 0644]
fetched/vit.json [new file with mode: 0644]

diff --git a/default.nix b/default.nix
new file mode 100644 (file)
index 0000000..1b9b4b0
--- /dev/null
@@ -0,0 +1,41 @@
+with import <nixpkgs> {};
+let
+  nixpkgs = import <nixpkgs> {};
+  fetchedGithub = path:
+    let
+      json = lib.importJSON path;
+    in rec {
+      version = json.tag;
+      name = "${json.meta.name}-${version}";
+      src = fetchFromGitHub json.github;
+    };
+
+  ledger = (nixpkgs.ledger.override { boost = boost166; }).overrideAttrs (oldAttrs:
+    fetchedGithub ./fetched/ledger.json // {
+      postInstall = "";
+    }
+  );
+
+  taskwarrior = nixpkgs.taskwarrior.overrideAttrs (oldAttrs: rec {
+    postInstall = ''${oldAttrs.postInstall}
+      mkdir -p "$out/share/vim/vimfiles/ftdetect"
+      mkdir -p "$out/share/vim/vimfiles/syntax"
+      ln -s "../../../../share/doc/task/scripts/vim/ftdetect/task.vim" "$out/share/vim/vimfiles/ftdetect/"
+      ln -s "../../../../share/doc/task/scripts/vim/syntax/taskrc.vim" "$out/share/vim/vimfiles/syntax/"
+      ln -s "../../../../share/doc/task/scripts/vim/syntax/taskdata.vim" "$out/share/vim/vimfiles/syntax/"
+      ln -s "../../../../share/doc/task/scripts/vim/syntax/taskedit.vim" "$out/share/vim/vimfiles/syntax/"
+    '';
+  });
+
+  vit = (nixpkgs.vit.override { inherit taskwarrior; }).overrideAttrs (oldAttrs:
+    fetchedGithub ./fetched/vit.json // {
+      buildInputs = oldAttrs.buildInputs ++ [perlPackages.TryTiny perlPackages.TextCharWidth];
+    }
+  );
+
+  #weechat = callPackage nixpkgs.weechat { guileSupport = false; luaSupport = false; rubySupport = false; tclSupport = false; };
+in
+  {
+    inherit ledger;
+    inherit taskwarrior vit;
+  }
diff --git a/fetch_version b/fetch_version
new file mode 100755 (executable)
index 0000000..db0af1b
--- /dev/null
@@ -0,0 +1,108 @@
+#!/bin/bash
+
+usage() {
+  echo "$0 file.json"
+  echo "$0 [-n|--name name] [-b|--branch branch] [-h|--help] (-u|--url) url"
+  exit
+}
+
+branch="master"
+while [[ $# -gt 0 ]]; do
+  a="$1"
+  shift
+  case "$a" in
+    *.json)
+      file=$a
+      content=$(cat $a)
+      name="$(echo "$content" | jq -r ".meta.name")"
+      url="$(echo "$content" | jq -r ".meta.url")"
+      branch="$(echo "$content" | jq -r ".meta.branch")"
+      ;;
+    -n|--name)
+      name=$1
+      shift
+      ;;
+    -u|--url)
+      url=$1
+      shift
+      ;;
+    -b|--branch)
+      branch=$1
+      shift
+      ;;
+    -h|--help)
+      usage
+      ;;
+  esac
+done
+if [ -z "$url" ]; then
+  usage
+fi
+if [ -z "$name" ]; then
+  name=$(echo "$url" | cut -d"/" -f5)
+fi
+if [ -z "$file" ]; then
+  file=$name.json
+fi
+
+# function fetch_ledger () {
+#   pushd $HOME/projets/ledger >/dev/null 2>/dev/null
+#   git fetch origin
+#   tag="$(git describe origin/next | sed -e "s/^v//")"
+#   rev="$(git show-ref -s refs/remotes/origin/next)"
+#   sha="$(nix-prefetch-url --unpack file://<(git archive --format=tar.gz HEAD) 2>/dev/null)"
+#   popd >/dev/null 2>/dev/null
+# }
+
+# awk_describe='BEGIN {
+#   FS = "[ /^]+"
+#   while ("git ls-remote " ARGV[1] "| sort -Vk2" | getline) {
+#     if (!sha)
+#       sha = substr($0, 1, 7)
+#     tag = $3
+#   }
+#   while ("curl -s " ARGV[1] "/releases/tag/" tag | getline)
+#     if ($3 ~ "commits")
+#       com = $2
+#   printf com ? "%s-%s-g%s\n" : "%s\n", tag, com, sha
+# }'
+
+function fetch_github () {
+  rev="$(git ls-remote --refs $url refs/heads/$branch | head -n1 | cut -f1)"
+  sha="$(nix-prefetch-url --unpack $url/archive/$branch.tar.gz)"
+  # Différent du git-describe et github-spécifique
+  #tag=$(echo "$awk_describe" | awk -f - $url | sed -e "s/^v//")
+  tag=${rev:0:7}-$branch
+}
+
+fetch_github 2>/dev/null
+
+owner=$(echo "$url" | cut -d"/" -f4)
+repo=$(echo "$url" | cut -d"/" -f5)
+
+F='{
+  "tag": $tag,
+  "meta": {
+    "name": $name,
+    "url": $url,
+    "branch": $branch
+  },
+  "github": {
+    "owner": $owner,
+    "repo": $repo,
+    "rev": $rev,
+    "sha256": $sha,
+    "fetchSubmodules": true
+  }
+}'
+
+jq -n \
+  --arg name "$name" \
+  --arg owner "$owner" \
+  --arg repo "$repo" \
+  --arg tag "$tag" \
+  --arg rev "$rev" \
+  --arg url "$url" \
+  --arg branch "$branch" \
+  --arg sha "$sha" \
+  "$F" > $file
diff --git a/fetched/ledger.json b/fetched/ledger.json
new file mode 100644 (file)
index 0000000..6ea613b
--- /dev/null
@@ -0,0 +1,15 @@
+{
+  "tag": "7567fb7-next",
+  "meta": {
+    "name": "ledger",
+    "url": "https://github.com/ledger/ledger",
+    "branch": "next"
+  },
+  "github": {
+    "owner": "ledger",
+    "repo": "ledger",
+    "rev": "7567fb7595c9937088abec6caaf7b59f8e2e772a",
+    "sha256": "07482bvd0mnvaad116cjlmg3ls6bg0ksy23gc99lmyz35nbf25v1",
+    "fetchSubmodules": true
+  }
+}
diff --git a/fetched/vit.json b/fetched/vit.json
new file mode 100644 (file)
index 0000000..d062f68
--- /dev/null
@@ -0,0 +1,15 @@
+{
+  "tag": "dbacada-1.3",
+  "meta": {
+    "name": "vit",
+    "url": "https://github.com/scottkosty/vit",
+    "branch": "1.3"
+  },
+  "github": {
+    "owner": "scottkosty",
+    "repo": "vit",
+    "rev": "dbacada5867b238fdf35dbf00a3ca0daf7703038",
+    "sha256": "1wlk62cv6dc0dqv8265xcx2l7ydzg40xf6l4qbrf6h5156ncc90l",
+    "fetchSubmodules": true
+  }
+}