Context and Goal
Upon discovering this user’s nixos configuration, I decided to try something similar, integrating flakes, organizing and installing packages with home-manager instead of the usual way:
.Nix Files
home.nix
{ user, ... }:
{
home = {
username = "${user}";
homeDirectory = "/home/${user}";
sessionVariables = {
CARGO_TARGET_DIR = "$HOME/.target/";
};
stateVersion = "22.05";
};
}
home-desktop.nix
{ inputs, config, pkgs, user, ... }:
{
imports = [
./software.nix
];
programs.home-manager.enable = true;
programs.direnv.enable = true;
# Enable Home Manager and Fish shell.
programs.home-manager.enable = true;
programs.fish = {
enable = true;
interactiveShellInit = "set fish_greeting";
};
}
software.nix
{ pkgs, ... }:
{
home.packages = with pkgs; [
# Command line utilities
wget
neofetch
killall
htop
unzip
pipes
wine
pandoc
texlive.combined.scheme-full
lsof
openssl
unrar
mesa
ntfs3g
fish
fishPlugins.done
fishPlugins.fzf-fish
fishPlugins.forgit
fishPlugins.hydro
fzf
fishPlugins.grc
grc
poppler_utils
gnumake
multipath-tools
cmake
xclip
# Programming languages and tools
jdk
git
kitty
neovim
python3Full
libgccjit
python311Packages.setuptools
qt6.full
gamemode
gtk3
# Tray applications
networkmanagerapplet # nm-applet
# GNOME apps
gnome.cheese
gnome.nautilus
gnome.file-roller
gnome.gnome-calculator
gnome.gnome-disk-utility
gnome.simple-scan
gnome.gnome-tweaks
# Applications
androidStudioPackages.canary
figma-linux
firefox
anki-bin
mpv
gimp
krita
inkscape
];
}
configuration.nix
{ config, pkgs, user, inputs, ... }:
let
inkscape = pkgs.callPackage /etc/nixos/inkscape.nix {};
gimp = pkgs.callPackage /etc/nixos/gimp.nix {};
in
{
# General System Settings
system.stateVersion = "23.11";
boot.kernelPackages = pkgs.linuxPackages_latest;
nix.settings.experimental-features = [ "nix-command" "flakes" ];
nixpkgs.config.allowUnfree = true;
imports = [ ./hardware-configuration.nix ];
# Bootloader
boot.loader.systemd-boot.enable = true;
boot.loader.efi.canTouchEfiVariables = true;
# Remove NixOS Manual
documentation.nixos.enable = false;
# Network config
networking = {
hostName = "space";
networkmanager.enable = true;
};
# User Configurations
users.users.${user} = {
isNormalUser = true;
extraGroups = [ "wheel" "audio" "video" "optical" "storage" "networkmanager" ];
initialPassword = "password";
};
users.defaultUserShell = pkgs.fish;
# X11 and GNOME
services.xserver = {
enable = true;
layout = "us";
xkbVariant = "";
displayManager.gdm.enable = true;
desktopManager.gnome.enable = true;
};
environment.gnome.excludePackages = (with pkgs; [
gnome-photos
gnome-tour
]) ++ gnomePackages;
# Virtualisation
virtualisation.docker = {
enable = true;
storageDriver = "btrfs";
rootless = {
enable = true;
setSocketVariable = true;
};
};
# Other Services
services.gvfs.enable = true;
nix.gc = {
automatic = true;
options = "--delete-generations 7d";
};
# Environment Variables
environment.variables.EDITOR = "nvim";
environment.gnome.excludePackages = (with pkgs; [
gnome-photos
gnome-tour
]) ++ (with pkgs.gnome; [
baobab # disk usage analyzer
cheese # photo booth
eog # image viewer
epiphany # web browser
gedit # text editor
simple-scan # document scanner
totem # video player
yelp # help viewer
evince # document viewer
file-roller # archive manager
geary # email client
seahorse # password manager
# these should be self explanatory
gnome-calculator gnome-calendar gnome-characters gnome-clocks gnome-contacts
gnome-logs gnome-maps gnome-music gnome-screenshot
gnome-system-monitor gnome-weather pkgs.gnome-connections
]);
# Programs
programs.neovim = {
enable = true;
defaultEditor = true;
};
programs.gamemode.enable = true;
programs.fish.enable = true;
# Supported Filesystems
boot.supportedFilesystems = [ "ntfs" ];
}
default.nix
{ lib, inputs, nixpkgs, home-manager, user, configDir, ... }:
let
system = "x86_64-linux";
pkgs = import nixpkgs {
inherit system;
config.allowUnfree = true;
};
lib = nixpkgs.lib;
configImports = [
./configuration.nix
];
hmImports = [
(import ./home.nix)
];
desktopHmImports = hmImports ++ [
(import ./home-desktop.nix)
];
hmArgs = { inherit user configDir; };
in
{
desktop = lib.nixosSystem {
inherit system;
specialArgs = { inherit user; };
modules = configImports ++ [
./desktop
./desktop.nix
{
boot.loader.grub.gfxmodeEfi = "1920x1080";
networking.hostName = "${user}";
}
home-manager.nixosModules.home-manager {
home-manager = {
useUserPackages = true;
extraSpecialArgs = hmArgs;
users.${user} = {
imports = desktopHmImports ++ [
(import ./desktop/home.nix)
];
};
};
}
];
};
}
desktop.nix
{ config, pkgs, lib, ... }:
{
# Printing and sound
services.printing.enable = true;
sound.enable = true;
hardware.pulseaudio.enable = false;
security.rtkit.enable = true;
# Pipewire config
services.pipewire = {
enable = true;
alsa = { enable = true; support32Bit = true; };
pulse.enable = true;
};
}
Please be aware that I’m still in the midst of editing my .nix files, so they may be a bit unorganized. Also changed the hostname to be the same as the username space.