checkmake: fix version information and date of the man page, refactor
This commit is contained in:
parent
2dfbb7c889
commit
76010e75e6
|
@ -1,4 +1,10 @@
|
|||
{ buildGoModule, fetchFromGitHub, pandoc, lib }:
|
||||
{ lib
|
||||
, buildGoModule
|
||||
, fetchFromGitHub
|
||||
, installShellFiles
|
||||
, pandoc
|
||||
, go
|
||||
}:
|
||||
|
||||
buildGoModule rec {
|
||||
pname = "checkmake";
|
||||
|
@ -8,37 +14,42 @@ buildGoModule rec {
|
|||
owner = "mrtazz";
|
||||
repo = pname;
|
||||
rev = version;
|
||||
sha256 = "sha256-Ql8XSQA/w7wT9GbmYOM2vG15GVqj9LxOGIu8Wqp9Wao=";
|
||||
hash = "sha256-Ql8XSQA/w7wT9GbmYOM2vG15GVqj9LxOGIu8Wqp9Wao=";
|
||||
};
|
||||
|
||||
vendorSha256 = null;
|
||||
vendorHash = null;
|
||||
|
||||
nativeBuildInputs = [ pandoc ];
|
||||
nativeBuildInputs = [
|
||||
installShellFiles
|
||||
pandoc
|
||||
];
|
||||
|
||||
preBuild =
|
||||
let
|
||||
buildVars = {
|
||||
version = version;
|
||||
buildTime = "N/A";
|
||||
builder = "nix";
|
||||
goversion = "$(go version | egrep -o 'go[0-9]+[.][^ ]*')";
|
||||
};
|
||||
buildVarsFlags = lib.concatStringsSep " " (lib.mapAttrsToList (k: v: "-X main.${k}=${v}") buildVars);
|
||||
in
|
||||
''
|
||||
buildFlagsArray+=("-ldflags=${buildVarsFlags}")
|
||||
ldflags = [
|
||||
"-s"
|
||||
"-w"
|
||||
"-X=main.version=${version}"
|
||||
"-X=main.buildTime=1970-01-01T00:00:00Z"
|
||||
"-X=main.builder=nixpkgs"
|
||||
"-X=main.goversion=go${go.version}"
|
||||
];
|
||||
|
||||
postPatch = ''
|
||||
substituteInPlace man/man1/checkmake.1.md \
|
||||
--replace REPLACE_DATE 1970-01-01T00:00:00Z
|
||||
'';
|
||||
|
||||
ldflags = [ "-s" "-w" ];
|
||||
postBuild = ''
|
||||
pandoc man/man1/checkmake.1.md -st man -o man/man1/checkmake.1
|
||||
'';
|
||||
|
||||
postInstall = ''
|
||||
mkdir -p $out/share/man/man1
|
||||
pandoc -s -t man -o $out/share/man/man1/checkmake.1 man/man1/checkmake.1.md
|
||||
installManPage man/man1/checkmake.1
|
||||
'';
|
||||
|
||||
meta = with lib; {
|
||||
description = "Experimental tool for linting and checking Makefiles";
|
||||
homepage = "https://github.com/mrtazz/checkmake";
|
||||
changelog = "https://github.com/mrtazz/checkmake/releases/tag/${src.rev}";
|
||||
license = licenses.mit;
|
||||
maintainers = with maintainers; [ vidbina ];
|
||||
longDescription = ''
|
||||
|
|
Loading…
Reference in a new issue