Hello all,
I’m about 8 hours into my first nixOS config, and I’ve reached a total blocker. To help with troubleshooting, I’ve put the entire config on a public github here:
There are two (possibly related) problems:
- Whenever I try to build a flake, I get the error:
error: The option
home-manager.users.gordy.environment’ does not exist.`
The full stack trace is in the readme of the above github repo
- This error might be happening because the home config is not recognized by the flake. When I run
nix flake show
it lists the homeConfig and homeManagerModules as “unknown”
[gordy@nixos:~/mysystem]$ nix flake show ~/mysystem
path:/home/gordy/mysystem?lastModified=1723015892&narHash=sha256-baVHD%2BPpBbmTAgJz9pW6pZLrGJzHPbZNfX1Rr8oJEM4%3D
├───homeConfigurations: unknown
├───homeManagerModules: unknown
├───nixosConfigurations
│ └───work: NixOS configuration
└───nixosModules
└───default: NixOS module
Both chatGPT and I are totally stuck on this. Things I’ve tried without effect are:
- Adding an
environment
property to the user schema in /modules/nixos/bundles/home-manager/users.nix with a default value as an empty dict
- Commenting out every line that invokes
environment
anywhere in the project
- Adding an
environment
property to the userSettings property in hosts/default/configuration.nix
I would really appreciate some assistance with this, thank you!
What command? You don’t build a flake, you build an output of the flake.
And nix flake show
is irrelevant, it doesn’t know HM properly.
EDIT: I saw the command in the readme, so are you using standalone HM or HM as a NixOS module? (Pick one.)
Thanks for the quick response! @waffle8946
What command? You don’t build a flake, you build an output of the flake.
nixos-rebuild switch --flake ~/mysystem/#work
so are you using standalone HM or HM as a NixOS module
I’m trying to use it as a nixos module. I like the idea of flake as orchestrator and everything else (including HM and nix itself) as modules inside it.
That means two things:
homeConfigurations
is no longer relevant here (you could remove it, for your own clarity)
- you’re likely accidentally importing a nixos module into your hm config, based on the error.
I can’t really say further as you’re using someone else’s abstraction, so you’d likely want to ask them for help or avoid their abstraction entirely and just start simple (my recommendation).
Thanks for the tip! I’ll do another search for nix modules in HM. There is literally modules/home-manager/nix.nix
which smells a lot like a nix module in home manager.
Otherwise, I’ll just fork GitHub - Misterio77/nix-starter-configs: Simple and documented config templates to help you get started with NixOS + home-manager + flakes. All the boilerplate you need! and start over again.
I would strongly recommend against using misterio’s configs, as again, that’s someone else’s abstraction (and specifically misterio’s configs also have significant problems).
All you need to create a flake.nix
for a NixOS configuration (assuming nixos-unstable
here) is the following:
{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
# add other inputs as applicable
};
outputs =
{ nixpkgs, ... }@inputs:
{
nixosConfigurations = {
# replace HOSTNAME with whatever you use in `networking.hostName`
HOSTNAME = nixpkgs.lib.nixosSystem {
modules = [
# replace with whatever your config's entrypoint is
./configuration.nix
];
specialArgs = { inherit inputs; }
};
};
};
}
Then follow the HM manual if you want to use HM, by adding only the additional bits mentioned in Home Manager Manual.
If you need help writing a config from scratch, ask! Don’t mindlessly copy others.
1 Like
@waffle8946 good timing; I was thiiiiiis close to forking misterio77’s configs.
Instead, I’ve put together a plan for how I want to approach building a config from scratch- would you mind giving some feedback?
- I like the idea of separate system and user configs; however as I’m the only one using this machine, it doesn’t make sense to start with multiple user profiles, and I can get away with shared system & user configs.
- The “system configs” would be things like GPU drivers, window manager, nix garbage collection / generation trimming, datetime, and default editor
- These system configs would not go in home.nix, but in configuration.nix
- I like having the configuration.nix outside of /etc/ for rootless access
- There are a good handful of packages I want to install, but many of them don’t have special config requirements. I can get away with having 30+ packages listed in home.nix
I think I can get away with a much smaller project and still meet these criteria. Probable something like:
mysystem/
L flake.nix # simple flake orchestrator
L home.nix # define user config here
L configuration.nix # define system config here
L hardware-configuration.nix # no touch-y
L modules/
default.nix # put all the package config here
Sure, that’s a reasonable start.
And yes, your config does not need to be in /etc, it can be in any directory or on github or so on.
If you want to modularise later on, you definitely can start adding more directories/files for various hosts/users/whatever, but not necessary to start out.
There are many configs out there for your reference. Here’s mine.
1 Like