Linux attribute not provided with basic flake setup

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'

Idk if this is helpful:

[reubenw@nixos:~/Documents/nix-config]$ nix flake show --all-systems
git+file:///home/reubenw/Documents/nix-config?ref=refs/heads/master&rev=1e0872a5cd7e34d802bdadc6122050f9fe090f4d
├───formatter
│   ├───aarch64-darwin: package 'alejandra-3.0.0'
│   ├───aarch64-linux: package 'alejandra-3.0.0'
│   ├───i686-linux: package 'alejandra-3.0.0'
│   ├───x86_64-darwin: package 'alejandra-3.0.0'
│   └───x86_64-linux: package 'alejandra-3.0.0'
├───homeConfigurations: unknown
├───homeManagerModules: unknown
├───nixosConfigurations
│   └───your-hostname: NixOS configuration
└───overlays
    ├───additions: Nixpkgs overlay
    ├───modifications: Nixpkgs overlay
    └───unstable-packages: Nixpkgs overlay

I’m not sure how I would define this attribute. Any help would be greatly appreciated.

What are you trying to achieve with this flake?

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.

1 Like

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

1 Like