1
0
nix-libsk-libfido2/flake.nix

39 lines
1.5 KiB
Nix

{
outputs = { self, nixpkgs }: {
packages.aarch64-darwin = let
pkgs = import nixpkgs { system = "aarch64-darwin"; };
in {
default = pkgs.stdenv.mkDerivation {
# Based on https://gist.github.com/thelastlin/c45b96cf460919e39ab5807b6d20ac2a
inherit (pkgs.openssh) version src;
pname = "libsk-libfido2";
patches = [
(builtins.fetchurl {
url = "https://gist.githubusercontent.com/thelastlin/c45b96cf460919e39ab5807b6d20ac2a/raw/d84ee70a8f0d8cf846ae8b9f1fa6a4071797123e/workaround-standalone-libsk.patch";
sha256 = "sha256:0bgzv7ch2cx9gjjy78fg4nr0i4icdh88s2jfn6x1hsv32vdsyqpw";
})
];
nativeBuildInputs = with pkgs; [ pkg-config libfido2 zlib ];
configureFlags = [ "--with-security-key-builtin=yes" ];
buildPhase = ''
make libssh.a CFLAGS="-O2 -fPIC"
make openbsd-compat/libopenbsd-compat.a CFLAGS="-O2 -fPIC"
make sk-usbhid.o CFLAGS="-O2 -DSK_STANDALONE -fPIC"
(
eval "$(grep -E '^(CC|LDFLAGS|LIBFIDO2)=' Makefile | sed -e 's;=;=";' -e 's;$;";')"
$CC -shared openbsd-compat/libopenbsd-compat.a sk-usbhid.o libssh.a -O2 -fPIC -flto -Wl,-dead_strip,-exported_symbol,_sk_\* $LDFLAGS $LIBFIDO2 -o libsk-libfido2.dylib
)
'';
installPhase = ''
mkdir -p "$out/libexec"
cp libsk-libfido2.dylib "$out/libexec/"
'';
};
};
};
}