Coder Social home page Coder Social logo

my-nixfiles's Introduction

Juca's NixOS & Home Manager Configurations

This repository contains a Nix Flake for configuring my computers and home environment. These are the computers this configuration currently manages:

Hostname OEM Model OS Role Status
nitro Acer Nitro i5-8300H Nixos Desktop WIP
pi3 Raspberry Pi Raspberry Pi 3b Dietpi Server tbd
MacbookPro Apple Macbook Pro 2008 Debian Laptop tbd
MacbookAir Apple Macbook Air 2011 NixOS Laptop tbd

Structure

The nixos/_mixins and home-manager/_mixins are a collection of generic configurations that are composited based on the arguments defined in flake.nix.

Installing ๐Ÿ’พ

  • Boot off a .iso image created by this flake using rebuild-iso (see below).
  • Put the .iso image on a USB drive
  • Boot the target computer from the USB drive
  • Run install-system <hostname> <username> from a terminal.
  • The install script uses Disko to automatically partition and format the disks then uses my flake via nixos-install to complete a full system installation
  • This flake is automatically copied to the target user's home directory as ~/Zero/nix-config
  • Make a cuppa ๐Ÿซ–
  • Reboot
  • Login and run rebuild-home (see below) from a terminal to complete the Home Manager configuration.

If the target system is booted from something other than the .iso image created by this flake, you can still install the system using the following:

curl -sL https://raw.githubusercontent.com/JucaRei/my-nixfiles/main/scripts/install.sh | bash -s <hostname> <username>
  • Run the install script ๐Ÿ“œ
  • The install script uses Disko to automatically partition and format the disks then uses my flake via nixos-install to complete a full system installation
cd nix-config
scripts/install.sh <hostname> <username>
  • Make a cuppa ๐Ÿซ–
  • Reboot

Applying Changes โœจ

I clone this repo to ~/Zero/nix-config. Home Manager and NixOS changes can be applied separately because I am planning to add support for some non-NixOS hosts.

gh repo clone JucaRei/nixos-configs ~/Zero/nix-config

NixOS โ„๏ธ

A rebuild-host alias is provided, that does the following:

sudo nixos-rebuild switch --flake $HOME/Zero/nix-config

Home Manager ๐Ÿ ๏ธ

A rebuild-home alias is provided, that does the following:

home-manager switch -b backup --flake $HOME/Zero/nix-config

ISO ๐Ÿ“€

A rebuild-iso alias is provided, that does the following:

pushd $HOME/Zero/nix-config
nix build .#nixosConfigurations.iso.config.system.build.isoImage
popd

A live image will be left in ~/$HOME/Zero/nix-config/result/iso/

More Cheatsheets

Install for single user:

sh <(curl -L https://nixos.org/nix/install) --no-daemon

Activate nix profile (and add it to the .profile)

. ~/.nix-profile/etc/profile.d/nix.sh
 
echo ". $HOME/.nix-profile/etc/profile.d/nix.sh" >> ~/.profile
echo ". $HOME/.nix-profile/etc/profile.d/nix.sh" >> ~/.bashrc
echo ". $HOME/.nix-profile/etc/profile.d/nix.sh" >> ~/.zprofile

# Open tempoary shell with nix and home-manager
nix-shell

# Remove nix (this is necessary, so home-manager can install nix)
nix-env -e nix

# Exit temporary shell
exit

# Set zsh (installed by nix) as default shell
echo ~/.nix-profile/bin/zsh | sudo tee -a /etc/shells
usermod -s ~/.nix-profile/bin/zsh $USER

Install for multi user:

sh <(curl -L https://nixos.org/nix/install) --daemon

nix environment :

nix-shell (legacy)

nix develop (new)

nix develop --extra-experimental-features nix-command --extra-experimental-features flakes

# Remove nix (this is necessary, so home-manager can install nix)
nix-env -e nix

Nix file:

mkdir -pv ~/.config/nix
touch ~/.config/nix/nix.conf

echo "experimental-features = nix-command flakes repl-flake" >> ~/.config/nix/nix.conf

Technical Details

nix-shell -p nix-info --run "nix-info -m"

Create flake file

nix flake init

Check info

nix flake metadata

Update nix flake lock file

nix flake update --recreate-lock-file

nix flake lock --update-input nixpkgs

nix flake update --commit-lock-file

Nix Repair

sudo nix-store --repair --verify --check-contents

Other :

# All as root
HOST=...  # set host variable to use proper configuration


nix-shell
git clone https://this.repo.url/ /etc/nixos # or $HOME/.setup
cd /etc/nixos # or cd $HOME/.setup 
nixos-install -v --root /mnt --impure --flake .#$HOST
nixos-install -v --root /mnt --impure --flake .#$HOST

# Reboot

What's in the box? ๐ŸŽ

Nix is configured with flake support and the unified CLI enabled.

Structure

This is the directory structure I'm using.

.
โ”œโ”€โ”€ home-manager
โ”‚   โ”œโ”€โ”€ _mixins
โ”‚   โ”‚   โ”œโ”€โ”€ console
โ”‚   โ”‚   โ””โ”€โ”€ desktop
โ”‚   โ””โ”€โ”€ default.nix
โ”œโ”€โ”€ nixos
โ”‚   โ”œโ”€โ”€ _mixins
โ”‚   โ”‚   โ”œโ”€โ”€ base
โ”‚   โ”‚   โ”œโ”€โ”€ boxes
โ”‚   โ”‚   โ”œโ”€โ”€ desktop
โ”‚   โ”‚   โ”œโ”€โ”€ services
โ”‚   โ”‚   โ””โ”€โ”€ users
โ”‚   โ”œโ”€โ”€ nitro
โ”‚   โ”œโ”€โ”€ raspberry
โ”‚   โ”œโ”€โ”€ oldmac
โ”‚   โ”œโ”€โ”€ mcbair
โ”‚   โ””โ”€โ”€ default.nix
โ”œโ”€โ”€ overlays
โ”œโ”€โ”€ pkgs
โ”œโ”€โ”€ scripts
โ””โ”€โ”€ flake.nix

The Shell ๐Ÿš

Fish shell with powerline-go and a collection of tools that deliver a somewhat "Modern Unix" experience. The base system has a firewall enabled and also includes OpenSSH, Tailscale, Podman & Distrobox and, of course, a delightfully configured nano. (Fight me! ๐ŸฅŠ)

neofetch on Designare

The Desktop ๐Ÿ–ฅ๏ธ

MATE Desktop ๐Ÿง‰ and Pantheon ๐Ÿ›๏ธ are the two desktop options available. The font configuration is common with both desktops using Work Sans and Fira Code. The usual creature comforts you'd expect to find in a Linux Desktop are integrated such as Pipewire, Bluetooth, Avahi, CUPS, SANE and NetworkManager.

Desktop System Configuration Theme
MATE MATE Install MATE Configuration Yaru Magenta (Dark)
Pantheon Pantheon Install Pantheon Configuration elementary Bubble Gum (Dark)

Eye Candy ๐Ÿ‘€๐Ÿฌ

Pantheon on Designare

TODO ๐Ÿ—’๏ธ

Hardware

Applications

  • Integrate an Emoji picker
  • Integrate AppCenter and Flathub
  • Integrate Steam

Services

  • Integrate Borg Backups using Pika or Vorta for workstations and borgmatic or Embord for servers
  • Integrate cockpit
  • Integrate fwupd
  • Integrate Keybase
  • Integrate nullmailer
  • Integrate Syncthing
  • Integrate sshgaurd

Configuration

  • Integrate dotfiles
  • Integrate agenix or sops-nix
  • Integrate capabilities from nix-starter-configs
  • Include image assets such as wallpapers and faces
  • Include Serif fonts
  • Create standard directories in /home/martin using systemd.user.tmpfiles.rules.
  • Create .envrc files in /home/martin.
  • Bind Syncthing GUI to ZeroTier.
  • Config Plank.
  • Include fallback fonts for Work Sans, Fira Code and Joypixels
  • Create common user settings and discrete user settings
  • Move application defaults out of the desktop defaults
  • Fix Unfree in Home Manager

Development

  • Defold

Shell

  • fzf
  • tmate or tmux
  • (WIP) micro
  • nnn or broot or felix or ranger

Inspirations ๐Ÿง‘โ€๐Ÿซ

Before preparing my NixOS and Home Manager configurations I took a look at what other Nix users are doing. My colleagues shared their configs and tips which included nome from Luc Perkins, nixos-config from Cole Helbling, flake from Ana Hoverbear and her Declarative GNOME configuration with NixOS blog post. A couple of friends also shared their configurations and here's Jon Seager's nixos-config and Aaron Honeycutt's nix-configs.

While learning Nix I watched some talks/interviews with Matthew Croughan and Will Taylor's Nix tutorials on Youtube. Will Taylor's dotfiles are worth a look, as are his videos, and Matthew Croughan's nixcfg is also a useful reference. After I created my initial flake I found nix-starter-configs by Gabriel Fontes which is an excellent starting point. I'll be incorporating many of the techniques it demonstrates in my nix-config.

I like the directory hierarchy in Jon Seager's nixos-config and the mixin pattern used in Matthew Croughan's nixcfg, so my initial Nix configuration is heavily influenced by both of those. Ana's excellent Declarative GNOME configuration with NixOS blog post was essential to get a personalised desktop. That said, there's plenty to learn from browsing other people's Nix configurations, not least for discovering cool software. I recommend a search of GitHub nixos configuration from time to time to see what interesting techniques you pick up and new tools you might discover. The disko implementation and automated installation is chasing the ideas outlined in these blog posts:

my-nixfiles's People

Contributors

jucarei avatar

Watchers

 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.