I’ve just installed nixos. I’ve tried multiple online configs to work with flakes. The most recent of which being here. All the configs (3) I tried I gave up (switched to a different online config) when I ran into the same error.
error: flake 'git+file:///home/reubenw/Documents/nix-config' does not provide attribute 'packages.x86_64-linux.default' or 'defaultPackage.x86_64-linux'
The error message suggests you’re trying nix run, which is supposed to execute whatever the “default” application your flake contains is - think making a flake for a CLI tool.
The template you used seems to contain a NixOS configuration, though, which you would need to manage with nixos-rebuild instead.
Thanks for your reply. I see I should’ve provided some additional information. I am trying to use the flake for a NixOS configuration. In all honesty I’m just trying to get the template to work as is so that I can build off of it. I didn’t want to make changes if I can’t get this fairly empty configuration to build. When I run sudo nixos-rebuild switch --flake . I get a similar error:
error: flake 'git+file:///home/reubenw/Documents/nix-config' does not provide attribute 'packages.x86_64-linux.nixosConfigurations."nixos".config.system.build.nixos-rebuild', 'legacyPackages.x86_64-linux.nixosConfigurations."nixos".config.system.build.nixos-rebuild' or 'nixosConfigurations."nixos".config.system.build.nixos-rebuild'
Although I am trying to use this flake (single flake?) for NixOS configuration. I’d like to understand the first use case. Can a flake be created as an environment for a specific application? The equivalent to a venv for python?
nixos-rebuild will try to use the nixosConfigurations attribute that matches the system hostname by default, you need to explicitly pass the attribute you want like sudo nixos-rebuild switch --flake .#your-hostname.
Yep, that’s one of the main use cases. You can create full venvs in packages (all nix packages are basically just language-agnostic venvs), something akin to venvs but for development in devShells, or simple shortcuts to actually run binaries in such a venv. I have a flake here with exclusively such: https://github.com/TLATER/tlaterpkgs/blob/d5503f100834236484a1d19fbcc1ccbf561ada84/flake.nix#L18