# flake.nix
{
inputs = {
nixpkgs = {
url = "github:NixOS/nixpkgs?ref=nixos-24.05";
};
home-manager = {
url = "github:nix-community/home-manager?ref=release-24.05";
inputs.nixpkgs.follows = "nixpkgs";
};
nixvim = {
url = "github:nix-community/nixvim?ref=nixos-24.05";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs = inputs @ { self, nixpkgs, home-manager, ... }: {
nixosConfigurations = {
hostname = nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
modules = [
./configuration.nix
home-manager.nixosModules.home-manager {
home-manager.extraSpecialArgs = { inherit inputs; };
home-manager.useGlobalPkgs = true;
home-manager.useUserPackages = true;
home-manager.users.user = {
imports = [
./home.nix
./modules/firefox/firefox.nix
./modules/nvim/nvim.nix
./modules/bash/bash.nix
];
};
}
];
};
};
};
}
# home.nix
{ config, lib, pkgs, inputs, ... }:
{
imports = [
inputs.nixvim.homeManagerModules.nixvim
];
home.username = "user";
home.homeDirectory = "/home/user";
# You do not need to change this if you're reading this in the future.
# Don't ever change this after the first build. Don't ask questions.
home.stateVersion = "24.05";
programs.nixvim = {
enable = true;
defaultEditor = true;
colorschemes.gruvbox.enable = true;
plugins.lightline.enable = true;
};
}
This is the stuff made it run for me:
error: The option `home-manager.users.user.programs.nixvim' in `/nix/store/svas0rbjm1vfiqhls8rmzcygwiwvcj32-source/flake.nix' is already declared in `/nix/store/0vd8bfjgaiwvxvqp51q9vdk1snjrxkfx-source/home.nix'.
This informed me that I was importing both in flake.nix
and in home.nix
You really should not import modules in flake.nix
Make sure not to miss some stuff in this config, I’ve removed diff
so it’s actually copy-pastable.
I’ve used this repo when debugging:
If the link expires:
# home.nix
{
inputs,
lib,
config,
pkgs,
theme,
gtkThemeFromScheme,
...
}:
{
colorScheme = inputs.nix-colors.colorSchemes."${theme}";
# You can import other home-manager modules here
imports = [
# If you want to use home-manager modules from other flakes (such as nix-colors):
inputs.nix-colors.homeManagerModules.default
inputs.nixvim.homeManagerModules.nixvim
#inputs.hyprland.homeManagerModules.default
# You can also split up your configuration and import pieces of it here:
./home-manager/imports.nix
];
home = {
username = "khoa";
homeDirectory = "/home/khoa";
};
# Add stuff for your user as you see fit:
# programs.neovim.enable = true;
# home.packages = with pkgs; [ steam ];
# Enable home-manager and git
programs = {
home-manager.enable = true;
git = {
enable = true;
userName = "dxcently";
userEmail = "dxcently@gmail.com";
};
};
# Nicely reload system units when changing configs
systemd.user.startServices = "sd-switch";
dconf.settings = {
"org/virt-manager/virt-manager/connections" = {
autoconnect = [ "qemu:///system" ];
uris = [ "qemu:///system" ];
};
};
# https://nixos.wiki/wiki/FAQ/When_do_I_update_stateVersion
home.stateVersion = "23.11";
}
flake.nix
{
description = "fart";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
home-manager.url = "github:nix-community/home-manager/master";
home-manager.inputs.nixpkgs.follows = "nixpkgs";
nixpkgs_patched.url = "github:nixos/nixpkgs/468a37e6ba01c45c91460580f345d48ecdb5a4db";
nix-colors.url = "github:misterio77/nix-colors";
spicetify-nix.url = "github:the-argus/spicetify-nix";
nixvim = {
url = "github:nix-community/nixvim";
inputs.nixpkgs.follows = "nixpkgs";
};
/*
hyprland.url = "github:hyprwm/Hyprland";
hyprland-plugins = {
url = "github:hyprwm/hyprland-plugins";
inputs.hyprland.follows = "hyprland";
};
*/
};
outputs =
inputs@{
nixpkgs,
home-manager,
spicetify-nix,
...
}:
let
system = "x86_64-linux";
# User Variables
hostname = "dxflake";
username = "khoa";
gitUsername = "dxcently";
gitEmail = "dxcently@gmail.com";
theme = "sakura";
pkgs = import nixpkgs {
inherit system;
config = {
allowUnfree = true;
};
};
in
{
nixosConfigurations = {
"${hostname}" = nixpkgs.lib.nixosSystem {
specialArgs = {
inherit system;
inherit inputs;
inherit username;
inherit hostname;
inherit gitUsername;
inherit gitEmail;
};
modules = [
./configuration.nix
home-manager.nixosModules.home-manager
{
home-manager.extraSpecialArgs = {
inherit username;
inherit gitEmail;
inherit inputs;
inherit gitUsername;
inherit theme;
inherit (inputs.nix-colors.lib-contrib { inherit pkgs; }) gtkThemeFromScheme;
inherit spicetify-nix;
};
home-manager.useGlobalPkgs = true;
home-manager.useUserPackages = true;
home-manager.backupFileExtension = "backup";
home-manager.users.${username} = import ./home.nix;
}
];
};
};
};
}
@dxcently thank you for the config
This is now solved.
some words to make the search easier: minimal nixvim installation, home manager, home-manager, flake, infinite recursion encountered, simple nixvim, flake.nix, home.nix, neovim