Skip to content

arunoruto/flake

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Mirza's Awesome Nix Config

https://www.reddit.com/r/NixOS/comments/16ky6ez/nixos_logo_variations/

Initial setup

Clone the repository into your local .config directory.

git clone https://github.com/arunoruto/flake ~/.config/flake

If it deviates from this, set the env-variable FLAKE to the new path.

NixOS

When first time trying to install the flake, you need to run:

sudo nixos-rebuild switch --flake ./#<device-name> --accept-flake-config

Home Manager

Like NixOS, home-manager can be also updated from the flake file like follows:

home-manager switch --flake ./#<username> --accept-flake-config

The flake specifications are surrounded by quotes, since some shells (e.g. zsh) are complaining due to the # symbol.

None NixOS Systems

If nix is used as a package manager on a system, home manager can be installed using nix run:

nix --experimental-features 'nix-command flakes' --accept-flake-config run nixpkgs#home-manager -- switch --flake .#<username>

Nix Helper

After the initial setup, the system can be configured using the nh command. It is important to provide the FLAKE variable in the system, and it needs to point to the flake's repository. This can be specified per system in its configuration.nix under environment.sessionVariables. If not, it can be appended to the commands.

NixOS

nh os switch # if the FLAKE variable is set, or
nh os switch ./#<device-name>

Home Manager

nh home switch # if the FLAKE variable is set, or
nh home switch ./#<username>

Facter

Generate a facter.json file for a system and place it in the correct host path:

sudo nix run \
  --option experimental-features "nix-command flakes" \
  --option extra-substituters https://numtide.cachix.org \
  --option extra-trusted-public-keys numtide.cachix.org-1:2ps1kLBUWjxIneOy1Ik6cQjb41X0iXVXeHigGmycPPE= \
  github:numtide/nixos-facter -- -o facter.json

Nixvim

Nixvim is the nix way to configure neovim. More information can be found in the nvim README.

Git Fetchers

When using a git fetcher, you need the commit hash/revision/tag/version and the corresponding hash. You can either fetch everything with an empty hash, let the build error out and copy the hash from the logs, or use nix-prefetch-git:

nix run nixpkgs#nix-prefetch-git <URL>

To prefetch candy-icons, you would call:

nix run nixpkgs#nix-prefetch-git https://github.com/EliverLara/candy-icons

Workflows

If edits are made to the workflow(s), a token with the workflow scope is needed:

gh auth status # Check current scopes in token
gh auth login --scopes workflow # Request a new one with the workflow scope

Helpful Material

Setup

Some nice intro is provided by thiscute.world.

vimjoyer has some amazing videos about nix and other nix related stuff:

Ampersand has a nice video about configuring a NixOS system similar to vimjoyer's Ultimate NixOS Guide | Flakes | Home-Manager

Nix Language

Clean-up

It can get a bit messy with the generations, especially if nix is installed as a package manager. To clean up such systems, you can use the following commands:

  • nix-collect-garbage: can be used on all systems and the parameter --delete-older-than can be specified with a period (for example "30 days"). This command is mostly an alias of nix-store --gc or nix store gc, but extends it with the --delete-older-than and --delete-old flag.
  • nh clean all: clean everything using the nh tool.

TODO

  • Integrate disko for each system, so it can be built easier later on.

Fixes

  • Thick black borders in Gnome apps. Using GSK_RENDERER=gl to fix it for now. Source
  • Sonarr needs DotNET 6, which has reached EOL. Using permit insecure packages we can allow those to be installed. Follow the issue for more information. Affected locations:
    • GitHub check action: remove impure when fixed
    • arr module: nixpkgs config is not working tho...
    • Kuchiki needs to be built with NIXPKGS_ALLOW_INSECURE=1 nh os switch -- --impure

Credits

  • use-the-fork helped me to move from a standalone config for home-manager to using it as a module
  • u/paulgdp gave advice on how nixosConfig is an attribute of args if the config is used in NixOS, used in modules/home-manager/imports.nix
  • olmokramer gave an example on how to use lib.genAttrs in a forum post to configure NixOS systems → extended it for home-manager too

About

My nix config

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published