From 824b53086ff96bec857bb1f5305a60d20287b629 Mon Sep 17 00:00:00 2001 From: zackartz Date: Sat, 27 Apr 2024 22:59:12 -0400 Subject: [PATCH] add install guide --- README.md | 132 ++++++++++++++++++++++++++++++++++ hosts/common/default.nix | 2 - hosts/earth/configuration.nix | 1 + hosts/vm/configuration.nix | 38 ++++++++++ 4 files changed, 171 insertions(+), 2 deletions(-) create mode 100644 hosts/vm/configuration.nix diff --git a/README.md b/README.md index 498e9a9..a4c54a8 100644 --- a/README.md +++ b/README.md @@ -30,3 +30,135 @@ With git installed, clone the repository with ```bash git clone https://github.com/zackartz/nixos-dots.git && cd nixos-dots ``` + +### 2. Configuring the System + +Generate your `hardware-configuration.nix` file. + +```bash +sudo nixos-generate-config --root /mnt +``` + +You will now have two files in `/mnt/etc/nixos`. We will need `hardware-configuration.nix` and part of `configuration.nix`. + +```bash +[nixos@live:~/nixos-dots]$ ls /mnt/etc/nixos/ +configuration.nix hardware-configuration.nix +``` + +Go ahead and make a new folder for your pc inside of the `hosts` directory. + +```bash +cd hosts && mkdir vm # change "vm" to your preferred hostname -- it MUST match the hostname you plan on using for scripts to work properly. +``` + +> [!TIP] +> You can use the "m" alias to create directories once you have booted into the installed system! + +Now, copy the files over from `/mnt/etc/nixos/`. + +```bash +cd vm && cp /mnt/etc/nixos/* . # remember to change "vm" to your hostname +mv configuration.nix config.old.nix # we will be writing our own configuration.nix +``` + +Now, make a new file: `configuration.nix`. + +```bash +touch configuration.nix +``` + +Open up `configuration.nix` in your favorite editor and paste the following: + +```nix +{ + pkgs, + inputs, + ... +}: { + imports = [ + ../common/default.nix + ./hardware-configuration.nix + ]; + + networking.hostName = "vm"; # Define your hostname. + + programs.zsh.enable = true; + # Define a user account. Don't forget to set a password with ‘passwd’. + users.users.zack = { + isNormalUser = true; + description = "zack"; + extraGroups = ["networkmanager" "wheel"]; + shell = pkgs.zsh; + }; + + home-manager = { + extraSpecialArgs = {inherit inputs;}; + users = { + "zack" = { + imports = [../../modules/home-manager/default.nix]; + _module.args.theme = import ../../core/theme.nix; + + home.username = "zack"; + home.homeDirectory = "/home/zack"; + }; + }; + }; +} +``` + +Change the instances of `zack` to your desired username, and customize as you see fit! + +We will need to copy some things over from `configuration.nix`, namely boot related options. I am doing this in a VM, so I see these boot related options. Find the `boot.loader` option, and copy it over from your old file into this new one. + +```nix + # Use the GRUB 2 boot loader. + boot.loader.grub.enable = true; + # boot.loader.grub.efiSupport = true; + # boot.loader.grub.efiInstallAsRemovable = true; + # boot.loader.efi.efiSysMountPoint = "/boot/efi"; + # Define on which hard drive you want to install Grub. + boot.loader.grub.device = "/dev/vda"; # the device to change +``` + +Make sure the device targets the correct drive for your EFI to be installed on. + +Finally, add the following to `flake.nix` (somewhere around line 100). + +```nix + nixosConfigurations.vm = nixpkgs.lib.nixosSystem { + specialArgs = {inherit inputs;}; + modules = [ + ./hosts/vm/configuration.nix + inputs.home-manager.nixosModules.default + ]; + }; +``` + +### 3. Installing the system + +Now that you have the config ready to go, run the following command. + +```bash +rm -rf .git # remove the github repository +sudo nixos-install --flake ~/nixos-dots#vm # again, remember to change vm to be your hostname +``` + +### 4. Post-Install configuration. + +Set a password for your user: + +```bash +sudo passwd zack # replace with your username +``` + +Copy the flake to your home folder + +```bash +cp -r ~/nixos-dots /mnt/home/zack/nixos # replace "zack" with your username +``` + +Reboot the system and you're done! Enjoy the system! + +> [!TIP] +> Check ./modules/shell/zsh/aliases.nix for useful aliases, like "r" to rebuild your system! diff --git a/hosts/common/default.nix b/hosts/common/default.nix index 1db699c..14bcdf2 100644 --- a/hosts/common/default.nix +++ b/hosts/common/default.nix @@ -123,8 +123,6 @@ # Enable touchpad support (enabled default in most desktopManager). # services.xserver.libinput.enable = true; - programs.zsh.enable = true; - users.groups.plugdev = {}; # Allow unfree packages diff --git a/hosts/earth/configuration.nix b/hosts/earth/configuration.nix index c8084f8..b187660 100644 --- a/hosts/earth/configuration.nix +++ b/hosts/earth/configuration.nix @@ -131,6 +131,7 @@ # }; # }; + programs.zsh.enable = true; # Define a user account. Don't forget to set a password with ‘passwd’. users.users.zack = { isNormalUser = true; diff --git a/hosts/vm/configuration.nix b/hosts/vm/configuration.nix new file mode 100644 index 0000000..a8728f4 --- /dev/null +++ b/hosts/vm/configuration.nix @@ -0,0 +1,38 @@ +{ + pkgs, + inputs, + ... +}: { + imports = [ + ../common/default.nix + ]; + + programs.zsh.enable = true; + # Define a user account. Don't forget to set a password with ‘passwd’. + users.users.zack = { + isNormalUser = true; + description = "zack"; + extraGroups = ["networkmanager" "wheel" "docker" "libvirtd" "plugdev"]; + shell = pkgs.zsh; + packages = with pkgs; [ + firefox + kate + rio + telegram-desktop + kitty + ]; + }; + + home-manager = { + extraSpecialArgs = {inherit inputs;}; + users = { + "zack" = { + imports = [../../modules/home-manager/zack.nix]; + _module.args.theme = import ../../core/theme.nix; + + home.username = "zack"; + home.homeDirectory = "/home/zack"; + }; + }; + }; +}