NixOS
Take note of 2024年03月31日 since it may be helpful.
Lately, I have been slowly relying on using nixos modules for installation, but it still not majority of it of course. Reading the nix file is still hard but I noticed that variables are typically laid out this way.
variable = mkEnableOption (lib.mdDoc "Something") // { ... };
I don’t know the purpose of //
there but it doesn’t seem like a comment.
Sometimes it is just mkOption
.
Installing VirtualBox
{ config, lib, pkgs, ... }:
{
imports =
[
# Include the results of the hardware scan.
./hardware-configuration.nix
];
virtualisation.virtualbox.host = {
enable = true;
enableExtensionPack = true; (1)
};
}
1 | This will force VirtualBox to compile. You can skip this if you don’t need the Extension Pack by Oracle. |
If you get an error saying.
The VirtualBox Linux kernel driver is either not loaded or not set up correctly. Please try setting it up again by executing '/sbin/vboxconfig' as root. If your system has EFI Secure Boot enabled you may also need to sign the kernel modules (vboxdrv, vboxnetflt, vboxnetadp, vboxpci) before you can load them. Please see your Linux system's documentation for more information. where: suplibOsInit what: 3 VERR_VM_DRIVER_NOT_INSTALLED (-1908) - The support driver is not installed. On linux, open returned ENOENT.
This can be solved by rebooting.
Installing VMWare Workstation Pro
{ config, lib, pkgs, ... }:
{
imports =
[
# Include the results of the hardware scan.
./hardware-configuration.nix
];
virtualisation.vmware.host = {
enable = true;
};
}
This automatically starts vmware-networks.service
.
You can disable this by adding.
systemd.services = {
vmware-networks.wantedBy = lib.mkForce [ ];
};
/tmp as tmpfs
By default, NixOS does not mount tmpfs
on /tmp
thus /tmp
will persists across reboot.
Use boot.tmp.useTmpfs = true;
to mount /tmp
as tmpfs.
VMWare
nixpkgs.overlays = [
(
final: prev: {
linuxPackages_latest = prev.linuxPackages_latest.extend (
_lpfinal: _lpprev: {
vmware = prev.linuxPackages_latest.vmware.overrideAttrs (_oldAttrs: {
version = "workstation-17.5.2-k6.9+-unstable-2024-08-22";
src = final.fetchFromGitHub {
owner = "nan0desu";
repo = "vmware-host-modules";
rev = "b489870663afa6bb60277a42a6390c032c63d0fa";
hash = "sha256-9t4a4rnaPA4p/SccmOwsL0GsH2gTWlvFkvkRoZX4DJE=";
};
});
}
);
}
)
];
Cleaning up Nix Store
Delete all profiles in /nix/var/nix/profiles
.
sudo nix profile wipe-history --profile /nix/var/nix/profiles/system --older-than 3d
Then clean up nix store.
nix store gc
This cleans more data and saves more storage than nix-garbage-collect
.
Might be because of removing the profile histories.