Skip to content

Commit

Permalink
[doc] update readme.md
Browse files Browse the repository at this point in the history
Signed-off-by: unlsycn <unlsycn@unlsycn.com>
  • Loading branch information
unlsycn committed Feb 9, 2025
1 parent c780bf4 commit 8e5ae95
Showing 1 changed file with 13 additions and 30 deletions.
43 changes: 13 additions & 30 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ It will provide you the below code structure:
* gcdemu/: source code for the DPI library
* configs/: default configurations for GCD and the testbench, which can be generated by elaborator
* nix/: nix build script for the whole lowering process
* build.sc & common.sc: Scala build script
* build.mill & common.mill: Scala build script
* flake.nix: the root for nix to search scripts

## Usage
Expand Down Expand Up @@ -145,7 +145,7 @@ To bump mill dependencies, run:
nix build '.#gcd.gcd-compiled.millDeps' --rebuild
```

and Then update `millDepsHash` in `nix/gcd/gcd.nix`
and Then update `millDepsHash` in `nix/pkgs/dependencies/default.nix` and `nix/gcd/gcd.nix`

### Use the fetchMillDeps function

Expand All @@ -154,7 +154,7 @@ Fetch project dependencies for later offline usage.
The `fetchMillDeps` function accept three args: `name`, `src`, `millDepsHash`:

* name: name of the mill dependencies derivation, suggest using `<module>-mill-deps` as suffix.
* src: path to a directory that contains at least `build.sc` file for mill to obtain dependencies.
* src: path to a directory that contains at least `build.mill` file for mill to obtain dependencies.
* millDepsHash: same functionality as the `sha256`, `hash` attr in stdenv.mkDerivation. To obtain new hash for new dependencies, replace the old hash with empty string, and let nix figure the new hash.

This derivation will read `$JAVA_OPTS` environment varialble, to set http proxy, you can export:
Expand All @@ -171,15 +171,17 @@ Example:
```nix
stdenv.mkDerivation rec {
# ...
millDeps = fetchMillDeps {
inherit name;
src = with lib.fileset; toSource {
root = ./.;
fileset = unions [
./build.sc
];
passthru = {
millDeps = fetchMillDeps {
inherit name;
src = with lib.fileset;
toSource {
root = ./../..;
fileset = unions [ ./../../build.mill ./../../common.mill ];
};
buildInputs = with mill-dependencies; [ chisel.setupHook ];
millDepsHash = "sha256-NybS2AXRQtXkgHd5nH4Ltq3sxZr5aZ4VepiT79o1AWo=";
};
millDepsHash = "sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=";
};
# ...
nativeBuildInputs = [
Expand All @@ -189,25 +191,6 @@ stdenv.mkDerivation rec {
}
```

### Use the `nvfetcherSource` attribute

`projectDependencies` attribute is an nix setup hook that will obtain nvfetcher generated sources
and place them under `dependencies` directory in build root.

Read [nvfetcher](https://github.com/berberman/nvfetcher) document for nvfetcher usage.
By default the `nvfetcherSource` attribute will read `nix/pkgs/dependencies/_sources/generated.nix`,
so developer should place nvfetcher config and run `nix run .#nvfetcher` under `nix/pkgs/dependencies`.

Usage:

```nix
stdenv.mkDerivation {
nativeBuildInputs = [
projectDependencies.setupHook
]
}
```

## License

The build system is released under the Apache-2.0 license, including all Nix and mill build system, All rights reserved by Jiuyang Liu <liu@Jiuyang.me>
Expand Down

0 comments on commit 8e5ae95

Please sign in to comment.