$ nix-shell -p git nh
$ git clone https://github.com/Aadniz/nix-config ~/.dots
When adding a new machine, you need to write a new host.
- Make a new directory in the hosts folder
- Copy the content of
/etc/nixos/
, into the newly created folder - Edit the
configuration.nix
file, addingsettings.nix
as an import as such:
imports =
[ # Include the results of the hardware scan.
./settings.nix
./hardware-configuration.nix
];
- Create a
settings.nix
file with the required fields, here is a minimal setup:
{ config, lib, pkgs, inputs, ... }:
{
imports = [
../../options
] ++ [ # Extended settings config (relative folder files ./file.nix)
] ++ [ # Include the modules you want to have on this host (from the module folder ../../modules/file.nix)
../../common
../../modules/home-manager.nix
../../modules/home.nix
] ++ [ # Include all apps you want to use on this host (from the apps in modules folder ../../modules/apps/file.nix)
];
# Don't need any additional config for the apps, just throw them in here
environment.systemPackages = with pkgs; [
discord anki
];
username = "user";
nickname = "User";
hostname = "laptop";
flakeDir = "/home/${config.username}/.dots";
wms = ["sway"];
}
- Choose a hostname, and add a new machine in the flake.nix file as follows:
outputs = { self, nixpkgs, home-manager, ... }@inputs: {
# Machine1 with hostname "sushi" for example
nixosConfigurations.sushi = nixpkgs.lib.nixosSystem {
specialArgs = { inherit inputs; };
modules = [
./hosts/sushi/configuration.nix
home-manager.nixosModules.home-manager
];
};
# Machine2 with hostname "taco" for example
nixosConfigurations.taco = nixpkgs.lib.nixosSystem {
specialArgs = { inherit inputs; };
modules = [
./hosts/taco/configuration.nix
home-manager.nixosModules.home-manager
];
};
};
-
Enter shell
nix-shell -p git nh
, and do the following command to test it:FLAKE=~/.dots nh os test --hostname <HOSTNAME> -- --extra-experimental-features nix-command --extra-experimental-features flakes
-
If everything worked, do
FLAKE=~/.dots nh os switch
, then reboot.
When adding an existing machine, all you need to do is to overwrite the hardware-configuration.nix
found in /etc/nixos
with the configuration in the hosts folder.
Then nix-shell -p git nh
, entering a shell with git and nh available. Then do the following command to confirm it's working:
FLAKE=~/.dots nh os test --hostname <HOSTNAME> -- --extra-experimental-features nix-command --extra-experimental-features flakes
If it works, then you can apply it with switch
:
FLAKE=~/.dots nh os switch --hostname <HOSTNAME> -- --extra-experimental-features nix-command --extra-experimental-features flakes
Then reboot.
The setup may not be the same, and so it might be needed to tune the configs such as the sway/hardware.nix
NixOS won't install doom emacs for you, so you have to go to their install instructions for that to be installed: https://github.com/doomemacs/doomemacs?tab=readme-ov-file#install
- You need to clone private status command repo to Documents
- Make the
~/.unison/org-files.prf
configuration - Need to make sure the appropriate sops are set
- Set up borg backup (borg.nix)
The configuration is not broken because these things are not added. It's structured to accept both.