Hi all,
I am trying to begin my transition to using flakes and home-manager. I read the online resources, watched several tutorials and used sample configs online. However, I keep getting one of two errors that I cannot figure out how to fix.
I have a flake.nix
file, a directory called hosts
(where I would in the future have folders for multiple different hosts, but right now have one) that has a default.nix
and a configuration.nix
file, and subfolder of hosts
called proxvm
that has a default.nix
and a hardware-configuration.nix
file.
When I run sudo nixos-rebuild switch --flake .#proxvm
it appears to fail but doesn’t generate a specific error, even if I use the --verbose flag. There is no rebuild process and no output at all.
Since I only have one host right now, I also tried to run sudo nixos-rebuild switch --flake .
which generated the below error:
error: flake 'path:/home/nixosadmin1/nixcfg' does not provide attribute 'packages.x86_64-linux.nixosConfigurations."hlnixos".config.system.build.nixos-rebuild', 'legacyPackages.x86_64-linux.nixosConfigurations."hlnixos".config.system.build.nixos-rebuild' or 'nixosConfigurations."hlnixos".config.system.build.nixos-rebuild'
Below are my files, as they exist right now (except hardware-configuration.nix since that is pretty basic and I don’t think the source of the problem). Any help would be much appreciated. I can’t figure out what I am doing wrong that won’t let the --flake .#proxvm
approach work.
Thanks in advance for the assistance.
flake.nix
{
description = "Personal NixOS/Home-Manager Flake Config";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
home-manager = {
url = "github:nix-community/home-manager/release-23.05";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs = inputs @ { self, nixpkgs, home-manager, ... }:
let
system = "x86_64-linux";
vars = {
user = "nixosadmin1";
};
pkgs = import nixpkgs {
inherit system;
config.allowUnfree = true;
};
lib = nixpkgs.lib;
in
{
nixosConfigurations = (
import ./hosts {
inherit (nixpkgs) lib;
inherit inputs system home-manager vars;
}
);
};
}
/hosts/default.nix
{ lib, inputs, system, vars, home-manager, ... }:
{
proxvm = lib.nixosSystem { # Desktop profile
inherit system;
specialArgs = {
inherit inputs lib system vars;
#host = {
# hostName = "hlnixos";
#};
};
modules = [ # Modules that are used.
./proxvm
./configuration.nix
home-manager.nixosModules.home-manager { # Home-Manager module that is used.
home-manager.useGlobalPkgs = true;
home-manager.useUserPackages = true;
}
];
};
}
./hosts/configuration.nix
{ config, lib, pkgs, vars, system, inputs, ... }:
{
imports = # Import window or display manager.
[
];
programs.zsh.enable = true;
users.users.${user} = { # System User
isNormalUser = true;
extraGroups = [ "wheel" "networkmanager" ];
shell = pkgs.zsh; # Default shell
};
time.timeZone = "America/New_York"; # Time zone and internationalisation
i18n = {
defaultLocale = "en_US.UTF-8";
extraLocaleSettings = { # Extra locale settings that need to be overwritten
LC_ADDRESS = "en_US.UTF-8";
LC_IDENTIFICATION = "en_US.UTF-8";
LC_MEASUREMENT = "en_US.UTF-8";
LC_MONETARY = "en_US.UTF-8";
LC_NAME = "en_US.UTF-8";
LC_NUMERIC = "en_US.UTF-8";
LC_PAPER = "en_US.UTF-8";
LC_TELEPHONE = "en_US.UTF-8";
LC_TIME = "en_US.UTF-8";
LC_ALL = "en_US.UTF-8";
};
};
fonts.packages = with pkgs; [ # Install fonts
roboto
(nerdfonts.override { fonts = [ "JetBrainsMono" ]; })
];
environment = {
variables = {
TERMINAL = "alacritty";
EDITOR = "nvim";
VISUAL = "nvim";
};
systemPackages = with pkgs; [ # Default packages installed system-wide
wget
curl
alacritty
chromium
google-chrome
vim
(neovim.override { withNodeJs = true; })
git
lazygit
ripgrep
fzf
fd
rofi
nitrogen
xautomation
xdo
xdotool
xvkbd
autokey
tmux
bat
htop
gcc
exa
zip
unzip
nordzy-icon-theme
nordzy-cursor-theme
open-vm-tools
nodejs
nordic
ruby_3_1
nodePackages_latest.neovim
xrdp
xclip
xfce.xfce4-pulseaudio-plugin
gnumake
lsof
python311
xfce.xfce4-screensaver
lxappearance
usbutils
];
};
# Allow unauthenticated reboot/shutdown
security.polkit.extraConfig = ''
polkit.addRule(function(action, subject) {
if (
subject.isInGroup("users")
&& (
action.id == "org.freedesktop.login1.reboot" ||
action.id == "org.freedesktop.login1.reboot-multiple-sessions" ||
action.id == "org.freedesktop.login1.power-off" ||
action.id == "org.freedesktop.login1.power-off-multiple-sessions"
)
)
{
return polkit.Result.YES;
}
})
'';
services = {
xrdp = { # Enable RDP
enable = true;
defaultWindowManager = "awesome";
};
pipewire = { # Sound
enable = true;
alsa = {
enable = true;
support32Bit = true;
};
pulse.enable = true;
jack.enable = true;
};
openssh = {
enable = true; # Enable SSH
extraConfig = ''
HostKeyAlgorithms +ssh-rsa
PubkeyAcceptedAlgorithms=+ssh-rsa
''; # Temporary extra config so ssh will work in guacamole
};
flatpak.enable = true; # download flatpak file from website - sudo flatpak install <path> - reboot if not showing up
# sudo flatpak uninstall --delete-data <app-id> (> flatpak list --app) - flatpak uninstall --unused
# List:
# com.obsproject.Studio
# com.parsecgaming.parsec
# com.usebottles.bottles
};
# Enable RDP
networking.firewall.allowedTCPPorts = [ 3389 ];
nix = { # Nix Package Manager settings
settings ={
auto-optimise-store = true; # Optimise syslinks
};
gc = { # Automatic garbage collection
automatic = true;
dates = "weekly";
options = "--delete-older-than 7d";
};
package = pkgs.nixVersions.unstable; # Enable nixFlakes on system
registry.nixpkgs.flake = inputs.nixpkgs;
extraOptions = ''
experimental-features = nix-command flakes
keep-outputs = true
keep-derivations = true
'';
};
nixpkgs.config.allowUnfree = true; # Allow proprietary software.
system = { # NixOS settings
stateVersion = "23.05";
};
}
./hosts/proxvm/default.nix
{ config, pkgs, lib, vars, system, ... }:
{
imports = [ # For now, if applying to other system, swap files
./hardware-configuration.nix # Current system hardware config @ /etc/nixos/hardware-configuration.nix
];
# Bootloader
boot.loader.grub = {
enable = true;
device = "/dev/sda";
useOSProber = true;
configurationLimit = 5;
};
# Set desktop, display and window managers
services.xserver = {
enable = true;
videoDrivers = [ "amdgpu" ];
desktopManager = {
xterm.enable = false;
xfce = {
enable = true;
noDesktop = true;
enableXfwm = false;
};
};
displayManager.defaultSession = "xfce+awesome";
windowManager.awesome = {
enable = true;
luaModules = with pkgs.luaPackages; [
luarocks #pkg manager for lua modules
luadbi-mysql #database abstraction layer
];
};
};
# Set greeter theme options
services.xserver.displayManager.lightdm = {
greeters.gtk = {
theme.name = "Nordic-darker";
iconTheme.name = "Nordzy-cyan-dark";
cursorTheme.name = "Nordzy-cursors";
extraConfig = ''
user-background = false
'';
};
};
# Picom
services.picom.enable = true;
services.picom.fade = true;
# Configure keymap in X11
services.xserver = {
layout = "us";
xkbVariant = "";
};
# Enable networking
networking.networkmanager.enable = true;
networking.hostName = "hlnixos";
programs.nm-applet.enable = true;
# OpenGL drivers
hardware.opengl.driSupport = true;
# For 32 bit applications
hardware.opengl.driSupport32Bit = true;
}