Skip to content

Instantly share code, notes, and snippets.

@kritoke
Last active November 11, 2021 19:51
Show Gist options
  • Save kritoke/a28855fc251a3725eac5afe7a6b74865 to your computer and use it in GitHub Desktop.
Save kritoke/a28855fc251a3725eac5afe7a6b74865 to your computer and use it in GitHub Desktop.
Various Tips/Tricks and Install Tips for NixOS
Installing on a newer PC with GFI requires a little differen't partitioning. When you open up gparted or your favorite command line partition tool, you need to do the following:
Create a partition scheme that is GPT. Then create the first partition as FAT32 and make it 200 mb or larger, set the flags to boot and esp. Then create your main partition and if you want, a home partition and swap partition.
Next step is to partition the main os partition:
mkfs.ext4 -L nixos /dev/sda1
Mount the partition:
mount /dev/disk/by-label/nixos /mnt
Generate the configuration file that we will be editing:
nixos-generate-config --root /mnt
Now to edit the main configuration file, you can use vim or nano:
nano /mnt/etc/nixos/configuration.nix
With regards to this, if you are using uefi, you don't have to mess with adding grub configurations, typically it will already have the required ones for gummiboot:
boot.loader.gummiboot.enable = true;
boot.loader.efi.canTouchEfiVariables = true;
You can change which branch of kernel you want to load, the version I installed had 4.4.x, since I run a skylake chipset on a NUC, I wanted a little more stability from the 4.6.x kernel. All that is required is for you to add this to the configuration file:
boot.kernelPackages = pkgs.linuxPackages_4_6;
I like to use some non-open source packages, so also added this:
nixpkgs.config.allowUnfree = true;
I want X and the window manager to load on startup, so I uncommented:
services.xserver.enable = true;
services.xserver.layout = "us";
If you want KDE to be your default, make sure you have this in there and uncommented:
services.xserver.displayManager.kdm.enable = true;
services.xserver.desktopManager.kde4.enable = true;
If you prefer Xfce, add the following:
services.xserver.desktopManager.xfce.enable = true;
If you want decent audio control, I'd add in pulseaudio as well:
hardware.pulseaudio.enable = true;
If you need a graphics driver to run that isn't automatically detected, add:
services.xserver.videoDrivers = [ "nvidia" ];
If you aren't using DHCP for networking, you can also set them here:
networking.interfaces.eth0.ipv4.addresses = [ { address = "192.168.1.100"; prefixLength = 24; } ];
networking.defaultGateway = "192.168.1.1";
networking.nameservers = [ "8.8.8.8" ];
networking.hostName = "nixos";
Any applications you want to install in the base install, you can add to the following (just put each package with a space between:
environment.systemPackages = with pkgs; [
wget firefox chromium ruby ntp ghc
];
Setup your extra users (don't forget to set the passwd after you boot):
users.extraUsers.newusername =
{ isNormalUser = true;
home = "/home/newusername";
description = "User's Name";
extraGroups = [ "wheel" "networkmanager" ];
};
Run the installer once you have the configuration finished up and set the root password:
nixos-install
Once you have a bootable system, here are a few more tips:
Create a local account configuration file to enable unique things for your account such as plugins:
~/.nixpkgs/config.nix
These are some of my favorite things to enable, just add these to the file:
{
allowUnfree = true; # Allow non-free applications such as Visual Studio Code to install
firefox = {
enableGoogleTalkPlugin = true;
enableAdobeFlash = true;
};
chromium = {
enableWideVine = true; # enable the DRM to allow things like Netflix to work
};
}
What I typically do is change my normal user account to run unstable, while leaving the main os running stable. This typically stops a lot of breakage, but lets you run more current software or have access to things not in the main channel. I use this to install things like a more current firefox and also visual studio code.
Do this under your normal account and not as root or sudo:
nix-channel --add https://nixos.org/channels/nixos-unstable nixos
To install applications, you can do the following (this also works in regular root mode and that would be system wide):
nix-env -i packagename
To search for a package, this seems to work the most reliably for me:
nix-env -qaP --description | grep -i packagename
To see what was explicitly installed (not from the config):
nix-env --query --installed
To change the nix file and recompile/install it, as when new versions come out before they get updated in the repo, do the following:
git clone https://github.com/NixOS/nixpkgs.git ~/nixpkgs-unstable
Go to the folder for the application in question, which should be under pkgs and then applications. Modify the needed files, you may have to run a shaw256sum on the source file and update it as well as version numbers in the default.nix file. Then you run the following to install it when you are done:
nix-env -iA packagename -f ~/nixpkgs-unstable/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment