Is it possible to use a Flake if configuration.nix isn't a Flake itself?

Hey there,

I’m attempting to write a custom flake for myself for Neovim. I already have Neovim configured directly within configuration.nix (using programs.neovim), but ideally I would like to be able to use the same configuration on non-NixOS machines that I’m using on NixOS. I currently have a supremely simple Flake for Neovim that is functional (I can nix run with no problem):

  description = "A simple Neovim configuration";

  inputs = {
    nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable";
    flake-utils.url = "github:numtide/flake-utils";

  outputs = { self, nixpkgs, flake-utils }:
      system = "x86_64-linux";
      pkgs = import nixpkgs { system = system; config.allowUnfree = true; };
      neovimConfig = pkgs.neovimUtils.makeNeovimConfig {};
    with pkgs; rec {
      packages.${system}  = rec {
        jkvim = wrapNeovimUnstable neovim-unwrapped neovimConfig;
        default = jkvim;
      apps.${system} = rec {
        jkvim = flake-utils.lib.mkApp {
          drv = packages.${system}.jkvim;
          name = "jkvim";
          exePath = "/bin/nvim";
        default = jkvim;
      devShell = mkShell {
        buildInputs = [

What I would ideally like to do is replace my NixOS Neovim configuration with this very simple Flake. Currently my configuration.nix looks like this:

[root@jkaye-nixos:/etc/nixos]# cat configuration.nix 
{ config, pkgs, ... }:

  imports = [
    ./nvim.nix # this is where I'm loading my programs.neovim with all of its config, need to replace?

  system.stateVersion = "24.05";
  nix.settings.experimental-features = [ "nix-command" "flakes" ];

  # You should only edit the lines below if you know what you are doing.

  boot.loader.grub.enable = true;
  boot.loader.grub.device = "/dev/sda";

  environment.systemPackages = with pkgs; [
# A bunch more stuff that's not relevant

Is there a simple way to do this? I wouldn’t necessarily mind moving my configuration.nix to be a Flake itself, but I was hoping to do this a step at a time.


You can use builtins.getFlake to use a flake from a non-flake context


Thanks, this worked!