diff --git a/.gitignore b/.gitignore index 239ffad..d7c04f9 100644 --- a/.gitignore +++ b/.gitignore @@ -49,11 +49,3 @@ venv # Nix and Nix flake files result result-* -nix/templates/haskell/haskell.cabal -nix/templates/haskell/haskell.cabal -nix/templates/haskell/haskell.cabal -nix/templates/haskell/dist-newstyle -nix/templates/haskell/app -nix/templates/haskell/CHANGELOG.md -nix/templates/haskell/LICENSE -nix/templates/haskell/project.nix diff --git a/nix/templates/haskell/flake.lock b/nix/templates/haskell/flake.lock index 1a94262..3b6da3a 100644 --- a/nix/templates/haskell/flake.lock +++ b/nix/templates/haskell/flake.lock @@ -77,13 +77,27 @@ "type": "github" } }, + "nixpkgs_2": { + "locked": { + "lastModified": 1748370509, + "narHash": "sha256-QlL8slIgc16W5UaI3w7xHQEP+Qmv/6vSNTpoZrrSlbk=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "4faa5f5321320e49a78ae7848582f684d64783e9", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, "p2prc-flake": { "inputs": { "flake-utils": "flake-utils_2", "gomod2nix": "gomod2nix", - "nixpkgs": [ - "nixpkgs" - ] + "nixpkgs": "nixpkgs_2" }, "locked": { "lastModified": 1748386148, diff --git a/nix/templates/haskell/flake.nix b/nix/templates/haskell/flake.nix index 5728c30..5055e4c 100644 --- a/nix/templates/haskell/flake.nix +++ b/nix/templates/haskell/flake.nix @@ -7,15 +7,14 @@ url = "github:NixOS/nixpkgs/nixos-unstable"; }; - p2prc-flake = { - url = "github:xecarlox94/p2p-rendering-computation?ref=nix"; - inputs.nixpkgs.follows = "nixpkgs"; - }; - flake-utils = { url = "github:numtide/flake-utils"; }; + p2prc-flake = { + url = "github:xecarlox94/p2p-rendering-computation?ref=nix"; + }; + }; outputs = { nixpkgs, p2prc-flake, flake-utils, ... }: @@ -36,44 +35,66 @@ initProject = pkgs.writeShellApplication { name = "initProject"; runtimeInputs = with pkgs; [ + ghc cabal2nix cabal-install ]; - text = '' - cabal init --minimal - echo "RUNNING" + text = + let - # TODO: sed command to fix bash import and add p2prc import - # TODO: sed command to add p2prc example to main file - cabal2nix . > ./project.nix; + # TODO: finish script +# getMainFileContent = appName: ''"\ +# module Main where\ +# \ +# import P2PRC\ +# ( runP2PRC\ +# , MapPortRequest(MkMapPortRequest)\ +# )\ +# \ +# main :: IO ()\ +# main =\ +# runP2PRC\ +# ( MkMapPortRequest 8080 \"${appName}.akilan.io\"\ +# )\ +# "''; + # FOLDER_NAME=$(echo */ | sed 's/ /\n/' | head -n 1) + # cat ${getMainFileContent "file_name"} > "$FOLDER_NAME"/Main.hs - git add . - ''; + in + '' + cabal init + + # sed -i 's/base.*$/base, p2prc/' haskell.cabal + + cabal2nix . > ./cabal.nix; + + cabal run + ''; }; in { packages = { - # TODO: fix issue - default = pkgs.haskellPackages.callPackage ./project.nix { }; - init = initProject; + default = pkgs.haskellPackages.callPackage ./cabal.nix { }; }; - # TODO: override haskell binding lib devshell - # FIX: p2prc library not available in dev shell - devShells.default = pkgs.mkShell { - packages = with pkgs; [ + + devShells.default = pkgs.haskellPackages.shellFor { + + packages = p: [ + (p.callPackage ./cabal.nix { }) + ]; + + buildInputs = with pkgs; [ + p2prc-flake.packages.${system}.default + ghc cabal2nix cabal-install - ]; - - buildInputs = [ - p2prc-flake.packages.${system}.default initProject - pkgs.haskellPackages.p2prc ]; + # TODO: add cabal2nix shell command shellHook = '' - cabal2nix . > ./project.nix + cabal2nix . > ./cabal.nix ''; }; }