How to install packages in CircleCI from flake

I have a monorepo that would depends on some external dependencies. It works fine locally with flake, using devShell, but for installing packages over CircleCI, how can I do that, if I am not using a NixOS docker image, but a machine image, which would be Ubuntu?

This is my simple flake, nothing fancy

{
  description = "closesource repo flake";

  inputs = {
    nixpkgs = { url = "github:nixos/nixpkgs/nixos-unstable"; };

    flake-utils = {
      url = "github:numtide/flake-utils";
      inputs = { nixpkgs.follows = "nixpkgs"; };
    };
  };

  outputs = { self, nixpkgs, flake-utils, ... }:
      flake-utils.lib.eachDefaultSystem (system:
      let
        pkgs = (import nixpkgs {
          inherit system;
          overlays = [];
        });
      in {
        devShell = (({ pkgs, ... }:
          pkgs.mkShell {
            buildInputs = with pkgs; [ terraform ];
          }) { inherit pkgs; });
      });
}

I am using this orbs for installing Nix in CircleCI: CircleCI Developer Hub - eld/nix

My circleCI config:

# Conditional job example
# https://github.com/winston0410/closesource/blob/bd858c6de8ed72ea01ca3df0df6d48563bfee0d4/.circleci/config.yml
version: 2.1

orbs:
  nx: nrwl/nx@1.4.0
  node: circleci/node@5.0.2
  nix: eld/nix@1.0.0

jobs:
  test:
    machine: true
    resource_class: medium
    steps:
      - checkout
      - node/install:
          node-version: "16.15.1"
      - node/install-packages
      - nix/install
      # Install packages from flake and try to do something great!
workflows:
  default:
    jobs:
      - test

Hm I have a solution, I can use nix profile install $(cat deps.txt) locally and in CircleCI to achieve what I want, but I would prefer using flake for this

I’d also like to know if there’s an elegant solution here.
I’ve been sprinkling nix develop commands all over the place like so:

      - run:
          name: pre-commit
          command: |
            nix develop --command pre-commit run --all-files

Which starts geting pretty unwieldy when you have multiple of them

            PYTHON=$(nix develop --command which python)
            nix develop --command poetry env use $PYTHON

I don’t think installing those packages into the env is exactly the right thing because now you’re not testing in the flake-defined environment, but instead some unholy union of circlci’s image and the flake-defined environment.

I wonder if it’s possible to write an orb that works pretty much just like run but evaluates in the devshell.