Convert Nix Derivation to Flake

So, I have a set of files I’m using for building a project, and I want to convert them to a flake format. How hard would that be? Non-Flake Derivation · GitHub

This is a good starting point. You’d replace the { hello = ...; default = ...; } attrset there with something like:

rec {
  drod = pkgs.callPackage ./drod.nix { inherit metakit; };
  default = drod; # if you want `nix build` to automatically build drod
  metakit = pkgs.callPackage ./metakit.nix { };
}

and you’re golden. This would replace your default.nix.

Nit: “converting a derivation to a flake” is not quite accurate. Derivations are still there, they’re essential to Nix. The flake is more of a “container” which can contain many derivations.

1 Like

@justinas You seem to have gotten things backwards here: drod is the main thing that I want to build. metakit is library that drod relies on.

My bad, I fixed the code snippet in the previous post! The general approach remains the same, though.