Hello guys, I’m quite new to NixOS, I’m still adapting to the NixOS way.
Recently I installed a new package via home manager. Also I wanted to configure the program but to me it seems, that it cannot find the packages installed via home.nix configuration.
I couldn’t find any information online, the examples only configure packages installed in configuration.nix and not those from home.nix
Please help me
On rebuild I get the following error:
The option `home-manager.users.aschulz.programs.nh' does not exist.
home.nix
{
config,
pkgs,
...
}: {
# Home Manager needs a bit of information about you and the paths it should
# manage.
home.username = "aschulz";
home.homeDirectory = "/home/aschulz";
# This value determines the Home Manager release that your configuration is
# compatible with. This helps avoid breakage when a new Home Manager release
# introduces backwards incompatible changes.
#
# You should not change this value, even if you update Home Manager. If you do
# want to update the value, then make sure to first check the Home Manager
# release notes.
home.stateVersion = "23.11"; # Please read the comment before changing.
# The home.packages option allows you to install Nix packages into your
# environment.
home.packages = with pkgs; [
# Utils
firefox
chromium
thunderbird
libreoffice
# ...
# Shell/Bash/Zsh
nh
thefuck
zoxide
bat
];
# Home Manager is pretty good at managing dotfiles. The primary way to manage
# plain files is through 'home.file'.
home.file = {
# ...
};
# Home Manager can also manage your environment variables through
# 'home.sessionVariables'.
home.sessionVariables = {
# EDITOR = "emacs";
};
home.sessionPath = [
"$HOME/.local/bin"
];
# Let Home Manager install and manage itself.
programs.home-manager.enable = true;
programs.zsh = {
enable = true;
enableCompletion = true;
enableAutosuggestions = true;
syntaxHighlighting.enable = true;
shellAliases = {
ll = "ls -l";
vim = "nvim";
shell = "nix-shell";
};
history.size = 10000;
history.path = "${config.xdg.dataHome}/zsh/history";
oh-my-zsh = {
enable = true;
plugins = ["git" "thefuck"];
theme = "robbyrussell";
};
initExtra = "eval \"$(zoxide init zsh)\"";
};
programs.bash = {
enable = true;
shellAliases = {
vim = "nvim";
};
};
programs.git = {
enable = true;
userName = "";
userEmail = "";
};
programs.nh = {
enable = true;
clean.enable = true;
clean.extraArgs = "--keep-since 4d --keep 3";
flake = "/home/aschulz/nixos";
};
programs.neovim = {
enable = true;
defaultEditor = true;
extraPackages = with pkgs; [
gcc
];
};
}
configuration.nix
# Edit this configuration file to define what should be installed on
# your system. Help is available in the configuration.nix(5) man page
# and in the NixOS manual (accessible by running ‘nixos-help’).
{
lib,
config,
pkgs,
inputs,
...
}: {
imports = [
# Include the results of the hardware scan.
./hardware-configuration.nix
];
# Bootloader.
boot.loader.systemd-boot.enable = true;
boot.loader.efi.canTouchEfiVariables = true;
networking.hostName = "nixos"; # Define your hostname.
# networking.wireless.enable = true; # Enables wireless support via wpa_supplicant.
nix.settings.experimental-features = ["nix-command" "flakes"];
# Configure network proxy if necessary
# networking.proxy.default = "http://user:password@proxy:port/";
# networking.proxy.noProxy = "127.0.0.1,localhost,internal.domain";
# Enable networking
networking.networkmanager.enable = true;
# Set your time zone.
# time.timeZone = "Europe/Berlin";
# Select internationalisation properties.
i18n.defaultLocale = "en_US.UTF-8";
i18n.extraLocaleSettings = {
LC_ADDRESS = "de_DE.UTF-8";
LC_IDENTIFICATION = "de_DE.UTF-8";
LC_MEASUREMENT = "de_DE.UTF-8";
LC_MONETARY = "de_DE.UTF-8";
LC_NAME = "de_DE.UTF-8";
LC_NUMERIC = "de_DE.UTF-8";
LC_PAPER = "de_DE.UTF-8";
LC_TELEPHONE = "de_DE.UTF-8";
LC_TIME = "de_DE.UTF-8";
};
# Enable the X11 windowing system.
services.xserver.enable = true;
# Enable the KDE Plasma Desktop Environment.
services.xserver.displayManager.sddm.enable = true;
services.xserver.desktopManager.plasma6.enable = true;
# Configure keymap in X11
services.xserver = {
layout = "de";
xkbVariant = "";
};
# Configure console keymap
console.keyMap = "de";
# Enable CUPS to print documents.
services.printing.enable = true;
# Enable sound with pipewire.
sound.enable = true;
hardware.pulseaudio.enable = false;
hardware.bluetooth.enable = true; # enables support for Bluetooth
hardware.bluetooth.powerOnBoot = true; # powers up the default Bluetooth controller on boot
security.rtkit.enable = true;
services.pipewire = {
enable = true;
alsa.enable = true;
alsa.support32Bit = true;
pulse.enable = true;
# If you want to use JACK applications, uncomment this
#jack.enable = true;
# use the example session manager (no others are packaged yet so this is enabled by default,
# no need to redefine it in your config for now)
#media-session.enable = true;
};
services.automatic-timezoned.enable = true;
time.hardwareClockInLocalTime = true;
# Enable touchpad support (enabled default in most desktopManager).
# services.xserver.libinput.enable = true;
# Enable docker
virtualisation.docker.enable = true;
# Define a user account. Don't forget to set a password with ‘passwd’.
users.users.aschulz = {
isNormalUser = true;
description = "";
extraGroups = ["networkmanager" "wheel" "docker"];
};
users.defaultUserShell = pkgs.zsh;
home-manager = {
# also pass inputs to home-manager modules
extraSpecialArgs = {inherit inputs;};
users = {
"aschulz" = import ./home.nix;
};
useGlobalPkgs = true;
useUserPackages = true;
};
# Allow unfree packages
# nixpkgs.config.allowUnfree = true;
nixpkgs.config.allowUnfreePredicate = pkg:
builtins.elem (lib.getName pkg) [
# Add additional package names here
"obsidian"
"vscode"
"jetbrains-toolbox"
"spotify"
"discord"
];
# To allow packages to be installed even when they are marked as insecure.
# nixpkgs.config.permittedInsecurePackages = ["adobe-reader-9.5.5"];
# List packages installed in system profile. To search, run:
# $ nix search wget
environment.systemPackages = with pkgs; [
libnotify
git
neovim
usbutils
alejandra
zsh
oh-my-zsh
];
# Some programs need SUID wrappers, can be configured further or are
# started in user sessions.
programs.zsh.enable = true;
# programs.mtr.enable = true;
# programs.gnupg.agent = {
# enable = true;
# enableSSHSupport = true;
# };
# List services that you want to enable:
# Enable the OpenSSH daemon.
# services.openssh.enable = true;
# Open ports in the firewall.
# networking.firewall.allowedTCPPorts = [ ... ];
# networking.firewall.allowedUDPPorts = [ ... ];
# Or disable the firewall altogether.
# networking.firewall.enable = false;
# This value determines the NixOS release from which the default
# settings for stateful data, like file locations and database versions
# on your system were taken. It‘s perfectly fine and recommended to leave
# this value at the release version of the first install of this system.
# Before changing this value read the documentation for this option
# (e.g. man configuration.nix or on https://nixos.org/nixos/options.html).
system.stateVersion = "23.11"; # Did you read the comment?
}
flake.nix
{
description = "Nixos config flake";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
home-manager = {
url = "github:nix-community/home-manager";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs = { self, nixpkgs, ... }@inputs:
let
system = "x86_64-linux";
pkgs = nixpkgs.legacyPackages.${system};
in
{
nixosConfigurations.default = nixpkgs.lib.nixosSystem {
specialArgs = {inherit inputs;};
modules = [
./hosts/default/configuration.nix
inputs.home-manager.nixosModules.default
];
};
};
}
Directory structure:
~/nixos/
├── flake.lock
├── flake.nix
└── hosts
└── default
├── configuration.nix
├── hardware-configuration.nix
├── home.nix