finishing automated setup

This commit is contained in:
2025-06-02 00:31:04 +01:00
parent 69b9ea3527
commit 539bceee7d

View File

@@ -35,10 +35,6 @@
(flake-utils.lib.eachDefaultSystem (system: (flake-utils.lib.eachDefaultSystem (system:
let let
# The current default sdk for macOS fails to compile go projects, so we use a newer one for now.
# This has no effect on other platforms.
callPackage = pkgs.darwin.apple_sdk_11_0.callPackage or pkgs.callPackage;
pkgs = import nixpkgs { pkgs = import nixpkgs {
inherit system; inherit system;
overlays = [ overlays = [
@@ -48,10 +44,15 @@
]; ];
}; };
# The current default sdk for macOS fails to compile go projects, so we use a newer one for now.
# This has no effect on other platforms.
callPackage = pkgs.darwin.apple_sdk_11_0.callPackage or pkgs.callPackage;
p2prcDefault = callPackage ./. { };
in in
{ {
packages.default = p2prcDefault;
packages.default = callPackage ./. { };
devShells.default = pkgs.mkShell { devShells.default = pkgs.mkShell {
buildInputs = with pkgs; [ buildInputs = with pkgs; [
@@ -70,10 +71,30 @@
ghc ghc
cabal2nix cabal2nix
cabal-install cabal-install
nix
git git
p2prcDefault
]; ];
text = text =
let
# TODO: add
p2prcMainContent = availablePort: availableUrl:
''
module Main where
import P2PRC
( runP2PRC
, MapPortRequest(MkMapPortRequest)
)
main :: IO ()
main =
runP2PRC
( MkMapPortRequest ${availablePort} "${availableUrl}.akilan.io"
)
'';
mainFileContent = p2prcMainContent 8080 "haskell";
in
'' ''
clear clear
if [ "$#" -eq 0 ]; then if [ "$#" -eq 0 ]; then
@@ -96,6 +117,8 @@
sed -i 's/base.*$/base, p2prc/' "$PROJECT_DIR".cabal sed -i 's/base.*$/base, p2prc/' "$PROJECT_DIR".cabal
cat ${mainFileContent} > app/main.hs
cabal2nix . > ./cabal.nix; cabal2nix . > ./cabal.nix;
cabal2nix . --shell > shell.nix cabal2nix . --shell > shell.nix
@@ -104,7 +127,7 @@
echo -e "run the following commands to finish nix development and production environment:\n\n" echo -e "run the following commands to finish nix development and production environment:\n\n"
echo -e "cd $PROJECT_DIR\n" echo -e "cd $PROJECT_DIR"
echo -e "nix flake init -t github:akilan1999/p2p-rendering-computation#haskell" echo -e "nix flake init -t github:akilan1999/p2p-rendering-computation#haskell"
echo -e "nix develop" echo -e "nix develop"
echo -e "nix run" echo -e "nix run"