Nix flake: build stuff in local repository, fixed commit

I’d like to build something from a previous commit in a local git repository, so I tried:

$ nix build "git://.?ref=master&rev=569f776585291bd3a06de95ac8c925131258d7e0#sapera_xtium"
fatal: aucun chemin spécifié ; référez-vous à 'git help pull' pour une syntaxe d'URL valide
error: program 'git' failed with exit code 128
(use '--show-trace' to show detailed location information)

and many other variations (including files/git+files…), but I can’t make it work.

Ok found:

 nix build ".?rev=569f776585291bd3a06de95ac8c925131258d7e0#bla"

the nix flake --help page is quite complete on the syntax

1 Like

I’m fairly certain this would work too:

git:.?ref=master&rev=569f776585291bd3a06de95ac8c925131258d7e0#sapera_xtium

And perhaps even (but probably not because this variant won’t have git access):

path:.?ref=master&rev=569f776585291bd3a06de95ac8c925131258d7e0#sapera_xtium

flake paths are not URIs, they don’t follow that schema, though are clearly inspired by it.

1 Like

I can’t resist being a pedant here. Technically, they are URIs, but they are not URLs. Most people use the terms interchangeably, though.

1 Like

Hah, I’m aware of the difference, but every time I try to use the terms correctly I get confused about whether the // is a mandatory part of them.

Clearly it’s not, and that doesn’t distinguish URI/L:

URI = scheme ":" ["//" authority] path ["?" query] ["#" fragment]

Thanks for the pedantry, maybe this is the time I’ll remember :wink:

As I understand it, URIs and URLs actually have identical parsing, but a URL has a standard for how to access the resource, and URIs do not.

Since only nix understands how to find the resources, and they aren’t accessed by the means that would be used for URLs, I think it’s correct to call them URIs but not URLs.

It’s also possible that you can technically only call them URI-like or URL-like, if the definition of URI requires conforming to standard structure and interpretation of existing schemes, which nix flake “URLs” do not.

For what it’s worth, the nix manual only describes them as “a URL-like syntax”, which is the most defensible approach.

They are URLs, as they describe where to find something, and do not “name” something.

By most definitions out there, any URL is an URI as well, as the location is the name of the ressource at the same time.

Lets take https://www.klett-cotta.de/buch/Gegenwartsliteratur/Agency/117331 for example, this URL is the store page of the German publisher of William Gibsons “Agency”, at the same time it uniquely identifies the page that sells that book.

urn:isbn:978-3-608-50474-3 though identifies the very same book, without telling were to find anything about it. URNs never carry a location data.

Both, URNs and URLs are URIs.

Seeing URI as the “base class” and URL beeing an “child class” inheritting some stuff is the most common definition I have seen so far, and also was what was taught at my UNI.

2 Likes