aboutsummaryrefslogtreecommitdiff
path: root/infra/libkookie/nixpkgs/pkgs/applications/editors/nano/nanorc/default.nix
blob: 54442fc21f43f2bad3462d392decece5c4d47d11 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
{ stdenv, fetchFromGitHub, writeScript, nixosTests, common-updater-scripts
, coreutils, git, gnused, nix, nixfmt }:

let
  owner = "scopatz";
  repo = "nanorc";
in stdenv.mkDerivation rec {
  pname = "nanorc";
  version = "2020-10-10";

  src = fetchFromGitHub {
    inherit owner repo;
    rev = builtins.replaceStrings [ "-" ] [ "." ] version;
    sha256 = "3B2nNFYkwYHCX6pQz/hMO/rnVqlCiw1BSNmGmJ6KCqE=";
  };

  dontBuild = true;

  installPhase = ''
    mkdir -p $out/share

    install *.nanorc $out/share/
  '';

  passthru.updateScript = writeScript "update.sh" ''
    #!${stdenv.shell}
    set -o errexit
    PATH=${
      stdenv.lib.makeBinPath [
        common-updater-scripts
        coreutils
        git
        gnused
        nix
        nixfmt
      ]
    }
    oldVersion="$(nix-instantiate --eval -E "with import ./. {}; lib.getVersion ${pname}" | tr -d '"' | sed 's|\\.|-|g')"
    latestTag="$(git -c 'versionsort.suffix=-' ls-remote --exit-code --refs --sort='version:refname' --tags git@github.com:${owner}/${repo} '*.*.*' | tail --lines=1 | cut --delimiter='/' --fields=3)"
    if [ "$oldVersion" != "$latestTag" ]; then
      nixpkgs="$(git rev-parse --show-toplevel)"
      default_nix="$nixpkgs/pkgs/applications/editors/nano/nanorc/default.nix"
      newTag=$(echo $latestTag | sed 's|\.|-|g')
      update-source-version ${pname} "$newTag" --version-key=version --print-changes
      nixfmt "$default_nix"
    else
      echo "${pname} is already up-to-date"
    fi
  '';

  meta = {
    description = "Improved Nano Syntax Highlighting Files";
    homepage = "https://github.com/scopatz/nanorc";
    license = stdenv.lib.licenses.gpl3;
    maintainers = with stdenv.lib.maintainers; [ nequissimus ];
    platforms = stdenv.lib.platforms.all;
  };
}