Code Monkey home page Code Monkey logo

dotfiles's Introduction

Nix Flakes-based System & Home Configuration, Dotfiles, and Install Scripts

CI Status

CI Workflow Target Platform CI Job Status
NixOS System Configuration NixOS NixOS
Home Manager User Configuration Linux / macOS Nix Home Manager
Nix-on-Droid Android (not implemented yet)
Legacy Install Scripts Linux + distro package manager Alpine Arch Linux Debian Ubuntu
Legacy Install Scripts macOS + HomeBrew macOS

Overall status: Actions Status

Overview

This repo contains my personal system configuration that consists of:

It includes a Nix Flake file which acts as an entrypoint for Nix and defines the following outputs:

  • nixosConfigurations.* - NixOS system configurations
  • homeConfigurations.* - Nix Home Manager configuration
  • nixOnDroidConfigurations.* - Nix-on-Droid configuration for Nix-powered Android shell environment

Basic Usage

This is how I apply my Nix configuration on my machines. If you fork this repo (to modify it as per your needs), you should be able to use the same commands as they're written in a generic way.

Apply NixOS system configuration

sudo nixos-rebuild switch --flake "$CFG#$(hostname)"

Apply Home Manager user config

home-manager switch --flake $CFG#$USER

Manually update all Nix Flake inputs

nix flake update $CFG

The versions of most software installed on the system are determined by the Nixpkgs commit hash stored in the flake.lock file. Running the command above will update it (and the other flake inputs) to latest version.

Getting started

Clone the repo, e.g. to $HOME/code/repos:

git clone https://github.com/PetarKirov/dotfiles

Copy a machine configuration and modify it as needed:

cd dotfiles
cp -r nixos/machines/zlx-nixos-desktop2 nixos/machines/my-machine
# Edit nixos/machines/my-machine/*

Nix Ecosystem Docs

Installing NixOS

  1. Boot into a live NixOS environment (either a live CD containing the NixOS installer or an existing NixOS installation on another drive)

    • If you're using a live CD environment, be sure to update /etc/nixos/configuration.nix like so:
    # Open the file and change it to the snippet below:
    sudo nvim /etc/nixos/configuration.nix
    
    # Once the file has been updated and saved, apply the settings:
    sudo nixos-rebuild switch
    { config, pkgs, ... }:
    {
      imports = [ <nixpkgs/nixos/modules/installer/cd-dvd/installation-cd-graphical-gnome.nix> ];
      nix = {
        trustedUsers = [ "root" "nixos" ];
        extraOptions = ''
          experimental-features = nix-command flakes
        '';
      };
    }

    These settings will ensure that you're using a recent enough version of Nix with the necessary features enabled.

  2. Clone this repo and cd into it: git clone https://github.com/PetarKirov/dotfiles && cd dotfiles

  3. Assuming that you're installing NixOS on a clean drive, run the automated ZFS partitioning tool:

    • Run it in "dry-run" mode to get information about your system: ./utils/make_zfs.bash
    • If you need to partition your drive run: env DRY_RUN=0 KEEP_PARTITIONS=0 ./utils/make_zfs.bash
    • If your drive is already partitioned, run: env DRY_RUN=0 ./utils/make_zfs.bash
  4. Now there should be a root ZFS partition mounted at /mnt. To install NixOS there, run:

Bash $
mkdir ./nixos/machines/my-machine
sudo nixos-generate-config --root /mnt --dir  /..$(git rev-parse --show-toplevel)/nixos/machines/my-machine
Fish โ‹Š>
mkdir ./nixos/machines/my-machine
sudo nixos-generate-config --root /mnt --dir  /..(git rev-parse --show-toplevel)/nixos/machines/my-machine

Your files were automatically generated. Now they could be manually changed!

note: Do not forget to set random hostId. You can use the following command for generation:

tr -dc 0-9a-f < /dev/urandom | head -c 8

With everything configured we can continue with:

Bash $
sudo nixos-install --impure --flake '.#my-machine' --root /mnt
Fish โ‹Š>
sudo nixos-install --impure --flake '.#my-machine' --root /mnt

(Replace my-machine in the command above with the name of the machine config you want to apply.)

  1. Now that NixOS is installed, chroot into (using nixos-enter) and change the password of the default user:

    sudo nixos-enter --root /mnt
    passwd zlx
    exit

    (Replace zlx in the command above with the your username.)

  2. Copy the dotfiles repo inside the user's home dir:

    mkdir -p /mnt/home/$USER/code/repos
    cp -a ../dotfiles /mnt/home/$USER/code/repos
  3. Build the home-manager config and copy it to the new Nix Store:

    nix build ".#homeConfigurations.$USER.activationPackage"
    sudo nix copy --to /mnt ./result/ --no-check-sigs
  4. Reboot into the new Nix install, open a terminal, cd into the dotfiles dir and activate the home-manager config:

    cd /home/$USER/code/repos/dotfiles
    nix path-info ".#homeConfigurations.$USER.activationPackage" | xargs -I@@ sh -c '@@/activate'
  5. You're done!

dotfiles's People

Contributors

petarkirov avatar emilivanichkovv avatar

Stargazers

Roman 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.