Accessing absolute paths in NixOS flake.nix

I am considering reorganizing my NixOS folder to improve its functionality and readability. Currently, it works well, but I believe that a more organized structure would be more future-proof. This is my NixOS folder right now:

├── flake.lock
├── flake.nix
├── hardware-configuration.nix
├── hosts
│   ├── apps.nix
│   ├── lukas
│   │   ├── apps.nix
│   │   ├── default.nix
│   │   ├── hardware-configuration.nix
│   │   └── home.nix
│   ├── configuration.nix
│   ├── dconf.nix
│   ├── default.nix
│   ├── desktop.nix
│   ├── home-desktop.nix
│   └── home.nix

And here’s what I have in mind:

├── flakes
│   └── flake.nix
├── hardware
│   └── hardware-configuration.nix
├── profiles
│   └── lukas
│       ├── apps.nix
│       ├── configuration.nix
│       ├── default.nix
│       ├── desktop.nix
│       ├── home-desktop.nix
│       └── home.nix
└── settings

I am attempting to move the files from the “hosts” folder to the “holden”, so everything is more on a user level. However, I am receiving an error message stating that “access to an absolute path is forbidden in pure eval mode” from my flake.nix.

nixosConfigurations = import ../profiles/lukas

I’m not quite sure what I have to do here, as I’m fairly new to flakes. Any help would be greatly appreciated!

1 Like

After studying the issue in more depth, i discovered that it was a misunderstanding on my part and that all subfolders do have to be in the same folder as the flake to keep it pure.

2 Likes