From 743ca6424e5eb2cd2f02d0aa39b05865384d950d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20=E2=80=9CAd=C3=A6dra=E2=80=9D=20Hamel?= Date: Wed, 17 Apr 2024 02:08:20 +0200 Subject: [PATCH] Import into git --- .gitignore | 1 + flake.lock | 25 +++++++++++++++++++++++++ flake.nix | 38 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 64 insertions(+) create mode 100644 .gitignore create mode 100644 flake.lock create mode 100644 flake.nix diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..c4a847d --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/result diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..d545218 --- /dev/null +++ b/flake.lock @@ -0,0 +1,25 @@ +{ + "nodes": { + "nixpkgs": { + "locked": { + "lastModified": 1713254108, + "narHash": "sha256-0TZIsfDbHG5zibtlw6x0yOp3jkInIGaJ35B7Y4G8Pec=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "2fd19c8be2551a61c1ddc3d9f86d748f4db94f00", + "type": "github" + }, + "original": { + "id": "nixpkgs", + "type": "indirect" + } + }, + "root": { + "inputs": { + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..7b60d1c --- /dev/null +++ b/flake.nix @@ -0,0 +1,38 @@ +{ + 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/" + ''; + }; + }; + }; +}