2024-04-17 00:08:20 +00:00
|
|
|
{
|
|
|
|
outputs = { self, nixpkgs }: {
|
2024-04-17 20:52:35 +00:00
|
|
|
packages = (nixpkgs.lib.attrsets.genAttrs ["x86_64-darwin" "aarch64-darwin"] (system: let
|
|
|
|
pkgs = import nixpkgs { inherit system; };
|
2024-04-17 00:08:20 +00:00
|
|
|
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/"
|
|
|
|
'';
|
|
|
|
};
|
2024-04-17 20:52:35 +00:00
|
|
|
}));
|
2024-04-17 00:08:20 +00:00
|
|
|
};
|
|
|
|
}
|