News for hackers. Stuff that matters.
Re:Single-file scripts that download their dependencies by mananaysiempre on Sunday January 15, 2023 @09:07AM (#34389479)
Evaluation can be slow, which is why flakes-based tools usually cache the evaluation results. (There aren’t going to be duplicate downloads in any case.)

There’s no shebang support in nix3 (the new, flakes-native CLI with a single “nix” command). The closest you can get is probably “nix run”—can’t be distilled down to a single file, but can fetch and cache even online Git repos (use “nix registry pin” to freeze the commit hash).

Re:Single-file scripts that download their dependencies by ewuhic on Sunday January 15, 2023 @09:43AM (#34389738)
What would be an example filetree structure for the nix run to match #!-interpreter via flake? Cannot all the definitions fit into a single "flake.nix"? Also, would it be possible to use some other name than "flake.nix"?
Re:Single-file scripts that download their dependencies by mananaysiempre on Sunday January 15, 2023 @10:35AM (#34390122)
As far as I know, flake.nix is hardcoded, so you’re going to use a separate directory for every script anyway. And then there’s flake.lock, which you have to go out of your way to avoid creating, and you’ll be spammed with obnoxious warnings if you still do.

So would you want to fit everything into just flake.nix? I don’t see why. Could you? Yeah, sure: http://ix.io/4ll5 for a single shell script, for example.

Re:Single-file scripts that download their dependencies by one-punch on Sunday January 15, 2023 @01:30PM (#34391700)
> There’s no shebang support in nix3.

This is a pain point, but there appears to be discussions and a PR for Shebang support with flakes: https://github.com/NixOS/nix/pull/5189