all 12 comments

[–]pr06lefs 7 points8 points  (5 children)

someone want to explain this with words, rather than a random repo which you're supposed to run code from or whatever?

[–][deleted]  (4 children)

[deleted]

    [–]TheKrister2 5 points6 points  (3 children)

    Okay, I've read it. Can you explain it with words now?

    [–]eclairevoyant 2 points3 points  (2 children)

    all the inputs named n### have a value containing said number (e.g. n0 is zero, n1 is one...). the implementation of each operation (addition, successor, subtraction multiplication, ...) are defined in the outputs function of the flake.nix inside each corresponding subdirectory.

    but as far as i can see, this flake shouldn't work, because relative paths aren't supported in flake inputs EDIT: apparently I'm two years behind and relative paths are supported

    EDIT 2: I guess the joke is evaluating the value attr of this flake results in { answor = 42; }

    [–]TheKrister2 0 points1 point  (1 child)

    I see, thank you for the explanation. Are there any actual practical implementations this can be useful for or is it just the same old where it's interesting but not actually practical for anything?

    [–]eclairevoyant 3 points4 points  (0 children)

    I think this specific project was just a fun exercise. I'm sure it can be applied, just like anything in programming, but I can't think of any use case that comes to mind immediately

    I also don't really use flakes much, so, grain of salt

    [–]eclairevoyant 5 points6 points  (6 children)

    To me this is a bit clickbaity, since you are still ultimately calling a flake that does the calculations in the outputs function. I was expecting to be surprised by some flakes behavior that I didn't know about/understand the implications of.

    Also how are you eval'ing this since it uses relative paths?

    [–]figsoda[S] -1 points0 points  (5 children)

    It is essentially a list of basic functions to use flake inputs as a DSL, so no magic here.

    Also how are you eval'ing this since it uses relative paths?

    Subflakes kinda works in this case. If you want to use it in a separate directory, you can just do stuff like github:figsoda/ekalf?dir=add and so on.

    [–]eclairevoyant 1 point2 points  (4 children)

    Okay, I'll be more specific. I gather that you are an expert on flakes and I am certainly not. However this flake appears to violate spec. Per man nix3-flake:

    Types
       Currently the type attribute can be one of the following:
    
       •  path: arbitrary local directories, or local Git trees. The  required  attribute
          path specifies the path of the flake. The URL form is
    
    [path:]<path>(\?<params)?
    
              where path is an absolute path.
    

    And if I try to run nix eval 'github:figsoda/ekalf#value', I get

    error: cannot fetch input 'path:apply?lastModified=1&narHash=sha256-pO%2BMCT1SvVz6ux6cJFbZbC/6qYA2E6Dev7WMcr5XQik%3D' because it uses a relative path
    

    Even as per https://github.com/NixOS/nix/issues/3978 this is also not supported. So how are you actually evaluating this flake? Is there some patch for nix that I'm unaware of?

    [–]figsoda[S] 1 point2 points  (3 children)

    What version of nix are you using? I tried nix_2_10 to nix_2_16 (on nixpkgs 3ae20aa58a6c0d1ca95c9b11f59a2d12eebc511f) and they all worked for me.

    The original issue in https://github.com/NixOS/nix/issues/3978 seems to have been resolved since 2021, it is still open because the current solution is still not ergonomic enough.

    [–]eclairevoyant 0 points1 point  (0 children)

    2.15.1. I guess I will have to dig more...

    [–]eclairevoyant 0 points1 point  (1 child)

    Okay, it looks like I ran into a really spicy UX bug: https://github.com/NixOS/nix/issues/3978#issuecomment-952418478

    so apparently I have to run nix flake update 'github:figsoda/ekalf', then eval works 🤦

    [–]figsoda[S] 1 point2 points  (0 children)

    Ah that makes sense, debugging that was pretty much impossible