Linux NixOsHyperV
Overview
Another try at NixOs using Hyper-V.
Hyper-V
Create a new VM CPU : 4 RAM : 4 Gb Hard disk : 50Gb
Stop VM, and go back to the VM settings. In Security, disable Enable Secure Boot. Start the VM and follow up Zorin installation.
Installation
Generate the system configuration file :
|
|
Rebuild after updating the configuration :
|
|
Custom Config files
I am using Alacritty, which uses a config file (~/alacritty/alacritty.toml) and I would like the configuration to be done when I am building the station.
The best way I have found is to use home-manager
and to make it copy the config file :
{ config, pkgs, lib, ... }:
let
home-manager = builtins.fetchTarball https://github.com/nix-community/home-manager/archive/release-24.11.tar.gz;
in
{
imports =
[ # Include the results of the hardware scan.
./hardware-configuration.nix
(import "${home-manager}/nixos")
];
...
# user configs
home-manager.users.myuser = { pkgs, ... }: {
home.packages = [ pkgs.atool pkgs.httpie ];
home.file."alacritty/alacritty.toml".source = ./alacritty.toml;
...
}
}
bash customization
To launch FastFetch
when opening a new bash add the following in the home.manager block :
|
|
Maintenance
Each configuration built, will generate a new generation. That list of generation is hown in the boot menu and it s allowing us to come back to a previous version if needed.
The Generations are in the /nix folders.
|
|
The ’nixos-rebuild’ command can list the generations too
|
|
It is possible to remove some generations
|
|
The command nix-collect-garbage
can be used to recover the disk space associated to those generations.
|
|
To update the boot menu to reflect the list of generations, rebuild the OS.
|
|
|
|
|
|
To clean up alder generation use the following command :
Conclusion
NixOs is a true blessing, making it possible to rebuild any machine with most of the configuration exactly as I like it to be. The only part I keep doing manually is related to the security requirements, like setting ssh keys, etc…