diff --git a/.gitignore b/.gitignore index 04ce1e7..120b4a6 100644 --- a/.gitignore +++ b/.gitignore @@ -58,3 +58,9 @@ result result-* .direnv/ .nix-* + +# Archlinux build artifacts +/pkg/ +/src/ +*.pkg.tar.* +*.tar.gz diff --git a/Makefile b/Makefile index 7bd2b04..1a36f16 100644 --- a/Makefile +++ b/Makefile @@ -80,4 +80,28 @@ man: # Maintanence targets .PHONY: clean clean: - rm -rf bin coverage.out + rm -rf \ + bin coverage.out result result-* tldr .SRCINFO \ + pkg/ src/ *.pkg.tar.* *.pkg.tar.zst *.tar.gz \ + *.log *.sig *-debug* .goreleaser-dist dist/ + +# Release targets +.PHONY: pkgsums +pkgsums: + updpkgsums + +.PHONY: pkgbuild +pkgbuild: + makepkg --syncdeps --cleanbuild + +.PHONY: nixbuild +nix-build: + nix build + +.PHONY: nixcheck +nix-check: + nix flake check + +.PHONY: nixupdate +nix-update: + nix flake update diff --git a/PKGBUILD b/PKGBUILD new file mode 100644 index 0000000..dbb8752 --- /dev/null +++ b/PKGBUILD @@ -0,0 +1,31 @@ +# Maintainer: TheRootDaemon + +pkgname=tlgc +pkgver=1.0.0 +pkgrel=1 +pkgdesc="A tldr client written in Go" +arch=('x86_64' 'aarch64') +url="https://github.com/TheRootDaemon/tlgc" +license=('MIT') +depends=() +makedepends=('go') +source=("$pkgname-$pkgver.tar.gz::https://github.com/TheRootDaemon/tlgc/archive/refs/tags/v$pkgver.tar.gz") +sha256sums=('4da677a05956869b5bab353d459eb46c3b918c220f6f7efb4dac66e0127f2d82') + +build() { + cd "$pkgname-$pkgver" + export CGO_ENABLED=0 + go build -trimpath \ + -ldflags "-s -w -X github.com/TheRootDaemon/tlgc/version.Version=$pkgver" \ + -o tldr ./cmd/tldr +} + +package() { + cd "$pkgname-$pkgver" + install -Dm755 tldr "$pkgdir/usr/bin/tldr" + install -Dm644 tldr.1 "$pkgdir/usr/share/man/man1/tldr.1" + install -Dm644 completions/tldr.bash "$pkgdir/usr/share/bash-completion/completions/tldr" + install -Dm644 completions/tldr.fish "$pkgdir/usr/share/fish/vendor_completions.d/tldr.fish" + install -Dm644 completions/_tldr "$pkgdir/usr/share/zsh/site-functions/_tldr" + install -Dm644 LICENSE "$pkgdir/usr/share/licenses/$pkgname/LICENSE" +} diff --git a/README.md b/README.md index f3ecbb6..aeaa4b0 100644 --- a/README.md +++ b/README.md @@ -24,7 +24,64 @@ A [tldr](https://github.com/tldr-pages/tlgc) client written in Go. Download the archive for your platform from the [releases page](https://github.com/TheRootDaemon/tlgc/releases). -### Using Go +### Homebrew + +Install `tlgc` by adding a tap: + +```sh +brew tap therootdaemon/tlgc && brew install tlgc +``` + +### Nix + +Install tlgc using Nix: + +```nix +nix profile install github:TheRootDaemon/tlgc +``` + +Run tlgc without installing it (ephemeral): + +```nix +nix run github:TheRootDaemon/tlgc -- --help +``` + +Use it in your existing flake: + +```nix +{ + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; + tlgc.url = "github:TheRootDaemon/tlgc"; + }; + + outputs = { nixpkgs, tlgc, ... }: { + nixosConfigurations.host = nixpkgs.lib.nixosSystem { + system = "x86_64-linux"; + + modules = [ + ({ pkgs, ... }: { + environment.systemPackages = [ + tlgc.packages.${pkgs.stdenv.hostPlatform.system}.default + ]; + }) + ]; + }; + }; +} +``` + +To use it along with your `home-manager`: + +```nix +{ inputs, pkgs, ... }: { + home.packages = [ + inputs.tlgc.packages.${pkgs.stdenv.hostPlatform.system}.default + ]; +} +``` + +### Go ```sh # This just installs the binary.