Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/novoid/nixos-config
NixOS + flakes + home-manager with xfce, zsh, tmux, ...
https://github.com/novoid/nixos-config
Last synced: 3 months ago
JSON representation
NixOS + flakes + home-manager with xfce, zsh, tmux, ...
- Host: GitHub
- URL: https://github.com/novoid/nixos-config
- Owner: novoid
- License: other
- Created: 2023-08-03T17:18:47.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-08-27T17:42:07.000Z (5 months ago)
- Last Synced: 2024-08-27T19:34:26.416Z (5 months ago)
- Language: Nix
- Size: 238 KB
- Stars: 38
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.org
- License: LICENSE.org
Awesome Lists containing this project
- my-awesome-github-stars - novoid/nixos-config - NixOS + flakes + home-manager with xfce, zsh, tmux, ... (Nix)
README
* NixOS Configuration With Flakes, Home-manager
I wrote [[https://karl-voit.at/2023/09/12/nix/][a long article about my journey to Nix, NixOS, Home Manager
and flakes]] where you may find more background information about this
repository and its goals.** Basic Concept
My setup is using the =flake.nix= as a central point.
=flake.nix= is calling most of the other files depending on the set hostname:
- =hosts/$HOSTNAME/default.nix=
- =configuration.nix=
- all files related to =home-manager=: =homemanager.nix= and =homemanager/*=The directory =assets= contain various configuration and binary files
I wanted to keep close to my NixOS configuration files.** Wrapper Shell Scripts
:PROPERTIES:
:CREATED: [2023-12-25 Mon 21:56]
:END:I wrote several shell scripts so that I don't have to remember the
commands for updating and so forth.you can update the setup using =nixos-rebuild_switch_flake.sh= which
basically invokes the command:: sudo nixos-rebuild switch --flake /home/vk/nixos
In practice, I'm using =nh-os-switch.sh= to update my setup to meet
the stored configuration. This is a visually appealing wrapper that is
using [[https://github.com/viperML/nh][nh]] to run:: nh os switch --ask "/home/vk/nixos"
You may need to adapt the paths to meet your path, of course.
You should start with the =nixos-rebuild= command and then optionally
switch to =nh= when everything is working so far.=update-flake.sh= is updating the flake definitions to the most
current ones and commit them to the git repository. Therefore, as long
as you don't invoke this command, no package updates will be
downloaded from the remote repositories.From time to time, you may want to invoke =garbage-collecting.sh= to
get rid of older data which is not required any more.
=configuration.nix= also contains a weekly garbage collection but I'm
not sure when and how this is invoked. If you need more space at a
certain point in time, you're save to invoke =garbage-collecting.sh=
any time.** Hosts
As of 2023-12-25, I do have four different hosts running this NixOS configuration:
*jackson* is my business notebook (Lenovo T490) which I'm using during a
business week. This is the most intensly used NixOS system at the
moment by far.*floyd* is my personal notebook (Lenovo X260) which I was using to
test NixOS without affecting my main systems that are running Xubuntu
LTS or Debian stable. I don't work on it much. It's mostly used for
FOSS conferences I attend.*nixosvmr* and *nixosvms* are two qemu virtual machines in order to
test multi-host setup or to play with my NixOS configuration without
having floyd around. Notice that as of 2023-08-09, 20GB (virtual) disk space
is too small. NixOS really adds up lots of space in comparison to Debian-based
distributions. I'm using the VMs rarely since I started with floyd and jackson.** Installation
1) Download installer ISO :focus:
- https://nixos.org/download.html#nixos-iso
- Don't use the "Minimal ISO" since it might not come with some GUI stuff we need.
- I was using "GNOME 64 Bit"
- [2023-07-29 Sat] I used: https://channels.nixos.org/nixos-23.05/latest-nixos-gnome-x86_64-linux.iso2) Install NixOS using that ISO
- Learn how to set up a USB thumb drive and boot from it for installing the basic OS3) Modify default configuration.nix:
1. Start an editor:
: sudo nano /etc/nixos/configuration.nix2. Change hostname on new host from default if necessary:
- https://borretti.me/article/nixos-for-the-impatient#postinstall
- by setting =networking.hostName= from "nixos" to a new hostname
3. Activate flakes: https://nixos.wiki/wiki/Flakes
"On NixOS set the following options in =configuration.nix= and run =nixos-rebuild="
#+begin_src nix
{ pkgs, ... }: { # usual, this line is already there
nix.settings.experimental-features = [ "nix-command" "flakes" ];
} # usual, this line is already there
#+end_src4. Add the =git= and package. Also add your favourite editor as well for fixing miscellaneous things. I'm using =vim= for that.
- Just write [[https://search.nixos.org/packages][the corresponding package name]] where =firefox= is installed in the =configuration.nix=.5. OPTIONALLY: Install packages like vim, sshd, flakes in case you need to play around more
- Just write [[https://search.nixos.org/packages][the corresponding package name]] where =firefox= is installed in the =configuration.nix=.6. Update and activate your setup
: sudo nixos-rebuild switch4) Get this NixOS configuration git repository via (=scp= or =git clone https://github.com/novoid/nixos-config.git ~/nixos=)
- target directory: =~/nixos/nixos-configuration=
- I'm using following command at my LAN:
: scp -r [email protected]:src/nixos-configuration ~/ && mv ~/nixos-configuration ~/nixos
5) Create a configuration for the =$HOSTNAME= in the nixos-configuration git repo1. Adapt =flakes.nix=
2. Create =~/nixos/hosts/$HOSTNAME= (from an existing host as template)
3. Get the =hardware-configuration.nix= into your new setup
#+BEGIN_SRC sh
cd ~/nixos
cp /etc/nixos/hardware-configuration.nix ~/nixos/hosts/$HOSTNAME/
cp /etc/nixos/configuration.nix ~/nixos/hosts/$HOSTNAME/default.nix
git add
#+END_SRC6) *Check for things that won't work or need attention when you're not Karl Voit*:
- Check out all spots marked with "SPECIFICTOKARL" for things that are different on your side:
: git grep -B 1 -A 2 SPECIFICTOKARL
- =flake.nix=: =description=, =system.stateVersion=, username "vk", ...- Check out all spots marked with "FIXXME" for things that may need attention to fix:
: git grep -B 1 -A 2 FIXXME- Check out all spots marked with "DEPENDENCY" for things that are referring to stuff which is *not available in this NixOS repository*:
: git grep -B 1 -A 2 DEPENDENCY
- Usually, you might want to get rid of those things because the would result in errors in your situation.7) Run flakes with the new setup:
1. Switch to nixos-config dir
2. Double-check: make sure that hostname matches a config
3. Run flakes with current nixos-config dir:
: sudo nixos-rebuild switch --flake .4. Fix any error that may arise at this point.
- Yes, this can be frustrating. I wish you good luck here.
- Usually, you just have to remove stuff from
=~/nixos/hosts/$HOSTNAME/default.nix= when it is also defined
in =flakes.nix= or other existing files.
- Futhermore, you might have to create (and =git add=)
configuration files that are assumed to exist such as
=assets/.tmuxp/$HOSTNAME.yaml=.5. I do recommend a reboot here to cleanly boot the updated OS with
all of its settings.6. Execute store optimization (replacing copies with hardlinks):
: nix-store --optimise7. OPTIONALLY: Symlink =/etc/nixos= to =~/nixos= if you want to use =nixos-rebuild= without the optional parameter for the path.
** Setup GitHub ssh authentication
:PROPERTIES:
:CREATED: [2023-08-06 Sun 21:11]
:END:This is quite handy to be included here because this is what I
typically do right after setting up NixOS if I don't take over the old
keys via my previous dotfiles.- [[https://docs.github.com/en/authentication/connecting-to-github-with-ssh/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent][main source for this]]
-----
Please do replace =$HOST= (your hostname), =$USER= (your local
username) and =$GITHUBUSER= (username at GitHub) accordingly:1. execute
: ssh-keygen -t ed25519 -C "[email protected]"
- This creates a new SSH key, using the provided email as a label.
2. At the prompt, type a secure passphrase.
3. Choose a file name:
: /home/$USER/.ssh/id_ed25519_Git_$HOST
4. adding to ssh-agend:
: ssh-add ~/.ssh/id_ed25519_Git_$HOST
5. visit https://github.com/settings/keys
6. click on "New SSH key"
7. insert a name and paste the content of the following file:
: ~/.ssh/id_ed25519_Git_$HOST.pub
8. add the following lines to your =~/.ssh/config= file (create if it doesn't exist):
: host github.com
: IdentityFile ~/.ssh/id_ed25519_Git_$HOST
: User $GITHUBUSER** License
If not specified otherwise, this configuration is licensed under a
[[http://creativecommons.org/licenses/by-sa/4.0/][Creative Commons Attribution-ShareAlike 4.0 International License]]