I'm starting to have a lot of flake inputs in my flake.nix file, and it's starting to get really cluttered. I'm wondering if there's a way to separate my inputs into multiple files so it looks cleaner. I've tried to look it up but couldn't really find anything abt it

Edit: Well as it turns out it's not something possible yet, apparently the flake.nix file isn't parsed like regular nix files and doesn't support stuff like import

you are viewing a single comment's thread
view the rest of the comments
[–] [S] 1 point 10 months ago (2 children)

o thanks, i'll take a closer look but for what i've seen so far it kinda looks complex I also flake-part mentioned in some of the commits,i remember seeing it a few times and apparently it can modularize flakes or sum like that, can it modularize inputs too outta curiosity

  • source
  • parent
  • hideshow 2 child comments
  • [–] 2 points 10 months ago (1 child)

    It's complex, because it does a lot of things, and it evolved over the past few years. The basics are very, very simple:

    #+begin_src nix :tangle out/flake.nix :noweb no-export :noweb-prefix no :mkdirp t
    {
      inputs = {
        <<flake-inputs>>
      };
    
      outputs = { self, nixpkgs, ... }@inputs: {
        <<flake-outputs>>
      };
    }
    #+end_src
    

    In some other file, you can then do:

    #+begin_src nix :noweb-ref flake-inputs
    nixpkgs.url = "github:NixOS/nixpkgs/nixos-25.11";
    #+end_src
    

    And voila, you now have:

    {
      inputs = {
        nixpkgs.url = "github:NixOS/nixpkgs/nixos-25.11";
      };
    
      // ...rest of the flake
    }
    

    How you organize your org documents, is entirely up to you. The trick is that this lets you split it up as you see fit, and you are no longer restricted by what the language or any framework built on top of it can provide.

  • source
  • parent
  • hideshow 1 child comment