Experimental NixOS repo
Find a file
2021-01-03 00:02:28 -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
compat factor out a generic fetch from nixpkgs-compat 2020-12-28 23:08:11 -07:00
hosts hosts: left out of #66 by mistake 2020-12-31 14:11:32 -07:00
lib ref: remove overlay xref to pkgs 2020-12-30 11:53:53 -05: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 overlays: fix darkwin builds 2021-01-03 00:02:28 -07:00
pkgs miningcore: mark as broken 2021-01-03 00:00:46 -07:00
profiles editorconfig: fixup 2020-12-30 01:00:12 -07:00
users direnv: use nix-direnv instead ad hoc hack 2020-12-25 22:09:09 -07:00
.editorconfig editorconfig: fixup 2020-12-30 01:00:12 -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
.pre-commit-config.yaml hooks: declare nixpkgs-fmt pre-commit hook 2020-12-30 01:47:42 -07:00
cachix.nix format: apply nixpkgs-fmt 2020-07-30 22:17:28 -06:00
configuration.nix configuration.nix: update home-manager url 2020-12-30 17:47:49 +01:00
CONTRIBUTING.md hooks: declare nixpkgs-fmt pre-commit hook 2020-12-30 01:47:42 -07:00
COPYING init 2019-12-02 22:18:30 -07:00
DOC.md DOC.md: update home-manager url 2020-12-30 17:47:41 +01:00
flake.lock shell: switch to using mkDevShell 2020-12-28 23:12:27 -07:00
flake.nix flake: add pkgs back to overlays 2020-12-31 14:02:19 -07:00
README.md README.md: update home-manager url 2020-12-30 17:47:46 +01:00
shell.nix don't be fancy 2020-12-31 12:41:01 -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 recommended not to install any. If your really want them, they should work if you hook them into NIX_PATH.

Sharing

One of the great benefits of flakes is the ability to easily share your user defined packages, modules and other nix expressions without having to merge anything upstream. In that spirit, everything defined in this flake is usable from other flakes. So even if you don't want to use this project as a template, you can still pull in any useful modules, packages or profiles defined here.

From the command line:

# to see what this flake exports
nix flake show "github:nrdxp/nixflk"

# run an app
nix run "github:nrdxp/nixflk#someApp"

# start a dev shell for a given derivation
nix develop "github:nrdxp/nixflk#somePackage"

# a nix shell with the package in scope
nix shell "github:nrdxp/nixflk#somePackage"

From within a flake:

{
  inputs.nixflk.url = "github:nrdxp/nixflk";

  outputs = { self, nixpkgs, nixflk, ... }:
  {
    nixosConfigurations.example = nixpkgs.lib.nixosSystem {
      # ...
        modules = [
        nixflk.nixosModules.someModule
        ({
          nixpkgs.overlays = [ nixflk.overlay nixflk.overlays.someOverlay ];
        })
        # ...
      ];
    };
  };
}

Setup

There are a few ways 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. The only hard requirement is nix itself. The shell.nix will pull in everything else.

Flake Templates

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

Nix Only

Once you have this repo, you'll want to move or symlink it to /etc/nixos for ease of use. Once inside:

# This will setup nix-command and pull in the needed tools
nix-shell # or `direnv allow` if you prefer

# quick way to setup your fileSystems (assuming they are partioned):
sudo mount /dev/<install-drive> /mnt
nixos-generate-config --root /mnt --show-hardware-config > hosts/yourConfig.nix

# Edit your config to add a bootloader
$EDITOR hosts/yourConfig.nix

# The following should work fine for EFI systems.
# boot.loader.systemd-boot.enable = true;
# boot.loader.efi.canTouchEfiVariables = true;

# Set your locale
$EDITOR local/locale.nix

# install NixOS to bare metal
flk install yourConfig # deploys hosts/yourConfig.nix

# if you already have NixOS and just want to deploy your new setup
flk yourConfig switch

Build an ISO

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

flk iso

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.