Nix Based Configuration
I use NixOS and home-manager to manage my system and user configuration respectively. You can see what options I have added to configure the system and user configuration in the next chapters.
The source repo is configuration.nix.
Table of Contents
How to Use
If you are not me, then you probably shouldn't use this, but feel free to draw inspiration from what I have done c:.
First you want to see what your environment is; if you are using NixOS then you want to look at the NixOS Module Setup, if you are just using home-manager, then you should look at the homa-manager Module Setup. Or if you just want to use my NeoVIM configuration then look at the NeoVIM standalone setup.
NixOS Module Setup
Although I am talking about the NixOS module setup, this uses both NixOS and home-manager, so you can (and should) use both modules.
Setup from LiveISO
Follow the NixOS Manual until before
you run nixos-generate-config
.
First you will want to create a directory for your NixOS configuration. I like
using ~/.config/nixos
. You then want to run nixos-generate-config --root /mnt --dir ~/.config/nixos
(assuming you mounted your filesystem to /mnt
). Now you
have configuration.nix
and hardware-configuration.nix
inside
~/.config/nixos
. I like renaming configuration.nix
to default.nix
and
putting it in a folder with the same hostname as the machine (See the source
repo).
Now you can add a flake.nix
file to your ~/.config/nixos
and make it a flake
based configuration. This is the general structure you'll want:
{
inputs.nixpkgs.url = "nixpkgs/nixos-unstable";
# My custom configuration module
inputs.config.url = "github:jalil-salame/configuration.nix";
inputs.config.inputs.follows.nixpkgs = "nixpkgs";
outputs = { self, nixpkgs, config }: let
pc = import (./. + hostname);
hostname = "nixos";
system = "x86_64-linux";
overlays = builtins.attrValues config.overlays;
config.allowUnfreePredicate = pkg: builtins.elem (lib.getName pkg) [
"steam-original"
];
pkgs = import nixpkgs { inherit system overlays config; };
in {
nixosConfigurations.${hostname} = nixpkgs.lib.nixosSystem {
inherit system pkgs;
modules = [
# My configuration module (includes home-manager)
config.nixosModules.nixosModule
# Results from `nixos-generate-config`
pc
# Custom options (see module configuration options)
{
# Enable my custom configuration
jconfig.enable = true;
jconfig.gui.enable = true; # Enable gui environment
# Add users to use with home-manager
users.users = {};
# You should probably also enable wifi if needed
# Add home-manager users configuration (here you can enable jhome options)
home-manager.users = {};
# home-manager globally set options
home-manager.sharedModules = [{ jhome.hostName = hostname; }];
}
];
};
};
}
Now you should be ready to do sudo nixos-rebuild switch --flake .#$hostname
and use the configuration c:.
home-manager Module Setup
If you are not using NixOS, then you probably want to only use the home-manager
configuration. In that case, you want to use the
nixosModules.homeManagerModuleSandalone
in your home-manager
configuration,
and probably disable GUI applications all together jhome.gui.enable = false
.
Your flake should then look like this (follow the home-manager Manual for more information):
{
inputs.nixpkgs.url = "nixpkgs/nixos-unstable";
inputs.home-manager.url = "github:nixos-community/home-manager";
inputs.home-manager.inputs.follows.nixpkgs = "nixpkgs";
# My custom configuration module
inputs.config.url = "github:jalil-salame/configuration.nix";
inputs.config.inputs.follows.nixpkgs = "nixpkgs";
inputs.config.inputs.follows.home-manager = "home-manager";
outputs = { self, nixpkgs, home-manager, config }: let
hostname = "nixos";
username = "jdoe";
system = "x86_64-linux";
overlays = builtins.attrValues config.overlays;
pkgs = import nixpkgs { inherit system overlays; };
in {
homeConfigurations.${username} = home-manager.lib.homeManagerConfiguration {
inherit pkgs;
modules = [
# My configuration module (includes home-manager)
config.nixosModules.homeManagerModuleSandalone
# Custom options (see module configuration options and home-manager options)
{
# Enable my custom configuration
jhome.enable = true;
jhome.hostName = hostname;
jhome.gui.enable = false;
# Extra configuration options
}
];
};
};
}
NeoVIM Standalone setup
My NeoVIM configuration is managed by NixVIM, so check that project out if you want to understand how it works. You can use this tutorial to extend my configuration without forking this repo or copying its files.
If you want to test out my configuration then you can run this handy nix command:
$ nix run github:jalil-salame/configuration.nix#nvim
It will download and build my NeoVIM configuration and run NeoVIM. Alternatively
you can replace nix run
with nix shell
which will temporarily add my NeoVIM
configuration to your shell and when you run nvim
it will launch it.
NixOS Module Options
Here you will find the NixOS module options and their default values (if they have any).
You might want to take a look at the NixOS Manual or search the available options through NixOS Options.
Table of Contents
- Options
- jconfig
- jconfig.enable
- jconfig.dev
- jconfig.dev.enable
- jconfig.dev.jupyter.enable
- jconfig.gui
- jconfig.gui.enable
- jconfig.gui."8bitdoFix"
- jconfig.gui.steamHardwareSupport
- jconfig.gui.sway
- jconfig.gui.ydotool
- jconfig.gui.ydotool.enable
- jconfig.gui.ydotool.autoStart
- jconfig.importSSHKeysFromGithub
- jconfig.styling
- jconfig.styling.enable
- jconfig.styling.bootLogo
- jconfig.styling.wallpaper
Options
jconfig
Jalil’s default NixOS configuration.
Type: submodule
Default:
{ }
Declared by:
jconfig.enable
Whether to enable jalil’s default configuration…
Type: boolean
Default:
false
Example:
true
Declared by:
jconfig.dev
Options for setting up a dev environment
Type: submodule
Default:
{ }
Declared by:
jconfig.dev.enable
Whether to enable dev configuration.
Type: boolean
Default:
false
Example:
true
Declared by:
jconfig.dev.jupyter.enable
Whether to enable jupyter configuration.
Type: boolean
Default:
false
Example:
true
Declared by:
jconfig.gui
Jalil’s default configuration for a NixOS gui.
Type: submodule
Default:
{ }
Declared by:
jconfig.gui.enable
Whether to enable jalil’s default gui configuration…
Type: boolean
Default:
false
Example:
true
Declared by:
jconfig.gui."8bitdoFix"
Whether to enable a fix for 8bitdo controllers.
Type: boolean
Default:
true
Example:
false
Declared by:
jconfig.gui.steamHardwareSupport
Whether to enable steam hardware support.
Type: boolean
Default:
true
Example:
false
Declared by:
jconfig.gui.sway
Whether to enable sway.
Type: boolean
Default:
true
Example:
false
Declared by:
jconfig.gui.ydotool
Jalil’s default ydotool configuration.
Type: submodule
Default:
{ }
Declared by:
jconfig.gui.ydotool.enable
Whether to enable ydotool.
Type: boolean
Default:
true
Example:
false
Declared by:
jconfig.gui.ydotool.autoStart
Whether to enable autostarting ydotool at login.
Type: boolean
Default:
true
Example:
false
Declared by:
jconfig.importSSHKeysFromGithub
Import public ssh keys from a github username.
This will fetch the keys from https://github.com/$${username}.keys.
The format is "$${github-username}" = $${sha256-hash}
. The example
will try to fetch the keys from https://github.com/jalil-salame.keys.
Warning: this will interfere with services like gitea that override
the default ssh behaviour. In that case you want to use
users.users.<name>.openssh.authorizedKeys.keyFiles
on the users you
want to allow ssh logins.
Type: attribute set of string
Default:
{ }
Example:
{
jalil-salame = "sha256:AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA";
}
Declared by:
jconfig.styling
Jalil’s styling options
Type: submodule
Default:
{ }
Declared by:
jconfig.styling.enable
Whether to enable jalil’s default styling (disables stylix).
Type: boolean
Default:
true
Example:
false
Declared by:
jconfig.styling.bootLogo
The logo used by plymouth at boot.
Type: path
Default:
Declared by:
jconfig.styling.wallpaper
The wallpaper to use.
Type: path
Default:
Declared by:
Neovim Module Options
Here you will find the neovim options and their default values (if they have any).
You might also want to take a look at the NixNeovim Manual or search the available options through NixNeovim option search.
Table of Contents
Options
jhome.nvim.enable
Whether to enable jalil’s Neovim configuration.
Type: boolean
Default:
true
Example:
false
Declared by:
jhome.nvim.dev
Development options
Disabling this is advised for headless setups (e.g. servers), where you won’t be doing software development and would prefer to instead have a smaller package.
Type: submodule
Default:
{ }
Example:
{
enable = false;
}
Declared by:
jhome.nvim.dev.enable
Whether to enable development configuration.
Type: boolean
Default:
true
Example:
false
Declared by:
jhome.nvim.dev.bundleGrammars
Whether to enable bundling treesitter grammars with Neovim (barely decreases size when disabled).
Type: boolean
Default:
true
Example:
false
Declared by:
jhome.nvim.dev.bundleLSPs
Whether to enable bundling LSPs with Neovim (decreases size when disabled).
Type: boolean
Default:
true
Example:
false
Declared by:
Home Manager Module Options
Here you will find the home-manager options and their default values (if they have any).
You might also want to take a look at the home-manager Manual or search the available options through home-manager option search
Table of Contents
- Options
- jhome
- jhome.enable
- jhome.dev
- jhome.dev.enable
- jhome.dev.extraPackages
- jhome.dev.neovimAsManPager
- jhome.dev.rust
- jhome.dev.rust.enable
- jhome.dev.rust.extraPackages
- jhome.gui
- jhome.gui.enable
- jhome.gui.sway
- jhome.gui.sway.enable
- jhome.gui.sway.autostart
- jhome.gui.sway.background
- jhome.gui.sway.exec
- jhome.gui.sway.exec.always
- jhome.gui.sway.exec.once
- jhome.gui.tempInfo
- jhome.gui.tempInfo.hwmon-path
- jhome.gui.terminal
- jhome.hostName
- jhome.styling
- jhome.styling.enable
- jhome.user
- jhome.user.enable
- jhome.user.defaultIdentity
- jhome.user.defaultIdentity.email
- jhome.user.defaultIdentity.encryptionKey
- jhome.user.defaultIdentity.name
- jhome.user.defaultIdentity.signingKey
- jhome.user.gpg
- jhome.user.gpg.unlockKeys
Options
jhome
Jalil’s default home-manager configuration.
Type: submodule
Default:
{ }
Declared by:
jhome.enable
Whether to enable jalil’s home defaults.
Type: boolean
Default:
false
Example:
true
Declared by:
jhome.dev
Setup development environment for programming languages.
Type: submodule
Default:
{ }
Declared by:
jhome.dev.enable
Whether to enable development settings.
Type: boolean
Default:
false
Example:
true
Declared by:
jhome.dev.extraPackages
Extra dev Packages.
Type: list of package
Default:
[ pkgs.jq pkgs.just pkgs.typos pkgs.gcc pkgs.git-absorb pkgs.man-pages pkgs.man-pages-posix ]
Example:
[ ]
Declared by:
jhome.dev.neovimAsManPager
Whether to enable neovim as the man pager.
Type: boolean
Default:
false
Example:
true
Declared by:
jhome.dev.rust
Jalil’s default rust configuration.
Type: submodule
Default:
{ }
Declared by:
jhome.dev.rust.enable
Whether to enable rust development settings.
Type: boolean
Default:
false
Example:
true
Declared by:
jhome.dev.rust.extraPackages
Extra Rust Packages.
Type: list of package
Default:
[ pkgs.cargo-insta pkgs.cargo-nextest pkgs.cargo-udeps pkgs.cargo-watch ]
Example:
[ ]
Declared by:
jhome.gui
Jalil’s default GUI configuration.
Type: submodule
Default:
{ }
Declared by:
jhome.gui.enable
Whether to enable GUI applications.
Type: boolean
Default:
false
Example:
true
Declared by:
jhome.gui.sway
Sway window manager configuration.
Type: submodule
Default:
{ }
Declared by:
jhome.gui.sway.enable
Whether to enable sway.
Type: boolean
Default:
true
Example:
true
Declared by:
jhome.gui.sway.autostart
Autostart Sway when logging in to /dev/tty1.
This will make it so exec sway
is run when logging in to TTY1, if
you want a non-graphical session (ie. your GPU drivers are broken)
you can switch TTYs when logging in by using CTRL+ALT+F2 (for TTY2,
F3 for TTY3, etc).
Type: boolean
Default:
true
Example:
false
Declared by:
jhome.gui.sway.background
The wallpaper to use.
Type: path
Default:
"/nix/store/jh80kfl7xk2bgpa3nxsld1zr86ns55fc-gruvbox-dark-rainbow.png"
Declared by:
jhome.gui.sway.exec
Run commands when starting sway.
Type: submodule
Default:
{ }
Declared by:
jhome.gui.sway.exec.always
Programs to start whenever the config is sourced (exec_always
).
Type: list of string
Default:
[ ]
Example:
[
"signal-desktop --start-in-tray"
]
Declared by:
jhome.gui.sway.exec.once
Programs to start only once (exec
).
Type: list of string
Default:
[ ]
Example:
[
"signal-desktop --start-in-tray"
]
Declared by:
jhome.gui.tempInfo
Temperature info to display in the statusbar.
Type: null or (submodule)
Default:
null
Declared by:
jhome.gui.tempInfo.hwmon-path
Path to the hardware sensor whose temperature to monitor.
Type: string
Example:
"/sys/class/hwmon/hwmon2/temp1_input"
Declared by:
jhome.gui.terminal
The terminal emulator to use.
Type: one of “wezterm”, “alacritty”
Default:
"wezterm"
Example:
"alacritty"
Declared by:
jhome.hostName
The hostname of this system.
Type: string
Default:
"nixos"
Example:
"my pc"
Declared by:
jhome.styling
My custom styling (uses stylix)
Type: submodule
Default:
{ }
Declared by:
jhome.styling.enable
Whether to enable styling.
Type: boolean
Default:
true
Example:
true
Declared by:
jhome.user
User settings.
Type: null or (submodule)
Default:
null
Declared by:
jhome.user.enable
Whether to enable Jalil’s default user configuration.
Type: boolean
Default:
false
Example:
true
Declared by:
jhome.user.defaultIdentity
The default identity to use in things like git.
Type: submodule
Declared by:
jhome.user.defaultIdentity.email
Primary email address
Type: string
Example:
"email@example.org"
Declared by:
jhome.user.defaultIdentity.encryptionKey
The encryption key programs should use (i.e. pass).
Type: null or string
Default:
null
Example:
"F016B9E770737A0B"
Declared by:
jhome.user.defaultIdentity.name
The default name you use.
Type: string
Example:
"John Doe"
Declared by:
jhome.user.defaultIdentity.signingKey
The signing key programs should use (i.e. git).
Type: null or string
Default:
null
Example:
"F016B9E770737A0B"
Declared by:
jhome.user.gpg
GnuPG Configuration.
Type: submodule
Default:
{ }
Declared by:
jhome.user.gpg.unlockKeys
Keygrips of keys to unlock through pam-gnupg
when logging in.
Type: list of string
Default:
[ ]
Example:
[
"6F4ABB77A88E922406BCE6627AFEEE2363914B76"
]
Declared by: