diff --git a/README.md b/README.md new file mode 100644 index 0000000..9b86c7f --- /dev/null +++ b/README.md @@ -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! diff --git a/configuration.nix b/configuration.nix index aed4dd0..ed0ac62 100644 --- a/configuration.nix +++ b/configuration.nix @@ -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. diff --git a/flake.nix b/flake.nix index 7d74f9f..9a40f43 100644 --- a/flake.nix +++ b/flake.nix @@ -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 { diff --git a/shell.nix b/shell.nix new file mode 100644 index 0000000..61a66c5 --- /dev/null +++ b/shell.nix @@ -0,0 +1,7 @@ +(import ( + fetchTarball { + url = "https://github.com/edolstra/flake-compat/archive/12c64ca55c1014cdc1b16ed5a804aa8576601ff2.tar.gz"; + sha256 = "0jm6nzb83wa6ai17ly9fzpqc40wg1viib8klq8lby54agpl213w5"; } +) { + src = ./.; +}).shellNix