Giter Site home page Giter Site logo

nixos-pc's Introduction

nixos-pc

NixOS configs for:

  • blackberry: Raspberry pi 3b+ (with custom installation instructions) running a local backup service.
  • neon: mini home server.
  • polonium: Laptop host (nvidia gpu).
  • radon: Main host (amd gpu)
  • xenon: Server containing mail, password service, and backups of local devices.

Flakes

Installation

Clone this repo, get in the project root, and execute:

sudo nixos-rebuild switch --flake .#<HOST>
home-manager switch --flake .#<USER>

For available HOSTs, check the /hosts/ directory.

For available USERs, check the /users/ directory.

Installing from nixos live usb

Clone this repo, get in the project root, and execute:

sudo mount /dev/<ROOT_PARTITION> /mnt
sudo mount /dev/<bOOT_PARTITION> /mnt/boot

Next, display the hardware configuration from:

sudo generate-nixos-conf --show-hardware-conf

Check for the UUID's of the /mnt and /mnt/boot filesystems. Place those UUID's inside the hardware-configuration.nix from this repo.

From the root of this project:

sudo nixos-install --flake .#<HOST>

After installation, do not forget to clone this repo in the installed NixOS and execute:

home-manager switch --flake .#<USER>

General info

Installing NixOS on a running instance

I have never seen a VPS provider which provides NixOS images out of the box. You can pay to provide your own image. Alternatively, a much better option is to use nixos-infect.

Upgrading NixOS

NixOS brings new releases on the 5'th and 11'th month of each year. To upgrade, we must change the nixos channel.

  1. Check your current nixos channel with:
sudo nix-channel --list | grep nixos
  1. Change using:
sudo nix-channel --add https://channels.nixos.org/[SOME-NAME-HERE] nixos

Common names follow format nixos-[VERSION]. 3. Then, upgrade using:

sudo nixos-rebuild switch --upgrade # regular NixOS
sudo nixos-rebuild switch --flake .#[FLAKE] --upgrade # flakes

Regular NixOS

When not dealing with flakes, we have only 3 config files:

  • /etc/nixos/configuration.nix (global definitions)
  • ~/.config/nixpkgs/home.nix (local definitions)

Installation

Get the configuration.nix of any host in the repo's /hosts/ repository on your device in /etc/nixos, then type:

sudo nixos-rebuild switch

Then get the home.nix from any user in the repo's /users/ repository on your device in ~/.config/nixpkgs/home.nix, then type:

home-manager switch

Cheatsheet

nix-channel --update         # Update installed packages (requires rebuild switch for changes to take effect)
nix-collect-garbage -d       # removes previous build leftovers
nix search <package name>    # search for a nix package
man configuration.nix        # docs for /etc/nixos/configuration.nix. Note: the paths below each option are the same in the nixpkgs repo.
man home-configuration.nix   # docs for home-manager, in ~/.config/nixpkgs/home.nix

Recover

When developing, the most important is knowing your way back in case of a screw-up. NixOS has us covered:

sudo nixos-rebuild switch --rollback
sudo nixos-rebuild boot --rollback
...

The rollback commands can be repeatedly executed to keep rolling back to previous versions of your OS installation. This does not change /etc/nixos/configuration.nix, however.

Errors

DBI connect

When running some command (e.g. git):

$ git
DBI connect('dbname=/nix/var/nix/profiles/per-user/root/channels/nixos/programs.sqlite','',...) failed: unable to open database file at /run/current-system/sw/bin/command-not-found line 13.
cannot open database '/nix/var/nix/profiles/per-user/root/channels/nixos/programs.sqlite' at /run/current-system/sw/bin/command-not-found line 13.

Fix: This happens when the root user is missing the nixos channel. You can fix this by adding a channel and naming it nixos:

sudo nix-channel --add https://nixos.org/channels/nixos-VERSION nixos
sudo nix-channel --update nixos

Resources

nixos-pc's People

Contributors

sebastiaan-alvarez-rodriguez avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.