nixos-config/README.adoc

130 lines
5.1 KiB
Plaintext
Raw Normal View History

2020-08-06 15:35:49 +00:00
= foo-dogsquared's NixOS config
This is the configuration setup for my https://nixos.org[NixOS] instance.
2020-08-16 08:33:44 +00:00
This setup is stolen from https://github.com/hlissner/dotfiles[hlissner's NixOS config] foot:[The author and one-man maintainer of Doom Emacs.].
The whole setup is mostly intended for single-user systems but you can easily configure it for multi-user systems.
2020-08-06 15:35:49 +00:00
== Getting started
2020-08-16 08:33:44 +00:00
You can replace your NixOS configuration with this bad boi.
2020-08-06 15:35:49 +00:00
2020-08-16 08:33:44 +00:00
To install, you have to do the following first:
- Set up your partitions.
- Copy this setup (either with `git` or what-have-you) to `/etc/dotfiles`.
- Install GNU Make.
Then simply run `make install`.
The default behavior of the installation installs my default setup.
It is equivalent to the following command:
2020-08-06 15:35:49 +00:00
[source, shell]
----
2020-08-16 08:33:44 +00:00
PREFIX=/mnt USER=foo-dogsquared HOST=zilch make --directory /etc/dotfiles install
2020-08-06 15:35:49 +00:00
----
2020-08-16 08:33:44 +00:00
For more information, simply inspect the Makefile.
Assuming you did install, your project will have the following stuff.
- Uses the nixpkgs unstable channel as `nixos` (i.e., `nix-channels --update https://nixos.org/channels/nixos-unstable`).
- Have the https://github.com/rycee/home-manager[home-manager] installed with the unstable release.
- You start with the TTY and nothing else is installed (i.e., bare installation similar in spirit to Arch Linux).
=== Precautions
There are some things you need to keep in mind when using this setup.
* This setup is not meant to be fully reproducible.
It is a personal setup for a person who wants to live on the bleeding edge, personally.
Despite being a NixOS setup which should be reproducible on paper, it mainly uses the unstable versions of the channels and packages.
If we're to install this setup at separate times, the full list of installed packages with their depedencies and versions wouldn't be the same.
* It may use third-party channels for certain versions of the packages, hammering the first precaution even further regarding reproducibility.
2020-08-06 15:35:49 +00:00
== Project structure
The project structure should look like the following:
[source, tree]
----
nixos-config
├── config/
2020-08-16 08:33:44 +00:00
├── hosts/
2020-08-06 15:35:49 +00:00
├── modules/
2020-08-16 08:33:44 +00:00
├── packages/
├── default.nix*
├── Makefile*
└── README.adoc*
2020-08-06 15:35:49 +00:00
----
2020-08-06 17:57:53 +00:00
* The directory paid with the most attention would most likely be the `modules/` folder.
2020-08-06 15:35:49 +00:00
Each module (and submodule) can contain multiple modules for multiple programs (i.e., `modules/shell/git`, `modules/desktop/bspwm`).
2020-08-16 08:33:44 +00:00
It could also contain a `base.nix` file where Nix packages with no configurations are placed similar to Arch package groups.
2020-08-06 15:35:49 +00:00
2020-08-06 17:57:53 +00:00
** Another folder worthy of attention is the `modules/themes` which sets up a complete desktop environment for you so you don't have to.
2020-08-16 08:33:44 +00:00
For more information, see the <<Themes>> section.
2020-08-06 17:57:53 +00:00
* The `config/` directory is simply the ad hoc configuration of several programs.
2020-08-06 15:35:49 +00:00
In this case, it is my https://github.com/foo-dogsquared/dotflies[dotfiles] directory.
2020-08-16 08:33:44 +00:00
* The `hosts/` contains the individual system configuration of my machine (I've only one but I plan to NixOS for my new ones).
Each folder inside of this directory represents one machine.
It is also used on the installation phase (from `make install`) by setting the `HOST` variable (i.e., `HOST=zilch make -C /etc/install`) with the folder name as the argument.
* The `packages/` folder is my custom packages either the new ones that haven't made into nixpkgs yet or packages with overrides.
Also contains third-party package repositories and overlays such as the NUR or the unstable branch of Emacs.
== Themes
My setup feature themes as a NixOS modules (in link:./modules/themes[`modules/themes`]) which sets up a complete graphical environment.
This lets me easily switch my graphical setup with a simple toggle (i.e., `theme.$THEME_NAME.enable = true;`).
For safety, you should have a bare installation ala-Arch Linux.
As you can see in the `default.nix` of the `modules/theme` directory, a theme should also pass in certain data to `modules.theme` as if it's enabled.
The following is an example metadata object of a theme.
[source, nix]
----
{
name = "Fair and square";
version = "0.1.0";
path = ./.;
wallpaper = "${config.modules.theme.path}/config/wallpaper";
}
----
For best practice, the general project structure of a theme should look like the following:
[source, tree]
----
$THEME_NAME
├── config/
│   ├── PROGRAM_1/
│   ├── PROGRAM_2/
│   ├── PROGRAM_3/
│   └── wallpaper*
├── default.nix*
└── README.adoc*
----
* The `config/` folder is where all of the specific configurations will go.
Each program to be configured is stored in its own folder (i.e., polybar, bspwm, sxhkd).
A wallpaper can be placed at `config/wallpaper` for convenience.
* `default.nix` is simply the entry point for our theme module.
This is where you can add certain packages, enable certain settings, setup your files to the home directory, and pass the theme metadata.
* For convenience, you should make the NixOS theme module as a https://github.com/cookiecutter/cookiecutter[Cookiecutter template] to easily replace the color schemes, fonts, and what-have-you.