I have two NixOS configurations:
-
/etc/nixos_works
: works fine -
/etc/nixos_bug
: swap device does not appear
(message at beginning of boot process)
But, in my opinion, the only difference is the order of attributes.
I do not understand, why the order is important.
nixos_works
The luks.device for the swap device is set in machineParameters.nix
:
{ pkgs }:
let
prop = import ./properties.nix { };
...
in {
...
attributes = {
boot.initrd.luks.devices."luks-eb078b50-9cc3-4a8c-b0fc-0008f7c4c1f3".device =
"/dev/disk/by-uuid/eb078b50-9cc3-4a8c-b0fc-0008f7c4c1f3";
boot.kernelParams = prop.bootKernelParams;
...
}; # end of attributes
}
which then is imported into configuration.nix
:
{ config, pkgs, ... }:
let
prop = import ./properties.nix { };
machine = import ./machineParameters.nix { inherit pkgs; };
in {
imports = [
...
];
...
system.stateVersion = prop.nixRelease; # Did you read the comment?
} // prop.fileSys // machine.attributes # include machine specific settings
The swap devices appears and I have 16 GiB of swap
nixos_bug
The luks.device for the swap device is defined directly in configuration.nix
and not in machineParameters.nix
:
{ config, pkgs, ... }:
let
prop = import ./properties.nix { };
machine = import ./machineParameters.nix { inherit pkgs; };
in {
imports = [
...
];
...
system.stateVersion = prop.nixRelease; # Did you read the comment?
boot.initrd.luks.devices."luks-eb078b50-9cc3-4a8c-b0fc-0008f7c4c1f3".device =
"/dev/disk/by-uuid/eb078b50-9cc3-4a8c-b0fc-0008f7c4c1f3";
} // prop.fileSys // machine.attributes # include machine specific settings
but it does not appear and my swap size is 0B:
free -h
gesamt benutzt frei gemns. Puffer/Cache verfĂĽgbar
Speicher: 15Gi 759Mi 12Gi 952Mi 1.8Gi 13Gi
Swap: 0B 0B 0B
Difference between nixos_works and nixos_bug
There is really no other difference:
âžś ~ diff -r /etc/nixos_works /etc/nixos_bug
diff --color -r /etc/nixos_works/configuration.nix /etc/nixos_bug/configuration.nix
80a81,83
> boot.initrd.luks.devices."luks-eb078b50-9cc3-4a8c-b0fc-0008f7c4c1f3".device =
> "/dev/disk/by-uuid/eb078b50-9cc3-4a8c-b0fc-0008f7c4c1f3";
>
diff --color -r /etc/nixos_works/machineParameters.nix /etc/nixos_bug/machineParameters.nix
44,46d43
< boot.initrd.luks.devices."luks-eb078b50-9cc3-4a8c-b0fc-0008f7c4c1f3".device =
< "/dev/disk/by-uuid/eb078b50-9cc3-4a8c-b0fc-0008f7c4c1f3";
<
Does anybody understand why the second configuration fails?
Thanks for your help.