Skip to content

Commit

Permalink
update flake.nix hash
Browse files Browse the repository at this point in the history
  • Loading branch information
pineapplehunter committed Mar 20, 2024
1 parent a0a826a commit 109b95c
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 31 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,6 @@ project/plugins/project/
/processor

stats*.jsonl
stats*.csv
stats*.csv

update-tmp
30 changes: 4 additions & 26 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,31 +66,9 @@ $ sbt test
### 依存関係周りを編集したらプロセッサが生成できない

コンパイル中に依存関係周りで問題が発生していれば、Nixの依存関係のキャッシュに問題がある場合があります。
その場合は`./flake.nix`を次のように編集します。
```diff
diff --git a/flake.nix b/flake.nix
index e04c9d2..5f6a965 100644
--- a/flake.nix
+++ b/flake.nix
@@ -26,7 +26,7 @@
verilator_4 = final.callPackage ./nix/verilator_4.nix { };
espresso = (import inputs.nixpkgs-pineapplehunter2 { inherit system; config.allowUnfree = true; }).espresso;
b4smtGen = final.callPackage ./nix { riscv-programs = self.packages.${system}.default; };
- b4smt = final.b4smtGen { hash = "sha256-dm8qlhY87+9tKoX9TWACi+yyzPbSFEnQTGEdJmQl4LE="; };
+ b4smt = final.b4smtGen { hash = ""; };
};
pkgs = import nixpkgs {
inherit system;
その場合は次のコマンドを実行してください。
```sh
$ nix run ".#update-hash"
```

また一度makeすると次のエラーメッセージが出てきます。

```
...
error: hash mismatch in fixed-output derivation '/nix/store/4i2jb1mhg695fbxm56wj50fpbyqjpc6n-b4smt-sbt-dependencies.tar.zst.drv':
specified: sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=
got: sha256-dm8qlhY87+9tKoX9TWACi+yyzPbSFEnQTGEdJmQl4LE=
...
```

ここで出てきたハッシュに置き換えてmakeするとうまくビルドされると思います。
このコマンドでnixの依存関係をを管理するHashを更新できます。
22 changes: 20 additions & 2 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
b4smtGen = final.callPackage ./nix/b4smtgen.nix {
riscv-programs = self.packages.${system}.default;
};
b4smt = final.b4smtGen { hash = "sha256-FWNVtPxzSDOJzF4V+zMTFQ3tgyZCiOCzWATgQ66dq9Q="; };
b4smt = final.b4smtGen { hash = "sha256-aAk0OvDg92FM/xy6rJbWFLY17proCSfNcjX0r+BOxyo="; };
};
pkgs = import nixpkgs {
inherit system;
Expand All @@ -37,7 +37,7 @@
"espresso"
];
};

inherit (nixpkgs) lib;
in
{
packages = rec {
Expand All @@ -64,5 +64,23 @@
devShells.default = pkgs.callPackage ./nix/shell.nix {
verilator = pkgs.verilator_4;
};

apps.update-hash = {
type = "app";
program = let
script = pkgs.writeShellScript "update-hash" ''
echo updating-hash
set -xe
export hash=$(nix eval ".#processor.dependencies.outputHash" --json | ${lib.getExe pkgs.jq} -r)
sed -i "s|$hash|${lib.fakeHash}|" flake.nix
echo this is a temporary file for updating the hash > update-tmp
nix build ".#processor.dependencies" -L |& tee -a update-tmp
export new_hash=$(grep "got:" update-tmp | tail -n1 | awk '{print $2}')
sed -i "s|${lib.fakeHash}|$new_hash|" flake.nix
rm update-tmp
echo "changed hash from:$hash to:$new_hash"
'';
in "${script}";
};
});
}
3 changes: 1 addition & 2 deletions nix/b4smtgen.nix
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@ let
'';

depsWarmupCommand = ''
sbt compile
sbt scalafmtCheck || true
sbt "compile;scalafmtCheck" || true
'';

fixupPhase = "";
Expand Down

0 comments on commit 109b95c

Please sign in to comment.