nixpkgs/pkgs/by-name/ta/tailscale-nginx-auth/package.nix
Artturin e0464e4788 treewide: replace stdenv.is with stdenv.hostPlatform.is
In preparation for the deprecation of `stdenv.isX`.

These shorthands are not conducive to cross-compilation because they
hide the platforms.

Darwin might get cross-compilation for which the continued usage of `stdenv.isDarwin` will get in the way

One example of why this is bad and especially affects compiler packages
https://www.github.com/NixOS/nixpkgs/pull/343059

There are too many files to go through manually but a treewide should
get users thinking when they see a `hostPlatform.isX` in a place where it
doesn't make sense.

```
fd --type f "\.nix" | xargs sd --fixed-strings "stdenv.is" "stdenv.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "stdenv'.is" "stdenv'.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "clangStdenv.is" "clangStdenv.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "gccStdenv.is" "gccStdenv.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "stdenvNoCC.is" "stdenvNoCC.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "inherit (stdenv) is" "inherit (stdenv.hostPlatform) is"
fd --type f "\.nix" | xargs sd --fixed-strings "buildStdenv.is" "buildStdenv.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "effectiveStdenv.is" "effectiveStdenv.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "originalStdenv.is" "originalStdenv.hostPlatform.is"
```
2024-09-25 00:04:37 +03:00

33 lines
1.0 KiB
Nix

{ lib, stdenv, buildGo123Module, tailscale }:
buildGo123Module {
pname = "tailscale-nginx-auth";
inherit (tailscale) version src vendorHash;
CGO_ENABLED = 0;
subPackages = [ "cmd/nginx-auth" ];
ldflags = [
"-w"
"-s"
"-X tailscale.com/version.longStamp=${tailscale.version}"
"-X tailscale.com/version.shortStamp=${tailscale.version}"
];
postInstall = lib.optionalString stdenv.hostPlatform.isLinux ''
mv $out/bin/nginx-auth $out/bin/tailscale.nginx-auth
sed -i -e "s#/usr/sbin#$out/bin#" ./cmd/nginx-auth/tailscale.nginx-auth.service
install -D -m0444 -t $out/lib/systemd/system ./cmd/nginx-auth/tailscale.nginx-auth.service
install -D -m0444 -t $out/lib/systemd/system ./cmd/nginx-auth/tailscale.nginx-auth.socket
'';
meta = with lib; {
homepage = "https://tailscale.com";
description = "Tool that allows users to use Tailscale Whois authentication with NGINX as a reverse proxy";
license = licenses.bsd3;
mainProgram = "tailscale.nginx-auth";
maintainers = with maintainers; [ phaer ];
};
}