use flake modules

This commit is contained in:
hsjobeki 2023-11-23 12:31:33 +01:00
parent 2d4197cd79
commit 2f1aead693
No known key found for this signature in database
13 changed files with 12301 additions and 436 deletions

9
.gitignore vendored
View File

@ -1,18 +1,11 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
# testing
coverage
# nix
.floco
.direnv/
result
result-*
.pre-commit-config.yaml
# dream2nix
## dream2nix internal cache
.dream2nix

10
devShell.nix Normal file
View File

@ -0,0 +1,10 @@
{
perSystem = { pkgs, self', config, ... }: {
devShells.default = pkgs.mkShell {
packages = [ ];
shellHook = ''
${self'.checks.pre-commit-check.shellHook}
'';
};
};
}

View File

@ -1,112 +1,5 @@
{
"nodes": {
"all-cabal-json": {
"flake": false,
"locked": {
"lastModified": 1665552503,
"narHash": "sha256-r14RmRSwzv5c+bWKUDaze6pXM7nOsiz1H8nvFHJvufc=",
"owner": "nix-community",
"repo": "all-cabal-json",
"rev": "d7c0434eebffb305071404edcf9d5cd99703878e",
"type": "github"
},
"original": {
"owner": "nix-community",
"ref": "hackage",
"repo": "all-cabal-json",
"type": "github"
}
},
"crane": {
"flake": false,
"locked": {
"lastModified": 1670900067,
"narHash": "sha256-VXVa+KBfukhmWizaiGiHRVX/fuk66P8dgSFfkVN4/MY=",
"owner": "ipetkov",
"repo": "crane",
"rev": "59b31b41a589c0a65e4a1f86b0e5eac68081468b",
"type": "github"
},
"original": {
"owner": "ipetkov",
"repo": "crane",
"type": "github"
}
},
"devshell": {
"flake": false,
"locked": {
"lastModified": 1663445644,
"narHash": "sha256-+xVlcK60x7VY1vRJbNUEAHi17ZuoQxAIH4S4iUFUGBA=",
"owner": "numtide",
"repo": "devshell",
"rev": "e3dc3e21594fe07bdb24bdf1c8657acaa4cb8f66",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "devshell",
"type": "github"
}
},
"dream2nix": {
"inputs": {
"all-cabal-json": "all-cabal-json",
"crane": "crane",
"devshell": "devshell",
"drv-parts": "drv-parts",
"flake-parts": "flake-parts",
"flake-utils-pre-commit": "flake-utils-pre-commit",
"ghc-utils": "ghc-utils",
"gomod2nix": "gomod2nix",
"mach-nix": "mach-nix",
"nix-pypi-fetcher": "nix-pypi-fetcher",
"nixpkgs": "nixpkgs",
"nixpkgsV1": "nixpkgsV1",
"poetry2nix": "poetry2nix",
"pre-commit-hooks": "pre-commit-hooks",
"pruned-racket-catalog": "pruned-racket-catalog"
},
"locked": {
"lastModified": 1679378030,
"narHash": "sha256-ThQCgw1YGcftpWv5hbhxLRCWENWvUBXPMzNUF0XLzQQ=",
"owner": "nix-community",
"repo": "dream2nix",
"rev": "f04f032418555119f1c9c6c5cb60809b48305191",
"type": "github"
},
"original": {
"owner": "nix-community",
"repo": "dream2nix",
"type": "github"
}
},
"drv-parts": {
"inputs": {
"flake-compat": "flake-compat",
"flake-parts": [
"dream2nix",
"flake-parts"
],
"nixpkgs": [
"dream2nix",
"nixpkgs"
]
},
"locked": {
"lastModified": 1679210066,
"narHash": "sha256-0t6UZrLmIEsH3R8Jk8mo2XFGIPJmSWLsCR6HlSp3va8=",
"owner": "davhau",
"repo": "drv-parts",
"rev": "38f59f9eb2dbcf9ad6b939ec47c005033445f13e",
"type": "github"
},
"original": {
"owner": "davhau",
"repo": "drv-parts",
"type": "github"
}
},
"flake-compat": {
"flake": false,
"locked": {
@ -123,35 +16,18 @@
"type": "github"
}
},
"flake-compat_2": {
"flake": false,
"locked": {
"lastModified": 1673956053,
"narHash": "sha256-4gtG9iQuiKITOjNQQeQIpoIB6b16fm+504Ch3sNKLd8=",
"owner": "edolstra",
"repo": "flake-compat",
"rev": "35bb57c0c8d8b62bbfd284272c928ceb64ddbde9",
"type": "github"
},
"original": {
"owner": "edolstra",
"repo": "flake-compat",
"type": "github"
}
},
"flake-parts": {
"inputs": {
"nixpkgs-lib": [
"dream2nix",
"nixpkgs"
]
},
"locked": {
"lastModified": 1675933616,
"narHash": "sha256-/rczJkJHtx16IFxMmAWu5nNYcSXNg1YYXTHoGjLrLUA=",
"lastModified": 1698882062,
"narHash": "sha256-HkhafUayIqxXyHH1X8d9RDl1M2CkFgZLjKD3MzabiEo=",
"owner": "hercules-ci",
"repo": "flake-parts",
"rev": "47478a4a003e745402acf63be7f9a092d51b83d7",
"rev": "8c9fa2545007b49a5db5f650ae91f227672c3877",
"type": "github"
},
"original": {
@ -161,12 +37,15 @@
}
},
"flake-utils": {
"inputs": {
"systems": "systems"
},
"locked": {
"lastModified": 1667395993,
"narHash": "sha256-nuEHfE/LcWyuSWnS8t12N1wc105Qtau+/OdUAjtQ0rA=",
"lastModified": 1685518550,
"narHash": "sha256-o2d0KcvaXzTrPRIo0kOLV0/QXHhDQ5DTi+OxcjO8xqY=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "5aed5285a952e0b949eb3ba02c12fa4fcfef535f",
"rev": "a1720a10a6cfe8234c0e93907ffe81be440f4cef",
"type": "github"
},
"original": {
@ -175,37 +54,26 @@
"type": "github"
}
},
"flake-utils-pre-commit": {
"floco": {
"inputs": {
"nixpkgs": [
"nixpkgs"
]
},
"locked": {
"lastModified": 1644229661,
"narHash": "sha256-1YdnJAsNy69bpcjuoKdOYQX0YxZBiCYZo4Twxerqv7k=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "3cecb5b042f7f209c56ffd8371b2711a290ec797",
"lastModified": 1694873346,
"narHash": "sha256-Uvh03bg0a6ZnNWiX1Gb8g+m343wSJ/wb8ryUASt0loc=",
"owner": "aakropotkin",
"repo": "floco",
"rev": "d16bd444ab9d29a6640f52ee4e43a66528e07515",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"owner": "aakropotkin",
"repo": "floco",
"type": "github"
}
},
"ghc-utils": {
"flake": false,
"locked": {
"lastModified": 1662774800,
"narHash": "sha256-1Rd2eohGUw/s1tfvkepeYpg8kCEXiIot0RijapUjAkE=",
"ref": "refs/heads/master",
"rev": "bb3a2d3dc52ff0253fb9c2812bd7aa2da03e0fea",
"revCount": 1072,
"type": "git",
"url": "https://gitlab.haskell.org/bgamari/ghc-utils"
},
"original": {
"type": "git",
"url": "https://gitlab.haskell.org/bgamari/ghc-utils"
}
},
"gitignore": {
"inputs": {
"nixpkgs": [
@ -227,60 +95,13 @@
"type": "github"
}
},
"gomod2nix": {
"flake": false,
"locked": {
"lastModified": 1627572165,
"narHash": "sha256-MFpwnkvQpauj799b4QTBJQFEddbD02+Ln5k92QyHOSk=",
"owner": "tweag",
"repo": "gomod2nix",
"rev": "67f22dd738d092c6ba88e420350ada0ed4992ae8",
"type": "github"
},
"original": {
"owner": "tweag",
"repo": "gomod2nix",
"type": "github"
}
},
"mach-nix": {
"flake": false,
"locked": {
"lastModified": 1634711045,
"narHash": "sha256-m5A2Ty88NChLyFhXucECj6+AuiMZPHXNbw+9Kcs7F6Y=",
"owner": "DavHau",
"repo": "mach-nix",
"rev": "4433f74a97b94b596fa6cd9b9c0402104aceef5d",
"type": "github"
},
"original": {
"id": "mach-nix",
"type": "indirect"
}
},
"nix-pypi-fetcher": {
"flake": false,
"locked": {
"lastModified": 1669065297,
"narHash": "sha256-UStjXjNIuIm7SzMOWvuYWIHBkPUKQ8Id63BMJjnIDoA=",
"owner": "DavHau",
"repo": "nix-pypi-fetcher",
"rev": "a9885ac6a091576b5195d547ac743d45a2a615ac",
"type": "github"
},
"original": {
"owner": "DavHau",
"repo": "nix-pypi-fetcher",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1665580254,
"narHash": "sha256-hO61XPkp1Hphl4HGNzj1VvDH5URt7LI6LaY/385Eul4=",
"lastModified": 1700390070,
"narHash": "sha256-de9KYi8rSJpqvBfNwscWdalIJXPo8NjdIZcEJum1mH0=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "f634d427b0224a5f531ea5aa10c3960ba6ec5f0f",
"rev": "e4ad989506ec7d71f7302cc3067abd82730a4beb",
"type": "github"
},
"original": {
@ -291,11 +112,11 @@
},
"nixpkgs-master": {
"locked": {
"lastModified": 1695278169,
"narHash": "sha256-0j9Rf6vLOueasqDaG/tTNZ3sDNrYRMxLxLDwbygxgWI=",
"lastModified": 1700733543,
"narHash": "sha256-yQysLoGKq78l2+zkof5NpBb/JTWIsmEfR3g7bcWHbLc=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "53204fe466f8eb622686d881287111396d97e8e9",
"rev": "fa094c6dd42f8e62334a146e463e3e4684d405c0",
"type": "github"
},
"original": {
@ -306,95 +127,23 @@
},
"nixpkgs-stable": {
"locked": {
"lastModified": 1678872516,
"narHash": "sha256-/E1YwtMtFAu2KUQKV/1+KFuReYPANM2Rzehk84VxVoc=",
"lastModified": 1685801374,
"narHash": "sha256-otaSUoFEMM+LjBI1XL/xGB5ao6IwnZOXc47qhIgJe8U=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "9b8e5abb18324c7fe9f07cb100c3cd4a29cda8b8",
"rev": "c37ca420157f4abc31e26f436c1145f8951ff373",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixos-22.11",
"ref": "nixos-23.05",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgsV1": {
"locked": {
"lastModified": 1678500271,
"narHash": "sha256-tRBLElf6f02HJGG0ZR7znMNFv/Uf7b2fFInpTHiHaSE=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "5eb98948b66de29f899c7fe27ae112a47964baf8",
"type": "github"
},
"original": {
"id": "nixpkgs",
"ref": "nixos-22.11",
"type": "indirect"
}
},
"nixpkgs_2": {
"locked": {
"lastModified": 1679262748,
"narHash": "sha256-DQCrrAFrkxijC6haUzOC5ZoFqpcv/tg2WxnyW3np1Cc=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "60c1d71f2ba4c80178ec84523c2ca0801522e0a6",
"type": "github"
},
"original": {
"id": "nixpkgs",
"ref": "nixos-unstable",
"type": "indirect"
}
},
"poetry2nix": {
"flake": false,
"locked": {
"lastModified": 1666918719,
"narHash": "sha256-BkK42fjAku+2WgCOv2/1NrPa754eQPV7gPBmoKQBWlc=",
"owner": "nix-community",
"repo": "poetry2nix",
"rev": "289efb187123656a116b915206e66852f038720e",
"type": "github"
},
"original": {
"owner": "nix-community",
"ref": "1.36.0",
"repo": "poetry2nix",
"type": "github"
}
},
"pre-commit-hooks": {
"inputs": {
"flake-utils": [
"dream2nix",
"flake-utils-pre-commit"
],
"nixpkgs": [
"dream2nix",
"nixpkgs"
]
},
"locked": {
"lastModified": 1646153636,
"narHash": "sha256-AlWHMzK+xJ1mG267FdT8dCq/HvLCA6jwmx2ZUy5O8tY=",
"owner": "cachix",
"repo": "pre-commit-hooks.nix",
"rev": "b6bc0b21e1617e2b07d8205e7fae7224036dfa4b",
"type": "github"
},
"original": {
"owner": "cachix",
"repo": "pre-commit-hooks.nix",
"type": "github"
}
},
"pre-commit-hooks_2": {
"inputs": {
"flake-compat": "flake-compat_2",
"flake-compat": "flake-compat",
"flake-utils": "flake-utils",
"gitignore": "gitignore",
"nixpkgs": [
@ -403,11 +152,11 @@
"nixpkgs-stable": "nixpkgs-stable"
},
"locked": {
"lastModified": 1678976941,
"narHash": "sha256-skNr08frCwN9NO+7I77MjOHHAw+L410/37JknNld+W4=",
"lastModified": 1700064067,
"narHash": "sha256-1ZWNDzhu8UlVCK7+DUN9dVQfiHX1bv6OQP9VxstY/gs=",
"owner": "cachix",
"repo": "pre-commit-hooks.nix",
"rev": "32b1dbedfd77892a6e375737ef04d8efba634e9e",
"rev": "e558068cba67b23b4fbc5537173dbb43748a17e8",
"type": "github"
},
"original": {
@ -416,29 +165,49 @@
"type": "github"
}
},
"pruned-racket-catalog": {
"flake": false,
"locked": {
"lastModified": 1672537287,
"narHash": "sha256-SuOvXVcLfakw18oJB/PuRMyvGyGG1+CQD3R+TGHIv44=",
"owner": "nix-community",
"repo": "pruned-racket-catalog",
"rev": "c8b89557fb53b36efa2ee48a769c7364df0f6262",
"type": "github"
},
"original": {
"owner": "nix-community",
"ref": "catalog",
"repo": "pruned-racket-catalog",
"type": "github"
}
},
"root": {
"inputs": {
"dream2nix": "dream2nix",
"nixpkgs": "nixpkgs_2",
"flake-parts": "flake-parts",
"floco": "floco",
"nixpkgs": "nixpkgs",
"nixpkgs-master": "nixpkgs-master",
"pre-commit-hooks": "pre-commit-hooks_2"
"pre-commit-hooks": "pre-commit-hooks",
"treefmt-nix": "treefmt-nix"
}
},
"systems": {
"locked": {
"lastModified": 1681028828,
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
"owner": "nix-systems",
"repo": "default",
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
"type": "github"
},
"original": {
"owner": "nix-systems",
"repo": "default",
"type": "github"
}
},
"treefmt-nix": {
"inputs": {
"nixpkgs": [
"nixpkgs"
]
},
"locked": {
"lastModified": 1699786194,
"narHash": "sha256-3h3EH1FXQkIeAuzaWB+nK0XK54uSD46pp+dMD3gAcB4=",
"owner": "numtide",
"repo": "treefmt-nix",
"rev": "e82f32aa7f06bbbd56d7b12186d555223dc399d1",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "treefmt-nix",
"type": "github"
}
}
},

129
flake.nix
View File

@ -1,127 +1,26 @@
{
description = "Noogle.dev | Discover the nix api surface";
inputs = {
nixpkgs.url = "nixpkgs/nixos-unstable";
nixpkgs-master.url = "nixpkgs/master";
dream2nix.url = "github:nix-community/dream2nix";
pre-commit-hooks = {
url = "github:cachix/pre-commit-hooks.nix";
inputs.nixpkgs.follows = "nixpkgs";
};
flake-parts.url = "github:hercules-ci/flake-parts";
flake-parts.inputs.nixpkgs-lib.follows = "nixpkgs";
treefmt-nix.url = "github:numtide/treefmt-nix";
treefmt-nix.inputs.nixpkgs.follows = "nixpkgs";
floco.url = "github:aakropotkin/floco";
floco.inputs.nixpkgs.follows = "nixpkgs";
};
outputs = { self, nixpkgs, pre-commit-hooks, dream2nix, nixpkgs-master }:
let
system = "x86_64-linux";
pkgs = nixpkgs.legacyPackages.${system};
websiteName = (builtins.fromJSON (builtins.readFile ./website/package.json)).name;
inherit (self.packages.${system}) indexer nixpkgs-data builtins-data;
prepareData = prefix: ''
cp -f ${nixpkgs-data.lib} ${prefix}/lib.json
cp -f ${nixpkgs-data.trivial_builders} ${prefix}/trivial-builders.json
cp -f ${nixpkgs-data.build_support} ${prefix}/build_support.json
cp -f ${builtins-data}/lib/data.json ${prefix}/builtins.json
'';
dream2nixOutput = dream2nix.lib.makeFlakeOutputs {
systems = [ system ];
projects = ./projects.toml;
config.projectRoot = ./.;
source = ./.;
packageOverrides = {
${websiteName}.staticPage = {
preBuild = prepareData "models/data";
installPhase = ''
runHook preInstall
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
'';
};
};
};
in
{
packages.${system} = dream2nixOutput.packages.${system} // {
nixpkgs-data = pkgs.stdenv.mkDerivation {
pname = "data";
version = "0.1.0";
description = ''
wrapper around the indexer.
Calls the indexer with '<nixpkgs>'/path.
and defines one output for every specified input path
currently this list is manually maintained below.
'';
src = nixpkgs-master;
outputs = [ "out" "lib" "trivial_builders" "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/trivial-builders
${indexer}/bin/indexer --dir ./pkgs/build-support
'';
installPhase = ''
cat lib.json > $lib
cat trivial-builders.json > $trivial_builders
cat build-support.json > $build_support
mkdir $out
ln -s $lib $out/lib
ln -s $trivial_builders $out/trivial_builders
ln -s $build_support $out/build_support
'';
};
default = self.packages.${system}.noogle;
};
devShells.${system}.default = pkgs.mkShell {
buildInputs = with pkgs; [ nodejs-18_x rustfmt rustc cargo clippy ];
inputsFrom = [ indexer ];
shellHook = ''
${prepareData "website/models/data"}
${prepareData "tests/data"}
${self.checks.${system}.pre-commit-check.shellHook}
'';
};
checks.${system} = {
pre-commit-check = pre-commit-hooks.lib.${system}.run {
src = ./.;
hooks = {
nixpkgs-fmt.enable = true;
statix.enable = true;
markdownlint.enable = true;
};
excludes = [ "indexer/test" ".github" "scripts/data" ];
settings = {
statix.ignore = [ "indexer/test" ];
};
};
};
};
outputs = inputs@{ flake-parts, ... }:
flake-parts.lib.mkFlake { inherit inputs; } ({ ... }: {
systems = [ "x86_64-linux" ];
imports = [ ./devShell.nix ./preCommit.nix ./website/flake-module.nix ];
});
}

14
preCommit.nix Normal file
View File

@ -0,0 +1,14 @@
{ self, ... }: {
perSystem = { pkgs, self', system, ... }: {
checks.pre-commit-check = self.inputs.pre-commit-hooks.lib.${system}.run {
src = ./.;
hooks = {
nixfmt.enable = true;
statix.enable = true;
# markdownlint.enable = true;
};
excludes = [ "indexer/test" ".github" "scripts/data" ];
settings = { statix.ignore = [ "indexer/test" ]; };
};
};
}

10
website/.envrc Normal file
View File

@ -0,0 +1,10 @@
source_up
files=(../../flake.nix flake-module.nix package-lock.json)
if type nix_direnv_watch_file &>/dev/null; then
nix_direnv_watch_file "${files[@]}"
else
watch_file "${files[@]}"
fi
use flake .#ui --builders ''

35
website/default.nix Normal file
View File

@ -0,0 +1,35 @@
{ floco, system, pkgs, nooglePkgs }:
let
inherit (floco) lib;
pjs = let
msg = "default.nix: Expected to find `package.json' to lookup "
+ "package name/version, but no such file exists at: "
+ (toString ./package.json);
in if builtins.pathExists ./package.json then
lib.importJSON ./package.json
else
throw msg;
ident = pjs.name;
inherit (pjs) version;
fmod = lib.evalModules {
modules = [
floco.nixosModules.floco
{
config.floco.settings = {
inherit system;
basedir = ./.;
};
}
./nix/floco-cfg.nix
];
specialArgs = { inherit pkgs nooglePkgs; };
};
# This attrset holds a few derivations related to our package.
# We'll expose these below to the CLI.
pkg = fmod.config.floco.packages.${ident}.${version};
in { inherit pkg fmod; }

17
website/flake-module.nix Normal file
View File

@ -0,0 +1,17 @@
{ self, ... }: {
perSystem = { self', pkgs, ... }:
let
inherit (self.inputs) floco;
base = pkgs.callPackage ./default.nix {
inherit floco;
nooglePkgs = self'.packages;
};
in {
packages = { ui = base.pkg.global; };
devShells.ui = pkgs.callPackage ./shell.nix {
inherit pkgs;
inherit (base) fmod pkg;
nooglePkgs = self'.packages;
};
};
}

View File

@ -1,10 +1,20 @@
import { MetaData } from "../nix";
import nixLibs from "./lib.json";
import nixBuiltins from "./builtins.json";
import nixTrivialBuilders from "./trivial-builders.json";
// import nixLibs from "./lib.json";
// import nixBuiltins from "./builtins.json";
// import nixTrivialBuilders from "./trivial-builders.json";
const mock = {
id: "mock",
category: "mock",
name: "mock",
fn_type: null,
description: "No data yet in dev mode",
example: null,
line: null,
};
export const data: MetaData = [
...(nixLibs as MetaData),
...(nixBuiltins as MetaData),
...(nixTrivialBuilders as MetaData),
mock,
// ...(nixLibs as MetaData),
// ...(nixBuiltins as MetaData),
// ...(nixTrivialBuilders as MetaData),
].sort((a, b) => a.name.localeCompare(b.name));

View File

@ -0,0 +1 @@
{ imports = [ ./pdefs.nix ./foverrides.nix ]; }

View File

@ -0,0 +1,63 @@
{ lib, config, ... }:
let
pjs = let
msg = "foverrides.nix: Expected to find `package.json' to lookup "
+ "package name/version, but no such file exists at: "
+ (toString ../package.json);
in if builtins.pathExists ../package.json then
lib.importJSON ../package.json
else
throw msg;
ident = pjs.name;
inherit (pjs) version;
# ---------------------------------------------------------------------------- #
# example: "13.4.2"
nextVersion = builtins.head (builtins.attrNames
(lib.filterAttrs (name: _attrs: name == "next") config.floco.pdefs).next);
# we must change the precompiled swc binary depending on the curerent system.
# example: "@next/swc-linux-x64-gnu"
swcArch = {
"x86_64-linux" = "@next/swc-linux-x64-gnu";
"aarch64-linux" = "@next/swc-linux-arm64-gnu";
"x86_64-darwin" = "@next/swc-darwin-x64";
"aarch64-darwin" = "@next/swc-darwin-arm64";
}.${config.floco.settings.system};
in {
config.floco.packages.${ident}.${version} =
let cfg = config.floco.packages.${ident}.${version};
in {
# ---------------------------------------------------------------------------- #
# Removes any `*.nix' files as well as `node_modules/' and
# `package-lock.json' from the source tree before using them in builds.
source = lib.libfloco.cleanLocalSource ../.;
# nextjs writes in node_mdules
built = {
override.copyTree = true;
# nextjs chaches some stuff in $HOME
override.preBuild = ''
export HOME=./home
'';
tree = let
customOverrides = cfg.trees.dev.overrideAttrs (prev: {
treeInfo = prev.treeInfo // {
"node_modules/${swcArch}" = {
key = "${swcArch}/${nextVersion}";
link = false;
optional = false;
dev = true;
};
# We can inject dependencies here
#
};
});
in lib.mkForce customOverrides;
};
};
}

12025
website/nix/pdefs.nix Normal file

File diff suppressed because it is too large Load Diff

19
website/shell.nix Normal file
View File

@ -0,0 +1,19 @@
{ fmod, pkg, pkgs, ... }:
pkgs.mkShell {
buildInputs = [ fmod.config.floco.settings.nodePackage ];
shellHook = ''
ID=${pkg.built.tree}
currID=$(cat .floco/.node_modules_id 2> /dev/null)
mkdir -p .floco
if [[ "$ID" != "$currID" || ! -d "node_modules" ]];
then
${pkgs.rsync}/bin/rsync -a --checksum --chmod=ug+w --delete ${pkg.built.tree}/node_modules/ ./node_modules/
echo -n $ID > .floco/.node_modules_id
echo "floco ok: node_modules updated"
fi
export PATH="$PATH:$(realpath ./node_modules)/.bin"
'';
}