I am new to NixOS, did my first build with this flake
{
description = "NixOS Config";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
home-manager.url = "github:nix-community/home-manager";
home-manager.inputs.nixpkgs.follows = "nixpkgs";
hardware.url = "github:nixos/nixos-hardware";
};
outputs = { self, nixpkgs, home-manager, ... }@inputs: {
# build: 'nixos-rebuild --flake .#the-hostname'
nixosConfigurations = {
jnix = nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
specialArgs = { inherit inputs; };
modules = [
./nixos/configuration.nix
];
};
};
# Available through 'home-manager --flake .#janmejay@jnix'
homeConfigurations = {
"janmejay@jnix" = home-manager.lib.homeManagerConfiguration {
system = "x86_64-linux";
pkgs = nixpkgs.legacyPackages.x86_64-linux; # Home-manager wants 'pkgs'
extraSpecialArgs = { inherit inputs; };
modules = [
./home-manager/home.nix
];
};
};
};
}
Src: GitHub - janmejay/nixos.d: NixOS config
After successful rebuild switch and reboot attempt to run nixos-option
fails with
janmejay@jnix:~/nixos.d(master○) » nixos-option
terminate called after throwing an instance of 'nix::ThrownError'
what(): error:
… while evaluating the attribute 'options'
at /nix/store/4cpakzyvfw1rmm9v5i3387x6jd2h1v86-source/nixos/default.nix:15:17:
14| {
15| inherit (eval) pkgs config options;
| ^
16|
… while evaluating the attribute 'options'
at /nix/store/4cpakzyvfw1rmm9v5i3387x6jd2h1v86-source/lib/modules.nix:333:9:
332| _type = "configuration";
333| options = checked options;
| ^
334| config = checked (removeAttrs config [ "_module" ]);
(stack trace truncated; use '--show-trace' to show the full trace)
error: file 'nixos-config' was not found in the Nix search path (add it using $NIX_PATH or -I)
at «none»:0: (source not available)
[1] 36703 abort (core dumped) nixos-option
janmejay@jnix:~/nixos.d(master○) »
I tried manipulating NIX_PATH and now it looks like it doesn’t like my flake definition
janmejay@jnix:~ » echo $NIX_PATH 134 ↵
nixpkgs=flake:nixpkgs:/nix/var/nix/profiles/per-user/root/channels
janmejay@jnix:~ » export NIX_PATH=$NIX_PATH:nixos-config=/home/janmejay/nixos.d/flake.nix
janmejay@jnix:~ » nixos-option
terminate called after throwing an instance of 'nix::ThrownError'
what(): error:
… while evaluating the attribute 'options'
at /nix/store/4cpakzyvfw1rmm9v5i3387x6jd2h1v86-source/nixos/default.nix:15:17:
14| {
15| inherit (eval) pkgs config options;
| ^
16|
… while evaluating the attribute 'options'
at /nix/store/4cpakzyvfw1rmm9v5i3387x6jd2h1v86-source/lib/modules.nix:333:9:
332| _type = "configuration";
333| options = checked options;
| ^
334| config = checked (removeAttrs config [ "_module" ]);
(stack trace truncated; use '--show-trace' to show the full trace)
error: The option `description' does not exist. Definition values:
- In `/home/janmejay/nixos.d/flake.nix': "NixOS Config"
[1] 60432 abort (core dumped) nixos-option
janmejay@jnix:~ »
But nix flake check
seems happy with the way the flake is defined.
janmejay@jnix:~/nixos.d(master○) » nix flake check
janmejay@jnix:~/nixos.d(master○) » echo $?
0
janmejay@jnix:~/nixos.d(master○) »
I temporarily deleted the key anyway
diff --git a/flake.nix b/flake.nix
index 2458d95..5c3fda0 100644
--- a/flake.nix
+++ b/flake.nix
@@ -1,5 +1,5 @@
{
- description = "NixOS Config";
+ # description = "NixOS Config";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
but then the error changed to
janmejay@jnix:~/nixos.d(master⚡) » nixos-option
terminate called after throwing an instance of 'nix::ThrownError'
what(): error:
… while evaluating the attribute 'options'
at /nix/store/4cpakzyvfw1rmm9v5i3387x6jd2h1v86-source/nixos/default.nix:15:17:
14| {
15| inherit (eval) pkgs config options;
| ^
16|
… while evaluating the attribute 'options'
at /nix/store/4cpakzyvfw1rmm9v5i3387x6jd2h1v86-source/lib/modules.nix:333:9:
332| _type = "configuration";
333| options = checked options;
| ^
334| config = checked (removeAttrs config [ "_module" ]);
(stack trace truncated; use '--show-trace' to show the full trace)
error: The option `inputs' does not exist. Definition values:
- In `/home/janmejay/nixos.d/flake.nix':
{
hardware = {
url = "github:nixos/nixos-hardware";
};
home-manager = {
...
[1] 71960 abort (core dumped) nixos-option
janmejay@jnix:~/nixos.d(master⚡) »
Flake check still looks good
janmejay@jnix:~/nixos.d(master⚡) » nix flake check
warning: Git tree '/home/janmejay/nixos.d' is dirty
janmejay@jnix:~/nixos.d(master⚡) » echo $?
0
janmejay@jnix:~/nixos.d(master⚡) »
What am I missing?