-
Notifications
You must be signed in to change notification settings - Fork 4
/
default.nix
49 lines (49 loc) · 1.54 KB
/
default.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
let
pkgs_mac = import <nixpkgs> { system = "x86_64-darwin"; };
pkgs_native = import <nixpkgs> { };
in
rec {
darwin-tools =
let
ghc = pkgs_mac.haskellPackages.ghcWithPackages (ps: [ ps.turtle (pkgs_mac.haskell.lib.dontCheck ps.universum) ps.megaparsec ]);
in
pkgs_mac.stdenv.mkDerivation {
name = "deploy-nix-darwin";
buildInputs = [ ghc ];
shellHook = "eval $(egrep ^export ${ghc}/bin/ghc)";
src = ./nix-darwin-tools;
installPhase = ''
mkdir -p $out/bin
ghc -o patch-prepare patch-prepare.hs
ghc -o $out/bin/prepare everything.hs
ln -s prepare $out/bin/nuke-nix
./patch-prepare
'';
};
prepare-mac = pkgs_native.writeScriptBin "prepare-mac" ''
#!${pkgs_native.stdenv.shell}
set -e
ssh -t $1 "chmod -R +w darwin-tools; rm -rf darwin-tools" || true
scp -r ${darwin-tools}/bin $1:darwin-tools
ssh -t $1 "sudo darwin-tools/nuke-nix"
ssh -t $1 "darwin-tools/prepare"
'';
deploy-darwin =
let
ghc = pkgs_native.haskellPackages.ghcWithPackages (ps: [ ps.turtle (pkgs_native.haskell.lib.dontCheck ps.universum) ps.megaparsec ]);
in
pkgs_native.stdenv.mkDerivation {
name = "deploy-darwin";
buildInputs = [ ghc ];
shellHook = "eval $(egrep ^export ${ghc}/bin/ghc)";
src = ./nix-darwin-tools;
installPhase = ''
mkdir -p $out/bin
ghc -o $out/bin/deploy deploy-darwin.hs
'';
};
tools = pkgs_native.buildEnv {
name = "scripts";
paths = [ prepare-mac deploy-darwin ];
};
}