How to import a nixpkgs profile using NixOS configuration flake


I’m switching a nixos configuration.nix file to flakes to use deploy-rs, but I don’t know how to fix the headless.nix import from nixpkgs :confused: I’m looking for some hints. :slight_smile:

 imports =
1 Like

I guess you are looking for modulesPath: NixOS Search

1 Like

You’d use it like this: tlaternet-server/flake.nix at master - tlaternet-server - Gitea: Git with a cup of tea

1 Like

thanks! It’s working doing this way, I have to admit I wouldn’t have figured easily alone how to use modulesPath in a flake :frowning:

it’s a bit unfortunate I have to spread the config between configuration.nix and flake.nix

You don’t have to, actually. You can also just add modulesPath to your configuration.nix's args:

{pkgs, lib, config, options, modulesPath, ...}:

    imports = [ (modulesPath + "/profiles/headless.nix") ];

And then import and add it to the flake’s modules like any other module.

Then maybe read through _module.args again and see if it’s any easier to grok. Tip: it defines what args your modules are called with, and its help text describes the defaults.

I frankly don’t recall why I put this config in my flake, that repo is due a refactor :slight_smile:

1 Like