2020-08-06 15:35:49 +00:00
= foo-dogsquared's NixOS config
2021-11-30 01:03:05 +00:00
:toc:
2022-07-09 06:04:17 +00:00
:devos_link: https://github.com/divnix/digga/tree/580fc57ffaaf9cf3a582372235759dccfe44ac92/examples/devos
2023-07-09 06:07:21 +00:00
:doc_site: https://foo-dogsquared.github.io/nixos-config
2022-09-28 11:11:12 +00:00
:canonical_flake_url: github:foo-dogsquared/nixos-config
:canonical_flake_url_tarball_master: https://github.com/foo-dogsquared/nixos-config/archive/master.tar.gz
:canonical_flake_url_tarball_specific: https://github.com/foo-dogsquared/nixos-config/archive/35c27749c55077727529f412dade862e4deb2ae8.tar.gz
2020-08-06 15:35:49 +00:00
2021-11-25 11:55:30 +00:00
This is my NixOS config as a link:https://www.tweag.io/blog/2020-05-25-flakes/[Nix flake].
2020-08-06 15:35:49 +00:00
2021-12-21 06:29:27 +00:00
I finally have some time trying to grok flakes and redo my NixOS config from scratch after leaving it for some time (because I have work and have to quickly set things up without me trying to debug how NixOS works).
2021-11-25 11:55:30 +00:00
Here is the result.
2020-08-06 15:35:49 +00:00
2023-07-09 06:07:21 +00:00
Anyways, this project also has a dedicated website at {doc_site}.
2020-08-06 15:35:49 +00:00
2022-02-11 04:31:44 +00:00
== Getting started
2022-07-05 14:33:01 +00:00
[CAUTION]
====
Despite being a NixOS system, it isn't entirely reproducible to the point of installing this config will work out-of-the-box.
It has some things needed in the first place to work like my external backup setup where it needs my SSH private keys to work in the first place.
Nonetheless, the parts is it isn't reproducible is only about 10% of this config.
Everything else is fine and dandy.
2022-07-09 06:04:17 +00:00
Oh right...
Don't expect everything is working in each commit but I'm doing my best to make them build successfully in each, yeah?
2022-08-27 05:31:13 +00:00
Also, this configuration is expected to use under non-restricted evaluation mode.
2022-07-05 14:33:01 +00:00
====
2022-02-11 04:31:44 +00:00
Hey there, fellow traveler!
You've fell into the rabbit hole we call Nix where it leads to other rabbit holes such as functional package management, reproducibility, declarative systems, and immutable operating systems.
This is one of the many tickets to that rabbit hole, allow me to be your guide in this mark:[painful] wonderful declarative journey.
Hope to see you on the other side!
=== Installation
2020-08-06 15:35:49 +00:00
2022-08-27 05:31:13 +00:00
Since this uses Nix flakes, you should have Nix v2.8 and above installed.
2021-12-21 06:29:27 +00:00
2022-02-11 04:31:44 +00:00
If you're going to install one of my NixOS configs, be sure to download the unstable versions from link:https://releases.nixos.org/?prefix=nixos/unstable/[their release page].
As an additional option, you can also use link:https://github.com/foo-dogsquared/nixos-config/releases/tag/latest[my personalized NixOS installers] which is primarily intended for me configs.
2021-11-25 11:55:30 +00:00
This primarily uses Nix flakes so you can have a preview of what's available in my config.
2020-08-06 15:35:49 +00:00
2022-10-01 04:51:10 +00:00
[source, shell, subs=attributes]
2020-08-06 15:35:49 +00:00
----
2022-09-28 11:11:12 +00:00
nix flake show {canonical_flake_url}
2020-08-19 18:35:23 +00:00
----
2021-11-29 05:30:57 +00:00
It should export my NixOS configurations of my different hosts (of only one so far excluding VMs and VPSs ;p) among other things.
2022-09-28 11:11:12 +00:00
To install it, run the `nixos-install --flake {canonical_flake_url}#ni`.
2021-11-29 05:30:57 +00:00
(Please see the respective appropriate host README for more information.)
2020-10-06 22:56:04 +00:00
2021-12-26 10:43:23 +00:00
2022-02-11 04:31:44 +00:00
=== The remote repo
For a complete overkill, we use a CI to further the configuration abomination.
It uses GitHub workflows to enable things such as...
2020-09-01 15:10:44 +00:00
2022-02-11 04:31:44 +00:00
* Automatically building link:./pkgs[my custom packages] and sending them to my binary cache to easily distribute it for others.
* Building my personalized NixOS installers and link:https://github.com/foo-dogsquared/nixos-config/releases[making a release out of it].
* Testing the flake outputs (in progress lel).
2020-09-01 15:10:44 +00:00
2022-02-11 04:31:44 +00:00
=== Project structure
Last and foremost, we have the project directory — the environment you'll be living in for the next year, tinkering your Nix configs.
.
It is required to be familiar with the workspace, after all.
2022-07-09 06:04:17 +00:00
My configuration takes a lot of cues from link:{devos_link}[devos] (which is unfortunately is a lot to take if you're just beginning to grok Nix as a whole).
2021-11-29 10:27:56 +00:00
My NixOS config should look like the following:
[source, tree]
----
nixos-config
├── hosts/
├── lib/
├── modules/
├── pkgs/
2022-11-26 16:52:16 +00:00
├── scripts/
2021-12-11 05:20:55 +00:00
├── secrets/
2021-12-13 07:32:58 +00:00
├── shells/
2022-01-25 01:28:10 +00:00
├── templates/
2021-11-29 10:27:56 +00:00
├── users/
2022-07-14 00:17:02 +00:00
├── default.nix
2021-11-29 10:27:56 +00:00
├── flake.lock
├── flake.nix
2023-06-22 10:04:02 +00:00
├── images.toml
2021-11-29 10:27:56 +00:00
└── README.adoc
----
2023-06-22 10:04:02 +00:00
One of the more notable files here when first start looking is the link:./images.toml[`./images.toml`] file where it contains a description of the images.
2023-06-23 02:24:35 +00:00
For more details, see <<declarative-host-management>>.
2023-06-22 10:04:02 +00:00
2022-02-23 08:34:48 +00:00
Most of the said folders are related to a flake output attribute, see <<whats-in-my-flake>> for more details.
2022-02-11 04:31:44 +00:00
2021-11-29 10:27:56 +00:00
* link:./hosts/[`./hosts/`] contain machine-specific configuration.
This usually configures like the hardware setup, timezone, and users.
Host configurations are also exported in the flakes in `outputs.nixosConfigurations`.
2021-12-06 09:57:54 +00:00
* link:./modules/[`./modules/`] contain my custom modules including NixOS and home-manager modules.
2021-11-29 10:27:56 +00:00
For more information, see the link:./modules/README.adoc[related documentation].
* link:./pkgs/[`./pkgs/`] contains my custom packages.
2021-12-06 10:12:00 +00:00
It is exported in the flakes at `outputs.packages` compiled through various systems.
2021-11-29 10:27:56 +00:00
2023-01-06 12:26:13 +00:00
* link:./scripts/[`./scripts/`] contains various scripts for various purposes.
2022-11-26 16:52:16 +00:00
Should be self-explanatory.
2023-01-12 15:00:06 +00:00
* link:./secrets/[`./secrets/`] contains my cluster-wide secrets managed with link:https://github.com/mozilla/sops[sops] and link:https://github.com/Mic92/sops-nix[sops-nix].
Take note, each component (e.g., hosts, modules, users) could have their own specific secrets.
2021-12-11 05:20:55 +00:00
2021-12-13 07:32:58 +00:00
* link:./shells/[`./shells/`] contains my development shells for interacting with the usual type of projects.
Setting this up can bring benefits outside of NixOS (unless you're interacting with projects with any OpenGL-related stuff).
footnote:[Since packages brought from Nix shells can only work with the store, a container might be better at some situations.]
2022-01-25 01:28:10 +00:00
* link:./templates/[`./templates/`] contains my custom templates handy for quickly initializing for various types of projects.
2022-01-03 09:30:24 +00:00
* link:./users/[`./users/`] contains my link:https://github.com/nix-community/home-manager[home-manager] configurations.
2021-11-29 10:27:56 +00:00
It is exported in the flakes at `outputs.homeConfigurations`.
For more information, see the link:./users/README.adoc[related documentation].
2021-11-25 11:55:30 +00:00
== TODO
2020-09-01 15:10:44 +00:00
2021-11-25 11:55:30 +00:00
In order of priority:
2020-09-01 15:10:44 +00:00
2021-11-29 05:30:57 +00:00
* [x] Create custom modules.
* [x] Create a themes system similar to link:https://github.com/hlissner/dotfiles[this NixOS config].
2022-02-04 15:59:57 +00:00
* [x] Create a good workflow for creating ISOs.
2021-12-13 07:32:58 +00:00
* [x] Create development shells.
2021-11-29 10:27:56 +00:00
* [x] Manage secrets with agenix.
2021-12-26 10:43:23 +00:00
* [ ] Create a good workflow for tests.
2021-11-29 05:30:57 +00:00
* [x] Automate backups with NixOS config.
2021-11-29 10:27:56 +00:00
* [x] Create custom packages and export it to flakes. (Maybe consider making it to upstream)
2021-11-29 05:30:57 +00:00
* [x] Create cluser-wide configs.
* [x] Create host-wide configs.
2021-11-29 10:27:56 +00:00
* [x] Create user-specific configs with home-manager.
2022-07-09 06:04:17 +00:00
* [x] ~Steal~ Get some ideas from link:{devos_link}[this overengineered template].
2021-11-29 10:27:56 +00:00
* [x] Make use of other established utilities such as link:https://github.com/divnix/digga/[digga], link:https://github.com/gytis-ivaskevicius/flake-utils-plus[flake-utils-plus], and link:https://github.com/nix-community/home-manager[home-manager] once I'm familiar to create my own Nix programs.
2020-09-01 15:10:44 +00:00
2022-02-23 08:34:48 +00:00
=== Out of scope:
* Set most program configurations with Nix.
This is especially applicable to programs I always use such as my text editor configs.
** The reason: managing them can be chaotic when applied with Nix.
The potential for it is pretty nice especially when seen with similar implementations such as Guix home environment.
However, I don't want to rebuild it every time I change it.
** Plus, most of my applications are now installed using link:https://flatpak.org/[Flatpak] anyways.
It is a tad easier to manage configurations installed this way (e.g., just copy `~/.var` between your systems or make backups with it).
2020-09-01 15:10:44 +00:00
2021-11-29 05:30:57 +00:00
* Migration of my link:https://github.com/foo-dogsquared/dotfiles[dotfiles].
I still use it on other non-NixOS systems.
2020-10-06 22:56:04 +00:00
2022-02-23 08:34:48 +00:00
* To be a configuration framework.
This is my personal configuration which means experimentation will always be here.
Sudden changes can happen at any point.
2020-10-06 22:56:04 +00:00
2020-09-01 15:10:44 +00:00
2022-09-28 11:11:12 +00:00
== Copyright
This project is licensed under MIT license.
I just chose it to make it easier to upstream parts of this project to nixpkgs and to make it easier to copy it without much problems (just don't forget to add attribution as indicated from the license).
Please see link:./LICENSE[`./LICENSE`] for the full text.