hi, thanks for the great tool!
i was trying to use it to convert an ostree checkout but it fails because of some files that are named weirdly (such as "[" or "sr@ijekavianlati"). I'm not sure why flatpak's default runtime would contain them, but such is life :)
repro:
$ ostree --repo=foo init $ ostree --repo=flathub remote add flathub https://dl.flathub.org/repo/ $ ostree --repo=flathub pull flathub:runtime/org.kde.Platform/x86_64/5.15-21.08 $ ostree checkout -U --repo=flathub flathub:runtime/org.kde.Platform/x86_64/5.15-21.08 dest/ $ cd dest && nix run "sourcehut:~jack/nix-freeze-tree" dest/ $ nix-instantiate # this fails with various syntax errors
best,
https://git.sr.ht/~jack/nix-freeze-tree/tree/526efaa834de294b823235f6a9bfa344e2fe4461/item/src/NixBuilder.hs#L106-112 is where derivation names are rewritten. I suspect
replaceLeadingDot
will need replacing with a function that does more mangling. Would you like to try and send a patch for this?
i've given it a try this weekend, but unfortunately it's not that simple.
imagine the you have a folder named "hi@hello". the generated code would be
import ./hi@hello { inherit stdend; }
this doesn't work, and as far as i know quoting the path doesn't help. so the only solution i can think is to generate a single default.nix at the root level...
In such situations, I'd try emitting code that calls the
path
builtin: https://nixos.org/manual/nix/stable/expressions/builtins.html#builtins-pathAn enrichment of the built-in path type, based on the attributes present in args. All are optional except path:
- name
The name of the path when added to the store. This can used to reference paths that have nix-illegal characters in their names, like@
.
That part I’ve already fixed. What’s wrong (and cannot be fixed afaik) is
myfolder/default.nix myfolder/some@other/default.nix
As far as I know there’s no way to import such a structure in nix due to limitations on how nix does parsing.
Thanks!
Il giorno 20 ago 2022, alle ore 13:48, ~jack outgoing@sr.ht ha scritto:
In such situations, I'd try emitting code that calls the
path
builtin: https://nixos.org/manual/nix/stable/expressions/builtins.html#builtins-pathAn enrichment of the built-in path type, based on the attributes present in args. All are optional except path:
- name
The name of the path when added to the store. This can used to reference paths that have nix-illegal characters in their names, like@
.-- View on the web: https://todo.sr.ht/~jack/nix-freeze-tree/8#event-201776
I believe that this is fixable, because I ran
nix-freeze-tree
over a little test directory and made the following changes:
- When importing a directory, we need to generate something like
paths = { "bar@baz" = import (./. + "/bar@baz") { inherit stdenv; }; };
- When emitting the
default.nix
for a directory with@
in its name, we need to not have illegal characters in thename
field of themkDerivation
call.
I stand corrected, I did not know about that trick :)
I've attached a patch that seems to work on my machine. It doesn't support symlinks, but I guess that's a separate problem.
Thanks a lot for the advice.
On Sat, Aug 20, 2022, at 14:23, ~jack wrote:
I believe that this is fixable, because I ran
nix-freeze-tree
over a little test directory and made the following changes:
- When importing a directory, we need to generate something like
paths = { "bar@baz" = import (./. + "/bar@baz") { inherit stdenv; }; };
- When emitting the
default.nix
for a directory with@
in its name, we need to not have illegal characters in thename
field of themkDerivation
call.-- View on the web: https://todo.sr.ht/~jack/nix-freeze-tree/8#event-201780
Seems like I cannot attach documents.
On Sat, Aug 20, 2022, at 14:55, Gianluca Stivan wrote:
I stand corrected, I did not know about that trick :)
I've attached a patch that seems to work on my machine. It doesn't support symlinks, but I guess that's a separate problem.
Thanks a lot for the advice.
On Sat, Aug 20, 2022, at 14:23, ~jack wrote:
I believe that this is fixable, because I ran
nix-freeze-tree
over a little test directory and made the following changes:
- When importing a directory, we need to generate something like
paths = { "bar@baz" = import (./. + "/bar@baz") { inherit stdenv; }; };
- When emitting the
default.nix
for a directory with@
in its name, we need to not have illegal characters in thename
field of themkDerivation
call.-- View on the web: https://todo.sr.ht/~jack/nix-freeze-tree/8#event-201780 Attachments:
- git-patch
Finally got around to looking at this. I rewrote your patch to avoid the regex dependency, and released v0.1.1.0.
Thank you for the report and for your patch.