Compare commits

..

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

297 changed files with 1329 additions and 6089 deletions
archiso
flake.nix
lib
profiles
scripts

View file

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

View file

@ -1,24 +1,31 @@
#!/bin/env fish
begin
set -l dir (status dirname)
source "$dir/../../scripts/lib/config.fish"
source "$dir/../../scripts/lib/nix.fish"
set -l nixVersion nixos-24.05
set -l projectName archiso-valhalla
set -l overlayDir (mktemp -d)
set -l upperDir (mktemp -d)
set -l workDir (mktemp -d)
set -l cacheRoot ~/".cache/$projectName"
set -l nixCache "$cacheRoot/nixpkgs/$nixVersion"
set -l root airootfs
set -l rootHome "$overlayDir/$root/root"
set -l profileDir "/mnt/$projectName"
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"
and fish "$(status dirname)/../../scripts/lib/copy-repo.fish" "$projectDir"
downloadNixPkgs
and fish "$(status dirname)/../../scripts/copy-repo.fish" "$projectDir"
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 --bind "$nixPkgsCache" "$nixDir"
and sudo mount --mkdir --bind "$nixCache" "$nixDir"
and sudo mkarchiso $argv "$profileDir"
sudo umount "$nixDir"
and sudo umount "$profileDir"

View file

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

View file

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

View file

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

View file

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

View file

@ -5,10 +5,8 @@ let
overlay = [ ];
};
property = (builtins.getEnv "PROPERTY");
processor =
if (builtins.stringLength property > 0) then
(_: lib.attrsets.getAttrFromPath (lib.strings.splitString "." property) _)
else
(_: _);
in
_: processor (lib.evalModules { modules = [ _ ]; }).config
processor = if (builtins.stringLength property > 0) then
(_: lib.attrsets.getAttrFromPath (lib.strings.splitString "." property) _)
else
(_: _);
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,369 +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}";
};
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;
optionalAttrs = lib.attrsets.optionalAttrs;
hw = config.valhalla.hardware;
in
{
in {
options = {
valhalla = {
hardware = {

View file

@ -4,8 +4,7 @@ in {
options = {
valhalla = mkOption {
type = types.submodule (
{ extendModules, ... }:
let
{ extendModules, ... }: let
osVariant = extendModules {
modules = [
({ config, ... }: {
@ -36,8 +35,7 @@ in {
};
windowsVariant = osVariant.extendModules { };
in
{
in {
options = {
linux = mkOption {
inherit (linuxVariant) type;
@ -53,8 +51,7 @@ in {
visible = "shallow";
};
};
}
);
});
description = "Configuration for PortValhalla.";
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
select "$header" "$outFile" "$message" "No valid device found!" "$(string collect $disks)" false
select "$header" "$outFile" "$message" "No valid disk found!" "$(string collect $disks)" false
and begin
set -l disk (string split -n " " (cat "$outFile"))
echo "/dev/$disk[1]" >$outFile

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";
btrfs = "btrfs";
swap = "swap";
ntfs = "ntfs";
fat32 = "fat32";

View file

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

View file

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

View file

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

View file

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

View file

@ -1,27 +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.";
default = { };
};
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, ... }:
let inherit (lib) mkOption types;
in {
imports = [
./programs.nix
];
let inherit (lib) mkOption types;
in {
imports = [
./programs.nix
];
options = {
valhalla = mkOption {
type = types.submodule (
{ config, ... }:
let
optionalAttrs = lib.attrsets.optionalAttrs;
cfg = config;
inherit (cfg.software) coding desktopExperience essential gaming server socialMedia;
options = {
valhalla = mkOption {
type = types.submodule (
{ config, ... }:
let
optionalAttrs = lib.attrsets.optionalAttrs;
cfg = config;
inherit (cfg.software) coding desktopExperience essential gaming socialMedia;
mkPrograms = programs: builtins.foldl'
(
programs: name: programs // {
${name}.enable = true;
}
)
{ }
programs;
in
{
options = {
software = {
essential = mkOption {
type = types.bool;
description = "A value indicating whether essentials should be installed.";
default = false;
mkPrograms = programs: builtins.foldl' (
programs: name: programs // {
${name}.enable = true;
}) {} programs;
in {
options = {
software = {
essential = mkOption {
type = types.bool;
description = "A value indicating whether essentials should be installed.";
default = false;
};
server = mkOption {
type = types.bool;
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 {
type = types.bool;
description = "A value indicating whether server applications 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"
"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 = [ ];
};
};
}
);
});
linuxUserType = types.submodule (
{ ... }: {
@ -37,8 +36,7 @@ let
default = null;
};
};
}
);
});
winUserType = types.submodule (
{ ... }: {
@ -49,10 +47,8 @@ let
default = false;
};
};
}
);
in
{
});
in {
options = {
valhalla = {
users = mkOption {

View file

@ -1,11 +1,11 @@
{ config, lib, ... }:
{ lib, ... }:
let inherit (lib) mkOption types;
in {
imports = [
./fileSystems.nix
./hardware.nix
./i18n.nix
./os.nix
./partition.nix
./programs.nix
./software.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 {
type = types.str;
description = "The hostname of the system.";

View file

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

View file

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

View file

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

View file

@ -1,12 +1,12 @@
{ lib, config, ... }:
let fs = import ../../../../lib/modules/fileSystems/fs.nix;
let fs = import ../../../../lib/modules/partition/fs.nix;
in {
imports = [ ../defaults.nix ];
config = {
valhalla = {
fileSystems.diskSetup.devices = {
OS = {
partition = {
os = {
partitions = {
Boot = {
index = 1;
@ -37,13 +37,12 @@ in {
keyboardLayout = "ch";
i18n = {
localeSettings =
let defaultLocale = "en_US.UTF-8";
in {
LANG = "de_CH.UTF-8";
LANGUAGE = defaultLocale;
LC_MESSAGE = defaultLocale;
};
localeSettings = let defaultLocale = "en_US.UTF-8";
in {
LANG = "de_CH.UTF-8";
LANGUAGE = defaultLocale;
LC_MESSAGE = defaultLocale;
};
};
software = {
@ -59,46 +58,45 @@ in {
linux.programs.grub.enable = true;
programs = {
git =
let defaultBranch = "main";
in {
inherit defaultBranch;
git = let defaultBranch = "main";
in {
inherit defaultBranch;
flow = {
mainBranch = defaultBranch;
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";
};
flow = {
mainBranch = defaultBranch;
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";
};
};
};
};
};

View file

@ -14,7 +14,7 @@
components = [ "Logitech G903" ];
};
fileSystems.diskSetup.devices.OS.name = "nvme0n1";
partition.os.deviceName = "nvme0n1";
};
};
}

View file

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

View file

@ -1,39 +0,0 @@
{ lib, ... }: {
imports = [
./defaults.nix
./Generic/Arch/config.nix
];
config = {
valhalla = {
hostname = "falcon";
hidpi = true;
linux.secureBoot = true;
windows = {
dualboot = {
enable = true;
linuxPercentage = 70;
};
users.manuel = {
groups = [ "Administrators" ];
};
};
fileSystems.diskSetup.devices.OS.partitions = {
# Keep Windows' boot partition
Boot.keepExisting = true;
Windows = {
index = 6;
label = "Windows";
format = "ntfs";
mountPoint = "/media/win";
mountOptions = [ "force" ];
keepExisting = true;
};
};
};
};
}

View file

@ -1,129 +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;
firefox-sync.enable = true;
forgejo.enable = true;
gotify.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 = {
valhalla = {
programs = {
nextcloud.enable = true;
};
linux.programs = {
rclone.enable = true;
};
users.manuel = {
displayName = "Manuel Thalmann";
mailAddress = "m@nuth.ch";
@ -23,6 +31,42 @@
"wheel"
"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
begin
set -l dir (status dirname)
source "$dir/../../lib/software.fish"
source "$dir/../../Scripts/software.fish"
function installSW -V dir
yayinst secureboot-grub
end
function configureSW -V dir
source "$dir/../../../lib/settings.fish"
source "$dir/../../../Common/Scripts/config.fish"
set -l label (getOSConfig boot.label)
set -l efiDir (getOSConfig boot.efiMountPoint)
set -l bootNums (efibootmgr | sed "/$label/{ s/^.*Boot\([[:digit:]]\+\)\*.*\$/\1/; p; }; d")
@ -20,11 +20,11 @@ begin
sudo sed -i \
-e "/esp=/{" \
-e "a esp=$(echo "$efiDir" | string escape)" \
-e d \
-e "d" \
-e "}" \
-e "/bootloader_id=/{" \
-e "a bootloader_id=$(echo "$label" | string escape)" \
-e d \
-e "d" \
-e "}" \
/etc/secureboot.conf

View file

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

View file

@ -1,7 +1,7 @@
#!/bin/env fish
begin
set -l dir (status dirname)
source "$dir/../../lib/software.fish"
source "$dir/../../Scripts/software.fish"
function installSW -V dir
yayinst \
@ -21,9 +21,6 @@ begin
sudo systemctl enable --global surface-dtx-userd.service
end
function installSWDependencies
fish "$dir/../Surface/main.fish" $argv
end
runInstaller --force $argv
fish "$dir/../Surface/main.fish" $argv
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
begin
set -l dir (status dirname)
source "$dir/../lib/dependencies.fish"
function getDeploymentScript -V dir
echo "$dir/../lib/deploy.fish"
echo "$dir/../Scripts/deploy.fish"
end
function initialize -V dir
source "$dir/../../lib/wait-network.fish"
source "$dir/../../Common/Scripts/wait-network.fish"
waitNetwork
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/pacman/main.fish"
and source "$dir/../Software/yay/main.fish"
@ -22,7 +22,7 @@ begin
and yayinst \
linux-headers \
pacman-contrib \
go-yq
yq
end
source "$dir/../../Common/OS/install.fish"

View file

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

View file

@ -1,7 +1,6 @@
function deploySoftware -d "Deploys a the specified software action" -a action
set -l dir (status dirname)
. "$dir/software.fish"
. "$dir/../../lib/settings.fish"
if [ -z "$action" ]
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
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"
case "Logitech G903"
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
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/../Software/sudo/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/zoxide/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!
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
end
and if isProgramEnabled --name thunderbird && $isInstall
and if isProgramEnabled "thunderbird" && $isInstall
yayinst thunderbird
end
# Server
and source "$dir/../Software/nginx/main.fish" $argv
# School & Studies
and if collectionActive school && $isInstall
yayinst \
@ -205,7 +198,7 @@ function deploySoftware -d "Deploys a the specified software action" -a action
audius-client-bin
end
and if isProgramEnabled --name nextcloud
and if isProgramEnabled "nextcloud"
yayinst nextcloud-client
end
end
@ -225,7 +218,7 @@ function deploySoftware -d "Deploys a the specified software action" -a action
end
end
and if isProgramEnabled --name discord
and if isProgramEnabled discord
yayinst vesktop-bin
end
@ -285,11 +278,11 @@ function deploySoftware -d "Deploys a the specified software action" -a action
end
end
and if isProgramEnabled --name "osu!lazer"
and if isProgramEnabled "osu!lazer"
yayinst osu-lazer-bin
end
and if isProgramEnabled --name retroarch
and if isProgramEnabled "retroarch"
yayinst libretro
end
end

View file

@ -1,7 +1,7 @@
#!/bin/env fish
begin
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"
if not isatty 0

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -1,10 +1,12 @@
#!/bin/env fish
begin
set -l dir (status dirname)
source "$dir/../../lib/software.fish"
source "$dir/../../Scripts/software.fish"
function installSW
yayinst
yayinst (
# Waydroid prerequisite: https://wiki.archlinux.org/title/Waydroid#DKMS_modules
) binder_linux-dkms \
waydroid (
# For installing ARM suppot on waydroid
) waydroid-script-git (

View file

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

View file

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

View file

@ -1,7 +1,7 @@
#!/bin/env fish
begin
set -l dir (status dirname)
source "$dir/../../lib/software.fish"
source "$dir/../../Scripts/software.fish"
inherit "$dir/../../../Common/Software/zoxide/main.fish"
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
begin
set -l dir (status dirname)
source "$dir/../../../lib/software.fish"
source "$dir/../../Scripts/software.fish"
function configureSW -V dir
. "$dir/../../Software/plasma/input.fish"

View file

@ -1,7 +1,7 @@
#!/bin/env fish
begin
set -l dir (status dirname)
source "$dir/../../../lib/software.fish"
source "$dir/../../Scripts/software.fish"
function configureSW -V dir
. "$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
set -l dir (status dirname)
source "$dir/../../lib/action.fish"
source "$dir/../Scripts/config.fish"
source "$dir/../Scripts/hooks.fish"
function installAction -V dir
source "$dir/../../lib/hooks.fish"
source "$dir/../../lib/restoration.fish"
if [ (id -u) -eq 0 ]
set -l name (getOSConfig setupUser.name)
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
function getDeploymentScript
echo "No deployment script specified! No software will be installed." 1>&2
@ -14,7 +37,6 @@ function installAction -V dir
end
set -l deployScript (getDeploymentScript)
initBackupConfig --action restore
runHook initialize || true
and runHook installOS || true
@ -32,29 +54,28 @@ function installAction -V dir
runHook initializeUsers || begin
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`..."
and source $deployScript userConfig --user $name
and source $deployScript userConfig $name
end
end
end
and runHook postInstall || true
and sudo git config remove-section --system safe || true
and begin
echo "Cleaning installation scripts..."
set -l projectPath (realpath "$(status dirname)/../../..")
cd (dirname "$projectPath")
# sudo rm -rf "$projectPath"
sudo rm -rf "$projectPath"
end
and echo "The installation finished successfully!"
and echo "This machine will reboot in 5 seconds..."
and echo "Press CTRL-C to abort..."
and sleep 5
and sudo systemctl reboot -i
and systemctl reboot -i
end
runSetupUserAction installAction

View file

@ -1,126 +1,86 @@
#!/bin/env fish
function runSetup
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 projectName (basename "$projectRoot")
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
source "$dir/../../lib/hooks.fish"
source "$dir/../../lib/nix.fish"
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
if not type -q runChroot
function runChroot -S
command chroot $argv
end
end
function actionPostRun
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
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
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

View file

@ -1,11 +1,11 @@
#!/bin/env fish
set -l dir (status dirname)
source "$dir/../../lib/settings.fish"
source "$dir/../Scripts/config.fish"
set -l users (getUsers)
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`..."
function getUserInfo -V name -a config

View file

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

View file

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

View file

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

View file

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

View file

@ -1,7 +1,7 @@
#!/bin/env fish
function evalFlake --argument-names config property
set -l argv $argv[3..]
set -l flakePath "$(realpath (status dirname))/../.."
set -l flakePath "$(realpath (status dirname))/../../.."
argparse --ignore-unknown "apply=" "fallback=" json -- $argv
if [ -z "$_flag_json" ]
@ -20,7 +20,7 @@ function evalFlake --argument-names config property
if [ -n "$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
PROPERTY="$property" \

View file

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

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