This repository contains configurations for various programs & Nix(OS).
This Nix(OS) section of this repository is located in the nixos directory.
nix-channel --add https://github.com/nix-community/home-manager/archive/master.tar.gz home-manager
nix-channel --update
nix-shell '<home-manager>' -A installdocker compose run --remove-orphans check- The
nixos/hostscontains theconfiguration.nixfiles for each of my computers that runs NixOS. - Each host is assigned a separate folder.
- The configuration that
flake.nixuses is decided by the hostname of the system. - The creation of users is managed by the
configuration.nixbut all the user related configuration is handled byhome-manager. The common link between the created user and configured user is just the username. This means that users with the same name on all systems will be configured the same way ifhome-manageris used configure the user.
- The
nixos/usersdirectory is thehome-managersection of the configuration. - Each username has a
username.nixfile that contains user levelhome-managermanaged configurations. - The
nixos/users/shareddirectory contains modules that are shared across multiple users.
- This directory contains a
secrets.jsonfile (encrypted using git crypt). which should contain a JSON object. - This JSON object is made available to both the home-manager user configurations in
nixos/users& system configurations innixos/hostsvia thesecretsfunction parameter.
This is the entrypoint for both the home-manager & NixOS.
After making any changes in the nixos/hosts directory, you can install the changes to the current host configuration into NixOS using the following command on the host.
# TO BE RUN FROM THE ROOT OF THIS CLONED REPSITORY
sudo nixos-rebuild switch --flake "./nixos"
# OR
sudo nixos-rebuild switch --flake "./nixos#<NAME OF THE HOST HERE>"Since we are using a nixos/flake.lock file, we need to update the flake using the command below and rebuild the system as normal.
# TO BE RUN FROM THE ROOT OF THIS CLONED REPSITORY
nix flake update './nixos'Any modifications to the nixos/users directory can be installed using this home-manager command
home-manager switch --flake './nixos' -j 4 --impure
# OR
home-manager switch --flake './nixos#<NAME OF THE USER HERE>' -j 4 --impure--impureflag is required because nixGL usesbuiltins.currentTimeas an impure parameter to force the rebuild on each access.
Since we are using a nixos/flake.lock file, we need to update the flake using the command below and rebuild using home-manager.
# TO BE RUN FROM THE ROOT OF THIS CLONED REPSITORY
nix flake update './nixos'