Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/fedeizzo/nix-dotfiles


https://github.com/fedeizzo/nix-dotfiles

Last synced: 4 days ago
JSON representation

Awesome Lists containing this project

README

        

* Nix dotfiles

Three laptops and one homelab:
- Dell XPS 9510
- Thinkpad X1 Carbon 6th gen
- Macbook pro M1 Max
- Raspberry pi 4th gen

#+ATTR_HTML: :width 400px :style margin-left: auto; margin-right: auto;
[[./images/architecture.png]]

My personal laptops have access to the homelab using ssh and [[https://www.wireguard.com/][Wireguard]].
My work laptop cannot does not have directly access to the homelab.

-  [[file:home/][home]]: home manager configurations.
- 󰍹 [[file:hosts/][hosts]]: host system configurations.
- 󱄅 [[file:nix/][nix]]: flake modules.
- 󱧘 [[file:overlays/][overlays]]: package overlays.
-  [[file:scripts/][scripts]]: system management scripts.
-  [[file:secrets/][secrets]]: secrets.

** Usage
You can use [[https://direnv.net/][direnv]] to easily manage this flake.

After executing ~direnv allow~, you should have a shell powered by [[https://numtide.github.io/devshell/][devshell]] and by running ~menu~ you have an help message.

#+begin_src sh :results verbatim
menu
#+end_src

#+RESULTS:
#+begin_example

[[[[general commands]]]]

menu - prints this menu

[ System installation]

erase-disk-and-install-raspberry -  Raspberry Pi4 8Gb.
erase-disk-and-install-x1. -  Thinkpad X1 Carbon 6th generation.
erase-disk-and-install-xps -  Dell XPS 9510.

[ System administration]

clean -  Delete old generations and clean nix store.
deploy -  Deploy the homelab configuration over ssh.
refresh -  Refresh the devshell.
secrets -  Edit secrets.
update -  Update the system configuration using the current flake and hostname.
update-input -  Update a flake.nix input.

#+end_example

** System installation
The following instructions are valid for all machines except the Macbook pro.

In my personal laptops the disk is erased at every boot in order to obtain a complete immutable and declarative system. This is achieved thanks to BTRFS.

Obviously some data, logs, cache, etc. must survive the boot process, this is achieved using [[https://github.com/nix-community/impermanence][imperamanence]].

Some useful readings if you are interested:
- [[https://mt-caret.github.io/blog/posts/2020-06-29-optin-state.html][erase with btrfs snapshot]]
- [[https://grahamc.com/blog/erase-your-darlings][erase with zfs]]
- [[https://elis.nu/blog/2020/05/nixos-tmpfs-as-root/][erase with tmpfs]]
- [[https://elis.nu/blog/2020/06/nixos-tmpfs-as-home/][erase home]]

#+begin_src sh
git clone https://github.com/fedeizzo/nix-dotfiles.git
cd nix-dotfiles
nix develop
erase-disk-and-install-{machine}
#+end_src

Unfortunately I didn't find a way to create a directory under ~/persist/home/{user}~ with the right permissions, the script run automatically the post initrd and it doesn't have the user ids.
A simple workaround is to setup the home manually after the first boot:

#+begin_src sh
chown {user}:users /persist/home/{user}/
chmod 700 /persist/home/{user}
#+end_src