Manage a project with an existing flake with flox

I am trying to understand what makes sense and what doesn’t. Let’s say I would like to publish the hasktorch project under my own flox catalog and use flox build as I would normally do.

hasktorch is a already using a flake file so flox init won’t work. Is there a way to still use flox build, flox publish for this kind of project? Does it even make sense for you?

Rest assured that flox is 100% nix-compatible and supports plain flakes. However, not all flakes will work on darwin, and it seems that’s one of them:

$ flox build github:hasktorch/hasktorch
error: flake 'github:hasktorch/hasktorch' does not provide attribute 'packages.aarch64-darwin.default' or 'defaultPackage.aarch64-darwin'

… whereas that command does work on Linux. In fact, when you run that command on Linux you’ll see they’ve configured the flake with several extra settings/features:

[brantley@ip-10-0-1-243«core»:~]$ nix build github:hasktorch/hasktorch
do you want to allow configuration setting 'allow-import-from-derivation' to be set to 'true' (y/N)? 
do you want to permanently mark this value as untrusted (y/N)? 
warning: ignoring untrusted flake configuration setting 'allow-import-from-derivation'
do you want to allow configuration setting 'extra-substituters' to be set to 'https://cache.iog.io https://hasktorch.cachix.org' (y/N)? 
do you want to permanently mark this value as untrusted (y/N)? 
warning: ignoring untrusted flake configuration setting 'extra-substituters'
do you want to allow configuration setting 'extra-trusted-public-keys' to be set to 'hydra.iohk.io:f/Ea+s+dFdN+3Y/G+FDgSq+a5NEWhJGzdjvKNGv0/EQ= hasktorch.cachix.org-1:wLjNS6HuFVpmzbmv01lxwjdCOtWRD8pQVR3Zr/wVoQc=' (y/N)? 
do you want to permanently mark this value as untrusted (y/N)? 
warning: ignoring untrusted flake configuration setting 'extra-trusted-public-keys'
do you want to allow configuration setting 'substituters' to be set to 'https://cache.nixos.org' (y/N)? 
do you want to permanently mark this value as untrusted (y/N)? 
warning: ignoring untrusted flake configuration setting 'substituters'
...

@tomberek will no doubt have further insights but my suspicion is that this project hasn’t been ported to darwin yet, but once it is working (or if you can work on Linux) then we can help you build and install the package to an environment or show you how to incorporate a flake as an extra input in your top level flake.nix file.

Right I forgot that I could create a project using another flake as an input, like we did here.

I will return to this when I have some time. I inferred from this entry on the hasktorch README, that building would work in whatever environment using nix. Maybe I will leave an issue on the hasktorch site.

2 Likes