I have a nix tarball on s3 so want to use fetchtarball. s3 is not a supported type for a nix flake input, so I’m trying to do something along the following lines [1]. But as the errors in the comments indicate that doesn’t work.
What would be the best way to get an input from a local repo? Maybe I’m thinking about this wrong?
[1]
{
inputs = {
# error: cannot fetch input 'path:./config.nix' because it uses a relative path
config = { type = "path"; path = "./config.nix"; };
# error: flake input attribute 'path' is a path while a string, Boolean, or integer is expected
config = { type = "path"; path = ./config.nix; };
};
outputs = { self, config }:
let nixpkgs = import (builtins.fetchTarball {
url = config.url;
sha256 = config.sha256;})
{ };
in
{
};
}
Can you clarify your usecase just a bit? You mention s3 but then you are attempting to import local paths.
If it’s paths you don’t need to fetch them, you can just referent them directly, or if you are in a flake and referencing an arbitrary file path you would use builtins.path and provide a hash as an argument.
For s3, you are right that nix cannot fetch from s3 directly yet (afaik), but many s3 providers offer htttp endpoints, so your best bet would be to target that.
The second option I proposed should solve that though, as each user has a different registry.
If you have users user_a and user_b, they can each add their own path like so:
[user_a@system:~]$ nix registry add flake:mylocalrepo git+file:///home/user_a/path/to/repo
[user_a@system:~]$ nix registry list
...
user flake:mylocalrepo git+file:///home/user_a/path/to/repo
...
[user_b@system:~]$ nix registry add flake:mylocalrepo git+file:///home/user_b/completely/different/path/to/repo
[user_b@system:~]$ nix registry list
...
user flake:mylocalrepo git+file:///home/user_b/completely/different/path/to/repo
...
Then if you use the registry name as the url, it will alias to their own repos:
inputs.mylocalrepo.url = "flake:mylocalrepo";
When user_a uses the flake, inputs.mylocalrepo.url will point to git+file:///home/user_a/path/to/repo, but when user_b uses the flake, it will point to git+file:///home/user_b/completely/different/path/to/repo.