add documentation and nix with flakes to devshell

This commit is contained in:
Gabriel Fontes 2021-12-16 19:12:15 -03:00
parent 0d5ca8396c
commit cfbd78cda2
No known key found for this signature in database
GPG key ID: 2E54EA7BFE630916
4 changed files with 46 additions and 0 deletions

28
README.md Normal file
View file

@ -0,0 +1,28 @@
# Nix Starter Config
This is a minimal (yet complete) nix flake for getting started with NixOS + home-manager.
## What this provides
- NixOS configuration on `configuration.nix`, accessible via `nixos-rebuild --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`
- Dev shell for bootstrapping, accessible via `nix develop`
## How to get started
Assuming you have a basic NixOS installation up and running:
### Getting the repo
- [Install git](https://nixos.wiki/wiki/git)
- 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`
- If you're already using home-manager, add your stuff from `~/.config/nixpkgs/home.nix` to `home.nix`
- Take a look at `flake.nix`, filling out stuff marked by `TODO`s
- Create a remote repo (github, gitlab, sr.ht, etc) and push your changes for safekeeping
### Bootstrapping
- Run `nix-shell` (or `nix develop`, if you already have flakes enabled) to bootstrap into flake-enabled nix and home-manager.
- Run `sudo nixos-rebuild switch --flake .` to apply system configuration
- Run `home-manager switch --flake .` to apply home configuration
- Reboot!

View file

@ -22,6 +22,14 @@
# Comment out if you wish to disable unfree packages for your system
nixpkgs.config.allowUnfree = true;
# Enable flakes and 'nix' command
nix = {
package = pkgs.nixFlakes;
extraOptions = ''
experimental-features = nix-command flakes
'';
};
# This will make all users source .nix-profile on login, activating home
# manager automatically. Will allow you to use home-manager standalone on
# setups with opt-in persistance.

View file

@ -71,6 +71,9 @@
// utils.lib.eachDefaultSystem (system:
let
pkgs = import nixpkgs { inherit system; overlays = self.overlays; };
nix = pkgs.writeShellScriptBin "nix" ''
exec ${pkgs.nixFlakes}/bin/nix --experimental-features "nix-command flakes" "$@"
'';
hm = home-manager.defaultPackage."${system}";
in
{

7
shell.nix Normal file
View file

@ -0,0 +1,7 @@
(import (
fetchTarball {
url = "https://github.com/edolstra/flake-compat/archive/12c64ca55c1014cdc1b16ed5a804aa8576601ff2.tar.gz";
sha256 = "0jm6nzb83wa6ai17ly9fzpqc40wg1viib8klq8lby54agpl213w5"; }
) {
src = ./.;
}).shellNix