-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
289 additions
and
97 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
{ | ||
description = "Nhost Functions"; | ||
|
||
inputs = { | ||
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; | ||
nix-filter.url = "github:numtide/nix-filter"; | ||
flake-utils.url = "github:numtide/flake-utils"; | ||
}; | ||
|
||
outputs = { self, nixpkgs, flake-utils, nix-filter }: | ||
flake-utils.lib.eachDefaultSystem (system: | ||
let | ||
overlays = [ | ||
(final: prev: { | ||
nodejs = prev.nodejs-18_x; | ||
}) | ||
]; | ||
|
||
pkgs = import nixpkgs { | ||
inherit overlays system; | ||
}; | ||
|
||
nix-src = nix-filter.lib.filter { | ||
root = ./.; | ||
include = [ | ||
(nix-filter.lib.matchExt "nix") | ||
]; | ||
}; | ||
|
||
node_modules = pkgs.stdenv.mkDerivation { | ||
inherit version; | ||
|
||
pname = "node_modules"; | ||
|
||
nativeBuildInputs = with pkgs; [ | ||
nodePackages.pnpm | ||
]; | ||
|
||
src = nix-filter.lib.filter { | ||
root = ./.; | ||
include = [ | ||
./package.json | ||
./pnpm-lock.yaml | ||
]; | ||
}; | ||
|
||
|
||
buildPhase = '' | ||
pnpm install | ||
''; | ||
|
||
installPhase = '' | ||
mkdir -p $out | ||
cp -r node_modules $out | ||
''; | ||
}; | ||
|
||
|
||
name = "functions"; | ||
version = "0.0.0-dev"; | ||
|
||
buildInputs = with pkgs;[ | ||
nodejs | ||
]; | ||
nativeBuildInputs = with pkgs; [ | ||
nodePackages.pnpm | ||
]; | ||
in | ||
{ | ||
checks = { | ||
nixpkgs-fmt = pkgs.runCommand "check-nixpkgs-fmt" | ||
{ | ||
nativeBuildInputs = with pkgs; | ||
[ | ||
nixpkgs-fmt | ||
]; | ||
} | ||
'' | ||
mkdir $out | ||
nixpkgs-fmt --check ${nix-src} | ||
''; | ||
|
||
}; | ||
|
||
devShells = flake-utils.lib.flattenTree rec { | ||
default = pkgs.mkShell { | ||
buildInputs = with pkgs; [ | ||
nixpkgs-fmt | ||
gnumake | ||
] ++ buildInputs ++ nativeBuildInputs; | ||
|
||
shellHook = '' | ||
export PATH=${node_modules}/node_modules/.bin:$PATH | ||
rm -rf node_modules | ||
ln -sf ${node_modules}/node_modules/ node_modules | ||
''; | ||
}; | ||
}; | ||
} | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.