A repository to contain all my nix stuff. For now only NixOS related.
Add all channels. We are going to use home-manager as a module, so add like this:
sudo nix-channel --add https://github.com/nix-community/home-manager/archive/release-23.05.tar.gz home-manager
sudo nix-channel --add https://channels.nixos.org/nixos-unstable nixos-unstable
sudo nix-channel --add https://nixos.org/channels/nixos-23.05 nixos
Show result:
sudo nix-channel --list
home-manager https://github.com/nix-community/home-manager/archive/release-23.05.tar.gz
nixos https://nixos.org/channels/nixos-23.05
nixos-unstable https://channels.nixos.org/nixos-unstable
A first flake.nix is generated, and filled from several examples (see links below). Now I have it in use for my Lenovo Thinkpads.
usually with sudo (and not applicable for current flake config):
nixos-rebuild build
nixos-rebuild test
nixos-rebuild switch
nixos-rebuild switch --rollback
nix-channel --update
normal commands
nix-store --gc # garbage-collect
nix-store --optimize #
flake commands
sudo nixos-rebuild switch --flake <config path>#<host>
sudo nixos-rebuild switch --flake .#lent480
sudo nixos-rebuild switch --flake ~/github/dotfiles-lent480/#lent480
nix run nixpkgs#htop
see .sh scripts for easy use.
The batchfiles in the directory can be used to easily build, test, switch the configurastion for the nachine you are logged on.
With update you can update the channels.
The flake.nix file contains the entry point for all NixOS configurations.
See nixosConfigurations array for the machines configured. Each machine configured has a corresponding folder in the hosts folder. The computer folder (like lent480) contains .nix files specific for this computer.
The modules folder contains generic code used in the machine configurations.
To add a module:
- create new category if needed (like desktop)
- add
mymodule.nix - add new files to git (important)
- refer to the module in an import like
desktop-mymodule. Not that the-is used instead of a path separator. - use
./fmt.shto format all nix files
To add a machine:
- add en new entry in
flake.nixin thenixosConfigurations. - create a new folder in
hostsnamed after the machine named - copy initial
configuration.nixandhardware-configuration.nixinto this folder - make sure the configuration in the flake points to the new
configuration.nix - add new files to git, else you may get errors (important, the scripts now also check this and issue a warning)
- notice that the
importsis done with nixosModules - choose a desktop from the modules/desktop
./build.shto check the syntax and see if it can build./test.shto build and test the configuration. New applications are available after a successful test.- use
./fmt.shto format all nix files ./switch.shto activate a new configuration. This will be the default in the startup of the machine.
1Password is enabled in the user_minimal.nix package. But before you can use the op cli tool you must enable it with:
- 'Settings/General/ Keep 1Password in system tray'
- 'Settings/Security/ Unlock using system authentication service'
- 'Settings/Developer/Command-Line Interface/ Integrate with 1Password CLI'
- wiki of this repo
- hardware See README in hosts.