Compare commits

..

No commits in common. "dev" and "main" have entirely different histories.
dev ... main

270 changed files with 1288 additions and 5458 deletions

View file

@ -5,16 +5,17 @@ fi
~/.automated_script.sh ~/.automated_script.sh
if bash -c "ls /sys/class/backlight/*/max_brightness" >/dev/null 2>&1; then if bash -c "ls /sys/class/backlight/*/max_brightness" > /dev/null 2>&1
cat /sys/class/backlight/*/max_brightness >/sys/class/backlight/*/brightness then
cat /sys/class/backlight/*/max_brightness > /sys/class/backlight/*/brightness
fi fi
cd "/root/PortValhalla" || exit cd "/root/PortValhalla" || exit
git diff -p -R --no-ext-diff --no-color --diff-filter=M | git diff -p -R --no-ext-diff --no-color --diff-filter=M \
grep -E "^(diff|(old|new) mode)" --color=never | | grep -E "^(diff|(old|new) mode)" --color=never \
sed "/^diff/{ x; d; }; x; /./{ p; z; }; x;" | | sed "/^diff/{ x; d; }; x; /./{ p; z; }; x;" \
git apply | git apply
loadkeys de_CH-latin1 loadkeys de_CH-latin1
./scripts/Arch/OS/setup.fish ./scripts/Arch/OS/setup.fish

View file

@ -1,24 +1,31 @@
#!/bin/env fish #!/bin/env fish
begin begin
set -l dir (status dirname) set -l nixVersion nixos-24.05
source "$dir/../../scripts/lib/config.fish"
source "$dir/../../scripts/lib/nix.fish"
set -l projectName archiso-valhalla set -l projectName archiso-valhalla
set -l overlayDir (mktemp -d) set -l overlayDir (mktemp -d)
set -l upperDir (mktemp -d) set -l upperDir (mktemp -d)
set -l workDir (mktemp -d) set -l workDir (mktemp -d)
set -l cacheRoot ~/".cache/$projectName"
set -l nixCache "$cacheRoot/nixpkgs/$nixVersion"
set -l root airootfs set -l root airootfs
set -l rootHome "$overlayDir/$root/root" set -l rootHome "$overlayDir/$root/root"
set -l profileDir "/mnt/$projectName" set -l profileDir "/mnt/$projectName"
set -l projectDir "$rootHome/PortValhalla" set -l projectDir "$rootHome/PortValhalla"
set -l nixDir "$profileDir/$root$nixPkgsDir" set -l nixDir "$profileDir/$root/nix/var/nix/profiles/per-user/root/channels/nixpkgs"
mkdir -p "$rootHome" mkdir -p "$rootHome"
and fish "$(status dirname)/../../scripts/lib/copy-repo.fish" "$projectDir" and fish "$(status dirname)/../../scripts/copy-repo.fish" "$projectDir"
downloadNixPkgs
and begin
if [ ! -d "$nixCache" ]
mkdir -p "$nixCache"
and git clone https://github.com/NixOS/nixpkgs.git --depth=1 -b "$nixVersion" "$nixCache"
and rm -rf "$nixCache/.git"
end
end
and sudo mount --mkdir -t overlay overlay -o lowerdir=.:"$overlayDir",upperdir="$upperDir",workdir="$workDir" "$profileDir" and sudo mount --mkdir -t overlay overlay -o lowerdir=.:"$overlayDir",upperdir="$upperDir",workdir="$workDir" "$profileDir"
and sudo mount --mkdir --bind "$nixPkgsCache" "$nixDir" and sudo mount --mkdir --bind "$nixCache" "$nixDir"
and sudo mkarchiso $argv "$profileDir" and sudo mkarchiso $argv "$profileDir"
sudo umount "$nixDir" sudo umount "$nixDir"
and sudo umount "$profileDir" and sudo umount "$profileDir"

View file

@ -16,8 +16,9 @@ begin
and begin and begin
git -C "$projectDir" ls-files git -C "$projectDir" ls-files
git -C "$projectDir" ls-files --exclude-standard --others git -C "$projectDir" ls-files --exclude-standard --others
end | rsync --files-from=/dev/stdin --exclude={.gitignore,README.md,scripts,LICENSE,valhalla.patch} "$dir/.." "$contextRoot" end | \
end &>/dev/null rsync --files-from=/dev/stdin --exclude={.gitignore,README.md,scripts,LICENSE,valhalla.patch} "$dir/.." "$contextRoot"
end &> /dev/null
and git -C "$contextRoot" diff and git -C "$contextRoot" diff
end end

View file

@ -2,5 +2,5 @@
# Updates the patch to be applicable to Arch's current `releng` template. # Updates the patch to be applicable to Arch's current `releng` template.
begin begin
set -l dir (status dirname) set -l dir (status dirname)
"$dir/show-diff.fish" >"$dir/valhalla.patch" "$dir/show-diff.fish" > "$dir/valhalla.patch"
end end

View file

@ -1,22 +1,23 @@
diff --git a/airootfs/root/.zlogin b/airootfs/root/.zlogin diff --git a/airootfs/root/.zlogin b/airootfs/root/.zlogin
index bf6bc8f..e71dc26 100644 index bf6bc8f..bdbe55c 100644
--- a/airootfs/root/.zlogin --- a/airootfs/root/.zlogin
+++ b/airootfs/root/.zlogin +++ b/airootfs/root/.zlogin
@@ -4,3 +4,17 @@ if grep -Fqa 'accessibility=' /proc/cmdline &> /dev/null; then @@ -4,3 +4,18 @@ if grep -Fqa 'accessibility=' /proc/cmdline &> /dev/null; then
fi fi
~/.automated_script.sh ~/.automated_script.sh
+ +
+if bash -c "ls /sys/class/backlight/*/max_brightness" >/dev/null 2>&1; then +if bash -c "ls /sys/class/backlight/*/max_brightness" > /dev/null 2>&1
+ cat /sys/class/backlight/*/max_brightness >/sys/class/backlight/*/brightness +then
+ cat /sys/class/backlight/*/max_brightness > /sys/class/backlight/*/brightness
+fi +fi
+ +
+cd "/root/PortValhalla" || exit +cd "/root/PortValhalla" || exit
+ +
+git diff -p -R --no-ext-diff --no-color --diff-filter=M | +git diff -p -R --no-ext-diff --no-color --diff-filter=M \
+ grep -E "^(diff|(old|new) mode)" --color=never | + | grep -E "^(diff|(old|new) mode)" --color=never \
+ sed "/^diff/{ x; d; }; x; /./{ p; z; }; x;" | + | sed "/^diff/{ x; d; }; x; /./{ p; z; }; x;" \
+ git apply + | git apply
+ +
+loadkeys de_CH-latin1 +loadkeys de_CH-latin1
+./scripts/Arch/OS/setup.fish +./scripts/Arch/OS/setup.fish

View file

@ -45,7 +45,6 @@
valhalla = { valhalla = {
DerGeret = import ./profiles/machines/manuel/DerGeret/Arch/config.nix; DerGeret = import ./profiles/machines/manuel/DerGeret/Arch/config.nix;
ManuSurface = import ./profiles/machines/manuel/ManuSurface/Arch/config.nix; ManuSurface = import ./profiles/machines/manuel/ManuSurface/Arch/config.nix;
server = import ./profiles/machines/manuel/server.nix;
}; };
}; };
} }

View file

@ -5,10 +5,8 @@ let
overlay = [ ]; overlay = [ ];
}; };
property = (builtins.getEnv "PROPERTY"); property = (builtins.getEnv "PROPERTY");
processor = processor = if (builtins.stringLength property > 0) then
if (builtins.stringLength property > 0) then (_: lib.attrsets.getAttrFromPath (lib.strings.splitString "." property) _)
(_: lib.attrsets.getAttrFromPath (lib.strings.splitString "." property) _) else
else (_: _);
(_: _); in _: processor (lib.evalModules { modules = [ _ ]; }).config
in
_: processor (lib.evalModules { modules = [ _ ]; }).config

View file

@ -1,120 +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))
);
affected = (builtins.map (_: _.deviceVariable) devices) ++
(builtins.concatMap
(_: builtins.map (_: lib.escapeShellArg _) _.devices)
(builtins.attrValues cfg.btrfs.volumes));
in
''
#!/bin/bash
set -o errexit
${cfg.diskSetup.scripts.init}
${lib.strings.concatLines (lib.optionals ((builtins.length devices) > 0) [
''echo "$(tput setaf 3)=== WARNING ====$(tput sgr0)"''
(''echo "Continuing this script will alter the partitions of ''
+ (lib.strings.concatStringsSep ", " (lib.lists.init affected))
+ (if (builtins.length affected) > 1 then " and " else "") + (lib.lists.last affected) + ''"'')
''
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}
'';
};
};
};
}

View file

@ -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" "--force" ] ++
(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;
};
};
}

View file

@ -1,375 +0,0 @@
{ lib, config, ... }:
let
inherit (lib) types mkOption;
fs = import ./fs.nix;
cfg = config.valhalla.fileSystems;
deviceListVarName = "myDevices";
isSwap = partition: builtins.elem partition.type [ fs.swap 19 ];
probeScript = builtins.concatStringsSep "\n" [
"partprobe 2> /dev/null || true"
"udevadm trigger"
];
mkDeviceType = types.submodule (
{ config, name, ... }: {
options = {
id = mkOption {
type = types.str;
description = "The internal identifier of the device.";
internal = true;
};
wipe = mkOption {
type = types.bool;
description = "A value indicating whether the device should be wiped.";
default = !(lib.lists.any (_: _.keepExisting) (builtins.attrValues config.partitions));
};
name = mkOption {
type = types.nullOr types.str;
description = "The name of the device.";
default = name;
};
path = mkOption {
type = types.nullOr types.str;
description = "The path to the device.";
default =
if config.name == null then
null
else
"/dev/${config.name}";
};
deviceScript = mkOption {
type = types.str;
description = "A command for loading the device path into the device variable";
internal = true;
};
deviceVariable = mkOption {
type = types.str;
description = "The name of the variable holding the name of the disk";
internal = true;
};
partitions = mkOption {
type = types.attrsOf (types.nullOr partitionType);
description = "The partitions of the disk.";
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.";
};
};
};
config =
let
deviceVarName = "${deviceListVarName}[${config.id}]";
deviceVar = "\${${deviceVarName}}";
deviceSelector = ''
result="$(mktemp)"
fish ${./choose-device.fish} "$result" "Please select the \"${name}\" device:" ${./select.fish}
${deviceVarName}="$(cat "$result")"
'';
partitions = lib.lists.sortOn (_: _.index)
(builtins.filter (_: _ != null)
(builtins.attrValues config.partitions));
mkType = type:
lib.strings.escapeShellArg (
if builtins.isInt type then
"${lib.trivial.toHexString type}"
else
type
);
fdiskCommand = arguments: "sudo sfdisk ${arguments}";
fdiskScript = script: args: append:
"echo ${script} | ${
fdiskCommand "${builtins.concatStringsSep " " args} ${
if append then "--append" else ""
} ${deviceVar}"
}";
appendScript = index: script: fdiskScript script [ "-N" (builtins.toString index) ] true;
cleanup = lib.strings.concatLines (builtins.map
(partition: "${fdiskCommand "--delete ${deviceVar} ${toString partition.index}"} || true")
(lib.lists.sortOn
(partition: partition.index * -1)
(builtins.filter (_: !_.keepExisting) partitions)));
fdiskCommands = lib.strings.concatLines
(lib.optionals config.wipe [
cleanup
(fdiskScript "label: gpt" [ ] false)
] ++ (builtins.concatMap
(
partition:
let
inherit (partition) format index keepExisting label sizeScript type;
partVarName = "myPartition";
partVar = "\${${partVarName}}";
sizeOption = ''
${sizeScript} | sed -e "s/.*[^[:space:]]/size=\0/"
'';
formatScripts = {
${fs.ext4} = "mkfs.ext4 -F ${partVar}";
${fs.btrfs} = "mkfs.btrfs --force ${partVar}";
${fs.swap} = "mkswap ${partVar}";
${fs.ntfs} = "mkfs.ntfs -F ${partVar}";
${fs.fat32} = "mkfs.fat -F 32 ${partVar}";
};
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 ([
(appendScript index ''${toString index}: "$(${sizeOption})" type=${mkType type}'')
probeScript
] ++ (lib.optionals (format != null) [
"sudo ${formatScripts.${format}}"
]));
fallback = ''
if ! { ls "${partVar}" 2>&1; } > /dev/null
then
${create}
fi
'';
in
[
''local diskPath="$(find -L /dev/disk/by-diskseq -samefile ${deviceVar})"''
''local ${partVarName}="$diskPath-part${toString index}"''
(if keepExisting then fallback else create)
] ++ (lib.optionals (format != null) [
"sudo ${labelScripts.${format} label}"
])
)
partitions));
fixType = lib.strings.concatLines (builtins.concatMap
(
partition:
lib.optional
(partition.keepExisting && !(builtins.isNull partition.type))
''sudo sfdisk --part-type ${deviceVar} ${toString partition.index} ${mkType partition.type}''
)
partitions);
in
{
id = "disk-${name}";
deviceVariable = deviceVar;
scripts = {
init =
if config.path == null then ''
${deviceSelector}
'' else ''
${deviceVarName}=${config.path}
if [ ! -b ${deviceVar} ]; 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}
else
exit 1
fi
}
fallback
fi
'';
partition = lib.mkDefault ''
function partition() {
${if (!config.wipe) then cleanup else ""}
${probeScript}
${fdiskCommands}
${fixType}
}
partition
'';
};
};
}
);
partitionType = types.submodule (
{ name, config, ... }: {
options = {
index = mkOption {
type = types.int;
description = "The index of the partition.";
};
label = mkOption {
type = types.str;
description = "The label of the partition.";
default = name;
};
keepExisting = mkOption {
type = types.bool;
description = "A value indicating whether the partition should be left untouched if it already exists.";
default = false;
};
type = mkOption {
type = types.nullOr (types.either types.str types.int);
description = "The type of the partition.";
default = null;
};
format = mkOption {
type = types.nullOr (types.enum (builtins.attrValues fs));
description = "The file system format of the partition.";
default =
if (isSwap config) then
fs.swap
else
null;
};
size = mkOption {
type = types.nullOr types.str;
description = "The size of the partition.";
default = null;
};
sizeScript = mkOption {
type = types.str;
description = "A script for printing the size to the console.";
internal = true;
};
useSwap = mkOption {
type = types.bool;
description = "A value indicating whether this partition should be used as swap.";
default = isSwap config;
};
mountPoint = mkOption {
type = types.nullOr types.str;
description = "The mountpoint of the partition.";
default = null;
};
mountOptions = mkOption {
type = types.listOf types.str;
description = "The options to apply to the mount.";
default = [ ];
};
};
config = {
sizeScript = (if isSwap config then
''echo "$(cat /proc/meminfo | awk -F " " '/^MemTotal/ { print $2 }' | awk '{ print int((($1 / 1024 / 1024) * 0.75) + 0.5)}')"G''
else
"echo ${lib.strings.escapeShellArg (toString config.size)}");
};
}
);
in
{
options = {
valhalla = {
fileSystems = {
diskSetup = {
devices = mkOption {
type = types.attrsOf (mkDeviceType);
description = "The disk devices to format.";
default = { };
};
scripts = {
init = mkOption {
type = types.str;
description = "The script for initializing the disk partitioning script.";
};
partition = mkOption {
type = types.str;
description = "The script for partitioning the disks.";
};
swap = mkOption {
type = types.str;
description = "The script for enabling swap devices.";
};
};
};
};
};
};
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);
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))
);
};
};
};
};
};
}

View file

@ -3,8 +3,7 @@ let
inherit (lib) mkOption types; inherit (lib) mkOption types;
optionalAttrs = lib.attrsets.optionalAttrs; optionalAttrs = lib.attrsets.optionalAttrs;
hw = config.valhalla.hardware; hw = config.valhalla.hardware;
in in {
{
options = { options = {
valhalla = { valhalla = {
hardware = { hardware = {

View file

@ -4,8 +4,7 @@ in {
options = { options = {
valhalla = mkOption { valhalla = mkOption {
type = types.submodule ( type = types.submodule (
{ extendModules, ... }: { extendModules, ... }: let
let
osVariant = extendModules { osVariant = extendModules {
modules = [ modules = [
({ config, ... }: { ({ config, ... }: {
@ -36,8 +35,7 @@ in {
}; };
windowsVariant = osVariant.extendModules { }; windowsVariant = osVariant.extendModules { };
in in {
{
options = { options = {
linux = mkOption { linux = mkOption {
inherit (linuxVariant) type; inherit (linuxVariant) type;
@ -53,8 +51,7 @@ in {
visible = "shallow"; visible = "shallow";
}; };
}; };
} });
);
description = "Configuration for PortValhalla."; description = "Configuration for PortValhalla.";
default = { }; default = { };

View file

@ -0,0 +1,5 @@
{ ... }: {
imports = [
./partition/disks.nix
];
}

View file

@ -22,7 +22,7 @@ function chooseDisk -a outFile message selectScript
end end
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 and begin
set -l disk (string split -n " " (cat "$outFile")) set -l disk (string split -n " " (cat "$outFile"))
echo "/dev/$disk[1]" >$outFile echo "/dev/$disk[1]" >$outFile

View file

@ -0,0 +1,360 @@
{ lib, config, ... }:
let
inherit (lib) types mkOption;
fs = import ./fs.nix;
diskListVarName = "myDisks";
isSwap = partition: builtins.elem partition.type [ fs.swap 19 ];
probeScript = builtins.concatStringsSep "\n" [
"partprobe 2> /dev/null || true"
"udevadm trigger"
];
mkDiskType = osDisk: types.submodule (
{ config, name, ... }: {
options = {
id = mkOption {
type = types.str;
description = "The internal identifier of the disk.";
internal = true;
};
wipe = mkOption {
type = types.bool;
description = "A value indicating whether the disk should be wiped.";
default = !(lib.lists.any (_: _.keepExisting) (builtins.attrValues config.partitions));
};
deviceName = mkOption {
type = types.nullOr types.str;
description = "The name of the device.";
default = if osDisk then null else name;
};
devicePath = mkOption {
type = if osDisk then
types.nullOr types.str
else
types.str;
description = "The path to the device.";
default = if osDisk && config.deviceName == null then
null
else
"/dev/${config.deviceName}";
};
deviceScript = mkOption {
type = types.str;
description = "A command for loading the device path into the device variable";
internal = true;
};
deviceVariable = mkOption {
type = types.str;
description = "The name of the variable holding the name of the disk";
internal = true;
};
partitions = mkOption {
type = types.attrsOf (types.nullOr partitionType);
description = "The partitions of the disk.";
default = { };
};
script = mkOption {
type = types.str;
description = "The script for formatting the disk.";
};
};
config = let
diskVarName = "${diskListVarName}[${config.id}]";
diskVar = "\${${diskVarName}}";
diskSelector = ''
result="$(mktemp)"
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)
(builtins.filter (_: _ != null)
(builtins.attrValues config.partitions));
mkType = type:
lib.strings.escapeShellArg (
if builtins.isInt type then
"${lib.trivial.toHexString type}"
else
type);
fdiskCommand = arguments: "sudo sfdisk ${arguments}";
fdiskScript = script: args: append:
"echo ${script} | ${
fdiskCommand "${builtins.concatStringsSep " " args} ${
if append then "--append" else ""
} ${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 ${diskVar} ${toString partition.index}"} || true")
(lib.lists.sortOn
(partition: partition.index * -1)
(builtins.filter (_: !_.keepExisting) partitions)));
fdiskCommands = lib.strings.concatLines
(lib.optionals config.wipe [
cleanup
(wipeScript "label: gpt")
] ++ (builtins.concatMap (
partition:
let
inherit (partition) format index keepExisting label sizeScript type;
partVarName = "myPartition";
partVar = "\${${partVarName}}";
sizeOption = ''
${sizeScript} | sed -e "s/.*[^[:space:]]/size=\0/"
'';
formatScripts = {
${fs.ext4} = "mkfs.ext4 -F ${partVar}";
${fs.swap} = "mkswap ${partVar}";
${fs.ntfs} = "mkfs.ntfs -F ${partVar}";
${fs.fat32} = "mkfs.fat -F 32 ${partVar}";
};
labelScripts = {
${fs.ext4} = label: "e2label ${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 [
(appendScript index ''${toString index}: "$(${sizeOption})" type=${mkType type}'')
probeScript
"sudo ${formatScripts.${format}}"
];
fallback = ''
if ! { ls "${partVar}" 2>&1; } > /dev/null
then
${create}
fi
'';
in [
''local diskPath="$(find -L /dev/disk/by-diskseq -samefile ${diskVar})"''
''local ${partVarName}="$diskPath-part${toString index}"''
(if keepExisting then fallback else create)
"sudo ${labelScripts.${format} label}"
]) partitions));
fixType = lib.strings.concatLines (builtins.concatMap (
partition:
lib.optional
(partition.keepExisting && !(builtins.isNull partition.type))
''sudo sfdisk --part-type ${diskVar} ${toString partition.index} ${mkType partition.type}'')
partitions);
in {
id = if osDisk then "os" else "disk-${name}";
deviceVariable = diskVar;
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 \"${diskVar}\"."
if fish ${./confirm.fish} "Do you want to install the OS on another disk?"; then
${diskSelector}
else
exit 1
fi
}
fallback
fi
'' else
""}
'';
script = lib.mkDefault ''
function partition() {
${if (!config.wipe) then cleanup else ""}
${probeScript}
${fdiskCommands}
${fixType}
}
partition
'';
};
});
partitionType = types.submodule (
{ name, config, ... }: {
options = {
index = mkOption {
type = types.int;
description = "The index of the partition.";
};
label = mkOption {
type = types.str;
description = "The label of the partition.";
default = name;
};
keepExisting = mkOption {
type = types.bool;
description = "A value indicating whether the partition should be left untouched if it already exists.";
default = false;
};
type = mkOption {
type = types.nullOr (types.either types.str types.int);
description = "The type of the partition.";
default = null;
};
format = mkOption {
type = types.enum (builtins.attrValues fs);
description = "The file system format of the partition.";
default = if (isSwap config) then
fs.swap
else
throw ("Partition format not specified.");
};
size = mkOption {
type = types.nullOr types.str;
description = "The size of the partition.";
default = null;
};
sizeScript = mkOption {
type = types.str;
description = "A script for printing the size to the console.";
internal = true;
};
useSwap = mkOption {
type = types.bool;
description = "A value indicating whether this partition should be used as swap.";
default = isSwap config;
};
mountPoint = mkOption {
type = types.nullOr types.str;
description = "The mountpoint of the partition.";
default = null;
};
mountOptions = mkOption {
type = types.listOf types.str;
description = "The options to apply to the mount.";
default = [ ];
};
};
config = {
sizeScript = (if isSwap config then
''echo "$(cat /proc/meminfo | awk -F " " '/^MemTotal/ { print $2 }' | awk '{ print int((($1 / 1024 / 1024) * 0.75) + 0.5)}')"G''
else
"echo ${lib.strings.escapeShellArg (toString config.size)}");
};
});
in {
options = {
valhalla = {
partition = {
rootDir = mkOption {
type = types.str;
description = "The root of the installation directory to mount disks into.";
default = "/mnt";
};
os = mkOption {
type = mkDiskType true;
description = "The partition layout of the OS disk.";
};
disks = mkOption {
type = types.attrsOf (mkDiskType false);
description = "The additional disks to format.";
default = { };
};
script = mkOption {
type = types.str;
description = "The script for partitioning the system's disks.";
};
};
};
};
config = {
valhalla = {
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);
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
]));
};
};
};
}

View file

@ -1,6 +1,5 @@
{ {
ext4 = "ext4"; ext4 = "ext4";
btrfs = "btrfs";
swap = "swap"; swap = "swap";
ntfs = "ntfs"; ntfs = "ntfs";
fat32 = "fat32"; fat32 = "fat32";

View file

@ -5,103 +5,88 @@ let
mkUsersOption = programs: osConfig: mkOption { mkUsersOption = programs: osConfig: mkOption {
type = types.attrsOf (types.submodule ( type = types.attrsOf (types.submodule (
{ config, ... }: { { ... }: {
options = { options = {
inherit programs; inherit programs;
}; };
config = { config = {
programs = lib.attrsets.concatMapAttrs programs = builtins.mapAttrs (
( name: config: {
name: program: enable = mkDefault config.enable;
if (builtins.elem name (builtins.attrNames config.programs)) then { }) osConfig.programs;
${name} = { };
enable = mkDefault program.enable; }));
};
} else { }
)
osConfig.programs;
};
}
));
}; };
mkPrograms = infos: builtins.foldl' mkPrograms = infos: builtins.foldl' (programs: info:
(programs: info: programs // {
programs // { ${builtins.elemAt info 0} = {
${builtins.elemAt info 0} = { enable = mkEnableOption (builtins.elemAt info 1);
enable = mkEnableOption (builtins.elemAt info 1); };
}; }) { } infos;
})
{ }
infos;
programs = mkPrograms [ programs = mkPrograms [
[ "aliae" "aliae" ] ["aliae" "aliae"]
[ "brave" "Brave Browser" ] ["brave" "Brave Browser"]
[ "discord" "Discord" ] ["discord" "Discord"]
[ "firefox" "Firefox Web Browser" ] ["docker" "docker"]
[ "openssh" "OpenSSH" ] ["firefox" "Firefox Web Browser"]
[ "osu!lazer" "osu!lazer" ] ["openssh" "OpenSSH"]
[ "pennywise" "Pennywise" ] ["osu!lazer" "osu!lazer"]
[ "powershell" "PowerShell Core" ] ["pennywise" "Pennywise"]
[ "retroarch" "RetroArch" ] ["powershell" "PowerShell Core"]
[ "steam" "Steam" ] ["retroarch" "RetroArch"]
[ "thunderbird" "Thunderbird" ] ["steam" "Steam"]
[ "vscode" "Visual Studio Code" ] ["thunderbird" "Thunderbird"]
[ "zoxide" "zoxide" ] ["vscode" "Visual Studio Code"]
["zoxide" "zoxide"]
]; ];
linuxPrograms = mkPrograms [ linuxPrograms = mkPrograms [
[ "bash" "Bash" ] ["bash" "Bash"]
[ "fish" "fish" ] ["fish" "fish"]
[ "icedtea" "IcedTea" ] ["icedtea" "IcedTea"]
[ "grub" "GRUB" ] ["grub" "GRUB"]
[ "logo-ls" "logo-ls" ] ["logo-ls" "logo-ls"]
[ "lutris" "Lutris" ] ["lutris" "Lutris"]
[ "minegrub-theme" "Minegrub Theme" ] ["minegrub-theme" "Minegrub Theme"]
[ "networkmanager" "NetworkManager" ] ["nodejs-n" "n"]
[ "nginx" "nginx" ] ["nuke-usb" "nuke-usb"]
[ "nodejs-n" "n" ] ["nvidia-dkms" "Nvidia Drivers"]
[ "nuke-usb" "nuke-usb" ] ["plasma" "Plasma"]
[ "nvidia-dkms" "Nvidia Drivers" ] ["pyenv" "pyenv"]
[ "plasma" "Plasma" ] ["sddm" "SDDM"]
[ "pyenv" "pyenv" ] ["vim" "Vim"]
[ "sddm" "SDDM" ] ["virt-manager" "Virtual Machine Manager"]
[ "vim" "Vim" ] ["waydroid" "Waydroid"]
[ "virt-manager" "Virtual Machine Manager" ] ["xone" "xone"]
[ "waydroid" "Waydroid" ]
[ "xone" "xone" ]
]; ];
windowsPrograms = mkPrograms [ windowsPrograms = mkPrograms [
[ "lghub" "Logitech G Hub" ] ["lghub" "Logitech G Hub"]
[ "maniaplanet" "ManiaPlanet" ] ["maniaplanet" "ManiaPlanet"]
[ "msedge-redirect" "MSEdgeRedirect" ] ["msedge-redirect" "MSEdgeRedirect"]
[ "nvs" "Node Version Switcher" ] ["nvs" "Node Version Switcher"]
[ "osu!" "Osu!" ] ["osu!" "Osu!"]
[ "posh-git" "posh-git" ] ["posh-git" "posh-git"]
[ "putty" "PuTTY" ] ["putty" "PuTTY"]
[ "rewasd" "reWASD" ] ["rewasd" "reWASD"]
[ "terminal-icons" "Terminal Icons" ] ["terminal-icons" "Terminal Icons"]
[ "tm-nations-forever" "TrackMania Nations Forever" ] ["tm-nations-forever" "TrackMania Nations Forever"]
[ "tm-united-forever" "TrackMania United Forever" ] ["tm-united-forever" "TrackMania United Forever"]
[ "tobii-gamehub" "Tobii Game Hub" ] ["tobii-gamehub" "Tobii Game Hub"]
[ "tobii-ghost" "Tobii Ghost" ] ["tobii-ghost" "Tobii Ghost"]
[ "ubiquiti-unifi-controller" "Ubiquiti UniFi Controller" ] ["ubiquiti-unifi-controller" "Ubiquiti UniFi Controller"]
[ "visualstudio" "Visual Studio" ] ["visualstudio" "Visual Studio"]
[ "winscp" "WinSCP" ] ["winscp" "WinSCP"]
]; ];
in in {
{
imports = [ imports = [
./programs/btrfs.nix
./programs/docker.nix
./programs/git.nix ./programs/git.nix
./programs/nextcloud.nix ./programs/nextcloud.nix
./programs/oh-my-posh.nix ./programs/oh-my-posh.nix
./programs/rclone.nix ./programs/rclone.nix
./programs/systemd-networkd.nix
]; ];
options = { options = {

View file

@ -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";
};
};
};
}

View file

@ -1,47 +0,0 @@
{ lib, ... }:
let
inherit (lib) mkEnableOption mkOption types;
commonOptions = {
enable = mkEnableOption "docker";
};
in
{
options = {
valhalla = {
programs.docker = commonOptions;
users = mkOption {
type = types.attrsOf (types.submodule (
{ ... }: {
options = {
programs.docker = commonOptions;
};
}
));
};
linux = {
programs = {
docker = {
services = {
anki-sync.enable = mkEnableOption "Anki Sync server";
drone.enable = mkEnableOption "drone server";
forgejo.enable = mkEnableOption "Forgejo server";
jellyfin.enable = mkEnableOption "Jellyfin media server";
minecraft.enable = mkEnableOption "Minecraft server";
nextcloud.enable = mkEnableOption "Nextcloud server";
ryot.enable = mkEnableOption "ryot server";
teamspeak.enable = mkEnableOption "TeamSpeak server";
terraria.enable = mkEnableOption "Terraria server";
trackmania.enable = mkEnableOption "TrackMania server";
vaultwarden.enable = mkEnableOption "Vaultwarden server";
wekan.enable = mkEnableOption "Wekan server";
woodpecker.enable = mkEnableOption "Woodpecker CI server";
};
};
};
};
};
};
}

View file

@ -31,8 +31,7 @@ let
default = { }; default = { };
}; };
}; };
in in {
{
options = { options = {
valhalla = { valhalla = {
programs.git = gitOption; programs.git = gitOption;
@ -43,8 +42,7 @@ in
options = { options = {
programs.git = gitOption; programs.git = gitOption;
}; };
} }));
));
}; };
}; };
}; };

View file

@ -31,8 +31,7 @@ let
default = [ ]; default = [ ];
}; };
}; };
in in {
{
options = { options = {
valhalla = { valhalla = {
programs.nextcloud = commonOptions; programs.nextcloud = commonOptions;
@ -43,8 +42,7 @@ in
options = { options = {
programs.nextcloud = commonOptions; programs.nextcloud = commonOptions;
}; };
} }));
));
}; };
windows.users = mkOption { windows.users = mkOption {
@ -53,8 +51,7 @@ in
options = { options = {
programs.nextcloud = userOptions; programs.nextcloud = userOptions;
}; };
} }));
));
}; };
}; };
}; };

View file

@ -16,8 +16,7 @@ let
default = lib.strings.removeSuffix ".omp" (lib.strings.removeSuffix ".json" (builtins.baseNameOf config.source)); default = lib.strings.removeSuffix ".omp" (lib.strings.removeSuffix ".json" (builtins.baseNameOf config.source));
}; };
}; };
} });
);
commonOptions = { commonOptions = {
enable = mkEnableOption "Oh My Posh"; enable = mkEnableOption "Oh My Posh";
@ -36,8 +35,7 @@ let
default = [ ]; default = [ ];
}; };
}; };
in in {
{
options = { options = {
valhalla = { valhalla = {
programs.oh-my-posh = commonOptions; programs.oh-my-posh = commonOptions;
@ -48,8 +46,7 @@ in
options = { options = {
programs.oh-my-posh = userOptions; programs.oh-my-posh = userOptions;
}; };
} }));
));
}; };
}; };
}; };

View file

@ -16,8 +16,7 @@ let
default = null; default = null;
}; };
}; };
} });
);
commonOptions = { commonOptions = {
enable = mkEnableOption "rclone"; enable = mkEnableOption "rclone";
@ -30,8 +29,7 @@ let
default = { }; default = { };
}; };
}; };
in in {
{
options = { options = {
valhalla.linux = { valhalla.linux = {
programs.rclone = commonOptions; programs.rclone = commonOptions;
@ -42,8 +40,7 @@ in
options = { options = {
programs.rclone = userOptions; programs.rclone = userOptions;
}; };
} }));
));
}; };
}; };
}; };

View file

@ -1,26 +0,0 @@
{ lib, config, ... }:
let
inherit (lib) mkEnableOption mkOption types;
in
{
options = {
valhalla = {
linux.programs.systemd-networkd = {
enable = mkEnableOption "systemd-networkd";
networks = mkOption {
type = types.attrsOf types.attrs;
description = "The networks to configure.";
};
networkFiles = mkOption {
type = types.attrsOf types.str;
description = "The files for configuring the networks.";
default = builtins.mapAttrs
(name: network: lib.generators.toINI { listsAsDuplicateKeys = true; } network)
config.valhalla.linux.programs.systemd-networkd.networks;
};
};
};
};
}

View file

@ -1,157 +1,148 @@
{ lib, ... }: { lib, ... }:
let inherit (lib) mkOption types; let inherit (lib) mkOption types;
in { in {
imports = [ imports = [
./programs.nix ./programs.nix
]; ];
options = { options = {
valhalla = mkOption { valhalla = mkOption {
type = types.submodule ( type = types.submodule (
{ config, ... }: { config, ... }:
let let
optionalAttrs = lib.attrsets.optionalAttrs; optionalAttrs = lib.attrsets.optionalAttrs;
cfg = config; cfg = config;
inherit (cfg.software) coding desktopExperience essential gaming server socialMedia; inherit (cfg.software) coding desktopExperience essential gaming socialMedia;
mkPrograms = programs: builtins.foldl' mkPrograms = programs: builtins.foldl' (
( programs: name: programs // {
programs: name: programs // { ${name}.enable = true;
${name}.enable = true; }) {} programs;
} in {
) options = {
{ } software = {
programs; essential = mkOption {
in type = types.bool;
{ description = "A value indicating whether essentials should be installed.";
options = { default = false;
software = { };
essential = mkOption {
type = types.bool; server = mkOption {
description = "A value indicating whether essentials should be installed."; type = types.bool;
default = false; description = "A value indicating whether server applications should be installed.";
default = false;
};
desktopExperience = mkOption {
type = types.bool;
description = "A value indicating whether GUI apps should be installed.";
default = false;
};
school = mkOption {
type = types.bool;
description = "A value indicating whether software for studies should be installed.";
default = false;
};
productivity = mkOption {
type = types.bool;
description = "A value indicating whether productivity apps should be installed.";
default = false;
};
socialMedia = mkOption {
type = types.bool;
description = "A value indicating whether social media apps should be installed.";
default = false;
};
media = mkOption {
type = types.bool;
description = "A value indicating whether media apps should be installed.";
default = false;
};
gaming = mkOption {
type = types.bool;
description = "A value indicating whether gaming apps should be installed.";
default = false;
};
coding = mkOption {
type = types.bool;
description = "A value indicating whether development apps should be installed.";
default = false;
};
};
}; };
server = mkOption { config = {
type = types.bool; programs = (optionalAttrs essential (mkPrograms [
description = "A value indicating whether server applications should be installed."; "aliae"
default = false; "git"
"oh-my-posh"
"openssh"
"powershell"
"zoxide"
])) // (optionalAttrs desktopExperience (mkPrograms [
"brave"
"firefox"
"pennywise"
"thunderbird"
])) // (optionalAttrs socialMedia (mkPrograms [
"discord"
])) // (optionalAttrs coding (mkPrograms [
"docker"
"vscode"
])) // (optionalAttrs gaming (mkPrograms [
"osu!lazer"
"retroarch"
"steam"
]));
linux.programs = (optionalAttrs essential (mkPrograms [
"bash"
"logo-ls"
"minegrub-theme"
"nuke-usb"
"vim"
])) // (optionalAttrs desktopExperience (mkPrograms [
"icedtea"
"plasma"
"sddm"
"waydroid"
"virt-manager"
])) // (optionalAttrs coding (mkPrograms [
"nodejs-n"
"pyenv"
])) // (optionalAttrs gaming (mkPrograms [
"lutris"
]));
# Essentials
windows.programs = (optionalAttrs essential (mkPrograms [
"posh-git"
"terminal-icons"
# Desktop Experience
])) // (optionalAttrs desktopExperience (mkPrograms [
"msedge-redirect"
"putty"
"winscp"
# Development
])) // (optionalAttrs coding (mkPrograms [
"nvs"
"visualstudio"
# Gaming
])) // (optionalAttrs gaming (mkPrograms [
"maniaplanet"
"osu!"
"rewasd"
"tm-nations-forever"
"tm-united-forever"
]));
}; };
});
desktopExperience = mkOption { };
type = types.bool;
description = "A value indicating whether GUI apps should be installed.";
default = false;
};
school = mkOption {
type = types.bool;
description = "A value indicating whether software for studies should be installed.";
default = false;
};
productivity = mkOption {
type = types.bool;
description = "A value indicating whether productivity apps should be installed.";
default = false;
};
socialMedia = mkOption {
type = types.bool;
description = "A value indicating whether social media apps should be installed.";
default = false;
};
media = mkOption {
type = types.bool;
description = "A value indicating whether media apps should be installed.";
default = false;
};
gaming = mkOption {
type = types.bool;
description = "A value indicating whether gaming apps should be installed.";
default = false;
};
coding = mkOption {
type = types.bool;
description = "A value indicating whether development apps should be installed.";
default = false;
};
};
};
config = {
programs = (optionalAttrs essential (mkPrograms [
"aliae"
"git"
"oh-my-posh"
"openssh"
"powershell"
"zoxide"
])) // (optionalAttrs desktopExperience (mkPrograms [
"brave"
"firefox"
"pennywise"
"thunderbird"
])) // (optionalAttrs socialMedia (mkPrograms [
"discord"
])) // (optionalAttrs coding (mkPrograms [
"docker"
"vscode"
])) // (optionalAttrs gaming (mkPrograms [
"osu!lazer"
"retroarch"
"steam"
]));
linux.programs = (optionalAttrs essential (mkPrograms [
"bash"
"logo-ls"
"minegrub-theme"
"nuke-usb"
"vim"
])) // (optionalAttrs desktopExperience (mkPrograms [
"icedtea"
"networkmanager"
"plasma"
"sddm"
"waydroid"
"virt-manager"
])) // (optionalAttrs coding (mkPrograms [
"nodejs-n"
"pyenv"
])) // (optionalAttrs gaming (mkPrograms [
"lutris"
])) // (optionalAttrs server (mkPrograms [
"nginx"
]));
# Essentials
windows.programs = (optionalAttrs essential (mkPrograms [
"posh-git"
"terminal-icons"
# Desktop Experience
])) // (optionalAttrs desktopExperience (mkPrograms [
"msedge-redirect"
"putty"
"winscp"
# Development
])) // (optionalAttrs coding (mkPrograms [
"nvs"
"visualstudio"
# Gaming
])) // (optionalAttrs gaming (mkPrograms [
"maniaplanet"
"osu!"
"rewasd"
"tm-nations-forever"
"tm-united-forever"
]));
};
}
);
}; };
}; }
}

View file

@ -25,8 +25,7 @@ let
default = [ ]; default = [ ];
}; };
}; };
} });
);
linuxUserType = types.submodule ( linuxUserType = types.submodule (
{ ... }: { { ... }: {
@ -37,8 +36,7 @@ let
default = null; default = null;
}; };
}; };
} });
);
winUserType = types.submodule ( winUserType = types.submodule (
{ ... }: { { ... }: {
@ -49,10 +47,8 @@ let
default = false; default = false;
}; };
}; };
} });
); in {
in
{
options = { options = {
valhalla = { valhalla = {
users = mkOption { users = mkOption {

View file

@ -1,11 +1,11 @@
{ config, lib, ... }: { lib, ... }:
let inherit (lib) mkOption types; let inherit (lib) mkOption types;
in { in {
imports = [ imports = [
./fileSystems.nix
./hardware.nix ./hardware.nix
./i18n.nix ./i18n.nix
./os.nix ./os.nix
./partition.nix
./programs.nix ./programs.nix
./software.nix ./software.nix
./users.nix ./users.nix
@ -28,12 +28,6 @@ in {
}; };
}; };
fqdn = mkOption {
type = types.str;
description = "The FQDN of the system.";
default = config.valhalla.hostname;
};
hostname = mkOption { hostname = mkOption {
type = types.str; type = types.str;
description = "The hostname of the system."; description = "The hostname of the system.";

View file

@ -2,8 +2,7 @@
let let
inherit (lib) mkDefault mkEnableOption mkIf mkOption types; inherit (lib) mkDefault mkEnableOption mkIf mkOption types;
capitalize = (import ../text.nix { inherit lib; }).capitalize; capitalize = (import ../text.nix { inherit lib; }).capitalize;
in in {
{
options = { options = {
valhalla = { valhalla = {
windows = { windows = {

View file

@ -2,6 +2,6 @@
capitalize = text: capitalize = text:
let chars = lib.strings.stringToCharacters text; let chars = lib.strings.stringToCharacters text;
in lib.strings.concatStrings in lib.strings.concatStrings
([ (lib.strings.toUpper (builtins.elemAt chars 0)) ] ([ (lib.strings.toUpper (builtins.elemAt chars 0)) ]
++ (lib.lists.drop 1 chars)); ++ (lib.lists.drop 1 chars));
} }

View file

@ -25,7 +25,7 @@
}; };
}; };
fileSystems.diskSetup.devices.OS.partitions = { partition.os.partitions = {
# Keep Windows' boot partition # Keep Windows' boot partition
Boot.keepExisting = true; Boot.keepExisting = true;

View file

@ -1,12 +1,12 @@
{ lib, config, ... }: { lib, config, ... }:
let fs = import ../../../../lib/modules/fileSystems/fs.nix; let fs = import ../../../../lib/modules/partition/fs.nix;
in { in {
imports = [ ../defaults.nix ]; imports = [ ../defaults.nix ];
config = { config = {
valhalla = { valhalla = {
fileSystems.diskSetup.devices = { partition = {
OS = { os = {
partitions = { partitions = {
Boot = { Boot = {
index = 1; index = 1;
@ -37,13 +37,12 @@ in {
keyboardLayout = "ch"; keyboardLayout = "ch";
i18n = { i18n = {
localeSettings = localeSettings = let defaultLocale = "en_US.UTF-8";
let defaultLocale = "en_US.UTF-8"; in {
in { LANG = "de_CH.UTF-8";
LANG = "de_CH.UTF-8"; LANGUAGE = defaultLocale;
LANGUAGE = defaultLocale; LC_MESSAGE = defaultLocale;
LC_MESSAGE = defaultLocale; };
};
}; };
software = { software = {
@ -59,46 +58,45 @@ in {
linux.programs.grub.enable = true; linux.programs.grub.enable = true;
programs = { programs = {
git = git = let defaultBranch = "main";
let defaultBranch = "main"; in {
in { inherit defaultBranch;
inherit defaultBranch;
flow = { flow = {
mainBranch = defaultBranch; mainBranch = defaultBranch;
devBranch = "dev"; devBranch = "dev";
};
aliases = {
ahfange = "init";
tuedezue = "add";
beschuldig = "blame";
zieh = "pull";
druck = "push";
machnah = "clone";
hol = "fetch";
zwiigab = "branch";
buechiih = "commit";
eich = "rebase";
erd = "rebase";
gahufwiifelde = "rebase";
vergliich = "diff";
tuezemme = "merge";
versorg = "stash";
markier = "tag";
pflueckoepfel = "cherry-pick";
pflueckhimbeeri = "cherry-pick";
buechuus = "checkout";
quaetsch = "merge --squash";
pfudle = "push --force";
beschuldigung = "blame";
zwiigli = "branch";
tagebuech = "log";
versteck = "stash";
zuestand = "status";
markierig = "tag";
};
}; };
aliases = {
ahfange = "init";
tuedezue = "add";
beschuldig = "blame";
zieh = "pull";
druck = "push";
machnah = "clone";
hol = "fetch";
zwiigab = "branch";
buechiih = "commit";
eich = "rebase";
erd = "rebase";
gahufwiifelde = "rebase";
vergliich = "diff";
tuezemme = "merge";
versorg = "stash";
markier = "tag";
pflueckoepfel = "cherry-pick";
pflueckhimbeeri = "cherry-pick";
buechuus = "checkout";
quaetsch = "merge --squash";
pfudle = "push --force";
beschuldigung = "blame";
zwiigli = "branch";
tagebuech = "log";
versteck = "stash";
zuestand = "status";
markierig = "tag";
};
};
}; };
}; };
}; };

View file

@ -1,5 +1,6 @@
{ ... }: { { ... }: {
imports = [ imports = [
../../users/manuel/desktop.nix ../../users/manuel/config.nix
../../../lib/modules/valhalla.nix
]; ];
} }

View file

@ -1,127 +0,0 @@
{ lib, config, ... }:
let fs = import ../../../lib/modules/fileSystems/fs.nix;
in {
imports = [ ../../users/manuel/config.nix ];
config = {
valhalla = {
boot.label = "Arch";
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";
};
};
};
};
btrfs = {
volumes = {
OS = {
mountPoint = "/";
devices = [ "/dev/sda3" "/dev/sdb" ];
metadataProfile = "raid1";
dataProfile = "single";
};
};
};
};
hostname = "nuth.ch";
timeZone = "Europe/Zurich";
keyMap = "de_CH-latin1";
keyboardLayout = "ch";
i18n = {
localeSettings =
let defaultLocale = "en_US.UTF-8";
in {
LANG = "de_CH.UTF-8";
LANGUAGE = defaultLocale;
LC_MESSAGE = defaultLocale;
};
};
software = {
essential = true;
server = true;
};
programs.docker.enable = true;
linux.programs = {
grub.enable = true;
systemd-networkd = {
enable = true;
networks =
let device = "enp0s31f6";
in {
${device} = {
Match = {
Name = device;
};
Network = {
Address = "2a01:4f8:10b:2644::2/64";
Gateway = [
"94.130.48.193"
"fe80::1"
];
DNS = [
"5.9.164.112"
"1.1.1.1"
];
};
Address = {
Address = "94.130.48.251";
Peer = "94.130.48.193/32";
};
};
};
};
docker = {
services = {
anki-sync.enable = true;
drone.enable = true;
forgejo.enable = true;
jellyfin.enable = true;
minecraft.enable = true;
nextcloud.enable = true;
ryot.enable = true;
teamspeak.enable = true;
terraria.enable = true;
trackmania.enable = true;
vaultwarden.enable = true;
wekan.enable = true;
woodpecker.enable = true;
};
};
};
};
};
}

View file

@ -3,6 +3,14 @@
config = { config = {
valhalla = { valhalla = {
programs = {
nextcloud.enable = true;
};
linux.programs = {
rclone.enable = true;
};
users.manuel = { users.manuel = {
displayName = "Manuel Thalmann"; displayName = "Manuel Thalmann";
mailAddress = "m@nuth.ch"; mailAddress = "m@nuth.ch";
@ -23,6 +31,42 @@
"wheel" "wheel"
"nix-users" "nix-users"
]; ];
programs = {
rclone = {
configurations = {
nextcloud = {
dirName = "Nextcloud";
};
proton = {
dirName = "Proton";
cacheDuration = "2w";
};
};
};
};
};
windows.users.manuel = {
programs = {
nextcloud = {
folderSyncs = let
localPath = "C:/tools/RetroArch-Win64";
remotePath = "/Saved Games/RetroArch";
in [
{
remotePath = "${remotePath}/Saves";
localPath = "${localPath}/saves";
virtualFiles = false;
}
{
remotePath = "${remotePath}/System";
localPath = "${localPath}/system";
}
];
};
};
}; };
}; };
}; };

View file

@ -1,53 +0,0 @@
{ ... }: {
imports = [ ./config.nix ];
config = {
valhalla = {
programs = {
nextcloud.enable = true;
};
linux.programs = {
rclone.enable = true;
};
linux.users.manuel.programs = {
rclone = {
configurations = {
nextcloud = {
dirName = "Nextcloud";
};
proton = {
dirName = "Proton";
cacheDuration = "2w";
};
};
};
};
windows.users.manuel = {
programs = {
nextcloud = {
folderSyncs =
let
localPath = "C:/tools/RetroArch-Win64";
remotePath = "/Saved Games/RetroArch";
in
[
{
remotePath = "${remotePath}/Saves";
localPath = "${localPath}/saves";
virtualFiles = false;
}
{
remotePath = "${remotePath}/System";
localPath = "${localPath}/system";
}
];
};
};
};
};
};
}

View file

@ -1,14 +1,14 @@
#!/bin/env fish #!/bin/env fish
begin begin
set -l dir (status dirname) set -l dir (status dirname)
source "$dir/../../lib/software.fish" source "$dir/../../Scripts/software.fish"
function installSW -V dir function installSW -V dir
yayinst secureboot-grub yayinst secureboot-grub
end end
function configureSW -V dir function configureSW -V dir
source "$dir/../../../lib/settings.fish" source "$dir/../../../Common/Scripts/config.fish"
set -l label (getOSConfig boot.label) set -l label (getOSConfig boot.label)
set -l efiDir (getOSConfig boot.efiMountPoint) set -l efiDir (getOSConfig boot.efiMountPoint)
set -l bootNums (efibootmgr | sed "/$label/{ s/^.*Boot\([[:digit:]]\+\)\*.*\$/\1/; p; }; d") set -l bootNums (efibootmgr | sed "/$label/{ s/^.*Boot\([[:digit:]]\+\)\*.*\$/\1/; p; }; d")
@ -20,11 +20,11 @@ begin
sudo sed -i \ sudo sed -i \
-e "/esp=/{" \ -e "/esp=/{" \
-e "a esp=$(echo "$efiDir" | string escape)" \ -e "a esp=$(echo "$efiDir" | string escape)" \
-e d \ -e "d" \
-e "}" \ -e "}" \
-e "/bootloader_id=/{" \ -e "/bootloader_id=/{" \
-e "a bootloader_id=$(echo "$label" | string escape)" \ -e "a bootloader_id=$(echo "$label" | string escape)" \
-e d \ -e "d" \
-e "}" \ -e "}" \
/etc/secureboot.conf /etc/secureboot.conf

View file

@ -1,7 +1,7 @@
#!/bin/env fish #!/bin/env fish
begin begin
set -l dir (status dirname) set -l dir (status dirname)
source "$dir/../../lib/software.fish" source "$dir/../../Scripts/software.fish"
function installSW -V dir function installSW -V dir
set -l repo linux-surface set -l repo linux-surface

View file

@ -1,7 +1,7 @@
#!/bin/env fish #!/bin/env fish
begin begin
set -l dir (status dirname) set -l dir (status dirname)
source "$dir/../../lib/software.fish" source "$dir/../../Scripts/software.fish"
function installSW -V dir function installSW -V dir
yayinst \ yayinst \
@ -21,9 +21,6 @@ begin
sudo systemctl enable --global surface-dtx-userd.service sudo systemctl enable --global surface-dtx-userd.service
end end
function installSWDependencies
fish "$dir/../Surface/main.fish" $argv
end
runInstaller --force $argv runInstaller --force $argv
fish "$dir/../Surface/main.fish" $argv
end end

View file

@ -1,15 +0,0 @@
#!/bin/env fish
begin
set -l dir (status dirname)
function installValhallaDeps -V dir
source "$dir/../lib/software.fish"
and pacinst fish git jq nix sudo tmux
end
function getDeploymentScript -V dir
echo "$dir/../lib/deploy.fish"
end
source "$dir/../../Common/OS/backup.fish"
end

View file

@ -1,18 +1,18 @@
#!/bin/env fish #!/bin/env fish
begin begin
set -l dir (status dirname) set -l dir (status dirname)
source "$dir/../lib/dependencies.fish"
function getDeploymentScript -V dir function getDeploymentScript -V dir
echo "$dir/../lib/deploy.fish" echo "$dir/../Scripts/deploy.fish"
end end
function initialize -V dir function initialize -V dir
source "$dir/../../lib/wait-network.fish" source "$dir/../../Common/Scripts/wait-network.fish"
waitNetwork waitNetwork
or exit or exit
and source "$dir/../lib/software.fish" sudo systemctl enable --now nix-daemon
and source "$dir/../Scripts/software.fish"
and source "$dir/../Software/base-devel/main.fish" and source "$dir/../Software/base-devel/main.fish"
and source "$dir/../Software/pacman/main.fish" and source "$dir/../Software/pacman/main.fish"
and source "$dir/../Software/yay/main.fish" and source "$dir/../Software/yay/main.fish"
@ -22,7 +22,7 @@ begin
and yayinst \ and yayinst \
linux-headers \ linux-headers \
pacman-contrib \ pacman-contrib \
go-yq yq
end end
source "$dir/../../Common/OS/install.fish" source "$dir/../../Common/OS/install.fish"

View file

@ -1,22 +1,20 @@
#!/bin/env fish #!/bin/env fish
begin begin
set -l dir (status dirname) set -l dir (status dirname)
set -l autologinConfig /etc/systemd/system/getty@tty1.service.d/autologin.conf
source "$dir/../lib/dependencies.fish"
source "$dir/../../Common/OS/setup.fish" source "$dir/../../Common/OS/setup.fish"
source "$dir/../../lib/settings.fish" source "$dir/../../Common/Scripts/config.fish"
function runChroot -S function runChroot -S
arch-chroot $argv arch-chroot $argv
end end
function bootstrapSetup -S function installValhallaDeps -S
pacstrap -K (getOSConfig fileSystems.rootDir) fish pacstrap -K "$mountDir" fish git jq nix sudo tmux
end end
function installDrivers -S function installDrivers -S
if isOSEnabled hardware.surfaceBook if isOSEnabled hardware.surfaceBook
pacstrap -K (getOSConfig fileSystems.rootDir) linux-firmware-marvell pacstrap -K "$mountDir" linux-firmware-marvell
end end
end end
@ -24,30 +22,9 @@ begin
echo "$dir/install.fish" echo "$dir/install.fish"
end end
function initOS -V dir
source "$dir/../lib/dependencies.fish"
source "$dir/../../lib/wait-network.fish"
set -l mountDir (getOSConfig fileSystems.rootDir)
waitNetwork
and pacman-key --init
and pacman-key --populate
and pacstrap -K "$mountDir" \
base \
linux \
linux-firmware \
man-db \
man-pages \
texinfo
installValhallaDeps "$mountDir"
end
function setupOS -S -V dir -S function setupOS -S -V dir -S
source "$dir/../../lib/hooks.fish" source "$dir/../../Common/Scripts/hooks.fish"
source "$dir/../../lib/wait-network.fish" source "$dir/../../Common/Scripts/wait-network.fish"
set -l mountDir (getOSConfig fileSystems.rootDir)
waitNetwork waitNetwork
and begin and begin
@ -62,12 +39,20 @@ begin
timedatectl set-timezone "$timezone" timedatectl set-timezone "$timezone"
end end
and genfstab -U "$mountDir" >>"$mountDir/etc/fstab" and pacman-key --init
and pacman-key --populate
and if isProgramEnabled "networkmanager" and pacstrap -K "$mountDir" \
and pacstrap -K "$mountDir" networkmanager base \
arch-chroot "$mountDir" systemctl enable NetworkManager linux \
end linux-firmware \
networkmanager \
man-db \
man-pages \
texinfo
and genfstab -U "$mountDir" >>"$mountDir/etc/fstab"
and arch-chroot "$mountDir" systemctl enable NetworkManager
and if set -q timezone and if set -q timezone
arch-chroot "$mountDir" ln -sf "/usr/share/zoneinfo/$timezone" /etc/localtime arch-chroot "$mountDir" ln -sf "/usr/share/zoneinfo/$timezone" /etc/localtime
@ -76,7 +61,7 @@ begin
and arch-chroot "$mountDir" hwclock --systohc and arch-chroot "$mountDir" hwclock --systohc
and begin and begin
getOSConfig i18n.localeSettings --json | getOSConfig i18n.localeSettings --json | \
jq --raw-output '[.[] | split(".") | .[0]] | unique | join("\\\\|")' jq --raw-output '[.[] | split(".") | .[0]] | unique | join("\\\\|")'
end | begin end | begin
read LOCALES read LOCALES
@ -85,7 +70,7 @@ begin
end end
and begin and begin
getOSConfig i18n.localeSettings --json | getOSConfig i18n.localeSettings --json | \
jq --raw-output '[keys[] as $key | "\($key)=\(.[$key])"] | join("\n")' jq --raw-output '[keys[] as $key | "\($key)=\(.[$key])"] | join("\n")'
end | arch-chroot "$mountDir" tee /etc/locale.conf >/dev/null end | arch-chroot "$mountDir" tee /etc/locale.conf >/dev/null
@ -95,8 +80,6 @@ begin
and echo (getOSConfig hostname) | arch-chroot "$mountDir" tee /etc/hostname >/dev/null and echo (getOSConfig hostname) | arch-chroot "$mountDir" tee /etc/hostname >/dev/null
and runInOS fish "$tempDir/../Software/systemd-networkd/main.fish"
and runInOS fish "$tempDir/../Software/btrfs/main.fish"
and arch-chroot "$mountDir" mkinitcpio -P and arch-chroot "$mountDir" mkinitcpio -P
and runInOS fish "$tempDir/../Software/grub/main.fish" and runInOS fish "$tempDir/../Software/grub/main.fish"
@ -112,20 +95,16 @@ begin
end end
end end
function autologin -S -V autologinConfig function autologin -S
set -l mountDir (getOSConfig fileSystems.rootDir) set -l file "/etc/systemd/system/getty@tty1.service.d/autologin.conf"
arch-chroot "$mountDir" mkdir -p (dirname "$autologinConfig") arch-chroot "$mountDir" mkdir -p (dirname "$file")
and begin and begin
printf %s\n \ printf %s\n \
"[Service]" \ "[Service]" \
"ExecStart=" \ "ExecStart=" \
"ExecStart=-/sbin/agetty -o '-p -f -- \\u' --noclear --autologin root %I \$TERM" "ExecStart=-/sbin/agetty -o '-p -f -- \\u' --noclear --autologin root %I \$TERM"
end | arch-chroot "$mountDir" tee "$autologinConfig" >/dev/null end | arch-chroot "$mountDir" tee "$file" >/dev/null
end
function getAutologinDisableCommand -V autologinConfig
echo "rm -rf $(string escape (dirname "$autologinConfig"))"
end end
if not type -q getInstallerScript if not type -q getInstallerScript

View file

@ -1,7 +1,6 @@
function deploySoftware -d "Deploys a the specified software action" -a action function deploySoftware -d "Deploys a the specified software action" -a action
set -l dir (status dirname) set -l dir (status dirname)
. "$dir/software.fish" . "$dir/software.fish"
. "$dir/../../lib/settings.fish"
if [ -z "$action" ] if [ -z "$action" ]
set action install set action install
@ -31,7 +30,7 @@ function deploySoftware -d "Deploys a the specified software action" -a action
source "$dir/../Software/xone/main.fish" $argv source "$dir/../Software/xone/main.fish" $argv
end end
and for component in (getOSConfig hardware.components --json | jq '.[]' --raw-output0 | string split0 || true) and for component in (getOSConfig hardware.components --json | jq '.[]' --raw-output0 | string split0)
switch "$component" switch "$component"
case "Logitech G903" case "Logitech G903"
source "$dir/../../Common/Drivers/Logitech G903/main.fish" $argv source "$dir/../../Common/Drivers/Logitech G903/main.fish" $argv
@ -71,8 +70,6 @@ function deploySoftware -d "Deploys a the specified software action" -a action
end end
and source "$dir/../../Common/Software/bash/main.fish" $argv and source "$dir/../../Common/Software/bash/main.fish" $argv
and source "$dir/../Software/systemd-networkd/main.fish" $argv
and source "$dir/../Software/btrfs/main.fish" $argv
and source "$dir/../../Common/Software/nuke-usb/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/sudo/main.fish" $argv
and source "$dir/../Software/aliae/main.fish" $argv and source "$dir/../Software/aliae/main.fish" $argv
@ -82,7 +79,6 @@ function deploySoftware -d "Deploys a the specified software action" -a action
and source "$dir/../Software/git/main.fish" $argv and source "$dir/../Software/git/main.fish" $argv
and source "$dir/../Software/zoxide/main.fish" $argv and source "$dir/../Software/zoxide/main.fish" $argv
and source "$dir/../Software/logo-ls/main.fish" $argv and source "$dir/../Software/logo-ls/main.fish" $argv
and source "$dir/../../Common/Software/linux/main.fish" $argv
# GRUB Shenanigans - if that's not essential I don't know what is! # GRUB Shenanigans - if that's not essential I don't know what is!
and source "$dir/../Software/minegrub-theme/main.fish" $argv and source "$dir/../Software/minegrub-theme/main.fish" $argv
@ -149,13 +145,10 @@ function deploySoftware -d "Deploys a the specified software action" -a action
and yayinst propertree-git # mac .plist config file editor and yayinst propertree-git # mac .plist config file editor
end end
and if isProgramEnabled thunderbird && $isInstall and if isProgramEnabled "thunderbird" && $isInstall
yayinst thunderbird yayinst thunderbird
end end
# Server
and source "$dir/../Software/nginx/main.fish" $argv
# School & Studies # School & Studies
and if collectionActive school && $isInstall and if collectionActive school && $isInstall
yayinst \ yayinst \
@ -205,7 +198,7 @@ function deploySoftware -d "Deploys a the specified software action" -a action
audius-client-bin audius-client-bin
end end
and if isProgramEnabled nextcloud and if isProgramEnabled "nextcloud"
yayinst nextcloud-client yayinst nextcloud-client
end end
end end
@ -289,7 +282,7 @@ function deploySoftware -d "Deploys a the specified software action" -a action
yayinst osu-lazer-bin yayinst osu-lazer-bin
end end
and if isProgramEnabled retroarch and if isProgramEnabled "retroarch"
yayinst libretro yayinst libretro
end end
end end

View file

@ -1,7 +1,7 @@
#!/bin/env fish #!/bin/env fish
begin begin
set -l dir (status dirname) set -l dir (status dirname)
source "$dir/../../lib/software.fish" source "$dir/../../Common/Scripts/software.fish"
function runYay -d "Run yay with pre-configured defaults" function runYay -d "Run yay with pre-configured defaults"
if not isatty 0 if not isatty 0

View file

@ -1,7 +1,7 @@
#!/bin/env fish #!/bin/env fish
begin begin
set -l dir (status dirname) set -l dir (status dirname)
source "$dir/../../lib/software.fish" source "$dir/../../Scripts/software.fish"
inherit "$dir/../../../Common/Software/aliae/main.fish" inherit "$dir/../../../Common/Software/aliae/main.fish"
function installSW function installSW

View file

@ -1,7 +1,7 @@
#!/bin/env fish #!/bin/env fish
begin begin
set -l dir (status dirname) set -l dir (status dirname)
source "$dir/../../lib/software.fish" source "$dir/../../Scripts/software.fish"
function installSW function installSW
pacinst base-devel pacinst base-devel

View file

@ -1,7 +1,7 @@
#!/bin/env fish #!/bin/env fish
begin begin
set -l dir (status dirname) set -l dir (status dirname)
source "$dir/../../lib/software.fish" source "$dir/../../Scripts/software.fish"
inherit "$dir/../../../Common/Software/brave/main.fish" inherit "$dir/../../../Common/Software/brave/main.fish"
function installSW function installSW

View file

@ -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

View file

@ -1,7 +1,7 @@
#!/bin/env fish #!/bin/env fish
begin begin
set -l dir (status dirname) set -l dir (status dirname)
source "$dir/../../lib/software.fish" source "$dir/../../Scripts/software.fish"
inherit "$dir/../../../Common/Software/docker/main.fish" inherit "$dir/../../../Common/Software/docker/main.fish"
function installSW function installSW
@ -10,8 +10,6 @@ begin
docker-compose \ docker-compose \
docker-buildx \ docker-buildx \
docker-scan docker-scan
installSWBase $argv
end end
runInstaller $argv runInstaller $argv

View file

@ -1,7 +1,7 @@
#!/bin/env fish #!/bin/env fish
begin begin
set -l dir (status dirname) set -l dir (status dirname)
source "$dir/../../lib/software.fish" source "$dir/../../Scripts/software.fish"
inherit "$dir/../../../Common/Software/firefox/main.fish" inherit "$dir/../../../Common/Software/firefox/main.fish"
function installSW -V dir function installSW -V dir

View file

@ -1,7 +1,7 @@
#!/bin/env fish #!/bin/env fish
begin begin
set -l dir (status dirname) set -l dir (status dirname)
source "$dir/../../lib/software.fish" source "$dir/../../Scripts/software.fish"
inherit "$dir/../../../Common/Software/git/main.fish" inherit "$dir/../../../Common/Software/git/main.fish"
function installSW function installSW

View file

@ -1,7 +1,7 @@
#!/bin/env fish #!/bin/env fish
begin begin
set -l dir (status dirname) set -l dir (status dirname)
source "$dir/../../lib/software.fish" source "$dir/../../Scripts/software.fish"
inherit "$dir/../../../Common/Software/grub/main.fish" inherit "$dir/../../../Common/Software/grub/main.fish"
function installSW -V dir function installSW -V dir

View file

@ -1,7 +1,7 @@
#!/bin/env fish #!/bin/env fish
begin begin
set -l dir (status dirname) set -l dir (status dirname)
source "$dir/../../lib/software.fish" source "$dir/../../Scripts/software.fish"
function installSW function installSW
yayinst \ yayinst \

View file

@ -1,7 +1,7 @@
#!/bin/env fish #!/bin/env fish
begin begin
set -l dir (status dirname) set -l dir (status dirname)
source "$dir/../../lib/software.fish" source "$dir/../../Scripts/software.fish"
inherit "$dir/../../../Common/Software/logo-ls/main.fish" inherit "$dir/../../../Common/Software/logo-ls/main.fish"
function installSW -V dir function installSW -V dir

View file

@ -1,7 +1,7 @@
#!/bin/env fish #!/bin/env fish
begin begin
set -l dir (status dirname) set -l dir (status dirname)
source "$dir/../../lib/software.fish" source "$dir/../../Scripts/software.fish"
function installSW function installSW
yayinst \ yayinst \

View file

@ -1,7 +1,7 @@
#!/bin/env fish #!/bin/env fish
begin begin
set -l dir (status dirname) set -l dir (status dirname)
source "$dir/../../lib/software.fish" source "$dir/../../Scripts/software.fish"
inherit "$dir/../../../Common/Software/minegrub-theme/main.fish" inherit "$dir/../../../Common/Software/minegrub-theme/main.fish"
function installSW function installSW

View file

@ -1,23 +0,0 @@
#!/bin/env fish
begin
set -l dir (status dirname)
source "$dir/../../lib/software.fish"
inherit "$dir/../../../Common/Software/aliae/main.fish"
function installSW
yayinst nginx
end
function configureSW
set -l file "/etc/nginx/nginx.conf"
set -l config "include /etc/nginx/conf.d/*.conf;"
if not grep --fixed-strings "$config" "$file" >/dev/null
sudo sed -i "$file" -e "/^http {/,/^}/{ /^}/{" -e "i\\" -e "" -e "i \ $config" -e "} }"
end
sudo systemctl enable --now nginx
end
runInstaller $argv
end

View file

@ -1,7 +1,7 @@
#!/bin/env fish #!/bin/env fish
begin begin
set -l dir (status dirname) set -l dir (status dirname)
source "$dir/../../lib/software.fish" source "$dir/../../Scripts/software.fish"
inherit "$dir/../../../Common/Software/nix/main.fish" inherit "$dir/../../../Common/Software/nix/main.fish"
function installSW function installSW
@ -14,7 +14,7 @@ begin
function configureSW -V dir function configureSW -V dir
sudo systemctl enable --now nix-daemon sudo systemctl enable --now nix-daemon
configureSWBase $argv configureSWBase configure $argv
end end
runInstaller $argv runInstaller $argv

View file

@ -1,7 +1,7 @@
#!/bin/env fish #!/bin/env fish
begin begin
set -l dir (status dirname) set -l dir (status dirname)
source "$dir/../../lib/software.fish" source "$dir/../../Scripts/software.fish"
function installSW function installSW
yayinst nodejs-n yayinst nodejs-n

View file

@ -1,7 +1,7 @@
#!/bin/env fish #!/bin/env fish
begin begin
set -l dir (status dirname) set -l dir (status dirname)
source "$dir/../../lib/software.fish" source "$dir/../../Scripts/software.fish"
inherit "$dir/../../../Common/Software/nvidia-dkms/main.fish" inherit "$dir/../../../Common/Software/nvidia-dkms/main.fish"
function installSW function installSW

View file

@ -1,7 +1,7 @@
#!/bin/env fish #!/bin/env fish
begin begin
set -l dir (status dirname) set -l dir (status dirname)
source "$dir/../../lib/software.fish" source "$dir/../../Scripts/software.fish"
inherit "$dir/../../../Common/Software/oh-my-posh/main.fish" inherit "$dir/../../../Common/Software/oh-my-posh/main.fish"
function installSW function installSW

View file

@ -1,7 +1,7 @@
#!/bin/env fish #!/bin/env fish
begin begin
set -l dir (status dirname) set -l dir (status dirname)
source "$dir/../../lib/software.fish" source "$dir/../../Scripts/software.fish"
function installSW function installSW
yayinst \ yayinst \

View file

@ -1,7 +1,7 @@
#!/bin/env fish #!/bin/env fish
begin begin
set -l dir (status dirname) set -l dir (status dirname)
source "$dir/../../lib/software.fish" source "$dir/../../Scripts/software.fish"
function installSW function installSW
configureSW configureSW

View file

@ -1,7 +1,7 @@
#!/bin/env fish #!/bin/env fish
begin begin
set -l dir (status dirname) set -l dir (status dirname)
source "$dir/../../lib/software.fish" source "$dir/../../Scripts/software.fish"
function installSW function installSW
yayinst \ yayinst \

View file

@ -1,7 +1,7 @@
#!/bin/env fish #!/bin/env fish
begin begin
set -l dir (status dirname) set -l dir (status dirname)
source "$dir/../../lib/software.fish" source "$dir/../../Scripts/software.fish"
function installSW function installSW
yayinst \ yayinst \

View file

@ -1,7 +1,7 @@
#!/bin/env fish #!/bin/env fish
begin begin
set -l dir (status dirname) set -l dir (status dirname)
source "$dir/../../lib/software.fish" source "$dir/../../Scripts/software.fish"
inherit "$dir/../../../Common/Software/powershell/main.fish" inherit "$dir/../../../Common/Software/powershell/main.fish"
function installSW function installSW

View file

@ -1,7 +1,7 @@
#!/bin/env fish #!/bin/env fish
begin begin
set -l dir (status dirname) set -l dir (status dirname)
source "$dir/../../lib/software.fish" source "$dir/../../Scripts/software.fish"
inherit "$dir/../../../Common/Software/pyenv/main.fish" inherit "$dir/../../../Common/Software/pyenv/main.fish"
function installSW function installSW

View file

@ -1,7 +1,7 @@
#!/bin/env fish #!/bin/env fish
begin begin
set -l dir (status dirname) set -l dir (status dirname)
source "$dir/../../lib/software.fish" source "$dir/../../Scripts/software.fish"
inherit "$dir/../../../Common/Software/rclone/main.fish" inherit "$dir/../../../Common/Software/rclone/main.fish"
function installSW function installSW

View file

@ -1,7 +1,7 @@
#!/bin/env fish #!/bin/env fish
begin begin
set -l dir (status dirname) set -l dir (status dirname)
source "$dir/../../lib/software.fish" source "$dir/../../Scripts/software.fish"
function installSW function installSW
# `git` version # `git` version

View file

@ -1,7 +1,7 @@
#!/bin/env fish #!/bin/env fish
begin begin
set -l dir (status dirname) set -l dir (status dirname)
source "$dir/../../lib/software.fish" source "$dir/../../Scripts/software.fish"
function installSW function installSW
yayinst steam yayinst steam
@ -9,7 +9,7 @@ begin
function configureSW -V dir function configureSW -V dir
. "$dir/../../../lib/settings.fish" . "$dir/../../../Common/Scripts/config.fish"
if isOSEnabled hidpi if isOSEnabled hidpi
begin begin

View file

@ -1,7 +1,7 @@
#!/bin/env fish #!/bin/env fish
begin begin
set -l dir (status dirname) set -l dir (status dirname)
source "$dir/../../lib/software.fish" source "$dir/../../Scripts/software.fish"
function installSW function installSW
pacinst sudo pacinst sudo

View file

@ -1,14 +0,0 @@
#!/bin/env fish
begin
set -l dir (status dirname)
source "$dir/../../../lib/software.fish"
inherit "$dir/../../../Common/Software/systemd-networkd/main.fish"
function configureSW -V dir
sudo systemctl enable systemd-networkd
sudo systemctl enable systemd-resolved
configureSWBase $argv
end
runInstaller $argv
end

View file

@ -1,7 +1,7 @@
#!/bin/env fish #!/bin/env fish
begin begin
set -l dir (status dirname) set -l dir (status dirname)
source "$dir/../../lib/software.fish" source "$dir/../../Scripts/software.fish"
inherit "$dir/../../../Common/Software/vim/main.fish" inherit "$dir/../../../Common/Software/vim/main.fish"
function installSW function installSW

View file

@ -1,7 +1,7 @@
#!/bin/env fish #!/bin/env fish
begin begin
set -l dir (status dirname) set -l dir (status dirname)
source "$dir/../../lib/software.fish" source "$dir/../../Scripts/software.fish"
inherit "$dir/../../../Common/Software/virt-manager/main.fish" inherit "$dir/../../../Common/Software/virt-manager/main.fish"
function installSW function installSW

View file

@ -1,11 +1,9 @@
#!/bin/env fish #!/bin/env fish
begin begin
set -l dir (status dirname) set -l dir (status dirname)
source "$dir/../../lib/software.fish" source "$dir/../../Scripts/software.fish"
function setFlags function setFlags -a user
argparse -i "user=" -- $argv
set -l user "$_flag_user"
set -l flags set -l flags
set -l bins codium code set -l bins codium code

View file

@ -1,7 +1,7 @@
#!/bin/env fish #!/bin/env fish
begin begin
set -l dir (status dirname) set -l dir (status dirname)
source "$dir/../../lib/software.fish" source "$dir/../../Scripts/software.fish"
function installSW function installSW
yayinst ( yayinst (

View file

@ -1,7 +1,7 @@
#!/bin/env fish #!/bin/env fish
begin begin
set -l dir (status dirname) set -l dir (status dirname)
source "$dir/../../lib/software.fish" source "$dir/../../Scripts/software.fish"
function installSW function installSW
set -l contextRoot (mktemp -d) set -l contextRoot (mktemp -d)

View file

@ -1,7 +1,7 @@
#!/bin/env fish #!/bin/env fish
begin begin
set -l dir (status dirname) set -l dir (status dirname)
source "$dir/../../lib/software.fish" source "$dir/../../Scripts/software.fish"
function installSW function installSW
if not type -q yay if not type -q yay

View file

@ -1,7 +1,7 @@
#!/bin/env fish #!/bin/env fish
begin begin
set -l dir (status dirname) set -l dir (status dirname)
source "$dir/../../lib/software.fish" source "$dir/../../Scripts/software.fish"
inherit "$dir/../../../Common/Software/zoxide/main.fish" inherit "$dir/../../../Common/Software/zoxide/main.fish"
function installSW function installSW

View file

@ -1,11 +0,0 @@
function installValhallaDeps -V dir -a mountDir
source "$dir/../lib/software.fish"
set -l args
if [ -n "$mountDir" ]
set -a args --root "$mountDir"
end
and pacinst $args fish git jq nix openssh sudo tmux
sudo systemctl enable --now nix-daemon
end

View file

@ -1,7 +1,7 @@
#!/bin/env fish #!/bin/env fish
begin begin
set -l dir (status dirname) set -l dir (status dirname)
source "$dir/../../../lib/software.fish" source "$dir/../../Scripts/software.fish"
function configureSW -V dir function configureSW -V dir
. "$dir/../../Software/plasma/input.fish" . "$dir/../../Software/plasma/input.fish"

View file

@ -1,7 +1,7 @@
#!/bin/env fish #!/bin/env fish
begin begin
set -l dir (status dirname) set -l dir (status dirname)
source "$dir/../../../lib/software.fish" source "$dir/../../Scripts/software.fish"
function configureSW -V dir function configureSW -V dir
. "$dir/../../Software/plasma/input.fish" . "$dir/../../Software/plasma/input.fish"

View file

@ -1,37 +0,0 @@
#!/bin/env fish
set -l dir (status dirname)
source "$dir/../../lib/action.fish"
function backupAction -V dir
source "$dir/../../lib/hooks.fish"
source "$dir/../../lib/restoration.fish"
if not type -q getDeploymentScript
function getDeploymentScript
echo "No deployment script specified! No software will be installed." 1>&2
false
end
end
set -l deployScript (getDeploymentScript)
initBackupConfig --action backup
runHook backupSoftware || begin
echo "Backing up software..."
and if [ -n "$deployScript" ]
source $deployScript backup
end
end
runHook backupUsers || begin
if [ -n "$deployScript" ]
for name in (getUsers | jq '.[]' --raw-output0 | string split0 || true)
echo "Backing up user `$name`..."
and source $deployScript userBackup --user $name
end
end
end
end
runSetupUserAction backupAction

View file

@ -1,11 +1,34 @@
#!/bin/env fish #!/bin/env fish
set -l dir (status dirname) set -l dir (status dirname)
source "$dir/../../lib/action.fish" source "$dir/../Scripts/config.fish"
source "$dir/../Scripts/hooks.fish"
function installAction -V dir if [ (id -u) -eq 0 ]
source "$dir/../../lib/hooks.fish" set -l name (getOSConfig setupUser.name)
source "$dir/../../lib/restoration.fish" set -l sudoConfig "/etc/sudoers.d/PortValhalla"
rm ~/.bash_profile
begin
echo "Creating setup user"
and useradd \
--comment "PortValhalla Setup User" \
--system \
--no-user-group \
--groups nix-users \
--create-home \
--uid (getOSConfig setupUser.id --json) \
"$name"
end
and begin
echo "$name ALL=(ALL:ALL) NOPASSWD: ALL"
end >"$sudoConfig"
and sudo --preserve-env --set-home --user "$name" "$INSTALLER_SCRIPT"
rm "$sudoConfig"
userdel -rf "$name"
else
if not type -q getDeploymentScript if not type -q getDeploymentScript
function getDeploymentScript function getDeploymentScript
echo "No deployment script specified! No software will be installed." 1>&2 echo "No deployment script specified! No software will be installed." 1>&2
@ -14,7 +37,6 @@ function installAction -V dir
end end
set -l deployScript (getDeploymentScript) set -l deployScript (getDeploymentScript)
initBackupConfig --action restore
runHook initialize || true runHook initialize || true
and runHook installOS || true and runHook installOS || true
@ -32,29 +54,28 @@ function installAction -V dir
runHook initializeUsers || begin runHook initializeUsers || begin
if [ -n "$deployScript" ] if [ -n "$deployScript" ]
source "$dir/../../lib/settings.fish" source "$dir/../Scripts/config.fish"
for name in (getUsers | jq '.[]' --raw-output0 | string split0 || true) for name in (getUsers | jq '.[]' --raw-output0 | string split0)
echo "Configuring user `$name`..." echo "Configuring user `$name`..."
and source $deployScript userConfig --user $name and source $deployScript userConfig $name
end end
end end
end end
and runHook postInstall || true and runHook postInstall || true
and sudo git config remove-section --system safe || true
and begin and begin
echo "Cleaning installation scripts..." echo "Cleaning installation scripts..."
set -l projectPath (realpath "$(status dirname)/../../..") set -l projectPath (realpath "$(status dirname)/../../..")
cd (dirname "$projectPath") cd (dirname "$projectPath")
# sudo rm -rf "$projectPath" sudo rm -rf "$projectPath"
end end
and echo "The installation finished successfully!" and echo "The installation finished successfully!"
and echo "This machine will reboot in 5 seconds..." and echo "This machine will reboot in 5 seconds..."
and echo "Press CTRL-C to abort..." and echo "Press CTRL-C to abort..."
and sleep 5 and sleep 5
and sudo systemctl reboot -i and systemctl reboot -i
end end
runSetupUserAction installAction

View file

@ -1,126 +1,86 @@
#!/bin/env fish #!/bin/env fish
function runSetup function runSetup
set -l dir (status dirname) set -l dir (status dirname)
source "$dir/../../lib/action.fish" source "$dir/../Scripts/config.fish"
source "$dir/../Scripts/hooks.fish"
if [ -z "$CONFIG_NAME" ]
selectProfile config
set -x CONFIG_NAME "$config"
end
set -l mountDir (getOSConfig partition.rootDir)
set -l projectRoot (realpath "$dir/../../..") set -l projectRoot (realpath "$dir/../../..")
set -l projectName (basename "$projectRoot") set -l projectName (basename "$projectRoot")
set -l PROJECT_CLONE_ROOT "/opt/$(basename "$projectName")" set -l PROJECT_CLONE_ROOT "/opt/$(basename "$projectName")"
set -l script (mktemp)
chmod +x "$script"
function setupAction -V dir -V projectRoot -V PROJECT_CLONE_ROOT if not type -q runChroot
source "$dir/../../lib/hooks.fish" function runChroot -S
source "$dir/../../lib/nix.fish" command chroot $argv
source "$dir/../../lib/restoration.fish"
source "$dir/../../lib/settings.fish"
set -l mountDir (getOSConfig fileSystems.rootDir)
if not type -q runChroot
function runChroot -S
command chroot $argv
end
end
if not type -q getAutologinDisableCommand
function getAutologinDisableCommand
echo "true"
end
end
function getCloneFile -S -a path
set -l relativeDir (realpath --relative-to "$projectRoot" "$dir")
set -l relativePath (realpath --relative-to "$dir" "$path")
echo "$PROJECT_CLONE_ROOT/$relativeDir/$relativePath"
end
function runInOS -S
set -l script /root/run_once
wrapScript $argv | chroot "$mountDir" tee "$script" >/dev/null
and runChroot "$mountDir" chmod +x "$script"
and runChroot "$mountDir" "$script"
and runChroot "$mountDir" rm "$script"
end
function wrapScript -S
printf %s\n \
"cd $PROJECT_CLONE_ROOT" \
"$argv"
end
initBackupConfig --action restore
echo "Partitioning drives..."
begin
set -l script (mktemp)
chmod +x "$script"
and getOSConfig fileSystems.script >"$script"
and "$script"
and rm "$script"
end
if [ -n "$VALHALLA_BACKUP_SERVER_KEY" ]
set -l knownHosts /root/.ssh/known_hosts
mkdir -p (dirname "$mountDir$VALHALLA_BACKUP_SERVER_KEY")
mkdir -p (dirname "$mountDir$knownHosts")
cp "$VALHALLA_BACKUP_SERVER_KEY" "$mountDir$VALHALLA_BACKUP_SERVER_KEY"
cp $knownHosts "$mountDir$knownHosts"
end
and echo "Cloning project..."
and source "$dir/../../lib/copy-repo.fish" "$mountDir$PROJECT_CLONE_ROOT"
and begin
set -l path "$mountDir/$nixPkgsDir"
and mkdir -p (dirname "$path")
and cp -r "$nixPkgsDir" "$path"
and git -C "$path" reset --hard
end
and runHook initOS "Please set up a function `initOS` for initializing the mounted OS and installing valhalla dependencies"
and runChroot "$mountDir" git config --system --add safe.directory "$PROJECT_CLONE_ROOT"
and runHook --force bootstrapSetup "Please set up a function `bootstrapSetup` for installing `fish` into the "
and runHook setupOS
and echo "Preparing auto-login..."
and runHook --force autologin "Please set up a function `autologin` for setting up autologin for the `root` user"
and begin
set -l profile "/root/.bash_profile"
begin
set -l profile (string escape "$profile")
set -l tmp (string escape "$profile""_")
set -l script (string escape (getCloneFile (getInstallerScript)))
printf "%s\n" \
"mv $profile $tmp" \
(wrapScript (
string join " " \
(begin
for var in \
CONFIG_NAME \
VALHALLA_BACKUP_DISABLED \
VALHALLA_BACKUP_DIR \
VALHALLA_BACKUP_SERVER \
VALHALLA_BACKUP_SERVER_PORT \
VALHALLA_BACKUP_SERVER_USER \
VALHALLA_BACKUP_SERVER_KEY
echo "$var=$(string escape "$$var")"
end
end) \
(string escape $script) "&&")) \
"rm $tmp &&" \
"$(getAutologinDisableCommand) ||" \
"mv $tmp $profile"
end | runChroot "$mountDir" tee "$profile" >/dev/null
end end
end end
function actionPostRun function getCloneFile -S -a path
echo "Setup finished!" set -l relativeDir (realpath --relative-to "$projectRoot" "$dir")
and echo "This machine will reboot in 5 seconds..." set -l relativePath (realpath --relative-to "$dir" "$path")
and echo "Press CTRL-C to abort..." echo "$PROJECT_CLONE_ROOT/$relativeDir/$relativePath"
and sleep 5
and systemctl reboot
end end
runAction setupAction function runInOS -S
set -l script /root/run_once
wrapScript $argv | chroot "$mountDir" tee "$script" >/dev/null
and runChroot "$mountDir" chmod +x "$script"
and runChroot "$mountDir" "$script"
and runChroot "$mountDir" rm "$script"
end
function wrapScript -S
printf %s\n \
"cd $PROJECT_CLONE_ROOT" \
"$argv"
end
echo "Partitioning drives..."
and getOSConfig partition.script >"$script"
and "$script"
and rm "$script"
# Copy `nixpkgs` channel
and echo "Preparing nix..."
and begin
set -l channelDir /nix/var/nix/profiles/per-user/root/channels/nixpkgs
mkdir -p (dirname "$mountDir/$channelDir")
cp -r "$channelDir" "$mountDir/$channelDir"
end
and echo "Installing dependencies..."
and runHook --force installValhallaDeps 'Please set up a function `installValhallaDeps` for installing `fish`, `git`, `jq`, `nix`, `sudo` and `tmux`.'
and echo "Cloning project..."
and source "$dir/../../copy-repo.fish" "$mountDir$PROJECT_CLONE_ROOT"
runChroot "$mountDir" git config --system --add safe.directory "$PROJECT_CLONE_ROOT"
and runHook setupOS
and echo "Preparing auto-login..."
and runHook --force autologin "Please set up a function `autologin` for setting up autologin for the `root` user"
and begin
set -l script (string escape (getCloneFile (getInstallerScript)))
wrapScript (
string join " " \
"INSTALLER_SCRIPT=$(string escape "$script")" \
"CONFIG_NAME=$(string escape "$CONFIG_NAME")" \
(string escape $script))
end | runChroot "$mountDir" tee /root/.bash_profile >/dev/null
and echo "Setup finished!"
and echo "This machine will reboot in 5 seconds..."
and echo "Press CTRL-C to abort..."
and sleep 5
and systemctl reboot
end end

View file

@ -1,11 +1,11 @@
#!/bin/env fish #!/bin/env fish
set -l dir (status dirname) set -l dir (status dirname)
source "$dir/../../lib/settings.fish" source "$dir/../Scripts/config.fish"
set -l users (getUsers) set -l users (getUsers)
echo "Creating users..." echo "Creating users..."
for name in (echo "$users" | jq '.[]' --raw-output0 | string split0 || true) for name in (echo "$users" | jq '.[]' --raw-output0 | string split0)
echo "Creating user `$name`..." echo "Creating user `$name`..."
function getUserInfo -V name -a config function getUserInfo -V name -a config

View file

@ -3,9 +3,9 @@ using namespace System.Management.Automation.Host;
$null = New-Module { $null = New-Module {
. "$PSScriptRoot/SoftwareManagement.ps1"; . "$PSScriptRoot/SoftwareManagement.ps1";
. "$PSScriptRoot/../Windows/lib/Registry.ps1"; . "$PSScriptRoot/../../Windows/Scripts/Registry.ps1";
. "$PSScriptRoot/../Windows/lib/WSL.ps1"; . "$PSScriptRoot/../../Windows/Scripts/WSL.ps1";
. "$PSScriptRoot/../Windows/Types/WindowsInstallerAction.ps1"; . "$PSScriptRoot/../../Windows/Types/WindowsInstallerAction.ps1";
<# <#
.SYNOPSIS .SYNOPSIS
@ -18,7 +18,7 @@ $null = New-Module {
return Invoke-ConfigScript "getProfiles"; return Invoke-ConfigScript "getProfiles";
} }
else { else {
return Get-ChildItem "$PSScriptRoot/../../.config" | ForEach-Object { Split-Path -LeafBase $_ }; return Get-ChildItem "$PSScriptRoot/../../../.config" | ForEach-Object { Split-Path -LeafBase $_ };
} }
}; };
@ -61,7 +61,7 @@ $null = New-Module {
<# <#
.SYNOPSIS .SYNOPSIS
Runs a script based on the `settings.fish` script. Runs a script based on the `config.fish` script.
.PARAMETER Script .PARAMETER Script
The script to run. The script to run.
@ -71,7 +71,7 @@ $null = New-Module {
[string] $Script [string] $Script
) )
$scriptPath = "$PSScriptRoot/settings.fish"; $scriptPath = "$PSScriptRoot/../../Common/Scripts/config.fish";
if ($env:CONFIG_NAME -or ($Script -eq "getProfiles")) { if ($env:CONFIG_NAME -or ($Script -eq "getProfiles")) {
$output = & { $output = & {
@ -82,7 +82,7 @@ $null = New-Module {
else { else {
if (-not $env:VALHALLA_FLAKE_ROOT) { if (-not $env:VALHALLA_FLAKE_ROOT) {
$cleanup = { }; $cleanup = { };
$projectRoot = "$PSScriptRoot/../.."; $projectRoot = "$PSScriptRoot/../../..";
$archisoDir = "$projectRoot/archiso"; $archisoDir = "$projectRoot/archiso";
if (Test-Path -PathType Container "$archisoDir") { if (Test-Path -PathType Container "$archisoDir") {
@ -94,7 +94,7 @@ $null = New-Module {
$cleanup = { & $git restore --staged "$archisoDir" }; $cleanup = { & $git restore --staged "$archisoDir" };
} }
$env:VALHALLA_FLAKE_ROOT = (Invoke-Nix flake metadata (ConvertTo-LinuxPath "$PSScriptRoot/../..") --json | ConvertFrom-Json).path; $env:VALHALLA_FLAKE_ROOT = (Invoke-Nix flake metadata (ConvertTo-LinuxPath "$PSScriptRoot/../../..") --json | ConvertFrom-Json).path;
& $cleanup *> $null; & $cleanup *> $null;
} }
@ -186,8 +186,7 @@ $null = New-Module {
$programs = & { $programs = & {
if ($User) { if ($User) {
return Get-UserConfig -UserName $User @args; return Get-UserConfig -UserName $User @args;
} } else {
else {
return Get-OSConfig @args; return Get-OSConfig @args;
} }
} "programs"; } "programs";
@ -208,8 +207,7 @@ $null = New-Module {
try { try {
(Get-ProgramConfig @PSBoundParameters).enable; (Get-ProgramConfig @PSBoundParameters).enable;
} } catch {
catch {
$false; $false;
} }
} }

View file

@ -3,14 +3,14 @@ using namespace System.Management.Automation.Host;
$null = New-Module { $null = New-Module {
. "$PSScriptRoot/Scripting.ps1"; . "$PSScriptRoot/Scripting.ps1";
. "$PSScriptRoot/SoftwareManagement.ps1"; . "$PSScriptRoot/SoftwareManagement.ps1";
. "$PSScriptRoot/../Windows/lib/Constants.ps1"; . "$PSScriptRoot/../../Windows/Scripts/Constants.ps1";
. "$PSScriptRoot/../Windows/lib/PowerManagement.ps1"; . "$PSScriptRoot/../../Windows/Scripts/PowerManagement.ps1";
. "$PSScriptRoot/../Windows/lib/Registry.ps1"; . "$PSScriptRoot/../../Windows/Scripts/Registry.ps1";
. "$PSScriptRoot/../Windows/lib/Security.ps1"; . "$PSScriptRoot/../../Windows/Scripts/Security.ps1";
. "$PSScriptRoot/../Windows/lib/SoftwareManagement.ps1"; . "$PSScriptRoot/../../Windows/Scripts/SoftwareManagement.ps1";
. "$PSScriptRoot/../Windows/lib/System.ps1"; . "$PSScriptRoot/../../Windows/Scripts/System.ps1";
. "$PSScriptRoot/../Windows/lib/Tasks.ps1"; . "$PSScriptRoot/../../Windows/Scripts/Tasks.ps1";
. "$PSScriptRoot/../Windows/lib/WSL.ps1"; . "$PSScriptRoot/../../Windows/Scripts/WSL.ps1";
<# <#
.SYNOPSIS .SYNOPSIS
@ -142,7 +142,7 @@ $null = New-Module {
$path = Join-Path ` $path = Join-Path `
"Z:\" ` "Z:\" `
([System.IO.Path]::GetRelativePath("$PSScriptRoot/../..", $variable.Value)); ([System.IO.Path]::GetRelativePath("$PSScriptRoot/../../..", $variable.Value));
Set-Item "Env:\$name" $path; Set-Item "Env:\$name" $path;
Write-Host "The new value of ``$name`` is ``$path``"; Write-Host "The new value of ``$name`` is ``$path``";
@ -203,7 +203,7 @@ $null = New-Module {
} }
if (-not (Test-Winget)) { if (-not (Test-Winget)) {
. "$PSScriptRoot/../Windows/Software/winget/Main.ps1"; . "$PSScriptRoot/../../Windows/Software/winget/Main.ps1";
continue; continue;
} }
@ -253,7 +253,7 @@ $null = New-Module {
Install-ChocoPackage selenium-gecko-driver firefox; Install-ChocoPackage selenium-gecko-driver firefox;
Install-WingetPackage AutoHotkey.AutoHotkey; Install-WingetPackage AutoHotkey.AutoHotkey;
. "$PSScriptRoot/../Windows/Software/pinned-item/Main.ps1"; . "$PSScriptRoot/../../Windows/Software/pinned-item/Main.ps1";
} }
Write-Host "Installing PowerShell Modules…"; Write-Host "Installing PowerShell Modules…";

View file

@ -1,10 +1,10 @@
. "$PSScriptRoot/Settings.ps1"; . "$PSScriptRoot/Config.ps1";
. "$PSScriptRoot/Operations.ps1"; . "$PSScriptRoot/Operations.ps1";
. "$PSScriptRoot/System.ps1"; . "$PSScriptRoot/System.ps1";
. "$PSScriptRoot/../Common/Types/InstallerAction.ps1"; . "$PSScriptRoot/../Types/InstallerAction.ps1";
$null = New-Module { $null = New-Module {
. "$PSScriptRoot/../Common/Types/InstallerAction.ps1"; . "$PSScriptRoot/../Types/InstallerAction.ps1";
$userArgument = "name"; $userArgument = "name";
function Start-SoftwareInstaller { function Start-SoftwareInstaller {
@ -90,7 +90,7 @@ $null = New-Module {
installer = $installHandler; installer = $installHandler;
arguments = $Arguments; arguments = $Arguments;
context = $Context; context = $Context;
base = { & $runBase @args }; base = { & $runBase @args };
}; };
switch ($Action) { switch ($Action) {

View file

@ -4,7 +4,7 @@ function isConfigured -S
end end
function selectProfile -S -a result 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 file (mktemp)
set -l header NAME set -l header NAME
set -l profiles set -l profiles
@ -40,21 +40,13 @@ function getOSConfig -S -a property
getConfig "$(getOSConfigRoot).$property" $argv[2..] getConfig "$(getOSConfigRoot).$property" $argv[2..]
end end
function getProgramConfig -S function getProgramConfig -S -a name user
argparse -i "name=" "user=" -- $argv
set -l name $_flag_name
set -l user $_flag_user
set -l option "programs.$name" set -l option "programs.$name"
if [ -z "$name" ]
set name $argv[1]
set argv $argv[2..]
end
if [ -z "$user" ] if [ -z "$user" ]
getOSConfig "$option" $argv --fallback "{}" getOSConfig "$option" $argv[3..] --fallback "{}"
else else
getUserConfig "$user" "$option" $argv --fallback "{}" getUserConfig "$user" "$option" $argv[3..] --fallback "{}"
end end
end end
@ -86,9 +78,8 @@ function isEnabled -S -a property
getConfig "$property" --json | jq --exit-status >/dev/null getConfig "$property" --json | jq --exit-status >/dev/null
end end
function isProgramEnabled -S function isProgramEnabled -S -a name user
argparse -i "user=" "name=" -- $argv getProgramConfig "$name" "$user" --json 2>/dev/null | jq --exit-status ".enable" >/dev/null
getProgramConfig --user "$_flag_user" --name "$_flag_name" --json 2>/dev/null | jq --exit-status ".enable" >/dev/null
end end
function isOSEnabled -S -a property function isOSEnabled -S -a property

View file

@ -1,7 +1,7 @@
#!/bin/env fish #!/bin/env fish
function evalFlake --argument-names config property function evalFlake --argument-names config property
set -l argv $argv[3..] set -l argv $argv[3..]
set -l flakePath "$(realpath (status dirname))/../.." set -l flakePath "$(realpath (status dirname))/../../.."
argparse --ignore-unknown "apply=" "fallback=" json -- $argv argparse --ignore-unknown "apply=" "fallback=" json -- $argv
if [ -z "$_flag_json" ] if [ -z "$_flag_json" ]
@ -20,7 +20,7 @@ function evalFlake --argument-names config property
if [ -n "$config" ] if [ -n "$config" ]
set config ".$config" set config ".$config"
set _flag_apply "_: ($_flag_apply) ((import $(realpath --relative-to (pwd) "$(status dirname)/../../lib/eval-attribute.nix")) _)" set _flag_apply "_: ($_flag_apply) ((import $(realpath --relative-to (pwd) "$(status dirname)/../../../lib/eval-attribute.nix")) _)"
end end
PROPERTY="$property" \ PROPERTY="$property" \

View file

@ -8,7 +8,7 @@ begin
set -l file (mktemp) set -l file (mktemp)
if [ -z "$title" ] if [ -z "$title" ]
set title "$name" set -l title "$name"
end end
if [ -z "$content" ] if [ -z "$content" ]

View file

@ -0,0 +1,100 @@
#!/bin/env fish
begin
set -l dir (status dirname)
functions -e installSW
functions -e configureSW
functions -e userConfig
function runPSUserAction -a script action name
pwsh -CommandWithArgs '& $args[0] $args[1] @{ name=$args[2]; }' "$script" "$action" "$name"
end
function runPSUserConfig -a script name
runPSUserAction "$script" ConfigureUser "$name"
end
function inherit -a script -d "Inherits the installer from the specified script."
set -l actions \
installSW \
install \
configureSW \
configure \
userConfig \
userConfig
for i in (seq 1 2 (count $actions))
set -l functionName "$actions[$i]Base"
function $functionName -V script -V actions -V i
fish "$script" $actions[(math $i + 1)] $argv
end
function $actions[$i] -V functionName
$functionName $argv
end
end
end
function runInstaller -V dir -a action
set -l path (status stack-trace | head -n4 | tail -n1 | string replace --regex -- '^\s*called on line \d+ of file (.*)$' '$1')
set -l name (basename (dirname $path))
runInstallerAction $name $argv
end
function runInstallerAction -V dir
argparse "force" -- $argv
set -l install
set -l args $_flag_force
set -l name $argv[1]
set -l action $argv[2]
source "$dir/config.fish"
if [ -n "$_flag_force" ]
set force true
else
set force false
end
if isProgramEnabled $name || $force
set install true
else
set install false
end
if [ -z "$action" ] || [ "$action" = install ]
if functions -q installSW && $install
echo "Installing `$name`..."
installSW $argv[3..]
end
runInstallerAction $args $name configure
if not isConfigured || [ "$USER" != (getConfig "valhalla.setupUser.name") ]
runInstallerAction $args $name userConfig
end
else if [ "$action" = configure ]
if functions -q configureSW && $install
echo "Configuring `$name`..."
configureSW $argv[3..]
end
else if [ "$action" = userConfig ]
set -l user $argv[3]
if [ -z "$user" ]
set user "$USER"
end
if isProgramEnabled "$name" "$user" || $force
set install true
else
set install false
end
if functions -q userConfig && $install
echo "Configuring `$name` for `$user`..."
userConfig "$user" $argv[4..]
end
end
end
end

View file

@ -10,8 +10,8 @@ function waitNetwork -a witness
end end
if [ -z "$witness" ] if [ -z "$witness" ]
if not testNetwork &>/dev/null if not testNetwork
tmux new-session -s network -d 'cat /etc/motd; echo "$(tput bold)Please establish an internet connection...$(tput sgr0)"; $SHELL' tmux new-session -d 'cat /etc/motd; echo "$(tput bold)Please establish an internet connection...$(tput sgr0)"; $SHELL'
fish (status filename) true & fish (status filename) true &
set -l pid "$last_pid" set -l pid "$last_pid"
@ -23,7 +23,7 @@ function waitNetwork -a witness
end end
end end
TMUX="" tmux attach -t network tmux attach
wait "$pid" wait "$pid"
return "$(cat "$codeFile")" return "$(cat "$codeFile")"
end end
@ -33,14 +33,14 @@ function waitNetwork -a witness
while true while true
set x (math $x + 1) set x (math $x + 1)
if testNetwork &>/dev/null if testNetwork
tmux kill-session -t network &>/dev/null tmux kill-session &>/dev/null
break break
else else
not tmux list-sessions -f "#{==:#S,network}" &>/dev/null not tmux list-sessions &>/dev/null
or test "$x" -gt 120 or test "$x" -gt 10
and begin and begin
tmux kill-session -t network &>/dev/null tmux kill-session &>/dev/null
exit 1 exit 1
end end
end end

Some files were not shown because too many files have changed in this diff Show more