Compare commits
No commits in common. "25b9dc42fb9a94b05899cf618eb5797c05bd5894" and "f44d0a4a73cb624044dfba7abe0e782c95066ab0" have entirely different histories.
25b9dc42fb
...
f44d0a4a73
22 changed files with 179 additions and 425 deletions
|
@ -1,115 +0,0 @@
|
|||
{ lib, config, ... }:
|
||||
let
|
||||
inherit (lib) types mkOption;
|
||||
cfg = config.valhalla.fileSystems;
|
||||
|
||||
mountType = types.submodule (
|
||||
{ config, name, ... }: {
|
||||
options = {
|
||||
device = mkOption {
|
||||
type = types.nullOr types.str;
|
||||
description = "The device to mount.";
|
||||
default = null;
|
||||
};
|
||||
|
||||
mountPoint = mkOption {
|
||||
type = types.str;
|
||||
description = "The path to mount the device to.";
|
||||
default = name;
|
||||
};
|
||||
|
||||
fsType = mkOption {
|
||||
type = types.nullOr types.str;
|
||||
description = "The file system type of the mount.";
|
||||
default = null;
|
||||
};
|
||||
|
||||
options = mkOption {
|
||||
type = types.listOf types.str;
|
||||
description = "The options of the mount.";
|
||||
default = [ ];
|
||||
};
|
||||
};
|
||||
}
|
||||
);
|
||||
in
|
||||
{
|
||||
imports = [
|
||||
./fileSystems/btrfs.nix
|
||||
./fileSystems/disks.nix
|
||||
];
|
||||
|
||||
options = {
|
||||
valhalla = {
|
||||
fileSystems = {
|
||||
rootDir = mkOption {
|
||||
type = types.str;
|
||||
description = "The root of the installation directory to mount disks into.";
|
||||
default = "/mnt";
|
||||
};
|
||||
|
||||
mounts = mkOption {
|
||||
type = types.attrsOf mountType;
|
||||
description = "The devices to mount.";
|
||||
default = { };
|
||||
};
|
||||
|
||||
script = mkOption {
|
||||
type = types.str;
|
||||
description = "The script for preparing the system's mounts.";
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
config = {
|
||||
valhalla = {
|
||||
fileSystems = {
|
||||
script =
|
||||
let
|
||||
inherit (lib.strings) normalizePath removeSuffix;
|
||||
devices = (builtins.attrValues cfg.diskSetup.devices);
|
||||
mountScript = lib.strings.concatLines (
|
||||
(builtins.concatMap
|
||||
(
|
||||
_: [
|
||||
"partprobe 2> /dev/null || true"
|
||||
"udevadm trigger"
|
||||
(builtins.concatStringsSep " " (
|
||||
[ "sudo" "mount" "--mkdir" ] ++
|
||||
(lib.optionals (_.fsType == "ntfs") [ "-t" "ntfs3" ]) ++
|
||||
[
|
||||
(builtins.concatStringsSep " " (builtins.map (_: "-o ${_}") _.options))
|
||||
(_.device)
|
||||
(removeSuffix "/" (normalizePath "/${cfg.rootDir}/${_.mountPoint}"))
|
||||
]
|
||||
))
|
||||
]
|
||||
)
|
||||
(builtins.attrValues cfg.mounts))
|
||||
);
|
||||
in
|
||||
''
|
||||
#!/bin/bash
|
||||
set -o errexit
|
||||
${cfg.diskSetup.scripts.init}
|
||||
${lib.strings.concatLines (lib.optionals ((builtins.length devices) > 0) [
|
||||
''echo $(tput setaf 3)=== WARNING ====$(jtput sgr0)"''
|
||||
(''echo "Continuing this script will alter the partitions of ''
|
||||
+ (lib.strings.concatStringsSep ", " (builtins.map (_: "${_.deviceVariable}") (lib.lists.init devices)))
|
||||
+ (if (builtins.length devices) > 1 then " and " else "") + (lib.lists.last devices).deviceVariable + ''"'')
|
||||
''
|
||||
if ! fish ${./fileSystems/confirm.fish} "Are you sure you want to continue?" "n"; then
|
||||
exit 1
|
||||
fi
|
||||
''
|
||||
])}
|
||||
${cfg.diskSetup.scripts.partition}
|
||||
${cfg.btrfs.script}
|
||||
${mountScript}
|
||||
${cfg.diskSetup.scripts.swap}
|
||||
'';
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
|
@ -1,108 +0,0 @@
|
|||
{ lib, config, ... }:
|
||||
let
|
||||
inherit (lib) types mkOption;
|
||||
cfg = config.valhalla.fileSystems.btrfs;
|
||||
|
||||
profileType = types.enum [
|
||||
"raid0"
|
||||
"raid1"
|
||||
"raid1c3"
|
||||
"raid1c4"
|
||||
"raid5"
|
||||
"raid6"
|
||||
"raid10"
|
||||
"dup"
|
||||
"single"
|
||||
];
|
||||
|
||||
volumeType = types.submodule (
|
||||
{ config, name, ... }: {
|
||||
options = {
|
||||
mountPoint = mkOption {
|
||||
type = types.nullOr types.str;
|
||||
description = "The path to mount the volume to.";
|
||||
default = null;
|
||||
};
|
||||
|
||||
devices = mkOption {
|
||||
type = types.listOf types.str;
|
||||
description = "The devices of the btrfs volume.";
|
||||
};
|
||||
|
||||
label = mkOption {
|
||||
type = types.nullOr types.str;
|
||||
description = "The label of the volume.";
|
||||
default = name;
|
||||
};
|
||||
|
||||
dataProfile = mkOption {
|
||||
type = types.nullOr profileType;
|
||||
description = "The data profile.";
|
||||
default = null;
|
||||
};
|
||||
|
||||
metadataProfile = mkOption {
|
||||
type = types.nullOr profileType;
|
||||
description = "The metadata profile.";
|
||||
default = null;
|
||||
};
|
||||
};
|
||||
}
|
||||
);
|
||||
in
|
||||
{
|
||||
options = {
|
||||
valhalla = {
|
||||
fileSystems.btrfs = {
|
||||
volumes = mkOption {
|
||||
type = types.attrsOf volumeType;
|
||||
description = "The btrfs volumes of the system.";
|
||||
default = { };
|
||||
};
|
||||
|
||||
script = mkOption {
|
||||
type = types.str;
|
||||
description = "The script for creating the btrfs volumes.";
|
||||
default = lib.strings.concatLines (
|
||||
builtins.map
|
||||
(
|
||||
_: builtins.concatStringsSep " " (
|
||||
[ "mkfs.btrfs" ] ++
|
||||
(lib.optionals (_.metadataProfile != null) [ "--metadata" "${_.metadataProfile}" ]) ++
|
||||
(lib.optionals (_.dataProfile != null) [ "--data" "${_.dataProfile}" ]) ++
|
||||
(lib.optionals (_.label != null) [ "--label" "${_.label}" ]) ++
|
||||
_.devices
|
||||
)
|
||||
)
|
||||
(builtins.attrValues cfg.volumes)
|
||||
);
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
config = {
|
||||
valhalla = {
|
||||
linux.programs.btrfs = lib.optionalAttrs
|
||||
(builtins.any
|
||||
(_: (builtins.length _.devices) > 1)
|
||||
(builtins.attrValues cfg.volumes))
|
||||
{
|
||||
enable = true;
|
||||
pools = true;
|
||||
};
|
||||
|
||||
fileSystems.mounts = lib.attrsets.concatMapAttrs
|
||||
(
|
||||
name: volume:
|
||||
if (volume.mountPoint != null) then {
|
||||
${volume.mountPoint} = {
|
||||
device = builtins.elemAt volume.devices 0;
|
||||
fsType = "btrfs";
|
||||
};
|
||||
} else { }
|
||||
)
|
||||
cfg.volumes;
|
||||
};
|
||||
};
|
||||
}
|
5
lib/modules/partition.nix
Normal file
5
lib/modules/partition.nix
Normal file
|
@ -0,0 +1,5 @@
|
|||
{ ... }: {
|
||||
imports = [
|
||||
./partition/disks.nix
|
||||
];
|
||||
}
|
|
@ -22,7 +22,7 @@ function chooseDisk -a outFile message selectScript
|
|||
end
|
||||
end
|
||||
|
||||
select "$header" "$outFile" "$message" "No valid device found!" "$(string collect $disks)" false
|
||||
select "$header" "$outFile" "$message" "No valid disk found!" "$(string collect $disks)" false
|
||||
and begin
|
||||
set -l disk (string split -n " " (cat "$outFile"))
|
||||
echo "/dev/$disk[1]" >$outFile
|
|
@ -4,8 +4,7 @@ let
|
|||
|
||||
fs = import ./fs.nix;
|
||||
|
||||
cfg = config.valhalla.fileSystems;
|
||||
deviceListVarName = "myDevices";
|
||||
diskListVarName = "myDisks";
|
||||
isSwap = partition: builtins.elem partition.type [ fs.swap 19 ];
|
||||
|
||||
probeScript = builtins.concatStringsSep "\n" [
|
||||
|
@ -13,35 +12,39 @@ let
|
|||
"udevadm trigger"
|
||||
];
|
||||
|
||||
mkDeviceType = types.submodule (
|
||||
mkDiskType = osDisk: types.submodule (
|
||||
{ config, name, ... }: {
|
||||
options = {
|
||||
id = mkOption {
|
||||
type = types.str;
|
||||
description = "The internal identifier of the device.";
|
||||
description = "The internal identifier of the disk.";
|
||||
internal = true;
|
||||
};
|
||||
|
||||
wipe = mkOption {
|
||||
type = types.bool;
|
||||
description = "A value indicating whether the device should be wiped.";
|
||||
description = "A value indicating whether the disk should be wiped.";
|
||||
default = !(lib.lists.any (_: _.keepExisting) (builtins.attrValues config.partitions));
|
||||
};
|
||||
|
||||
name = mkOption {
|
||||
deviceName = mkOption {
|
||||
type = types.nullOr types.str;
|
||||
description = "The name of the device.";
|
||||
default = name;
|
||||
default = if osDisk then null else name;
|
||||
};
|
||||
|
||||
path = mkOption {
|
||||
type = types.nullOr types.str;
|
||||
devicePath = mkOption {
|
||||
type =
|
||||
if osDisk then
|
||||
types.nullOr types.str
|
||||
else
|
||||
types.str;
|
||||
description = "The path to the device.";
|
||||
default =
|
||||
if config.name == null then
|
||||
if osDisk && config.deviceName == null then
|
||||
null
|
||||
else
|
||||
"/dev/${config.name}";
|
||||
"/dev/${config.deviceName}";
|
||||
};
|
||||
|
||||
deviceScript = mkOption {
|
||||
|
@ -62,28 +65,21 @@ let
|
|||
default = { };
|
||||
};
|
||||
|
||||
scripts = {
|
||||
init = mkOption {
|
||||
type = types.str;
|
||||
description = "A script for loading the device path into the device variable";
|
||||
};
|
||||
|
||||
partition = mkOption {
|
||||
type = types.str;
|
||||
description = "A script for partitioning and formatting the device.";
|
||||
};
|
||||
script = mkOption {
|
||||
type = types.str;
|
||||
description = "The script for formatting the disk.";
|
||||
};
|
||||
};
|
||||
|
||||
config =
|
||||
let
|
||||
deviceVarName = "${deviceListVarName}[${config.id}]";
|
||||
deviceVar = "\${${deviceVarName}}";
|
||||
diskVarName = "${diskListVarName}[${config.id}]";
|
||||
diskVar = "\${${diskVarName}}";
|
||||
|
||||
deviceSelector = ''
|
||||
diskSelector = ''
|
||||
result="$(mktemp)"
|
||||
fish ${./choose-device.fish} "$result" "Please select the \"${name}\" device:" ${./select.fish}
|
||||
${deviceVarName}="$(cat "$result")"
|
||||
fish ${./choose-disk.fish} "$result" "Which disk do you wish to install the OS on?" ${./select.fish}
|
||||
${diskVarName}="$(cat "$result")"
|
||||
'';
|
||||
|
||||
partitions = lib.lists.sortOn (_: _.index)
|
||||
|
@ -103,12 +99,13 @@ let
|
|||
"echo ${script} | ${
|
||||
fdiskCommand "${builtins.concatStringsSep " " args} ${
|
||||
if append then "--append" else ""
|
||||
} ${deviceVar}"
|
||||
} ${diskVar}"
|
||||
}";
|
||||
wipeScript = script: fdiskScript script [ ] false;
|
||||
appendScript = index: script: fdiskScript script [ "-N" (builtins.toString index) ] true;
|
||||
|
||||
cleanup = lib.strings.concatLines (builtins.map
|
||||
(partition: "${fdiskCommand "--delete ${deviceVar} ${toString partition.index}"} || true")
|
||||
(partition: "${fdiskCommand "--delete ${diskVar} ${toString partition.index}"} || true")
|
||||
(lib.lists.sortOn
|
||||
(partition: partition.index * -1)
|
||||
(builtins.filter (_: !_.keepExisting) partitions)));
|
||||
|
@ -116,7 +113,7 @@ let
|
|||
fdiskCommands = lib.strings.concatLines
|
||||
(lib.optionals config.wipe [
|
||||
cleanup
|
||||
(fdiskScript "label: gpt" [ ] false)
|
||||
(wipeScript "label: gpt")
|
||||
] ++ (builtins.concatMap
|
||||
(
|
||||
partition:
|
||||
|
@ -132,7 +129,6 @@ let
|
|||
|
||||
formatScripts = {
|
||||
${fs.ext4} = "mkfs.ext4 -F ${partVar}";
|
||||
${fs.btrfs} = "mkfs.btrfs ${partVar}";
|
||||
${fs.swap} = "mkswap ${partVar}";
|
||||
${fs.ntfs} = "mkfs.ntfs -F ${partVar}";
|
||||
${fs.fat32} = "mkfs.fat -F 32 ${partVar}";
|
||||
|
@ -140,18 +136,16 @@ let
|
|||
|
||||
labelScripts = {
|
||||
${fs.ext4} = label: "e2label ${partVar} ${label}";
|
||||
${fs.btrfs} = label: "btrfs filesystem label ${partVar} ${label}";
|
||||
${fs.swap} = label: "swaplabel ${partVar} --label ${label}";
|
||||
${fs.ntfs} = label: "ntfslabel ${partVar} ${label}";
|
||||
${fs.fat32} = label: "fatlabel ${partVar} ${label}";
|
||||
};
|
||||
|
||||
create = lib.strings.concatLines ([
|
||||
create = lib.strings.concatLines [
|
||||
(appendScript index ''${toString index}: "$(${sizeOption})" type=${mkType type}'')
|
||||
probeScript
|
||||
] ++ (lib.optionals (format != null) [
|
||||
"sudo ${formatScripts.${format}}"
|
||||
]));
|
||||
];
|
||||
|
||||
fallback = ''
|
||||
if ! { ls "${partVar}" 2>&1; } > /dev/null
|
||||
|
@ -161,12 +155,11 @@ let
|
|||
'';
|
||||
in
|
||||
[
|
||||
''local diskPath="$(find -L /dev/disk/by-diskseq -samefile ${deviceVar})"''
|
||||
''local diskPath="$(find -L /dev/disk/by-diskseq -samefile ${diskVar})"''
|
||||
''local ${partVarName}="$diskPath-part${toString index}"''
|
||||
(if keepExisting then fallback else create)
|
||||
] ++ (lib.optionals (format != null) [
|
||||
"sudo ${labelScripts.${format} label}"
|
||||
])
|
||||
]
|
||||
)
|
||||
partitions));
|
||||
|
||||
|
@ -175,25 +168,25 @@ let
|
|||
partition:
|
||||
lib.optional
|
||||
(partition.keepExisting && !(builtins.isNull partition.type))
|
||||
''sudo sfdisk --part-type ${deviceVar} ${toString partition.index} ${mkType partition.type}''
|
||||
''sudo sfdisk --part-type ${diskVar} ${toString partition.index} ${mkType partition.type}''
|
||||
)
|
||||
partitions);
|
||||
in
|
||||
{
|
||||
id = "disk-${name}";
|
||||
deviceVariable = deviceVar;
|
||||
id = if osDisk then "os" else "disk-${name}";
|
||||
deviceVariable = diskVar;
|
||||
|
||||
scripts = {
|
||||
init =
|
||||
if config.path == null then ''
|
||||
${deviceSelector}
|
||||
'' else ''
|
||||
${deviceVarName}=${config.path}
|
||||
if [ ! -b ${deviceVar} ]; then
|
||||
deviceScript =
|
||||
if osDisk && config.devicePath == null then ''
|
||||
${diskSelector}
|
||||
'' else ''
|
||||
${diskVarName}=${config.devicePath}
|
||||
${if osDisk then ''
|
||||
if [ ! -b ${diskVar} ]; then
|
||||
function fallback() {
|
||||
echo "Couldn't find the specified disk \"${deviceVar}\"."
|
||||
if fish ${./confirm.fish} "Do you want to choose a different \"${name}\" disk?"; then
|
||||
${deviceSelector}
|
||||
echo "Couldn't find the specified disk \"${diskVar}\"."
|
||||
if fish ${./confirm.fish} "Do you want to install the OS on another disk?"; then
|
||||
${diskSelector}
|
||||
else
|
||||
exit 1
|
||||
fi
|
||||
|
@ -201,19 +194,20 @@ let
|
|||
|
||||
fallback
|
||||
fi
|
||||
'';
|
||||
|
||||
partition = lib.mkDefault ''
|
||||
function partition() {
|
||||
${if (!config.wipe) then cleanup else ""}
|
||||
${probeScript}
|
||||
${fdiskCommands}
|
||||
${fixType}
|
||||
}
|
||||
|
||||
partition
|
||||
'' else
|
||||
""}
|
||||
'';
|
||||
};
|
||||
|
||||
script = lib.mkDefault ''
|
||||
function partition() {
|
||||
${if (!config.wipe) then cleanup else ""}
|
||||
${probeScript}
|
||||
${fdiskCommands}
|
||||
${fixType}
|
||||
}
|
||||
|
||||
partition
|
||||
'';
|
||||
};
|
||||
}
|
||||
);
|
||||
|
@ -245,13 +239,13 @@ let
|
|||
};
|
||||
|
||||
format = mkOption {
|
||||
type = types.nullOr (types.enum (builtins.attrValues fs));
|
||||
type = types.enum (builtins.attrValues fs);
|
||||
description = "The file system format of the partition.";
|
||||
default =
|
||||
if (isSwap config) then
|
||||
fs.swap
|
||||
else
|
||||
null;
|
||||
throw ("Partition format not specified.");
|
||||
};
|
||||
|
||||
size = mkOption {
|
||||
|
@ -297,30 +291,27 @@ in
|
|||
{
|
||||
options = {
|
||||
valhalla = {
|
||||
fileSystems = {
|
||||
diskSetup = {
|
||||
devices = mkOption {
|
||||
type = types.attrsOf (mkDeviceType);
|
||||
description = "The disk devices to format.";
|
||||
default = { };
|
||||
};
|
||||
partition = {
|
||||
rootDir = mkOption {
|
||||
type = types.str;
|
||||
description = "The root of the installation directory to mount disks into.";
|
||||
default = "/mnt";
|
||||
};
|
||||
|
||||
scripts = {
|
||||
init = mkOption {
|
||||
type = types.str;
|
||||
description = "The script for initializing the disk partitioning script.";
|
||||
};
|
||||
os = mkOption {
|
||||
type = mkDiskType true;
|
||||
description = "The partition layout of the OS disk.";
|
||||
};
|
||||
|
||||
partition = mkOption {
|
||||
type = types.str;
|
||||
description = "The script for partitioning the disks.";
|
||||
};
|
||||
disks = mkOption {
|
||||
type = types.attrsOf (mkDiskType false);
|
||||
description = "The additional disks to format.";
|
||||
default = { };
|
||||
};
|
||||
|
||||
swap = mkOption {
|
||||
type = types.str;
|
||||
description = "The script for enabling swap devices.";
|
||||
};
|
||||
};
|
||||
script = mkOption {
|
||||
type = types.str;
|
||||
description = "The script for partitioning the system's disks.";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
@ -328,47 +319,67 @@ in
|
|||
|
||||
config = {
|
||||
valhalla = {
|
||||
fileSystems = {
|
||||
mounts = (lib.attrsets.concatMapAttrs
|
||||
(
|
||||
name: device:
|
||||
lib.attrsets.concatMapAttrs
|
||||
(
|
||||
name: partition:
|
||||
if partition.mountPoint != null then {
|
||||
${partition.mountPoint} = {
|
||||
device = "/dev/disk/by-label/${partition.label}";
|
||||
fsType = partition.format;
|
||||
options = partition.mountOptions;
|
||||
};
|
||||
} else { }
|
||||
)
|
||||
device.partitions
|
||||
)
|
||||
cfg.diskSetup.devices);
|
||||
partition = {
|
||||
script = lib.mkDefault (
|
||||
let
|
||||
cfg = config.valhalla.partition;
|
||||
inherit (cfg) os rootDir;
|
||||
inherit (lib.strings) normalizePath;
|
||||
partPath = part: "/dev/disk/by-label/${part.label}";
|
||||
disks = ([ os ] ++ (builtins.attrValues cfg.disks));
|
||||
partitions = (builtins.concatMap (_: (builtins.attrValues _.partitions)) disks);
|
||||
|
||||
diskSetup = {
|
||||
scripts =
|
||||
let
|
||||
partPath = part: "/dev/disk/by-label/${part.label}";
|
||||
disks = ((builtins.attrValues cfg.diskSetup.devices));
|
||||
partitions = (builtins.concatMap (_: (builtins.attrValues _.partitions)) disks);
|
||||
in
|
||||
{
|
||||
init = lib.strings.concatLines (builtins.map (_: _.scripts.init) disks);
|
||||
partition = lib.strings.concatLines (builtins.map (_: _.scripts.partition) disks);
|
||||
swap = lib.strings.concatLines (
|
||||
(builtins.map
|
||||
(
|
||||
_: ''
|
||||
${probeScript}
|
||||
sudo swapon ${partPath _}
|
||||
''
|
||||
)
|
||||
(builtins.filter (_: _.useSwap) partitions))
|
||||
);
|
||||
};
|
||||
};
|
||||
mountScript = lib.strings.concatLines (builtins.concatMap
|
||||
(
|
||||
_: [
|
||||
probeScript
|
||||
(builtins.concatStringsSep " " ([
|
||||
"sudo"
|
||||
"mount"
|
||||
"--mkdir"
|
||||
] ++ (lib.optionals (_.format == "ntfs") [
|
||||
"-t"
|
||||
"ntfs3"
|
||||
]) ++ [
|
||||
(builtins.concatStringsSep " " (builtins.map (_: "-o ${_}") _.mountOptions))
|
||||
(partPath _)
|
||||
(normalizePath "/${rootDir}/${_.mountPoint}")
|
||||
]))
|
||||
]
|
||||
)
|
||||
(lib.lists.sortOn
|
||||
(_: normalizePath "/${_.mountPoint}")
|
||||
(builtins.filter (_: _.mountPoint != null) partitions)));
|
||||
|
||||
swapScript = lib.strings.concatLines (builtins.map
|
||||
(
|
||||
_: ''
|
||||
${probeScript}
|
||||
sudo swapon ${partPath _}
|
||||
''
|
||||
)
|
||||
(builtins.filter (_: _.useSwap) partitions));
|
||||
in
|
||||
lib.strings.concatLines ([
|
||||
"#!/bin/bash"
|
||||
"set -o errexit"
|
||||
]
|
||||
++ (builtins.map (_: _.deviceScript) disks)
|
||||
++ lib.optionals ((builtins.length disks) > 0) [
|
||||
''echo "$(tput setaf 3)==== WARNING ====$(tput sgr0)"''
|
||||
(''echo "Continuing this script will alter the partitions of ''
|
||||
+ (lib.strings.concatStringsSep ", " (builtins.map (_: "${_.deviceVariable}") (lib.lists.init disks)))
|
||||
+ (if (builtins.length disks) > 1 then " and " else "") + (lib.lists.last disks).deviceVariable + ''"'')
|
||||
''
|
||||
if ! fish ${./confirm.fish} "Are you sure you want to continue?" "n"; then
|
||||
exit 1
|
||||
fi
|
||||
''
|
||||
] ++ (builtins.map (_: _.script) disks) ++ [
|
||||
mountScript
|
||||
swapScript
|
||||
])
|
||||
);
|
||||
};
|
||||
};
|
||||
};
|
|
@ -1,6 +1,5 @@
|
|||
{
|
||||
ext4 = "ext4";
|
||||
btrfs = "btrfs";
|
||||
swap = "swap";
|
||||
ntfs = "ntfs";
|
||||
fat32 = "fat32";
|
|
@ -91,7 +91,6 @@ let
|
|||
in
|
||||
{
|
||||
imports = [
|
||||
./programs/btrfs.nix
|
||||
./programs/docker.nix
|
||||
./programs/git.nix
|
||||
./programs/nextcloud.nix
|
||||
|
|
|
@ -1,14 +0,0 @@
|
|||
{ lib, ... }:
|
||||
let
|
||||
inherit (lib) mkEnableOption;
|
||||
in
|
||||
{
|
||||
options = {
|
||||
valhalla = {
|
||||
linux.programs.btrfs = {
|
||||
enable = mkEnableOption "btrfs tools";
|
||||
pools = mkEnableOption "btrfs pool support in bootloaders";
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
|
@ -2,10 +2,10 @@
|
|||
let inherit (lib) mkOption types;
|
||||
in {
|
||||
imports = [
|
||||
./fileSystems.nix
|
||||
./hardware.nix
|
||||
./i18n.nix
|
||||
./os.nix
|
||||
./partition.nix
|
||||
./programs.nix
|
||||
./software.nix
|
||||
./users.nix
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
};
|
||||
};
|
||||
|
||||
fileSystems.diskSetup.devices.OS.partitions = {
|
||||
partition.os.partitions = {
|
||||
# Keep Windows' boot partition
|
||||
Boot.keepExisting = true;
|
||||
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
{ lib, config, ... }:
|
||||
let fs = import ../../../../lib/modules/fileSystems/fs.nix;
|
||||
let fs = import ../../../../lib/modules/partition/fs.nix;
|
||||
in {
|
||||
imports = [ ../defaults.nix ];
|
||||
|
||||
config = {
|
||||
valhalla = {
|
||||
fileSystems.diskSetup.devices = {
|
||||
OS = {
|
||||
partition = {
|
||||
os = {
|
||||
partitions = {
|
||||
Boot = {
|
||||
index = 1;
|
||||
|
|
|
@ -1,43 +1,32 @@
|
|||
{ lib, config, ... }:
|
||||
let fs = import ../../../lib/modules/fileSystems/fs.nix;
|
||||
let fs = import ../../../lib/modules/partition/fs.nix;
|
||||
in {
|
||||
imports = [ ../../users/manuel/config.nix ];
|
||||
|
||||
config = {
|
||||
valhalla = {
|
||||
fileSystems = {
|
||||
diskSetup.devices = {
|
||||
OS = {
|
||||
path = "/dev/sda";
|
||||
|
||||
partitions = {
|
||||
Boot = {
|
||||
index = 1;
|
||||
type = "uefi";
|
||||
size = "+1G";
|
||||
format = fs.fat32;
|
||||
mountPoint = config.valhalla.boot.efiMountPoint;
|
||||
};
|
||||
|
||||
Swap = {
|
||||
index = 2;
|
||||
type = "swap";
|
||||
};
|
||||
|
||||
OS = {
|
||||
index = 3;
|
||||
label = lib.mkDefault config.valhalla.boot.label;
|
||||
type = "linux";
|
||||
};
|
||||
partition = {
|
||||
os = {
|
||||
partitions = {
|
||||
Boot = {
|
||||
index = 1;
|
||||
type = "uefi";
|
||||
size = "+1G";
|
||||
format = fs.fat32;
|
||||
mountPoint = config.valhalla.boot.efiMountPoint;
|
||||
};
|
||||
|
||||
Swap = {
|
||||
index = 2;
|
||||
type = "swap";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
btrfs = {
|
||||
volumes = {
|
||||
OS = {
|
||||
index = 3;
|
||||
label = lib.mkDefault config.valhalla.boot.label;
|
||||
type = "linux";
|
||||
format = fs.ext4;
|
||||
mountPoint = "/";
|
||||
devices = [ "/dev/sda3" "/dev/sdb" ];
|
||||
};
|
||||
};
|
||||
};
|
||||
|
|
|
@ -91,7 +91,6 @@ begin
|
|||
|
||||
and echo (getOSConfig hostname) | arch-chroot "$mountDir" tee /etc/hostname >/dev/null
|
||||
|
||||
and runInOS fish "$tempDir/../Software/btrfs/main.fish"
|
||||
and arch-chroot "$mountDir" mkinitcpio -P
|
||||
and runInOS fish "$tempDir/../Software/grub/main.fish"
|
||||
|
||||
|
|
|
@ -1,19 +0,0 @@
|
|||
#!/bin/env fish
|
||||
begin
|
||||
set -l dir (status dirname)
|
||||
source "$dir/../../lib/software.fish"
|
||||
|
||||
function installSW
|
||||
pacinst btrfs-progs
|
||||
end
|
||||
|
||||
function configureSW -V dir
|
||||
source "$dir/../../../lib/settings.fish"
|
||||
|
||||
if isOSEnabled "programs.btrfs.pools"
|
||||
echo "HOOKS+=(btrfs)" | sudo tee /etc/mkinitcpio.conf.d/btrfs.conf >/dev/null
|
||||
end
|
||||
end
|
||||
|
||||
runInstaller $argv
|
||||
end
|
|
@ -71,7 +71,6 @@ function deploySoftware -d "Deploys a the specified software action" -a action
|
|||
end
|
||||
|
||||
and source "$dir/../../Common/Software/bash/main.fish" $argv
|
||||
and source "$dir/../Software/btrfs/main.fish" $argv
|
||||
and source "$dir/../../Common/Software/nuke-usb/main.fish" $argv
|
||||
and source "$dir/../Software/sudo/main.fish" $argv
|
||||
and source "$dir/../Software/aliae/main.fish" $argv
|
||||
|
|
|
@ -31,6 +31,7 @@ begin
|
|||
set -l port
|
||||
set -l file (mktemp)
|
||||
set -l root (getServiceRoot $argv)
|
||||
set -l bin /usr/local/bin/forgejo
|
||||
set -l config "$root/docker-compose.base.yml"
|
||||
set -l overrides (getServiceOverrides $argv)
|
||||
set -l envKey "$(getServiceKey "$service").environment"
|
||||
|
@ -71,6 +72,14 @@ begin
|
|||
end
|
||||
|
||||
rm "$file"
|
||||
|
||||
begin
|
||||
printf "%s\n" \
|
||||
"#!/bin/sh" \
|
||||
"ssh -p $port -o StrictHostKeyChecking=no git@127.0.0.1 \"SSH_ORIGINAL_COMMAND=\\\"$SSH_ORIGINAL_COMMAND\\\" \$0 \$@\""
|
||||
end | sudo tee "$bin" >/dev/null
|
||||
|
||||
chmod +x "$bin"
|
||||
end
|
||||
|
||||
function getServiceServers -V server
|
||||
|
|
|
@ -7,7 +7,7 @@ function initBackupConfig -V dir -d "Fetches the configuration by prompting the
|
|||
if [ -z "$VALHALLA_BACKUP_DIR" ]
|
||||
argparse -i "action=" -- $argv
|
||||
set -l index
|
||||
set -l confirm fish "$dir/../../lib/modules/fileSystems/confirm.fish"
|
||||
set -l confirm fish "$dir/../../lib/modules/partition/confirm.fish"
|
||||
|
||||
switch "$_flag_action"
|
||||
case backup
|
||||
|
|
|
@ -4,7 +4,7 @@ function isConfigured -S
|
|||
end
|
||||
|
||||
function selectProfile -S -a result
|
||||
source "$(status dirname)/../../lib/modules/fileSystems/select.fish"
|
||||
source "$(status dirname)/../../lib/modules/partition/select.fish"
|
||||
set -l file (mktemp)
|
||||
set -l header NAME
|
||||
set -l profiles
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#!/bin/env fish
|
||||
function chooseDisk -a result message
|
||||
set -l file (mktemp)
|
||||
fish "$(status dirname)/../../lib/modules/fileSystems/choose-disk.fish" "$file" "$message"
|
||||
fish "$(status dirname)/../../lib/modules/partition/choose-disk.fish" "$file" "$message"
|
||||
set -g "$result" (cat "$file")
|
||||
end
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#!/bin/env fish
|
||||
function confirm -a message default
|
||||
fish "$(status dirname)/../../lib/modules/fileSystems/confirm.fish" $argv
|
||||
fish "$(status dirname)/../../lib/modules/partition/confirm.fish" $argv
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue