Using external Nix packages in repl.it

Hey,

total nix newbie here, so please bear with me…

I’d like to use this external package collection from within my repl.it. Unfortunately, I have no clue what to write into the replit.nix file in order to use it.

I understand that I don’t want the packages from the upstream channels (unstable or 2021.11).

I know that this is no repl.it support forum in the first place. However, I have the feeling that this is more a Nix than a repl.it question.

Any help highly appreciated!

Seems repl.it support default.nix, so something like this might work? Haven’t used repl.it with Nix so not entirely sure.

{pkgs ? import <nixpkgs> {}}: let
  zigpkgs =
    (import (fetchTarball {
      url = "https://github.com/joachimschmidt557/zigpkgs/archive/trunk.tar.gz";
    }))
    .packages;
in
  pkgs.mkShell {
    name = "replit-zig";
    buildInputs = [pkgs.alejandra zigpkgs.x86_64-linux.zls];
  }

Where pkgs is referring to nixpkgs and zigpkgs is referring to your Zig source, so you can mix and match from both sources. Threw pkgs.alejandra in there just as an example, it’s not needed for anything.

3 Likes

Slightly modified

# replit.nix file
{pkgs ? import <nixpkgs> {}}: let
  zigpkgs =
    (import (fetchTarball {
      url = "https://github.com/joachimschmidt557/zigpkgs/archive/trunk.tar.gz";
    }))
    .packages;
in {
    name = "replit-zig";
    deps = [zigpkgs.x86_64-linux.zls];
  }

seems to work but one might get “Disk quota exceeded” there.

@voigt maybe one can self-host repl.it ?

1 Like

First of all, thanks for the support. The proposed script worked, but I also hit the “Disk quota exceeded” error.

According to repli.it docs:

Due to some limitations in our platform, we are unable to provide more than 1 GB of storage in any repl. We are actively working on improvements that will allow us to give users arbitrarily large filesystems to work with.
– source: Replit - Understanding Repl Resource Utilization

So seems like there is no way around that.