Skip to content

Commit fa666a7

Browse files
authored
make age-plugin-fido2-hmac work on darwin (NixOS#339299)
2 parents a96e54f + 8c50788 commit fa666a7

File tree

1 file changed

+26
-10
lines changed

1 file changed

+26
-10
lines changed
Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,27 @@
1-
{ lib
2-
, buildGoModule
3-
, fetchFromGitHub
4-
, libfido2
5-
, stdenv
1+
{
2+
lib,
3+
buildGoModule,
4+
fetchFromGitHub,
5+
stdenv,
6+
libfido2,
7+
openssl,
8+
libcbor
69
}:
10+
let
11+
darwin_arch = if stdenv.hostPlatform.system == "aarch64-darwin" then "arm64" else "amd64";
12+
darwin_configure = ''
13+
chmod -R +w vendor/github.com/keys-pub/go-libfido2
14+
cat << EOF > vendor/github.com/keys-pub/go-libfido2/fido2_static_${darwin_arch}.go
15+
package libfido2
716
17+
/*
18+
#cgo darwin LDFLAGS: -framework CoreFoundation -framework IOKit -L${lib.getLib openssl}/lib -L${lib.getLib libcbor}/lib -lfido2
19+
#cgo darwin CFLAGS: -I${libfido2.dev}/include -I${openssl.dev}/include
20+
*/
21+
import "C"
22+
EOF
23+
'';
24+
in
825
buildGoModule rec {
926
pname = "age-plugin-fido2-hmac";
1027
version = "0.2.3";
@@ -18,18 +35,17 @@ buildGoModule rec {
1835

1936
vendorHash = "sha256-h4/tyq9oZt41IfRJmmsLHUpJiPJ7YuFu59ccM7jHsFo=";
2037

21-
ldflags = [ "-s" "-w" ];
38+
ldflags = [ "-s" "-w" "-X main.version=v${version}" ];
2239

23-
buildInputs = [
24-
libfido2
25-
];
40+
buildInputs = [ libfido2 ];
41+
42+
postConfigure = lib.optional stdenv.isDarwin darwin_configure;
2643

2744
meta = with lib; {
2845
description = "Age plugin to encrypt files with fido2 tokens using the hmac-secret extension and non-discoverable credentials";
2946
homepage = "https://github.com/olastor/age-plugin-fido2-hmac/";
3047
license = licenses.mit;
3148
maintainers = with maintainers; [ matthewcroughan ];
3249
mainProgram = "age-plugin-fido2-hmac";
33-
broken = stdenv.isDarwin;
3450
};
3551
}

0 commit comments

Comments
 (0)