Skip to content

Commit 539bcee

Browse files
committed
finishing automated setup
1 parent 69b9ea3 commit 539bcee

File tree

1 file changed

+31
-8
lines changed

1 file changed

+31
-8
lines changed

flake.nix

Lines changed: 31 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,6 @@
3535
(flake-utils.lib.eachDefaultSystem (system:
3636
let
3737

38-
# The current default sdk for macOS fails to compile go projects, so we use a newer one for now.
39-
# This has no effect on other platforms.
40-
callPackage = pkgs.darwin.apple_sdk_11_0.callPackage or pkgs.callPackage;
41-
4238
pkgs = import nixpkgs {
4339
inherit system;
4440
overlays = [
@@ -48,10 +44,15 @@
4844
];
4945
};
5046

47+
# The current default sdk for macOS fails to compile go projects, so we use a newer one for now.
48+
# This has no effect on other platforms.
49+
callPackage = pkgs.darwin.apple_sdk_11_0.callPackage or pkgs.callPackage;
50+
51+
p2prcDefault = callPackage ./. { };
52+
5153
in
5254
{
53-
54-
packages.default = callPackage ./. { };
55+
packages.default = p2prcDefault;
5556

5657
devShells.default = pkgs.mkShell {
5758
buildInputs = with pkgs; [
@@ -70,10 +71,30 @@
7071
ghc
7172
cabal2nix
7273
cabal-install
73-
nix
7474
git
75+
p2prcDefault
7576
];
7677
text =
78+
let
79+
# TODO: add
80+
p2prcMainContent = availablePort: availableUrl:
81+
''
82+
module Main where
83+
84+
import P2PRC
85+
( runP2PRC
86+
, MapPortRequest(MkMapPortRequest)
87+
)
88+
89+
main :: IO ()
90+
main =
91+
runP2PRC
92+
( MkMapPortRequest ${availablePort} "${availableUrl}.akilan.io"
93+
)
94+
'';
95+
96+
mainFileContent = p2prcMainContent 8080 "haskell";
97+
in
7798
''
7899
clear
79100
if [ "$#" -eq 0 ]; then
@@ -96,6 +117,8 @@
96117
97118
sed -i 's/base.*$/base, p2prc/' "$PROJECT_DIR".cabal
98119
120+
cat ${mainFileContent} > app/main.hs
121+
99122
cabal2nix . > ./cabal.nix;
100123
cabal2nix . --shell > shell.nix
101124
@@ -104,7 +127,7 @@
104127
105128
echo -e "run the following commands to finish nix development and production environment:\n\n"
106129
107-
echo -e "cd $PROJECT_DIR\n"
130+
echo -e "cd $PROJECT_DIR"
108131
echo -e "nix flake init -t github:akilan1999/p2p-rendering-computation#haskell"
109132
echo -e "nix develop"
110133
echo -e "nix run"

0 commit comments

Comments
 (0)