Haskell Nix

Haskell has many mature tools and infrustructures. Nix is another one. This documentation is ment to help the live sessions and will require more study and reading of this https://input-output-hk.github.io/haskell.nix/index.html

Installing NIXOS

1. **Download NixOS ISO**:
   - Go to the [NixOS download page](https://nixos.org/download.html).
   - Choose the appropriate version of NixOS for your system architecture (usually 64-bit).
   - Click on the download link to get the ISO file.

2. **Create Bootable USB Drive**:
   - Insert a USB drive with at least 4GB of storage capacity into your Windows computer.
   - Download and install Rufus, a tool for creating bootable USB drives ([Rufus](https://rufus.ie/)).
   - Run Rufus and select your USB drive from the Device dropdown menu.
   - Click on the "Select" button next to "Boot selection" and choose the NixOS ISO file you downloaded.
   - Leave all other settings as default and click on the "Start" button.
   - Rufus will now create a bootable USB drive with the NixOS ISO.

3. **Configure BIOS/UEFI Settings**:
   - Restart your computer and enter the BIOS/UEFI settings.
   - Change the boot order to prioritize booting from USB devices.
   - Save the changes and exit the BIOS/UEFI settings.

4. **Boot from USB Drive**:
   - Insert the bootable USB drive into your computer.
   - Restart your computer.
   - Your computer should now boot from the USB drive and load the NixOS installer.

5. **Start NixOS Installation**:
   - Once the NixOS installer loads, you'll be presented with the boot menu.
   - Select the "Graphical Installation" option if you prefer a graphical installer, or "Normal Installation" for a text-based installer.

6. **Configure NixOS Installation**:
   - Create a configuration file (`configuration.nix`) that specifies how you want your system to be set up.
   - You can either create this file manually or generate it using the `nixos-generate-config` command.

7. **Install NixOS**:
   - Once your configuration file is ready, start the installation process by running:
     ```
     sudo nixos-install
     ```
   - This command will install NixOS onto your system according to the configuration specified in `configuration.nix`.

8. **Reboot**:
    - After the installation process completes successfully, remove the USB drive and reboot your computer:
      ```
      sudo reboot
      ```

9. **Post-Installation**:
    - After rebooting, log in to your new NixOS system.
    - You can now customize your system further, install additional packages using the Nix package manager, and configure any remaining settings according to your preferences.

# HOW TO CONFIGURE YOUR NIXOS

**Step 1:** After the successful installation of NIXOS, open the terminal and type the following command to enter into the NIXOS directory:

cd /etc/nixos/


**Step 2:** Use the command `ls` to confirm and view the files in the NIXOS directory. There should be `configuration.nix` and `hardware-configuration.nix` files.

**Step 3:** Type the following command to enter into the `configuration.nix` file:

sudoedit configuration.nix


**Step 4:** To install the Vim package provided in the `configuration.nix` file, type/click:
- Press "ctrl + o" to enter the edit/write mode.
- Scroll down the `configuration.nix` file and uncomment Vim by removing the "#" character.
- Press "ctrl + x" to exit the edit/writing mode.

**Step 5:** On the terminal, type the following command to build the new configurations:

sudo nixos-rebuild switch

NIXOS will then configure the changes accordingly.

**Step 6:** To configure the file further, you can search for other packages using the following link: [NixOS Package Search](https://search.nixos.org/packages).
Follow steps 3 - 5 to configure the changes to NIXOS successfully.

# After installing NixOS, here are some logical steps to get started:

1. **Update Packages**:
- Start by updating the packages. Even if you used the latest ISO for installation, updates are essential.
- Check for updates in added channels:
  ```
  nix-channel --update
  ```
- Install any available updates:
  ```
  sudo nixos-rebuild switch --upgrade
  ```

2. **Change Hostname**:
- Unlike traditional methods (using `hostnamectl`), NixOS handles hostname changes differently.
- Edit the main configuration file:
  ```
  sudo nano /etc/nixos/configuration.nix
  ```
- Locate the line:
  ```
  networking.hostName = "nixos";
  ```
- Change it to your desired hostname:
  ```
  networking.hostName = "Your_Hostname";
  ```
- Save the changes and apply them:
  ```
  sudo nixos-rebuild switch
  ```

3. **Setup Flatpak**:
- NixOS doesn't handle Flatpak installations the same way as Ubuntu or other distributions.
- Edit the `configuration.nix` file:
  ```
  sudo nano /etc/nixos/configuration.nix
  ```
- Add the following line at the end:
  ```
  services.flatpak.enable = true;
  ```
- Save the changes and apply them:
  ```
  sudo nixos-rebuild switch
  ```
- Add the Flathub repository:
  ```
  flatpak remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo
  ```

## Why it is important to install Flatpak

1. **Universal Packaging**:
- Flatpak is like a universal gift box for apps.
- It wraps up an app along with all its necessary stuff (dependencies) in one package.

2. **No More Dependency Hassles**:
- With Flatpak, you don't need to worry about missing pieces.
- It brings everything needed, so apps work smoothly on any Linux system.

3. **Secure and Self-Contained**:
- Flatpak apps run in a safe sandbox.
- They can even update themselves without bothering you.

4. **Install Anywhere**:
- Whether you're on Ubuntu, Fedora, or any other Linux, Flatpak works everywhere.

# Installing Google Chrome on NixOS

1. **Update your package list**:
Before downloading any new software, it's a good practice to update your package list to ensure you're getting the latest versions of available software. You can do this by running:

sudo nix-channel --update


2. **Add the overlay**:
You need to add the overlay containing Google Chrome to your NixOS configuration. You can do this by editing your `configuration.nix` file located at `/etc/nixos/configuration.nix` and adding the overlay like this:

nixpkgs.overlays = [ (import (fetchTarball "https://github.com/NixOS/nixpkgs-channels/archive/nixos-unstable.tar.gz