-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathflake.nix
89 lines (86 loc) · 3.37 KB
/
flake.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
{
description = "connect machines over SSH using Amazon EC2 VMs";
outputs = { self, nixpkgs }: let
ssh-proxy = system:
with nixpkgs.legacyPackages.${system}.extend (self: super: {
# add swift to Xcode wrapper
xcodeenv = super.xcodeenv // {
composeXcodeWrapper = args: (super.xcodeenv.composeXcodeWrapper args).overrideAttrs (attrs: {
buildCommand = attrs.buildCommand + ''
ln -s /usr/libexec/PlistBuddy $out/bin/
ln -s /usr/bin/xcode-select $out/bin/
cat <<- "EOF" > $out/bin/swift
#!/bin/sh
unset DEVELOPER_DIR SDKROOT
exec /usr/bin/swift "$@" --disable-sandbox
EOF
chmod a+x $out/bin/swift
'';
});
};
});
stdenvNoCC.mkDerivation {
name = "ssh-proxy-${lib.substring 0 8 self.lastModifiedDate}";
src = self;
__noChroot = true;
nativeBuildInputs =
lib.optionals stdenvNoCC.buildPlatform.isLinux [
clang swift swiftpm
] ++ lib.optionals stdenvNoCC.buildPlatform.isDarwin [
(xcodeenv.composeXcodeWrapper {})
];
patchPhase = let
swift-argument-parser = fetchFromGitHub ({
owner = "apple";
repo = "swift-argument-parser";
rev = "1.5.0";
hash = "sha256-TRaJG8ikzuQQjH3ERfuYNKPty3qI3ziC/9v96pvlvRs=";
} // lib.optionalAttrs stdenvNoCC.buildPlatform.isLinux {
# TODO: compilation of argument parser 1.3.0 fails
# https://github.com/NixOS/nixpkgs/pull/256956#issuecomment-1891063661
rev = "1.2.3";
hash = "sha256-qEJ329hqQyQVxtHScD7qPmWW9ZDf9bX+4xgpDlX0w5A=";
});
swift-asn1 = fetchFromGitHub {
owner = "apple";
repo = "swift-asn1";
rev = "1.3.0";
hash = "sha256-9WrDipPXevLnevsu3VEF2/W1l38vZIrXDCorpKZ6edo=";
};
swift-crypto = fetchFromGitHub {
owner = "apple";
repo = "swift-crypto";
rev = "3.10.0";
hash = "sha256-PfaOjxs4uLnpCYeDRBF9/KnoIhU98P8WZpnOnfizkmI=";
};
in ''
ln -s ${swift-argument-parser} swift-argument-parser
ln -s ${swift-asn1} swift-asn1
cp -r ${swift-crypto} swift-crypto
substituteInPlace swift-crypto/Package.swift --replace-fail 'url: "https://github.com/apple/swift-asn1.git"' 'path: "../swift-asn1"), //'
substituteInPlace proxy/Package.swift --replace-fail 'url: "https://github.com/apple/swift-argument-parser.git"' 'path: "../swift-argument-parser"), //'
substituteInPlace proxy/Package.swift --replace-fail 'url: "https://github.com/apple/swift-crypto.git"' 'path: "../swift-crypto"), //'
substituteInPlace proxy/common/ssh.swift --replace-fail /usr/bin/ssh ${openssh}/bin/ssh
'';
dontUseSwiftpmBuild = true;
makeFlags = [ "-C proxy" "DESTDIR=$(out)" "LOCAL_ID=" "API_URL=" "API_KEY=" "USERNAME=" ];
};
shell = system:
with nixpkgs.legacyPackages.${system};
mkShellNoCC {
packages = [ php ] ++
lib.optionals stdenv.isLinux [ gnumake clang swift swiftpm openssh ];
shellHook = ''
unset DEVELOPER_DIR SDKROOT
test -r ~/.local/config/shell/rc && . ~/.local/config/shell/rc
'';
};
in {
packages.x86_64-darwin.default = ssh-proxy "x86_64-darwin";
packages.x86_64-linux.default = ssh-proxy "x86_64-linux";
packages.x86_64-darwin.ssh-proxy = ssh-proxy "x86_64-darwin";
packages.x86_64-linux.ssh-proxy = ssh-proxy "x86_64-linux";
devShells.x86_64-darwin.default = shell "x86_64-darwin";
devShells.x86_64-linux.default = shell "x86_64-linux";
};
}