Files
p2p-rendering-computation/flake.nix
2025-06-01 19:34:32 +01:00

124 lines
2.8 KiB
Nix

{
description = "P2PRC nix flake";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
flake-utils = {
url = "github:numtide/flake-utils";
};
gomod2nix = {
url = "github:nix-community/gomod2nix";
inputs.nixpkgs.follows = "nixpkgs";
inputs.flake-utils.follows = "flake-utils";
};
};
outputs =
{
nixpkgs,
flake-utils,
gomod2nix,
...
}:
let
bindingsOverlay = import ./nix/overlays/bindings.nix;
coreOverlay = (final: prev: {
p2prc = final.callPackage ./. { };
});
in
(flake-utils.lib.eachDefaultSystem (system:
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 {
inherit system;
overlays = [
gomod2nix.overlays.default
coreOverlay
bindingsOverlay
];
};
in
{
packages.default = callPackage ./. { };
devShells.default = pkgs.mkShell {
buildInputs = with pkgs; [
go
gopls
gotools
go-tools
gomod2nix.packages.${system}.default
sqlite-interactive
];
};
packages.initHaskellProject = pkgs.writeShellApplication {
name = "initHaskellProject";
runtimeInputs = with pkgs; [
ghc
cabal2nix
cabal-install
nix
git
];
text =
''
clear
echo "Hello, this shell script will bootstrap a P2PRC Haskell project with Nix Flake\n"
echo "Could you input the name of your project?\n"
read "$PROJECT_NAME"
cd "$PROJECT_NAME"
git init .
echo "$PWD"
cabal init --exe --simple
# TODO: remove reference to cabal file
sed -i 's/base.*$/base, p2prc/' "$PROJECT_NAME".cabal
cabal2nix . > ./cabal.nix;
# TODO: add cabal2nix shell.nix generator
git add .
clear
echo "run the following commands:\n\n"
echo "cd "$PROJECT_NAME"\n"
echo "nix run github:xecarlox94/p2p-rendering-computation?ref=nix#initHaskellProject"
'';
};
}
)) //
{
overlays = {
default = coreOverlay;
bindings = bindingsOverlay;
};
templates.haskell = {
path = ./nix/templates/haskell;
description = "Haskell Bindings to p2prc protocol";
};
};
}