Experimental NixOS repo
Find a file
Timothy DeHerrera 5b46f6a038
Merge pull request #47 from nrdxp/fix-system-arg
Revert "Add extraArgs to lib.nixosSystem call..."
2020-12-28 16:39:27 -07:00
.github/ISSUE_TEMPLATE Update issue templates 2020-01-04 17:21:01 -07:00
cachix format: apply nixpkgs-fmt 2020-07-30 22:17:28 -06:00
hosts Revert "Add extraArgs to lib.nixosSystem call..." 2020-12-28 16:36:49 -07:00
lib flake: clean up by moving implementation to utils 2020-12-25 12:53:57 -07:00
local change formatter to nixfmt 2020-01-03 22:06:31 -07:00
modules gamemode: remove pkg from packages 2020-08-04 00:45:33 -06:00
overlays kakoune: fix vertical selection shortcut 2020-12-27 20:04:32 -07:00
pkgs pkgs: add platform information to all packages 2020-12-27 21:07:40 -07:00
profiles virt: enable container configs 2020-12-27 17:38:49 -07:00
users direnv: use nix-direnv instead ad hoc hack 2020-12-25 22:09:09 -07:00
.envrc shell: don't overwrite nix by default 2020-12-19 18:11:21 -07:00
.gitattributes .gitattributes: match the entire secrets/** subtree 2020-08-09 03:17:07 +02:00
.gitignore direnv: add flake profile so shell isn't GC'd 2020-07-20 18:53:21 -06:00
cachix.nix format: apply nixpkgs-fmt 2020-07-30 22:17:28 -06:00
configuration.nix shell: add a nixpkgs-compat file 2020-12-27 00:40:12 -07:00
CONTRIBUTING.md replace nixfmt with nixpkgs-fmt 2020-07-30 22:07:59 -06:00
COPYING init 2019-12-02 22:18:30 -07:00
DOC.md README.md: explain externModules 2020-12-28 15:31:17 -07:00
flake.lock flake: initial multiarch support 2020-12-27 21:19:45 -07:00
flake.nix flake: add externModules list 2020-12-28 15:07:15 -07:00
nixpkgs-compat.nix shell: add a nixpkgs-compat file 2020-12-27 00:40:12 -07:00
README.md README.md: add some useful links 2020-12-28 15:27:32 -07:00
shell.nix shell: add a nixpkgs-compat file 2020-12-27 00:40:12 -07:00

Since flakes are still quite new, I've listed some learning resources below.

Introduction

Herein lies a NixOS configuration template using the new flakes mechanism. Its aim is to provide a generic repository which neatly separates concerns and allows one to get up and running with NixOS faster than ever, while keeping your code clean and organized.

Some key advantages include:

  • A single home for all your Nix expressions, easily sharable and portable!
  • Skip the boilerplate, simply use the included nix-shell or direnv profile and get up and running with flakes right away.
  • Thanks to flakes, the entire system is more deterministic.
  • Systems defined under hosts are automatically imported into nixosConfigurations, ready to deploy.
  • Profiles are a simple mechanism for using portable code across machines, and are available to share via the nixosModules.profiles output.
  • Defined packages and modules, are automatically wired and available from anywhere. They are also sharable via their respective flake outputs.
  • Easily override packages from different nixpkgs versions.
  • Keep user configuration isolated and easily reusable by taking advantage of user profiles and home-manager.
  • Overlay files are automatically available and sharable.
  • Automatic NUR support.

For a more detailed explanation of the code structure, check out the docs.

⚠ Advisory

Flakes are still new, so not everything works yet. However, it has been to merged in nixpkgs via pkgs.nixFlakes. Thus, this project should be considered experimental, until flakes become the default.

Also, flakes are meant to deprecate nix-channels. It's recommend not to install any. If your really want them, they should work if you hook them into NIX_PATH.

Setup

There are many way to get up and running. You can fork this repo or use it as a template. There is a bare branch if you want to start with a completely empty template and make your own profiles from scratch.

You'll need to have NixOS already installed since the nixos-install script doesn't yet support flakes.

If you already have nix-command setup you can:

# for standard template
nix flake new -t "github:nrdxp/nixflk" flk

# for bare template
nix flake new -t "github:nrdxp/nixflk/bare" flk

However you decide to acquire the repo, once you have it, you'll want to move or symlink it to /etc/nixos for ease of use. Once inside:

nix-shell # or `direnv allow` if you prefer

From here it's up to you. You can deploy the barebones NixOS host and build from there, or you can copy your existing configuration.nix. You'll probably at least need to setup your fileSystems and make sure the locale is correct.

Once you're ready to deploy you can use nixos-rebuild if your NixOS version is recent enough to support flakes, or the shell.nix defines its own flk command in case you need it.

# Usage: flk host {switch|boot|test|iso}
flk <host-filename> test

Build an ISO

flk iso

You can make an ISO and customize it by modifying the niximg file:

Use a Package from NUR

NUR is wired in from the start. For safety, nothing is added from it by default, but you can easily pull packages from inside your configuration like so:

{ pkgs, ... }:
{
  environment.systemPackages = with pkgs; [ nur.repos.<owner>.<package> ];
}

Resources

Flake Talk:

Flake talk at NixConf

License

This software is licensed under the MIT License.

Note: MIT license does not apply to the packages built by this configuration, merely to the files in this repository (the Nix expressions, build scripts, NixOS modules, etc.). It also might not apply to patches included here, which may be derivative works of the packages to which they apply. The aforementioned artifacts are all covered by the licenses of the respective packages.