Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make more string values work as installables #7601

Merged
merged 5 commits into from
May 15, 2023

Commits on May 15, 2023

  1. Configuration menu
    Copy the full SHA
    9550c38 View commit details
    Browse the repository at this point in the history
  2. Split mkOutputString in two

    This well help us with some unit testing
    Ericson2314 committed May 15, 2023
    Configuration menu
    Copy the full SHA
    0a9afce View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    8e1a990 View commit details
    Browse the repository at this point in the history
  4. Create EvalState::coerceToDerivedPath

    This gives us some round trips to test.
    
    `EvalState::coerceToDerivedPathUnchecked` is a factored out helper just
    for unit testing.
    Ericson2314 committed May 15, 2023
    Configuration menu
    Copy the full SHA
    5a23b80 View commit details
    Browse the repository at this point in the history
  5. Make more string values work as installables

    As discussed in NixOS#7417, it would be good to make more string values work
    as installables. That is to say, if an installable refers to a value,
    and the value is a string, it used to not work at all, since NixOS#7484, it
    works somewhat, and this PR make it work some more.
    
    The new cases that are added for `BuiltPath` contexts:
    
    - Fixed input- or content-addressed derivation:
    
      ```
      nix-repl> hello.out.outPath
      "/nix/store/jppfl2bp1zhx8sgs2mgifmsx6dv16mv2-hello-2.12"
    
      nix-repl> :p builtins.getContext hello.out.outPath
      { "/nix/store/c7jrxqjhdda93lhbkanqfs07x2bzazbm-hello-2.12.drv" = { outputs = [ "out" ]; }; }
    
      The string matches the specified single output of that derivation, so
      it should also be valid.
    
    - Floating content-addressed derivation:
    
      ```
      nix-repl> (hello.overrideAttrs (_: { __contentAddressed = true; })).out.outPath
      "/1a08j26xqc0zm8agps8anxpjji410yvsx4pcgyn4bfan1ddkx2g0"
    
      nix-repl> :p builtins.getContext (hello.overrideAttrs (_: { __contentAddressed = true; })).out.outPath
      { "/nix/store/qc645pyf9wl37c6qvqzaqkwsm1gp48al-hello-2.12.drv" = { outputs = [ "out" ]; }; }
      ```
    
      The string is not a path but a placeholder, however it also matches
      the context, and because it is a CA derivation we have no better
      option. This should also be valid.
    
    We may also want to think about richer attrset based values (also
    discussed in that issue and NixOS#6507), but this change "completes" our
    string-based building blocks, from which the others can be desugared
    into or at least described/document/taught in terms of.
    
    Progress towards NixOS#7417
    
    Co-authored-by: Robert Hensing <roberth@users.noreply.github.com>
    Ericson2314 and roberth committed May 15, 2023
    Configuration menu
    Copy the full SHA
    d2162e7 View commit details
    Browse the repository at this point in the history