You may need to enable flakes since they are still experimental
export NIX_CONFIG="experimental-features = nix-command flakes"
Clone the configuration into /etc/nixos
.
nixos-install --flake '/mnt/etc/nixos#<config>'
After the installation finished, set a password for the user:
passwd <user>
Update all flake inputs:
nix flake update
Update a specific flake input:
nix flake lock --update-input <input>
Rebuild the system:
sudo nixos-rebuild switch
# Or if nomos-rebuild custom package is already installed:
sudo nomos-rebuild switch
Contains the configuration for each host. The hostname of the machine must match the name of the folder.
It must contain these files: [default.nix
hardware-configuration.nix
hardware-partitions.nix
] that are imported by the flake.nix. See here
The main configuration file for the host. Use as a normal nixos configuration file. You can also use the generated options to enable some of the generated modules.
You should not do any complex logic over here, instead use the modules/generated/nixos
folder and create module for that and just enable it over here. (Unless it is specific to the host, such as windows dual boot mount)
Contains the hardware configuration for the host. Usually generated by the nixos-generate-config
command.
Contains the partition configuration for the host. Usually generated by the nixos-generate-config
command.
This is the most complex part about this config.
Modules is split into 3 sub folders nixos
, home-manager
and generated
.
Contains the nixos modules. And default.nix
which specifies which modules to import (into each nixos host (configuration)).
Contains the home-manager modules. And default.nix
which specifies which modules to import (into each home-manager host (configuration)).
The default.nix
will also be included when using home-manager as nixos module. This is done automatically if you use the lib'.mkHomeNixOsUser function.
Contains the MODULE GENERATOR, the heart of this config. This is where all the magic happens. That's why it has it's own readme.
Contains helper functions:
mkOverlay
:
Creates a nixpkgs overlay from just the name of the input,
You must provide the name
of the input and the flake.nix must have input named nixpkgs-${name}
.
mkHost
:
Generates nixosConfigurations.${hostname} config, this will:
- Import the files as specified in the
hosts/${hostname}
folder. - Import the default modules
modules/nixos/default.nix
. - Import the default home-manager modules
modules/home-manager/default.nix
. - Apply overlays
overlays/
to the nixpkgs.
mkHomeNixOsUser
:
Takes 2 arguments:
- username
- additional modules Generates a home-manager user when home-manager is used as a nixos module. This will:
- Import the default home-manager modules
modules/home-manager/default.nix
. - Import the home configuration as specified in
home/
. - Import the default home-manager options based on nixos config
home/nixosDefaults.nix
.
Usage example:
home-manager.users = self.lib'.internal.mkHomeNixOsUser "martin" [];
mkHomeModules
:
- Import the default home-manager modules
modules/home-manager/default.nix
. - Import the home configuration as specified in
home/
.
Contains the home-manager configuration.
Included every single time for every user (stand alone or as nixos module).
Included every single time (stand alone or as nixos module).
Included only when home-manager is used as a nixos module.
Included only if the hostname matches. (stand alone or as nixos module).
Included only when home-manager is used as a nixos module. This file includes default values that should be used if used as nixos module. The default values are chosen based on the nixosConfig that the home-manager is being used in.
Contains nixpkgs overlays. Mainly generated by the mkOverlay
lib function.