fixed devshell environment

This commit is contained in:
2025-05-29 00:23:42 +01:00
parent 0e86459122
commit 3fb225676f
3 changed files with 64 additions and 37 deletions

8
.gitignore vendored
View File

@@ -49,11 +49,3 @@ venv
# Nix and Nix flake files # Nix and Nix flake files
result result
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

View File

@@ -77,13 +77,27 @@
"type": "github" "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": { "p2prc-flake": {
"inputs": { "inputs": {
"flake-utils": "flake-utils_2", "flake-utils": "flake-utils_2",
"gomod2nix": "gomod2nix", "gomod2nix": "gomod2nix",
"nixpkgs": [ "nixpkgs": "nixpkgs_2"
"nixpkgs"
]
}, },
"locked": { "locked": {
"lastModified": 1748386148, "lastModified": 1748386148,

View File

@@ -7,15 +7,14 @@
url = "github:NixOS/nixpkgs/nixos-unstable"; url = "github:NixOS/nixpkgs/nixos-unstable";
}; };
p2prc-flake = {
url = "github:xecarlox94/p2p-rendering-computation?ref=nix";
inputs.nixpkgs.follows = "nixpkgs";
};
flake-utils = { flake-utils = {
url = "github:numtide/flake-utils"; url = "github:numtide/flake-utils";
}; };
p2prc-flake = {
url = "github:xecarlox94/p2p-rendering-computation?ref=nix";
};
}; };
outputs = { nixpkgs, p2prc-flake, flake-utils, ... }: outputs = { nixpkgs, p2prc-flake, flake-utils, ... }:
@@ -36,44 +35,66 @@
initProject = pkgs.writeShellApplication { initProject = pkgs.writeShellApplication {
name = "initProject"; name = "initProject";
runtimeInputs = with pkgs; [ runtimeInputs = with pkgs; [
ghc
cabal2nix cabal2nix
cabal-install cabal-install
]; ];
text = '' text =
cabal init --minimal let
echo "RUNNING"
# TODO: sed command to fix bash import and add p2prc import # TODO: finish script
# TODO: sed command to add p2prc example to main file # getMainFileContent = appName: ''"\
cabal2nix . > ./project.nix; # 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 { in {
packages = { packages = {
# TODO: fix issue default = pkgs.haskellPackages.callPackage ./cabal.nix { };
default = pkgs.haskellPackages.callPackage ./project.nix { };
init = initProject;
}; };
# TODO: override haskell binding lib devshell
# FIX: p2prc library not available in dev shell devShells.default = pkgs.haskellPackages.shellFor {
devShells.default = pkgs.mkShell {
packages = with pkgs; [ packages = p: [
(p.callPackage ./cabal.nix { })
];
buildInputs = with pkgs; [
p2prc-flake.packages.${system}.default
ghc
cabal2nix cabal2nix
cabal-install cabal-install
];
buildInputs = [
p2prc-flake.packages.${system}.default
initProject initProject
pkgs.haskellPackages.p2prc
]; ];
# TODO: add cabal2nix shell command
shellHook = '' shellHook = ''
cabal2nix . > ./project.nix cabal2nix . > ./cabal.nix
''; '';
}; };
} }