noogle/flake.nix

125 lines
3.6 KiB
Nix
Raw Normal View History

2022-11-26 12:36:08 +03:00
{
2023-01-25 17:54:44 +03:00
inputs = {
2023-02-23 18:19:19 +03:00
nixpkgs.url = "nixpkgs/nixos-unstable";
nixpkgs-master.url = "nixpkgs/master";
2023-01-25 17:54:44 +03:00
dream2nix.url = "github:nix-community/dream2nix";
2023-02-23 18:19:19 +03:00
2023-01-25 17:54:44 +03:00
pre-commit-hooks = {
url = "github:cachix/pre-commit-hooks.nix";
inputs.nixpkgs.follows = "nixpkgs";
};
};
2023-02-23 18:19:19 +03:00
outputs = { self, nixpkgs, pre-commit-hooks, dream2nix, nixpkgs-master }:
2023-01-25 17:54:44 +03:00
let
system = "x86_64-linux";
2023-02-23 18:19:19 +03:00
pkgs = nixpkgs.legacyPackages.${system};
websiteName = (builtins.fromJSON (builtins.readFile ./website/package.json)).name;
inherit (self.packages.${system}) indexer nixpkgs-data builtins-data;
2023-02-23 18:19:19 +03:00
prepareData = prefix: ''
cp -f ${nixpkgs-data.lib} ${prefix}/lib.json
cp -f ${nixpkgs-data.build_support} ${prefix}/trivial-builders.json
cp -f ${builtins-data}/lib/data.json ${prefix}/builtins.json
'';
2023-02-23 18:19:19 +03:00
dream2nixOutput = dream2nix.lib.makeFlakeOutputs {
systems = [ system ];
projects = ./projects.toml;
config.projectRoot = ./.;
source = ./.;
packageOverrides = {
${websiteName}.staticPage = {
preBuild = prepareData "models/data";
2023-02-23 18:19:19 +03:00
installPhase = ''
runHook preInstall
npm run export
mkdir -p $out/static
cp -r ./out/* $out/static/
cp -r ./ $lib
runHook postInstall
'';
};
tests.run = {
installPhase = "";
preBuild = ''
ls -la
mkdir -p data
${prepareData "data"}
'';
doCheck = true;
checkPhase = ''
ls -la
npm run test -- --ci
'';
};
2023-02-23 18:19:19 +03:00
};
};
2023-01-25 17:54:44 +03:00
in
2023-02-23 18:19:19 +03:00
{
packages.${system} = dream2nixOutput.packages.${system} // {
nixpkgs-data = pkgs.stdenv.mkDerivation {
pname = "data";
version = "0.1.0";
description = ''
wrapper around the indexer.
2022-11-26 12:36:08 +03:00
2023-02-23 18:19:19 +03:00
Calls the indexer with '<nixpkgs>'/path.
and defines one output for every specified input path
2022-11-26 12:36:08 +03:00
2023-02-23 18:19:19 +03:00
currently this list is manually maintained below.
'';
src = nixpkgs-master;
outputs = [ "out" "lib" "build_support" ];
nativeBuildInputs = [ indexer ];
buildPhase = ''
echo "running nix metadata collect in nixpkgs/lib"
${indexer}/bin/indexer --dir ./lib
${indexer}/bin/indexer --dir ./pkgs/build-support
'';
installPhase = ''
cat lib.json > $lib
cat build-support.json > $build_support
mkdir $out
ln -s $lib $out/lib
ln -s $build_support $out/build_support
2022-11-26 12:36:08 +03:00
'';
};
2023-02-23 18:19:19 +03:00
default = self.packages.${system}.noogle;
2022-11-26 12:36:08 +03:00
};
2023-02-23 18:19:19 +03:00
2022-12-18 19:31:42 +03:00
devShells.${system}.default = pkgs.mkShell {
2023-02-23 18:19:19 +03:00
buildInputs = with pkgs; [ nodejs-18_x rustfmt rustc cargo clippy ];
inputsFrom = [ indexer ];
2023-01-25 17:54:44 +03:00
shellHook = ''
${prepareData "website/models/data"}
${prepareData "tests/data"}
2023-01-25 17:54:44 +03:00
${self.checks.${system}.pre-commit-check.shellHook}
'';
};
2023-02-23 18:19:19 +03:00
2023-01-25 17:54:44 +03:00
checks.${system} = {
pre-commit-check = pre-commit-hooks.lib.${system}.run {
src = ./.;
hooks = {
nixpkgs-fmt.enable = true;
statix.enable = true;
markdownlint.enable = true;
};
2023-02-25 15:13:39 +03:00
excludes = [ "indexer/test" ".github" "scripts/data" ];
2023-02-23 18:19:19 +03:00
settings = {
statix.ignore = [ "indexer/test" ];
};
2023-01-25 17:54:44 +03:00
};
2022-12-18 19:31:42 +03:00
};
};
2022-11-26 12:36:08 +03:00
}