Add direnv with reproducible nix flake dev env

This commit is contained in:
expelledboy 2024-03-23 12:10:02 +02:00
parent 7050ed204b
commit 7c5c0a41d7
No known key found for this signature in database
GPG Key ID: C7349812E65CD854
7 changed files with 143 additions and 0 deletions

1
.env.public Normal file
View File

@ -0,0 +1 @@
GROK_MAGNET_LINK=magnet:?xt=urn:btih:5f96d43576e3d386c9ba65b883210a393b68210e&tr=https%3A%2F%2Facademictorrents.com%2Fannounce.php&tr=udp%3A%2F%2Ftracker.coppersurfer.tk%3A6969&tr=udp%3A%2F%2Ftracker.opentrackr.org%3A1337%2Fannounce

4
.envrc Normal file
View File

@ -0,0 +1,4 @@
dotenv .env.public
dotenv_if_exists
use flake
layout python

3
.gitignore vendored
View File

@ -1,2 +1,5 @@
/.direnv/
/.venv/
checkpoints/*
!checkpoints/README.md
__pycache__/

14
Justfile Normal file
View File

@ -0,0 +1,14 @@
[private]
@default:
just --list --unsorted
# Run the sample prompt against the model
test:
python run.py
# Download the weights for the Grok model
download-weights:
transmission-cli \
--download-dir ./checkpoints \
$GROK_MAGNET_LINK
ln -s ./checkpoints/grok-1/ckpt-0 ./checkpoints/ckpt-0

View File

@ -49,6 +49,18 @@ pip install huggingface_hub[hf_transfer]
huggingface-cli download xai-org/grok-1 --repo-type model --include ckpt-0/* --local-dir checkpoints --local-dir-use-symlinks False
```
# Reproducible Environment
Those familiar with `nix` and `direnv` can use a reproducible development environment.
```sh
cd ~/src/grok-1
direnv allow .
just --list
just download-weights
just test
```
# License
The code and associated Grok-1 weights in this release are licensed under the

61
flake.lock Normal file
View File

@ -0,0 +1,61 @@
{
"nodes": {
"flake-utils": {
"inputs": {
"systems": "systems"
},
"locked": {
"lastModified": 1710146030,
"narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1711124224,
"narHash": "sha256-l0zlN/3CiodvWDtfBOVxeTwYSRz93muVbXWSpaMjXxM=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "56528ee42526794d413d6f244648aaee4a7b56c0",
"type": "github"
},
"original": {
"owner": "nixos",
"ref": "nixos-23.11",
"repo": "nixpkgs",
"type": "github"
}
},
"root": {
"inputs": {
"flake-utils": "flake-utils",
"nixpkgs": "nixpkgs"
}
},
"systems": {
"locked": {
"lastModified": 1681028828,
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
"owner": "nix-systems",
"repo": "default",
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
"type": "github"
},
"original": {
"owner": "nix-systems",
"repo": "default",
"type": "github"
}
}
},
"root": "root",
"version": 7
}

48
flake.nix Normal file
View File

@ -0,0 +1,48 @@
{
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-23.11";
flake-utils.url = "github:numtide/flake-utils";
};
outputs = { self, nixpkgs, flake-utils }: flake-utils.lib.eachDefaultSystem (system:
let
pkgs = import nixpkgs { inherit system; };
python = pkgs.python311;
in
{
devShells.default = pkgs.mkShell {
# build-time
nativeBuildInputs = with pkgs; [
bashInteractive
];
# run-time
buildInputs = (with pkgs; [
transmission
just
]) ++ (with python.pkgs; [
setuptools
wheel
venvShellHook
pylint
]);
# python setup
src = null;
venvDir = ".venv";
postVenv = ''
unset SOURCE_DATE_EPOCH
'';
postShellHook = ''
# python setup
unset SOURCE_DATE_EPOCH
unset LD_PRELOAD
PYTHONPATH=$PWD/$venvDir/${python.sitePackages}:$PYTHONPATH
pip install --require-virtualenv -r requirements.txt | grep -v 'already satisfied'
'';
};
}
);
}