Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add instructions on how to run the tests with Nix(OS) #38

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
__pycache__

build/
out/
out.zip
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,13 @@ $ python run_algtest.py all

**Important:** If during keygen test you don't see lines ending with `rc 0000`, but see some other number (return code), the key generation fails and it doesn't make sense to continue. Please contact me and send me the `out.zip` file anyway, the logs and TPM info there will still help us. A few erroneous return codes are ok.

### Running the tool with Nix(OS)

On NixOS, update your `/etc/nixos/configuration.nix` according to the [TPM instructions](https://nixos.wiki/wiki/TPM) and rebuild your environment. To enter a development shell, use `nix develop`. Then you can build the `tpm2-algtest` using the previously mentioned build instructions. Python's virtual environment is set up automatically, therefore, run the tests after the build with:
```sh
$ python run_algtest.py all
```

### Troubleshooting
If the script crashes with this message:
```
Expand Down
61 changes: 61 additions & 0 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

42 changes: 42 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{
description = "TPM Algtest";

inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";
};

outputs = { self, nixpkgs, flake-utils, ... }:
flake-utils.lib.eachDefaultSystem (system:
let
overlays = [];
pkgs = import nixpkgs {
inherit system overlays;
};
pythonPackages = with pkgs.python311Packages; [
venvShellHook

];
in
with pkgs;
{
devShells.default = mkShell {
buildInputs = [
python311
cmake
openssl
tpm2-tools
tpm2-tss
] ++ pythonPackages;

venvDir = ".virt";
postVenvCreation = ''
unset SOURCE_DATE_EPOCH
pip install --upgrade pip
pip install wheel
pip install --requirement requirements.txt
'';
};
}
);
}