Skip to content

Commit

Permalink
More release organizing
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasjm committed Nov 24, 2020
1 parent bcf2a4d commit 5723171
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 8 deletions.
25 changes: 18 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,28 @@

## Usage

First, create a Julia environment containing the packages you want.
First, `cd` to a folder and create a Julia `Project.toml` and `Manifest.toml` containing the packages you want.

```bash
pkg> activate myproject
mkdir depot
cd depot
julia
# Press "]" to enter package mode
pkg> activate .
pkg> add SomePackage
pkg> add SomeOtherPackage
pkg> [Ctrl+D to exit]
```

Now, the `myproject` folder should contain `Manifest.toml` and `Project.toml`. Invoke the `julia-to-nix-depot` script:
Now use `julia2nix` to generate the Nix files.

```python
> julia-to-nix-depot /path/to/myproject > myproject.nix
```
```bash
cd ~/tools
git clone git@github.com:thomasjm/julia2nix.git

This will generate a Nix file called `myproject.nix`, which will contain a derivation for building a depot with the desired packages.
# Make sure you have a NIX_PATH set
export NIX_PATH=nixpkgs=...

cd /path/to/depot
~/tools/julia2nix/julia2nix
```
3 changes: 2 additions & 1 deletion julia-to-nix-depot.py → gather_packages.py
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@
f'src = {src};'])
+ "\n}")

print("""{fetchgit}: {
print("""# This file is autogenerated, do not edit by hand!
{fetchgit}: {
registryUrl = "TODO";
registryRev = "TODO";
registrySha256 = "TODO";
Expand Down
19 changes: 19 additions & 0 deletions julia2nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#! /usr/bin/env nix-shell
#! nix-shell -i python3 -p "python3.withPackages (ps: [ps.toml ps.GitPython])" nix-prefetch-git

import os
from pathlib import Path
import shutil
import subprocess

script_dir = Path(os.path.dirname(os.path.realpath(__file__)))

output_dir = Path(".")
shutil.copy(script_dir.joinpath("templates").joinpath("common.nix"), output_dir)
shutil.copy(script_dir.joinpath("templates").joinpath("default.nix"), output_dir)

environment_dir = Path(".")
repo_url = "https://github.com/JuliaRegistries/General.git"
packages_nix = subprocess.check_output(["python", script_dir.joinpath("gather_packages.py"), environment_dir, repo_url])
with open(output_dir.joinpath("packages.nix"), "w") as f:
f.write(packages_nix)
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit 5723171

Please sign in to comment.