some more docs, and a minimal working system config
This commit is contained in:
parent
d30f2b867a
commit
2ac6ef6c55
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
result
|
||||||
|
*.qcow2
|
46
README.md
46
README.md
|
@ -6,14 +6,15 @@ This is a minimal (yet complete) nix flake for getting started with NixOS + home
|
||||||
|
|
||||||
- NixOS configuration on `configuration.nix`, accessible via `nixos-rebuild --flake`
|
- NixOS configuration on `configuration.nix`, accessible via `nixos-rebuild --flake`
|
||||||
- Home-manager configuration on `home.nix`, accessible via `home-manager --flake`
|
- Home-manager configuration on `home.nix`, accessible via `home-manager --flake`
|
||||||
- Basic boilerplate for adding custom packages (under `pkgs`) and overlays (on `overlays.nix`). Acessible on your system, home config, as well as `nix build .#package-name`
|
- Basic boilerplate for adding custom packages (under `pkgs`) and overlays (under `overlays`). Acessible on your system, home config, as well as `nix build .#package-name`
|
||||||
|
- Boilerplate for custom NixOS (`modules/nixos`) and home-manager (`modules/home-manager`) modules
|
||||||
- Dev shell for bootstrapping, accessible via `nix develop`
|
- Dev shell for bootstrapping, accessible via `nix develop`
|
||||||
|
|
||||||
## How to get started
|
## Getting started
|
||||||
|
|
||||||
Assuming you have a basic NixOS installation up and running:
|
Assuming you have a basic NixOS installation up and running:
|
||||||
|
|
||||||
### Getting the repo
|
### The repo
|
||||||
- [Install git](https://nixos.wiki/wiki/git)
|
- [Install git](https://nixos.wiki/wiki/git)
|
||||||
- Clone this repo to somewhere acessible (i usually have a `/dotfiles` folder for this)
|
- Clone this repo to somewhere acessible (i usually have a `/dotfiles` folder for this)
|
||||||
- Add stuff you currently have on `/etc/nixos/configuration.nix` to `configuration.nix`, and `/etc/nixos/hardware-configuration.nix` to `hardware-configuration.nix`
|
- Add stuff you currently have on `/etc/nixos/configuration.nix` to `configuration.nix`, and `/etc/nixos/hardware-configuration.nix` to `hardware-configuration.nix`
|
||||||
|
@ -26,3 +27,42 @@ Assuming you have a basic NixOS installation up and running:
|
||||||
- Run `sudo nixos-rebuild switch --flake .` to apply system configuration
|
- Run `sudo nixos-rebuild switch --flake .` to apply system configuration
|
||||||
- Run `home-manager switch --flake .` to apply home configuration
|
- Run `home-manager switch --flake .` to apply home configuration
|
||||||
- Reboot!
|
- Reboot!
|
||||||
|
|
||||||
|
### How to's
|
||||||
|
|
||||||
|
#### Customize your NixOS configuration
|
||||||
|
|
||||||
|
Use the `configuration.nix` file.
|
||||||
|
|
||||||
|
For a list of options, see `man configuration.nix`. Also see [the manual](https://nixos.org/manual/nixos/stable/index.html#ch-configuration).
|
||||||
|
|
||||||
|
### Customize your home-manager configuration
|
||||||
|
|
||||||
|
Use the `home.nix` file.
|
||||||
|
|
||||||
|
For a list of options, see `man home-configuration.nix`. Also see [the manual](https://rycee.gitlab.io/home-manager/index.html#ch-usage).
|
||||||
|
|
||||||
|
|
||||||
|
### Adding packages
|
||||||
|
|
||||||
|
Create a folder inside `pkgs`, and add a `default.nix` file containing a derivation. Be sure to also `callPackage` them on `pkgs/default.nix`.
|
||||||
|
|
||||||
|
See [the manual](https://nixos.org/manual/nixpkgs/stable/).
|
||||||
|
|
||||||
|
### Adding overlays
|
||||||
|
|
||||||
|
Use the `overlays/default.nix` file. If it gets too big, feel free to split it up.
|
||||||
|
|
||||||
|
If you're applying patches, i recommend you keep the patches on the `overlays` folder as well.
|
||||||
|
|
||||||
|
See [the wiki article](https://nixos.wiki/wiki/Overlays).
|
||||||
|
|
||||||
|
### Adding your own modules
|
||||||
|
|
||||||
|
Create a file for them on either `modules/nixos` or `modules/home-manager`. Be sure to also add them to the listing at `modules/nixos/default.nix` or `modules/home-manager/default.nix`.
|
||||||
|
|
||||||
|
See [the wiki article](https://nixos.wiki/wiki/Module).
|
||||||
|
|
||||||
|
### Adding more hosts or users, or multiple files
|
||||||
|
|
||||||
|
If you're starting to manage more than one host or user (or splitting up a big configuration in multiple files), you might want to create a `hosts` and/or `users` folder, and move your configs there. Be sure to change the path on `flake.nix` as well.
|
||||||
|
|
|
@ -19,10 +19,31 @@
|
||||||
# TODO: Set your hostname
|
# TODO: Set your hostname
|
||||||
networking.hostName = "cool-computer";
|
networking.hostName = "cool-computer";
|
||||||
|
|
||||||
# Comment out if you wish to disable unfree packages for your system
|
# TODO: This is just an example, be sure to use whatever bootloader you prefer
|
||||||
|
boot.loader.systemd-boot.enable = true;
|
||||||
|
|
||||||
|
# TODO: Configure your users as usual.
|
||||||
|
users.users = {
|
||||||
|
you = {
|
||||||
|
isNormalUser = true;
|
||||||
|
openssh.authorizedKeys.keys = [
|
||||||
|
# Add your SSH public key(s) here.
|
||||||
|
"ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQDci4wJghnRRSqQuX1z2xeaUR+p/muKzac0jw0mgpXE2T/3iVlMJJ3UXJ+tIbySP6ezt0GVmzejNOvUarPAm0tOcW6W0Ejys2Tj+HBRU19rcnUtf4vsKk8r5PW5MnwS8DqZonP5eEbhW2OrX5ZsVyDT+Bqrf39p3kOyWYLXT2wA7y928g8FcXOZjwjTaWGWtA+BxAvbJgXhU9cl/y45kF69rfmc3uOQmeXpKNyOlTk6ipSrOfJkcHgNFFeLnxhJ7rYxpoXnxbObGhaNqn7gc5mt+ek+fwFzZ8j6QSKFsPr0NzwTFG80IbyiyrnC/MeRNh7SQFPAESIEP8LK3PoNx2l1M+MjCQXsb4oIG2oYYMRa2yx8qZ3npUOzMYOkJFY1uI/UEE/j/PlQSzMHfpmWus4o2sijfr8OmVPGeoU/UnVPyINqHhyAd1d3Iji3y3LMVemHtp5wVcuswABC7IRVVKZYrMCXMiycY5n00ch6XTaXBwCY00y8B3Mzkd7Ofq98YHc= (none)"
|
||||||
|
];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
# This setups SSH for the system (with SSH keys ONLY). Feel free to remove if you don't need it.
|
||||||
|
services.openssh = {
|
||||||
|
enable = true;
|
||||||
|
passwordAuthentication = false;
|
||||||
|
permitRootLogin = "no";
|
||||||
|
};
|
||||||
|
|
||||||
|
# Remove if you wish to disable unfree packages for your system
|
||||||
nixpkgs.config.allowUnfree = true;
|
nixpkgs.config.allowUnfree = true;
|
||||||
|
|
||||||
# Enable flakes and 'nix' command
|
# Enable flakes and new 'nix' command
|
||||||
nix = {
|
nix = {
|
||||||
package = pkgs.nixFlakes;
|
package = pkgs.nixFlakes;
|
||||||
extraOptions = ''
|
extraOptions = ''
|
||||||
|
@ -42,6 +63,4 @@
|
||||||
nix.registry = lib.mapAttrs' (n: v:
|
nix.registry = lib.mapAttrs' (n: v:
|
||||||
lib.nameValuePair ("${n}") ({ flake = inputs."${n}"; })
|
lib.nameValuePair ("${n}") ({ flake = inputs."${n}"; })
|
||||||
) inputs;
|
) inputs;
|
||||||
|
|
||||||
system.stateVersion = "22.05";
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
|
|
||||||
outputs = { self, nixpkgs, home-manager, utils, ... }@inputs: {
|
outputs = { self, nixpkgs, home-manager, utils, ... }@inputs: {
|
||||||
# Overlayed packages
|
# Overlayed packages
|
||||||
overlay = (import ./overlays.nix);
|
overlay = (import ./overlays);
|
||||||
|
|
||||||
# This repo's overlay plus any other overlays you use
|
# This repo's overlay plus any other overlays you use
|
||||||
# If you want to use packages from flakes that are not nixpkgs (such as NUR), add their overlays here.
|
# If you want to use packages from flakes that are not nixpkgs (such as NUR), add their overlays here.
|
||||||
|
@ -42,6 +42,8 @@
|
||||||
./configuration.nix
|
./configuration.nix
|
||||||
# Adds your overlay and packages to nixpkgs
|
# Adds your overlay and packages to nixpkgs
|
||||||
{ nixpkgs.overlays = self.overlays; }
|
{ nixpkgs.overlays = self.overlays; }
|
||||||
|
# Adds your custom nixos modules
|
||||||
|
./modules/nixos
|
||||||
];
|
];
|
||||||
# Pass our flake inputs into the config
|
# Pass our flake inputs into the config
|
||||||
specialArgs = { inherit inputs; };
|
specialArgs = { inherit inputs; };
|
||||||
|
@ -62,6 +64,8 @@
|
||||||
extraModules = [
|
extraModules = [
|
||||||
# Adds your overlay and packages to nixpkgs
|
# Adds your overlay and packages to nixpkgs
|
||||||
{ nixpkgs.overlays = self.overlays; }
|
{ nixpkgs.overlays = self.overlays; }
|
||||||
|
# Adds your custom home-manager modules
|
||||||
|
./modules/home-manager
|
||||||
];
|
];
|
||||||
# Pass our flake inputs into the config
|
# Pass our flake inputs into the config
|
||||||
extraSpecialArgs = { inherit inputs; };
|
extraSpecialArgs = { inherit inputs; };
|
||||||
|
|
|
@ -1,2 +1,7 @@
|
||||||
# This should be generated with nixos-generated-config
|
# This is just an example, you should generate yours with nixos-generate-config and put it in here.
|
||||||
{}
|
{
|
||||||
|
fileSystems."/" = {
|
||||||
|
device = "/dev/sda1";
|
||||||
|
fsType = "ext4";
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
6
home.nix
6
home.nix
|
@ -4,7 +4,7 @@
|
||||||
{ inputs, lib, config, pkgs, ... }: {
|
{ inputs, lib, config, pkgs, ... }: {
|
||||||
imports = [
|
imports = [
|
||||||
# If you want to use home-manager modules from other flakes (such as nix-colors), use something like:
|
# If you want to use home-manager modules from other flakes (such as nix-colors), use something like:
|
||||||
# inputs.nix-colors.nixosModule
|
# inputs.nix-colors.homeManagerModule
|
||||||
|
|
||||||
# Feel free to split up your configuration and import pieces of it here.
|
# Feel free to split up your configuration and import pieces of it here.
|
||||||
];
|
];
|
||||||
|
@ -12,7 +12,7 @@
|
||||||
# Comment out if you wish to disable unfree packages for your system
|
# Comment out if you wish to disable unfree packages for your system
|
||||||
nixpkgs.config.allowUnfree = true;
|
nixpkgs.config.allowUnfree = true;
|
||||||
|
|
||||||
# TODO: Add stuff for your user as you see fit:
|
# Add stuff for your user as you see fit:
|
||||||
# programs.neovim.enable = true;
|
# programs.neovim.enable = true;
|
||||||
# home.packages = with pkgs; [ steam ];
|
# home.packages = with pkgs; [ steam ];
|
||||||
|
|
||||||
|
@ -22,6 +22,4 @@
|
||||||
|
|
||||||
# Nicely reload system units when changing configs
|
# Nicely reload system units when changing configs
|
||||||
systemd.user.startServices = "sd-switch";
|
systemd.user.startServices = "sd-switch";
|
||||||
|
|
||||||
home.stateVersion = "22.05";
|
|
||||||
}
|
}
|
||||||
|
|
7
modules/home-manager/default.nix
Normal file
7
modules/home-manager/default.nix
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
# Add your home-manager modules to this directory, on their own file (https://nixos.wiki/wiki/Module).
|
||||||
|
|
||||||
|
{
|
||||||
|
imports = [
|
||||||
|
# List your module files here
|
||||||
|
];
|
||||||
|
}
|
7
modules/nixos/default.nix
Normal file
7
modules/nixos/default.nix
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
# Add your NixOS modules to this directory, on their own file (https://nixos.wiki/wiki/Module).
|
||||||
|
|
||||||
|
{
|
||||||
|
imports = [
|
||||||
|
# List your module files here
|
||||||
|
];
|
||||||
|
}
|
|
@ -3,5 +3,5 @@ final: prev: {
|
||||||
# example = prev.example.overrideAttrs (oldAttrs: rec {
|
# example = prev.example.overrideAttrs (oldAttrs: rec {
|
||||||
# ...
|
# ...
|
||||||
# });
|
# });
|
||||||
} // import ./pkgs { pkgs = final; }
|
} // import ../pkgs { pkgs = final; }
|
||||||
# This line adds your custom packages to the overlay.
|
# This line adds your custom packages into the overlay.
|
Loading…
Reference in a new issue