diff --git a/docs/content/en-US/02-lay-of-the-land/04-channels-support/index.adoc b/docs/content/en-US/02-lay-of-the-land/04-channels-support/index.adoc index b570cdb1..72015490 100644 --- a/docs/content/en-US/02-lay-of-the-land/04-channels-support/index.adoc +++ b/docs/content/en-US/02-lay-of-the-land/04-channels-support/index.adoc @@ -15,21 +15,5 @@ The entry point is found at github:{github-repo}[`./default.nix`, path=./default include::../../../../../default.nix[] ---- -However, you have to keep some limitations and guidelines in mind. - -* It exports an attribute based from the github:nix-community/NUR/[NUR template]. -+ --- -Several exports includes... - -* My custom library at `lib`. -* Custom NixOS modules at `modules`. -* Custom home-manager modules at `hmModules`. -* An overlay of my custom packages at `overlays.foo-dogsquared-pkgs`. -* My packages as the rest of the top-level attributes from the attrset. --- - -* Keep in mind it doesn't export the NixOS hosts and home-manager user configurations. -It would be pointless as it is duplicating effort plus **I really like managing my NixOS config more with the flakes way** compared to setting up channels. -It has a lot of advantages such as the ease of provisioning and updating your setups along with its dependencies, enforcing certain values in a certain attribute that can be seen in the revised Nix CLI, and nicer interface overall. -While possible with channels, this is just better experience overall and I have no interest in maintaining setups in both ways. +As you can tell, it is made with github:edolstra/flake-compat[opts=repo]. +This is to support both use cases easily at the expense of making the traditional method a bit more tedious such as the Nix project being completely locked in with its dependencies (thus you can't configure it with your own nixpkgs version). footnote:[Then again, the way it used to be before flakes already has a host of problems. This is the least of them.] diff --git a/docs/content/en-US/03-project-specific-setup/01-declarative-host-management/index.adoc b/docs/content/en-US/03-project-specific-setup/01-declarative-host-management/index.adoc index 31d6246f..655d2fb0 100644 --- a/docs/content/en-US/03-project-specific-setup/01-declarative-host-management/index.adoc +++ b/docs/content/en-US/03-project-specific-setup/01-declarative-host-management/index.adoc @@ -4,87 +4,62 @@ title: Declarative host management = Declarative host management This project uses a custom setup for declarative host management. -Specifically, it is done with a simple file at github:{github-repo}[`./setups/nixos.nix`, path=./setups/nixos.nix, rev=master] where it expects an attribute set of the hosts' metadata. -Each host in the set represents one of the hosts at github:{github-repo}[`./hosts/`, path=./hosts/, rev=master]. +It is a custom github:hercules-ci/flake-parts[opts=repo] module that allows you to easily initialize NixOS systems of multiple platforms (with multiple images output) while making it purely-built as much as possible. -Each of declared hosts are then exported as part of the `images` flake output attribute where each is a derivation for building them as an image output. +This custom flake-parts modules integrates the following projects: + +* It automatically adds github:serokell/deploy-rs[opts=repo] nodes ready to be deployed with `deploy` CLI tool. +* Mandatory inclusion of github:nix-community/home-manager[opts=repo]. +* Image output generation made easy with github:nix-community/nixos-generators[opts=repo]. + +Each of the declared hosts are then exported either as part of the `images` or `nixosConfigurations` (or both) flake output attribute. +The `images` flake output attribute contains a per-system set of packages of the NixOS systems as the indicated package format. For example, you can build my personalized NixOS installer ISO with the following command. [source, shell, subs=attributes] ---- -nix build {canonical-flake-url}#images.x86_64-linux.bootstrap +nix build {canonical-flake-url}#images.x86_64-linux.bootstrap-iso ---- -[NOTE] -==== -Not every image listed here is not meant to be built as a certain output but rather deployed somewhere else. -We'll see to specify it in the following section. -==== +This is an example of a declarative NixOS setup. +The following configuration should have the following effects in the flake output: -A host metadata has a certain schema which the following example is a complete version of it. -The data is then used for certain functions in the flake definition file (i.e., `flake.nix`). +* Two additional NixOS configurations to be deployed at `nixosConfigurations.plover-{x86_64-linux,aarch64-linux}`. +By default, declarative NixOS setups are not added automatically to `nixosConfigurations` output unless we have `configs..formats = null;` but we did configure `configs..deploy` so that makes it even. + +* Four additional derivations added in `images` flake output (since there's 2 formats and 2 platforms) at `images.{x86_64-linux,aarch64-linux}.plover-{do,gce}`. [#lst:images-metadata-example] [source, nix] ---- { - plover = { + setups.nixos.configs.plover = { systems = [ "x86_64-linux" "aarch64-linux" ]; - format = null; + formats = [ "do" "gce" ]; domain = "foodogsquared.one"; - nixpkgs-channel = "nixos-unstable-small"; - home-manager-channel = "home-manager-unstable"; + nixpkgs-branch = "nixos-unstable-small"; + home-manager-branch = "home-manager-unstable"; modules = [ ({ config, lib, ... }: { services.foo.enable = true; }) ]; + overlays = [ + inputs.neovim-nightly-overlay.overlays.default + ]; deploy = { - hostname = "plover.foodogsquared.one"; - ssh-user = "admin"; - fast-connection = true; - auto-rollback = true; - magic-rollback = true; - remote-build = true; + fastConnection = true; + autoRollback = true; + magicRollback = true; + remoteBuild = true; + profiles = os: { + system = { + sshUser = "root"; + user = "admin"; + path = inputs.deploy.lib.${os.system}.activate.nixos os.config; + }; + }; }; }; } ---- - -For a complete reference, here are the expected attributes. - -- `systems` contains a list of platforms of the host system. -This is mainly used to indicate the platform used for the nixpkgs repository. - -- `format` is the image output format for the host. -It expects an accepted value from github:nix-community/nixos-generators[opts=repo] project. -To include a host as part of `nixosConfigurations`, you'll have to set this as `null`. - -- `hostname` is the canonical hostname for the host. -If unset, the hostname is the name of the table key. -In the <>, if `plover.hostname` is unset, the value would be `plover` instead of `ploverrific`. - -- `domain` is the domain used for networking configuration. -It is set for `networking.domain` in NixOS configuration. - -- `nixpkgs-channel` is the nixpkgs channel to be used for the host. -The value could be any one of the nixpkgs flake inputs imported into this flake. -By default, it uses `nixpkgs` flake input which points to the `nixos-unstable` channel. - -- `home-manager-channel` is the home-manager channel to be used for the host. -The value could be any one of the home-manager flake inputs imported into this flake. -By default, it uses `home-manager` flake input which follows the `home-manager-unstable` channel. - -- `modules` is an extra list of modules to be imported with the configuration. - -- `deploy` is a table containing arguments from github:serokell/deploy-rs[opts=repo]. -Only a few arguments are accepted (i.e., `hostname`, `fast-connection`, `remote-build`, `magic-rollback`, and `auto-rollback`). -Once this attribute is present, it will be included as part of `nixosConfigurations` flake output no matter what `format` is given. - -Those imported NixOS configurations are also exported as part of the deploy nodes for deploy-rs with the `nixos` prefix. -For example, here's the command to deploy my Plover server. - -[source, shell, subs=attributes] ----- -deploy {canonical-flake-url}#nixos-plover ----- diff --git a/docs/content/en-US/03-project-specific-setup/02-declarative-user-management/index.adoc b/docs/content/en-US/03-project-specific-setup/02-declarative-user-management/index.adoc index 62b7d9a0..515bdc47 100644 --- a/docs/content/en-US/03-project-specific-setup/02-declarative-user-management/index.adoc +++ b/docs/content/en-US/03-project-specific-setup/02-declarative-user-management/index.adoc @@ -4,10 +4,9 @@ title: Declarative user management = Declarative user management Similarly to xref:../01-declarative-host-management/index.adoc[Declarative host management], this project also provides a way to declare home-manager users. -The `./setups/home-manager.nix` sits in the project root expecting certain data. -Similar to the declarative NixOS setup, it expects an attribute set of users with each representing one of the users from github:{github-repo}[`./users/home-manager/`, path=./users/home-manager/, rev=master]. -These are then included as part of `homeConfigurations` for easier installation with the standalone home-manager tool. -Of which they are then included as part of deploy nodes for deploy-rs (also for easier deployment). +This is also presented as a custom flake-parts module as well, ready to be configured at `setups.home-manager` namespace of the flake-parts config. + +This module is a bit simpler that it only makes configured users to be added to `homeConfigurations` and `deploy.nodes`. Here's an example user with complete schema. @@ -15,10 +14,15 @@ Here's an example user with complete schema. [source, nix] ---- { - foo-dogsquared = { - systems = [ "x86_64-linux" ]; - nixpkgs-channel = "nixos-stable"; - home-manager-channel = "home-manager-23.05"; + setups.home-manager.sharedModules = [ + inputs.your-mom.homeModules.default + ]; + + # Here is the meat, what you're likely going to do. + setups.home-manager.configs.foo-dogsquared = { + systems = [ "x86_64-linux" "aarch64-linux" ]; + nixpkgs-branch = "nixos-stable"; + home-manager-branch = "home-manager-23.05"; home-directory = "/home/foo-dogsquared"; username = "foodogsquared"; modules = [ @@ -26,37 +30,16 @@ Here's an example user with complete schema. services.foo.enable = true; }) ]; + overlays = [ + inputs.neovim-nightly-overlay.overlays.default + ]; deploy = { hostname = "local.foodogsquared.one"; - ssh-user = "admin"; - profile = "foodogsquared"; - fast-connection = true; - auto-rollback = true; - magic-rollback = true; - remote-build = true; + fastConnection = true; + autoRollback = true; + magicRollback = true; + remoteBuild = true; }; }; } ---- - -- `systems` contains a list of platforms of the home-manager user. -This is mainly used to indicate the platform used for the nixpkgs repository. - -- `nixpkgs-channel` indicates the branch of the nixpkgs to be used. -By default, this uses the `nixpkgs` which follows the `nixos-unstable` branch. - -- `home-manager-channel` contains the home-manager channel to be used. -The value should be one of the home-manager channel that is imported into this flake. -By default, it sets the home-manager channel at `home-manager` which is pointed at the unstable channel. - -- `home-directory` is the associated home directory of the home-manager. -It is set for `config.home.directory` at the home-manager configuration. -By default, it will be set at `/home/$USERNAME`. - -- `username` is the username of the home-manager user to be used for `config.home.username` at the home-manager configuration. -If unset, it will use the table key. -In the above example, the unset value would be `foo-dogsquared`. - -- `modules` is an extra list of modules to be imported with the configuration. - -- `deploy` is pretty similar to the previous configuration setting that it sets certain options for deploy-rs. diff --git a/docs/content/en-US/04-nixos-modules/03-disko/index.adoc b/docs/content/en-US/04-nixos-modules/03-disko/index.adoc index df8d3988..de1cb5a9 100644 --- a/docs/content/en-US/04-nixos-modules/03-disko/index.adoc +++ b/docs/content/en-US/04-nixos-modules/03-disko/index.adoc @@ -13,7 +13,7 @@ Here's an example configuration for my desktop workstation. .`./hosts/ni/disko.nix` [source, nix] ---- -include::../../../../../hosts/ni/disko.nix[] +include::../../../../../configs/nixos/ni/disko.nix[] ---- Take note the disko NixOS module already handles NixOS filesystem configuration (i.e., `fileSystems.`) so if you have already have an existing hardware configuration, you have to delete it to prevent conflicting fstab configuration. diff --git a/docs/content/en-US/06-using-parts-of-my-configuration/index.adoc b/docs/content/en-US/06-using-parts-of-my-configuration/index.adoc index ef6a6a27..7dd0b5de 100644 --- a/docs/content/en-US/06-using-parts-of-my-configuration/index.adoc +++ b/docs/content/en-US/06-using-parts-of-my-configuration/index.adoc @@ -56,9 +56,7 @@ In that case, you can simply plop them into your list of imports for your NixOS ---- { imports = [ - inputs.foo-dogsquared-nixos-config.nixosModules.programs - inputs.foo-dogsquared-nixos-config.nixosModules.services - inputs.foo-dogsquared-nixos-config.nixosModules.workflows + inputs.foo-dogsquared-nixos-config.nixosModules.default ]; # Use my GNOME desktop configuration for some reason. @@ -87,22 +85,20 @@ nix-channel --update [source, nix] ---- -import { inherit pkgs; } +import { } ---- -You can see github:{github-repo}[`./default.nix`, path=default.nix, rev=master] to see more details but there are general guidelines to the attributes that is contained in this file which is outlined in xref:../02-lay-of-the-land/04-channels-support/index.adoc[Channels support] section. +This is made with flake-compat flake which can have conflicts with the traditional method of using it. Here's an example snippet in a NixOS config making use of my configuration without flakes: [source, nix] ---- let - foo-dogsquared-nixos-config = import { inherit pkgs; }; + foo-dogsquared-nixos-config = import { }; in { imports = [ - foo-dogsquared-nixos-config.modules.programs - foo-dogsquared-nixos-config.modules.services - foo-dogsquared-nixos-config.modules.workflows + foo-dogsquared-nixos-config.nixosModules.default ]; # Still using my GNOME desktop configuration for some reason. @@ -122,15 +118,13 @@ Here's a snippet of using it as part of a NixOS configuration. [source, nix] ---- let - foo-dogsquared-nixos-config = import (fetchTarball "{canonical-flake-url-tarball-specific}") { inherit pkgs; }; + foo-dogsquared-nixos-config = import (fetchTarball "{canonical-flake-url-tarball-specific}") { }; in { imports = [ - foo-dogsquared-nixos-config.modules.programs - foo-dogsquared-nixos-config.modules.services - foo-dogsquared-nixos-config.modules.workflows + foo-dogsquared-nixos-config.nixosModules.default ]; - # Still using my GNOME desktop configuration for some reason. + # GNOME4LIFE!!! workflows.workflows.a-happy-gnome.enable = true; } ---- diff --git a/docs/content/en-US/08-acknowledgement/index.adoc b/docs/content/en-US/08-acknowledgement/index.adoc index 30dbd9d0..0ceb982a 100644 --- a/docs/content/en-US/08-acknowledgement/index.adoc +++ b/docs/content/en-US/08-acknowledgement/index.adoc @@ -20,4 +20,4 @@ I may have to use this at some point. footnote:[Unfortunately, digga is consider * github:hlissner/dotfiles/[hlissner's dotfiles], the original inspiration for this functional abomination of a configuration. The very reason why I'm using NixOS after seeing their configuration and what it can be setup with one command. -Very nice. +Anyways, screw you for bringing me into this [.line-through]#hell# rabbit hole.