Combined Manager provides a new structure for personal NixOS configurations.
Note: Requires patching nix
to solve this issue. See more in the Nix Patches section.
Combined Manager's main feature is to break separation. If you want, you should be able to keep everything in a single module.
Most NixOS configuration structures are designed to separate related things into multiple files.
Most prominent separations:
- Dividing modules into system and home categories. These categories are then further maintained in separate files.
- All flake inputs must be in the same file in flake.nix.
Combined Manager breaks this pattern by allowing modules to add inputs, overlays and Home Manager and Nixpkgs options as if they are simple options.
{
lib,
pkgs,
config,
osConfig,
hmConfig,
inputs,
combinedManager, # Path to the root of combinedManager
configs, # The results of all NixOS/CombinedManager configurations
...
}: {
imports = [ ];
options = { };
config = {
# Adding inputs.
inputs = { name.url = "..."; };
# Importing system modules.
osModules = [ ];
# Importing Home Manager modules.
hmModules = [ ];
# Setting overlays.
os.nixpkgs.overlays = [ ];
# Using `os` to set Nixpkgs options.
os = { };
# Set Home Manager username (Required to be set in at least one of the modules).
hmUsername = "myname";
# Using `hm` to set Home Manager options.
hm = { };
};
}
- Home Manager required and only a single user with Home Manager.
- Nix must be patched.
- Only for NixOS.
As of the time of writing, stable enough.
While I'll use it for my configuraiton, I have not tested everything and cannot guarantee stability.
There might be breaking changes.
- Patch Nix with the patches in the
nix-patches
directory. See more in the Nix Patches section. - Generate a template with
nix flake init -t github:FlafyDev/combined-manager#example
. - Run
nix flake metadata
. You might need to run it twice if there is noflake.lock
file(A message will appear).
To bulid a VM: nixos-rebuild build-vm --flake .#default
.
To swtich: sudo nixos-rebuild switch --flake .#default
.
Combined Manager requires applying certain patches to Nix in order to work.
Alternatively, you can use Nix Super.
This patch enables inputs(and the entire flake) to be evaluable. Solves issue #3966.
Combined Manager requires this since it evaluates inputs
from all the modules.
See line 9 of the example flake.
You can add the following to your config:
nix = {
enable = true;
package = let
combinedManager = pkgs.fetchFromGitHub {
owner = "flafydev";
repo = "combined-manager";
rev = "9474a2432b47c0e6fa0435eb612a32e28cbd99ea";
sha256 = "";
};
in
pkgs.nix.overrideAttrs (old: {
patches =
(old.patches or [])
++ (
map
(file: "${combinedManager}/nix-patches/${file}")
(lib.attrNames (lib.filterAttrs (_: type: type == "regular") (builtins.readDir "${combinedManager}/nix-patches")))
);
});
};
Once you start using Combined Manager, you'll be able to source the patches directly from your combinedManager
module arg.
Each Combined Manager module has an inputs
option. That option will eventually be merged and set as the inputs of the NixOS configuration.