Git Product home page Git Product logo

Comments (5)

Gabriella439 avatar Gabriella439 commented on June 9, 2024

Yeah, I have ran into this issue myself. One way to address this problem is to interpolate the relative path to the Dhall expression, like this:

let
  pkgs = import <nixpkgs> { };
  inherit (pkgs) dhallToNix;

in
  { vbox = (dhallToNix "{ headless = True, vcpu = +2 } : ${../../../ops/VirtualBox.dhall}");
  }

That will then ensure that Nix adds ../../../ops/VirtualBox.dhall to the /nix/store as some /nix/store/....-VirtualBox.dhall path and Nix will then interpolate path that into the string giving you the following final Dhall expression

{ headless = True, vcpu = +2 } : /nix/store/...-VirtualBox.dhall

The other benefit of doing this is that Nix will then correctly detect that the VirtualBox.dhall file is a build-time dependency of the Dhall expression, ensuring that the import will be present on any machine that evaluates that Dhall expression.

from dhall-nix.

barakber avatar barakber commented on June 9, 2024

Thanks. Our problem is that the ../../ops/VirtualBox.dhall file also uses many other type-files in other places in the directory tree. Will this trick work for an entire directory tree?

from dhall-nix.

Gabriella439 avatar Gabriella439 commented on June 9, 2024

Oh, I see the issue. So if all of the Dhall expressions are located within a single subdirectory (such as ../../../ops) and they all reference each other by relative paths then you can do this instead:

let
  pkgs = import <nixpkgs> { };
  inherit (pkgs) dhallToNix;

in
  { vbox = (dhallToNix "{ headless = True, vcpu = +2 } : ${../../../ops}/VirtualBox.dhall");
  }

Then the entire ../../../ops directory will be copied to the /nix/store and the VirtualBox.dhall dependency will be replaced with an absolute path within that directory. Every transitive dependency of VirtualBox.dhall should be correctly referenced via relative paths.

from dhall-nix.

barakber avatar barakber commented on June 9, 2024

Thanks! works great!

from dhall-nix.

Gabriella439 avatar Gabriella439 commented on June 9, 2024

You're welcome! :)

from dhall-nix.

Related Issues (10)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.