From 53fc53d5c4419573c9c9c43e5f936a4c65b24464 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jalil=20David=20Salam=C3=A9=20Messina?= Date: Wed, 31 Jan 2024 22:17:28 +0100 Subject: [PATCH] feat(docs): Improving documentation c: --- docs/src/SUMMARY.md | 5 +- docs/src/configuration-overview.md | 88 ++++++++++++++++++++++++++++++ 2 files changed, 91 insertions(+), 2 deletions(-) create mode 100644 docs/src/configuration-overview.md diff --git a/docs/src/SUMMARY.md b/docs/src/SUMMARY.md index d66231c..9af3e96 100644 --- a/docs/src/SUMMARY.md +++ b/docs/src/SUMMARY.md @@ -1,4 +1,5 @@ # Summary -- [NixOS Module Options](./nixos-options.md) -- [Home Manager Module Options](./home-options.md) +- [Nix Based Configuration](./configuration-overview.md) + - [NixOS Module Options](./nixos-options.md) + - [Home Manager Module Options](./home-options.md) diff --git a/docs/src/configuration-overview.md b/docs/src/configuration-overview.md new file mode 100644 index 0000000..ba1c87b --- /dev/null +++ b/docs/src/configuration-overview.md @@ -0,0 +1,88 @@ +# Nix Based Configuration + +I use [NixOS](https://nixos.org) and +[home-manager](https://github.com/nixos-community/home-manager) to manage my +system and user configuration respectively. You can see what options I have +added to configure the system and user configuration in the next chapters. + +## How to Use + +If you are not me, then you probably shouldn't use this, but feel free to draw +inspiration from what I have done c:. + +First you want to see what your environment is; if you are using NixOS then you +want to look at the [NixOS Module Setup](#nixos-module-setup), if you are just +using home-manager, then you should look at the [homa-manager Module +Setup](#home-manager-module-setup). + +### NixOS Module Setup + +> Although I am talking about the NixOS module setup, this uses both NixOS and +> home-manager, so you can (and should) use both modules. + +#### Setup from LiveISO + +Follow the [NixOS Manual](https://nixos.org/manual/nixos/stable) until before +you run `nixos-generate-config`. + +First you will want to create a directory for your NixOS configuration. I like +using `~/.config/nixos`. You then want to run `nixos-generate-config --root /mnt +--dir ~/.config/nixos` (assuming you mounted your filesystem to `/mnt`). Now you +have `configuration.nix` and `hardware-configuration.nix` inside +`~/.config/nixos`. I like renaming `configuration.nix` to `default.nix` and +putting it in a folder with the same hostname as the machine (See [the source +repo](https://github.com/jalil-salame/configuration.nix/tree/main/machines)). + +Now you can add a `flake.nix` file to your `~/.config/nixos` and make it a flake +based configuration. This is the general structure you'll want: + +```nix +{ + inputs.nixpkgs.url = "nixpkgs/nixos-unstable"; + # My custom configuration module + inputs.config.url = "github:jalil-salame/configuration.nix"; + inputs.config.inputs.follows.nixpkgs = "nixpkgs"; + + outputs = { self, nixpkgs, config }: let + pc = import (./. + hostname); + hostname = "nixos"; + system = "x86_64-linux"; + overlays = builtins.attrValues config.overlays; + config.allowUnfreePredicate = pkg: builtins.elem (lib.getName pkg) [ + "steam-original" + ]; + pkgs = import nixpkgs { inherit system overlays config; }; + in { + nixosConfigurations.${hostname} = nixpkgs.lib.nixosSystem { + inherit system pkgs; + modules = [ + # My configuration module (includes home-manager) + config.nixosModules.nixosModule + # Results from `nixos-generate-config` + pc + # Custom options (see module configuration options) + { + # Enable my custom configuration + jconfig.enable = true; + jconfig.gui.enable = true; # Enable gui environment + + # Add users to use with home-manager + users.users = {}; + + # Add home-manager users configuration (here you can enable jhome options) + home-manager.users = {}; + # home-manager globally set options + home-manager.sharedModules = [{ jhome.hostName = hostname; }]; + } + ]; + }; + }; +} +``` + +### home-manager Module Setup + +If you are not using NixOS, then you probably want to only use the home-manager +configuration. In that case, you want to use the +`nixosModules.homeManagerModuleSandalone` in your `home-manager` configuration, +and probably disable GUI applications all together `jhome.gui.enable = false`.