Skip to content

Commit

Permalink
nixos/storage: Integrate storage UUIDs in fs/swaps
Browse files Browse the repository at this point in the history
This implements the deterministically generated UUIDs to be used while
mounting file systems, but only if there is no label set already. So the
user still has a way to set labels (which are also applied by nixpart)
and use them accordingly, even though the UUIDs should be more
distincive.

Signed-off-by: aszlig <aszlig@redmoonstudios.org>
  • Loading branch information
aszlig committed Jan 6, 2017
1 parent 2b00955 commit a8952b1
Showing 1 changed file with 20 additions and 7 deletions.
27 changes: 20 additions & 7 deletions nixos/modules/tasks/storage/default.nix
Expand Up @@ -272,16 +272,23 @@ in
'';
};

# If a fileSystems submodule references "btrfs." via the storage option,
# set the default value for fsType to "btrfs".
config = lib.mkIf (isBtrfs config.storage) {
fsType = lib.mkDefault "btrfs";
};
config = lib.mkMerge [
# If a fileSystems submodule references "btrfs." via the storage option,
# set the default value for fsType to "btrfs".
(lib.mkIf (isBtrfs config.storage) {
fsType = lib.mkDefault "btrfs";
})
# If no label is set, reference the device via the generated UUID in
# genericOptions.uuid.
(lib.mkIf (config.storage != null && config.label == null) {
device = "/dev/disk/by-uuid/${config.storage.config.uuid}";
})
];
}));
};

options.swapDevices = mkOption {
type = types.listOf (types.submodule {
type = types.listOf (types.submodule ({ config, options, ... }: {
options.storage = storageLib.mkDeviceSpecOption {
validDeviceTypes = containerTypes;
typeContainer = types.nullOr;
Expand All @@ -293,7 +300,13 @@ in
this swap device.
'';
};
});

# If no label is set, reference the device via the generated UUID in
# genericOptions.uuid.
config = lib.mkIf (config.storage != null && !options.label.isDefined) {
device = "/dev/disk/by-uuid/${config.storage.config.uuid}";
};
}));
};

config = {
Expand Down

0 comments on commit a8952b1

Please sign in to comment.