Compare commits
224 commits
Author | SHA1 | Date | |
---|---|---|---|
ebbd106e0a | |||
660f9561cf | |||
ae101e2eb2 | |||
a0874d9f37 | |||
7df90179c9 | |||
99fa900c1a | |||
4161fce8d7 | |||
896c77559a | |||
ce70e66c70 | |||
84818c2bac | |||
c349a2d5be | |||
56f7f4228b | |||
cf717d7a50 | |||
f0fef82fa1 | |||
db247315cf | |||
93284f2016 | |||
9a911cb93b | |||
da1870c250 | |||
97e372ae08 | |||
a8e0f37416 | |||
c1483d29e1 | |||
e435ce8c48 | |||
71a301ff0f | |||
2e087298a3 | |||
37f3b3980b | |||
9007570d94 | |||
73734293fd | |||
fad6cbe1d2 | |||
bcdd7b0d8a | |||
fa295f3b1a | |||
6a5ec8d5de | |||
19871a2e49 | |||
ab8a6f8609 | |||
52fd59c017 | |||
02dd399284 | |||
7c3297b993 | |||
ccbf77ce3f | |||
1944356d05 | |||
5e7cfccff6 | |||
a4fe8d78dc | |||
605c32e467 | |||
9caedac094 | |||
f1ed876cc1 | |||
3790fd267e | |||
70a02aa8b9 | |||
0df6d5ece3 | |||
b16e1d420e | |||
5ffe98a56d | |||
7b5564a632 | |||
68e1990c87 | |||
0ce36394ac | |||
ed4fa1a33d | |||
7b3b7fcdbc | |||
ce13e03ef1 | |||
77d8c350b7 | |||
055955a1bf | |||
569204babe | |||
f3ff0cb0db | |||
f8eed79dd6 | |||
e527b33d82 | |||
19e9aecc5b | |||
7f60744056 | |||
f3b6f3be23 | |||
1e6bf93191 | |||
ad36fe02b3 | |||
656f21e849 | |||
d6105a22b8 | |||
d0f7f6e4f9 | |||
1051fe01c1 | |||
6f5d13f07f | |||
eac4dba453 | |||
87b032ed70 | |||
800a6ed542 | |||
4ba2c1b1a5 | |||
ee4906cf4d | |||
8e02826f4b | |||
20c1f1558f | |||
8b2d6a8a6a | |||
53c35a5742 | |||
4f446cc189 | |||
aebc398989 | |||
d52ce97c6c | |||
ff05734cdf | |||
a94a589c77 | |||
3758baba8b | |||
406c25b3d3 | |||
45b0ed910c | |||
1c452512ef | |||
500ab697f6 | |||
ca2b623e1a | |||
a7b9572165 | |||
972de35629 | |||
562c55b78f | |||
801e010efb | |||
6f68f021a3 | |||
c75228380a | |||
4c23b600f2 | |||
3607765313 | |||
a46ea0cacc | |||
5411281d95 | |||
86576476ba | |||
0b2d39ea7c | |||
30254ea01c | |||
67ccef8474 | |||
84dc19dd95 | |||
2b34819227 | |||
8f09b02fc2 | |||
1c93d4b3f4 | |||
9dc93b1b8e | |||
e0f4c7e74a | |||
5384b38613 | |||
0413612bce | |||
f5001a28b7 | |||
9634789027 | |||
6d221cf07c | |||
d2522d42a3 | |||
ba371f6417 | |||
7b53d0b506 | |||
351d3070d2 | |||
6abc2240be | |||
046627eca4 | |||
084897f5ee | |||
86fecfd3e4 | |||
c533b66c4e | |||
8c9c6cd411 | |||
91fee52e81 | |||
080cca791f | |||
c9ba881ab2 | |||
f1f4364c63 | |||
8bcce1c5a1 | |||
786e422aa6 | |||
53d140394a | |||
eb2436c562 | |||
fa98fc8f5b | |||
a314e502e0 | |||
59f0c8e254 | |||
f36f26daeb | |||
c024066139 | |||
9b7f9275c9 | |||
38d8eeedde | |||
9a3d7d4f68 | |||
df74ac2337 | |||
6fabcdc304 | |||
30c1618318 | |||
8101b9e817 | |||
6a442f8392 | |||
c5e15c21e4 | |||
422f36f523 | |||
b2d6524b0b | |||
d80dbadc7b | |||
5589b6534b | |||
9ed3aa6fe4 | |||
a6414a60a2 | |||
822008f459 | |||
84e5a9d7c0 | |||
bc914ff88e | |||
db0b8637ab | |||
a9f62c3648 | |||
d5bc49759b | |||
8cd59ae6e9 | |||
fe99897a2a | |||
5fd56d46fa | |||
5c37ec4649 | |||
941c89e896 | |||
e2b08c77db | |||
83a5e144da | |||
e6c28188e5 | |||
9507bb1034 | |||
a538a3d3cf | |||
4d26c4b23e | |||
5e1019c39e | |||
c763ce67bb | |||
57e2052529 | |||
b0a46b83c0 | |||
dc3ecc4f69 | |||
9645efd836 | |||
dcf8deaaa6 | |||
3938859b8a | |||
8853e0fafa | |||
d2e8a4561e | |||
5629bad681 | |||
75e0f0e419 | |||
84c05480a6 | |||
a949458b40 | |||
62335b8c30 | |||
f10df90b88 | |||
5f345337fa | |||
2484541827 | |||
2d4e4c348e | |||
a12b65fcc7 | |||
929d2efdb0 | |||
e6efda0a55 | |||
a36f78dff1 | |||
3332ed43ee | |||
7063e5697d | |||
1cc07f9bda | |||
f47a1f56f5 | |||
280de3223e | |||
a8b96c7219 | |||
b96f286593 | |||
43c1bdf57a | |||
e1de6b78c6 | |||
a2f27209b5 | |||
027e0f9fd6 | |||
421cd32373 | |||
c0c34f7a37 | |||
f5f51e6a6b | |||
0e5370f7ca | |||
029ad68e20 | |||
b2c85d71c5 | |||
94b22720b6 | |||
1ded9f42bb | |||
c4250cd27d | |||
772b7adc0b | |||
1ba4113e56 | |||
3291928a11 | |||
1047b5ed69 | |||
bfcd7be17f | |||
c364b53d33 | |||
15bfed7f1f | |||
fd5fc86b1b | |||
4a783e3725 | |||
e24ed85fa9 | |||
a34ee1847b |
270 changed files with 5457 additions and 1287 deletions
|
@ -5,17 +5,16 @@ fi
|
||||||
|
|
||||||
~/.automated_script.sh
|
~/.automated_script.sh
|
||||||
|
|
||||||
if bash -c "ls /sys/class/backlight/*/max_brightness" > /dev/null 2>&1
|
if bash -c "ls /sys/class/backlight/*/max_brightness" >/dev/null 2>&1; then
|
||||||
then
|
cat /sys/class/backlight/*/max_brightness >/sys/class/backlight/*/brightness
|
||||||
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
|
||||||
|
|
|
@ -1,31 +1,24 @@
|
||||||
#!/bin/env fish
|
#!/bin/env fish
|
||||||
begin
|
begin
|
||||||
set -l nixVersion nixos-24.05
|
set -l dir (status dirname)
|
||||||
|
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/nix/var/nix/profiles/per-user/root/channels/nixpkgs"
|
set -l nixDir "$profileDir/$root$nixPkgsDir"
|
||||||
|
|
||||||
mkdir -p "$rootHome"
|
mkdir -p "$rootHome"
|
||||||
and fish "$(status dirname)/../../scripts/copy-repo.fish" "$projectDir"
|
and fish "$(status dirname)/../../scripts/lib/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 "$nixCache" "$nixDir"
|
and sudo mount --mkdir --bind "$nixPkgsCache" "$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"
|
||||||
|
|
|
@ -16,9 +16,8 @@ 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 | \
|
end | rsync --files-from=/dev/stdin --exclude={.gitignore,README.md,scripts,LICENSE,valhalla.patch} "$dir/.." "$contextRoot"
|
||||||
rsync --files-from=/dev/stdin --exclude={.gitignore,README.md,scripts,LICENSE,valhalla.patch} "$dir/.." "$contextRoot"
|
end &>/dev/null
|
||||||
end &> /dev/null
|
|
||||||
|
|
||||||
and git -C "$contextRoot" diff
|
and git -C "$contextRoot" diff
|
||||||
end
|
end
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -1,23 +1,22 @@
|
||||||
diff --git a/airootfs/root/.zlogin b/airootfs/root/.zlogin
|
diff --git a/airootfs/root/.zlogin b/airootfs/root/.zlogin
|
||||||
index bf6bc8f..bdbe55c 100644
|
index bf6bc8f..e71dc26 100644
|
||||||
--- a/airootfs/root/.zlogin
|
--- a/airootfs/root/.zlogin
|
||||||
+++ b/airootfs/root/.zlogin
|
+++ b/airootfs/root/.zlogin
|
||||||
@@ -4,3 +4,18 @@ if grep -Fqa 'accessibility=' /proc/cmdline &> /dev/null; then
|
@@ -4,3 +4,17 @@ 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
|
+if bash -c "ls /sys/class/backlight/*/max_brightness" >/dev/null 2>&1; then
|
||||||
+then
|
+ cat /sys/class/backlight/*/max_brightness >/sys/class/backlight/*/brightness
|
||||||
+ 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
|
||||||
|
|
|
@ -45,6 +45,7 @@
|
||||||
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;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,8 +5,10 @@ let
|
||||||
overlay = [ ];
|
overlay = [ ];
|
||||||
};
|
};
|
||||||
property = (builtins.getEnv "PROPERTY");
|
property = (builtins.getEnv "PROPERTY");
|
||||||
processor = if (builtins.stringLength property > 0) then
|
processor =
|
||||||
|
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
|
||||||
|
|
120
lib/modules/fileSystems.nix
Normal file
120
lib/modules/fileSystems.nix
Normal file
|
@ -0,0 +1,120 @@
|
||||||
|
{ 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}
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
108
lib/modules/fileSystems/btrfs.nix
Normal file
108
lib/modules/fileSystems/btrfs.nix
Normal file
|
@ -0,0 +1,108 @@
|
||||||
|
{ 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;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
|
@ -22,7 +22,7 @@ function chooseDisk -a outFile message selectScript
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
select "$header" "$outFile" "$message" "No valid disk found!" "$(string collect $disks)" false
|
select "$header" "$outFile" "$message" "No valid device 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
|
375
lib/modules/fileSystems/disks.nix
Normal file
375
lib/modules/fileSystems/disks.nix
Normal file
|
@ -0,0 +1,375 @@
|
||||||
|
{ 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))
|
||||||
|
);
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
|
@ -1,5 +1,6 @@
|
||||||
{
|
{
|
||||||
ext4 = "ext4";
|
ext4 = "ext4";
|
||||||
|
btrfs = "btrfs";
|
||||||
swap = "swap";
|
swap = "swap";
|
||||||
ntfs = "ntfs";
|
ntfs = "ntfs";
|
||||||
fat32 = "fat32";
|
fat32 = "fat32";
|
|
@ -3,7 +3,8 @@ 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 = {
|
||||||
|
|
|
@ -4,7 +4,8 @@ in {
|
||||||
options = {
|
options = {
|
||||||
valhalla = mkOption {
|
valhalla = mkOption {
|
||||||
type = types.submodule (
|
type = types.submodule (
|
||||||
{ extendModules, ... }: let
|
{ extendModules, ... }:
|
||||||
|
let
|
||||||
osVariant = extendModules {
|
osVariant = extendModules {
|
||||||
modules = [
|
modules = [
|
||||||
({ config, ... }: {
|
({ config, ... }: {
|
||||||
|
@ -35,7 +36,8 @@ in {
|
||||||
};
|
};
|
||||||
|
|
||||||
windowsVariant = osVariant.extendModules { };
|
windowsVariant = osVariant.extendModules { };
|
||||||
in {
|
in
|
||||||
|
{
|
||||||
options = {
|
options = {
|
||||||
linux = mkOption {
|
linux = mkOption {
|
||||||
inherit (linuxVariant) type;
|
inherit (linuxVariant) type;
|
||||||
|
@ -51,7 +53,8 @@ in {
|
||||||
visible = "shallow";
|
visible = "shallow";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
});
|
}
|
||||||
|
);
|
||||||
|
|
||||||
description = "Configuration for PortValhalla.";
|
description = "Configuration for PortValhalla.";
|
||||||
default = { };
|
default = { };
|
||||||
|
|
|
@ -1,5 +0,0 @@
|
||||||
{ ... }: {
|
|
||||||
imports = [
|
|
||||||
./partition/disks.nix
|
|
||||||
];
|
|
||||||
}
|
|
|
@ -1,360 +0,0 @@
|
||||||
{ 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
|
|
||||||
]));
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
}
|
|
|
@ -5,88 +5,103 @@ 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 = builtins.mapAttrs (
|
programs = lib.attrsets.concatMapAttrs
|
||||||
name: config: {
|
(
|
||||||
enable = mkDefault config.enable;
|
name: program:
|
||||||
}) osConfig.programs;
|
if (builtins.elem name (builtins.attrNames config.programs)) then {
|
||||||
|
${name} = {
|
||||||
|
enable = mkDefault program.enable;
|
||||||
};
|
};
|
||||||
}));
|
} else { }
|
||||||
|
)
|
||||||
|
osConfig.programs;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
));
|
||||||
};
|
};
|
||||||
|
|
||||||
mkPrograms = infos: builtins.foldl' (programs: info:
|
mkPrograms = infos: builtins.foldl'
|
||||||
|
(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" ]
|
||||||
["docker" "docker"]
|
[ "firefox" "Firefox Web Browser" ]
|
||||||
["firefox" "Firefox Web Browser"]
|
[ "openssh" "OpenSSH" ]
|
||||||
["openssh" "OpenSSH"]
|
[ "osu!lazer" "osu!lazer" ]
|
||||||
["osu!lazer" "osu!lazer"]
|
[ "pennywise" "Pennywise" ]
|
||||||
["pennywise" "Pennywise"]
|
[ "powershell" "PowerShell Core" ]
|
||||||
["powershell" "PowerShell Core"]
|
[ "retroarch" "RetroArch" ]
|
||||||
["retroarch" "RetroArch"]
|
[ "steam" "Steam" ]
|
||||||
["steam" "Steam"]
|
[ "thunderbird" "Thunderbird" ]
|
||||||
["thunderbird" "Thunderbird"]
|
[ "vscode" "Visual Studio Code" ]
|
||||||
["vscode" "Visual Studio Code"]
|
[ "zoxide" "zoxide" ]
|
||||||
["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" ]
|
||||||
["nodejs-n" "n"]
|
[ "networkmanager" "NetworkManager" ]
|
||||||
["nuke-usb" "nuke-usb"]
|
[ "nginx" "nginx" ]
|
||||||
["nvidia-dkms" "Nvidia Drivers"]
|
[ "nodejs-n" "n" ]
|
||||||
["plasma" "Plasma"]
|
[ "nuke-usb" "nuke-usb" ]
|
||||||
["pyenv" "pyenv"]
|
[ "nvidia-dkms" "Nvidia Drivers" ]
|
||||||
["sddm" "SDDM"]
|
[ "plasma" "Plasma" ]
|
||||||
["vim" "Vim"]
|
[ "pyenv" "pyenv" ]
|
||||||
["virt-manager" "Virtual Machine Manager"]
|
[ "sddm" "SDDM" ]
|
||||||
["waydroid" "Waydroid"]
|
[ "vim" "Vim" ]
|
||||||
["xone" "xone"]
|
[ "virt-manager" "Virtual Machine Manager" ]
|
||||||
|
[ "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 = {
|
||||||
|
|
14
lib/modules/programs/btrfs.nix
Normal file
14
lib/modules/programs/btrfs.nix
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
{ lib, ... }:
|
||||||
|
let
|
||||||
|
inherit (lib) mkEnableOption;
|
||||||
|
in
|
||||||
|
{
|
||||||
|
options = {
|
||||||
|
valhalla = {
|
||||||
|
linux.programs.btrfs = {
|
||||||
|
enable = mkEnableOption "btrfs tools";
|
||||||
|
pools = mkEnableOption "btrfs pool support in bootloaders";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
47
lib/modules/programs/docker.nix
Normal file
47
lib/modules/programs/docker.nix
Normal file
|
@ -0,0 +1,47 @@
|
||||||
|
{ 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";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
|
@ -31,7 +31,8 @@ let
|
||||||
default = { };
|
default = { };
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
in {
|
in
|
||||||
|
{
|
||||||
options = {
|
options = {
|
||||||
valhalla = {
|
valhalla = {
|
||||||
programs.git = gitOption;
|
programs.git = gitOption;
|
||||||
|
@ -42,7 +43,8 @@ in {
|
||||||
options = {
|
options = {
|
||||||
programs.git = gitOption;
|
programs.git = gitOption;
|
||||||
};
|
};
|
||||||
}));
|
}
|
||||||
|
));
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
@ -31,7 +31,8 @@ let
|
||||||
default = [ ];
|
default = [ ];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
in {
|
in
|
||||||
|
{
|
||||||
options = {
|
options = {
|
||||||
valhalla = {
|
valhalla = {
|
||||||
programs.nextcloud = commonOptions;
|
programs.nextcloud = commonOptions;
|
||||||
|
@ -42,7 +43,8 @@ in {
|
||||||
options = {
|
options = {
|
||||||
programs.nextcloud = commonOptions;
|
programs.nextcloud = commonOptions;
|
||||||
};
|
};
|
||||||
}));
|
}
|
||||||
|
));
|
||||||
};
|
};
|
||||||
|
|
||||||
windows.users = mkOption {
|
windows.users = mkOption {
|
||||||
|
@ -51,7 +53,8 @@ in {
|
||||||
options = {
|
options = {
|
||||||
programs.nextcloud = userOptions;
|
programs.nextcloud = userOptions;
|
||||||
};
|
};
|
||||||
}));
|
}
|
||||||
|
));
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
@ -16,7 +16,8 @@ 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";
|
||||||
|
@ -35,7 +36,8 @@ let
|
||||||
default = [ ];
|
default = [ ];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
in {
|
in
|
||||||
|
{
|
||||||
options = {
|
options = {
|
||||||
valhalla = {
|
valhalla = {
|
||||||
programs.oh-my-posh = commonOptions;
|
programs.oh-my-posh = commonOptions;
|
||||||
|
@ -46,7 +48,8 @@ in {
|
||||||
options = {
|
options = {
|
||||||
programs.oh-my-posh = userOptions;
|
programs.oh-my-posh = userOptions;
|
||||||
};
|
};
|
||||||
}));
|
}
|
||||||
|
));
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
@ -16,7 +16,8 @@ let
|
||||||
default = null;
|
default = null;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
});
|
}
|
||||||
|
);
|
||||||
|
|
||||||
commonOptions = {
|
commonOptions = {
|
||||||
enable = mkEnableOption "rclone";
|
enable = mkEnableOption "rclone";
|
||||||
|
@ -29,7 +30,8 @@ let
|
||||||
default = { };
|
default = { };
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
in {
|
in
|
||||||
|
{
|
||||||
options = {
|
options = {
|
||||||
valhalla.linux = {
|
valhalla.linux = {
|
||||||
programs.rclone = commonOptions;
|
programs.rclone = commonOptions;
|
||||||
|
@ -40,7 +42,8 @@ in {
|
||||||
options = {
|
options = {
|
||||||
programs.rclone = userOptions;
|
programs.rclone = userOptions;
|
||||||
};
|
};
|
||||||
}));
|
}
|
||||||
|
));
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
26
lib/modules/programs/systemd-networkd.nix
Normal file
26
lib/modules/programs/systemd-networkd.nix
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
{ 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;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
|
@ -1,6 +1,6 @@
|
||||||
{ lib, ... }:
|
{ lib, ... }:
|
||||||
let inherit (lib) mkOption types;
|
let inherit (lib) mkOption types;
|
||||||
in {
|
in {
|
||||||
imports = [
|
imports = [
|
||||||
./programs.nix
|
./programs.nix
|
||||||
];
|
];
|
||||||
|
@ -12,13 +12,18 @@
|
||||||
let
|
let
|
||||||
optionalAttrs = lib.attrsets.optionalAttrs;
|
optionalAttrs = lib.attrsets.optionalAttrs;
|
||||||
cfg = config;
|
cfg = config;
|
||||||
inherit (cfg.software) coding desktopExperience essential gaming socialMedia;
|
inherit (cfg.software) coding desktopExperience essential gaming server socialMedia;
|
||||||
|
|
||||||
mkPrograms = programs: builtins.foldl' (
|
mkPrograms = programs: builtins.foldl'
|
||||||
|
(
|
||||||
programs: name: programs // {
|
programs: name: programs // {
|
||||||
${name}.enable = true;
|
${name}.enable = true;
|
||||||
}) {} programs;
|
}
|
||||||
in {
|
)
|
||||||
|
{ }
|
||||||
|
programs;
|
||||||
|
in
|
||||||
|
{
|
||||||
options = {
|
options = {
|
||||||
software = {
|
software = {
|
||||||
essential = mkOption {
|
essential = mkOption {
|
||||||
|
@ -109,6 +114,7 @@
|
||||||
"vim"
|
"vim"
|
||||||
])) // (optionalAttrs desktopExperience (mkPrograms [
|
])) // (optionalAttrs desktopExperience (mkPrograms [
|
||||||
"icedtea"
|
"icedtea"
|
||||||
|
"networkmanager"
|
||||||
"plasma"
|
"plasma"
|
||||||
"sddm"
|
"sddm"
|
||||||
"waydroid"
|
"waydroid"
|
||||||
|
@ -118,6 +124,8 @@
|
||||||
"pyenv"
|
"pyenv"
|
||||||
])) // (optionalAttrs gaming (mkPrograms [
|
])) // (optionalAttrs gaming (mkPrograms [
|
||||||
"lutris"
|
"lutris"
|
||||||
|
])) // (optionalAttrs server (mkPrograms [
|
||||||
|
"nginx"
|
||||||
]));
|
]));
|
||||||
|
|
||||||
# Essentials
|
# Essentials
|
||||||
|
@ -142,7 +150,8 @@
|
||||||
"tm-united-forever"
|
"tm-united-forever"
|
||||||
]));
|
]));
|
||||||
};
|
};
|
||||||
});
|
|
||||||
};
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
);
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
|
@ -25,7 +25,8 @@ let
|
||||||
default = [ ];
|
default = [ ];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
});
|
}
|
||||||
|
);
|
||||||
|
|
||||||
linuxUserType = types.submodule (
|
linuxUserType = types.submodule (
|
||||||
{ ... }: {
|
{ ... }: {
|
||||||
|
@ -36,7 +37,8 @@ let
|
||||||
default = null;
|
default = null;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
});
|
}
|
||||||
|
);
|
||||||
|
|
||||||
winUserType = types.submodule (
|
winUserType = types.submodule (
|
||||||
{ ... }: {
|
{ ... }: {
|
||||||
|
@ -47,8 +49,10 @@ let
|
||||||
default = false;
|
default = false;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
});
|
}
|
||||||
in {
|
);
|
||||||
|
in
|
||||||
|
{
|
||||||
options = {
|
options = {
|
||||||
valhalla = {
|
valhalla = {
|
||||||
users = mkOption {
|
users = mkOption {
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
{ lib, ... }:
|
{ config, 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,6 +28,12 @@ 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.";
|
||||||
|
|
|
@ -2,7 +2,8 @@
|
||||||
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 = {
|
||||||
|
|
|
@ -25,7 +25,7 @@
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
partition.os.partitions = {
|
fileSystems.diskSetup.devices.OS.partitions = {
|
||||||
# Keep Windows' boot partition
|
# Keep Windows' boot partition
|
||||||
Boot.keepExisting = true;
|
Boot.keepExisting = true;
|
||||||
|
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
{ lib, config, ... }:
|
{ lib, config, ... }:
|
||||||
let fs = import ../../../../lib/modules/partition/fs.nix;
|
let fs = import ../../../../lib/modules/fileSystems/fs.nix;
|
||||||
in {
|
in {
|
||||||
imports = [ ../defaults.nix ];
|
imports = [ ../defaults.nix ];
|
||||||
|
|
||||||
config = {
|
config = {
|
||||||
valhalla = {
|
valhalla = {
|
||||||
partition = {
|
fileSystems.diskSetup.devices = {
|
||||||
os = {
|
OS = {
|
||||||
partitions = {
|
partitions = {
|
||||||
Boot = {
|
Boot = {
|
||||||
index = 1;
|
index = 1;
|
||||||
|
@ -37,7 +37,8 @@ in {
|
||||||
keyboardLayout = "ch";
|
keyboardLayout = "ch";
|
||||||
|
|
||||||
i18n = {
|
i18n = {
|
||||||
localeSettings = let defaultLocale = "en_US.UTF-8";
|
localeSettings =
|
||||||
|
let defaultLocale = "en_US.UTF-8";
|
||||||
in {
|
in {
|
||||||
LANG = "de_CH.UTF-8";
|
LANG = "de_CH.UTF-8";
|
||||||
LANGUAGE = defaultLocale;
|
LANGUAGE = defaultLocale;
|
||||||
|
@ -58,7 +59,8 @@ in {
|
||||||
linux.programs.grub.enable = true;
|
linux.programs.grub.enable = true;
|
||||||
|
|
||||||
programs = {
|
programs = {
|
||||||
git = let defaultBranch = "main";
|
git =
|
||||||
|
let defaultBranch = "main";
|
||||||
in {
|
in {
|
||||||
inherit defaultBranch;
|
inherit defaultBranch;
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
{ ... }: {
|
{ ... }: {
|
||||||
imports = [
|
imports = [
|
||||||
../../users/manuel/config.nix
|
../../users/manuel/desktop.nix
|
||||||
../../../lib/modules/valhalla.nix
|
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
127
profiles/machines/manuel/server.nix
Normal file
127
profiles/machines/manuel/server.nix
Normal file
|
@ -0,0 +1,127 @@
|
||||||
|
{ 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;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
|
@ -3,14 +3,6 @@
|
||||||
|
|
||||||
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";
|
||||||
|
@ -31,42 +23,6 @@
|
||||||
"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";
|
|
||||||
}
|
|
||||||
];
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
53
profiles/users/manuel/desktop.nix
Normal file
53
profiles/users/manuel/desktop.nix
Normal file
|
@ -0,0 +1,53 @@
|
||||||
|
{ ... }: {
|
||||||
|
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";
|
||||||
|
}
|
||||||
|
];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
|
@ -1,14 +1,14 @@
|
||||||
#!/bin/env fish
|
#!/bin/env fish
|
||||||
begin
|
begin
|
||||||
set -l dir (status dirname)
|
set -l dir (status dirname)
|
||||||
source "$dir/../../Scripts/software.fish"
|
source "$dir/../../lib/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/../../../Common/Scripts/config.fish"
|
source "$dir/../../../lib/settings.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
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#!/bin/env fish
|
#!/bin/env fish
|
||||||
begin
|
begin
|
||||||
set -l dir (status dirname)
|
set -l dir (status dirname)
|
||||||
source "$dir/../../Scripts/software.fish"
|
source "$dir/../../lib/software.fish"
|
||||||
|
|
||||||
function installSW -V dir
|
function installSW -V dir
|
||||||
set -l repo linux-surface
|
set -l repo linux-surface
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#!/bin/env fish
|
#!/bin/env fish
|
||||||
begin
|
begin
|
||||||
set -l dir (status dirname)
|
set -l dir (status dirname)
|
||||||
source "$dir/../../Scripts/software.fish"
|
source "$dir/../../lib/software.fish"
|
||||||
|
|
||||||
function installSW -V dir
|
function installSW -V dir
|
||||||
yayinst \
|
yayinst \
|
||||||
|
@ -21,6 +21,9 @@ begin
|
||||||
sudo systemctl enable --global surface-dtx-userd.service
|
sudo systemctl enable --global surface-dtx-userd.service
|
||||||
end
|
end
|
||||||
|
|
||||||
runInstaller --force $argv
|
function installSWDependencies
|
||||||
fish "$dir/../Surface/main.fish" $argv
|
fish "$dir/../Surface/main.fish" $argv
|
||||||
|
end
|
||||||
|
|
||||||
|
runInstaller --force $argv
|
||||||
end
|
end
|
||||||
|
|
15
scripts/Arch/OS/backup.fish
Executable file
15
scripts/Arch/OS/backup.fish
Executable file
|
@ -0,0 +1,15 @@
|
||||||
|
#!/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
|
|
@ -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/../Scripts/deploy.fish"
|
echo "$dir/../lib/deploy.fish"
|
||||||
end
|
end
|
||||||
|
|
||||||
function initialize -V dir
|
function initialize -V dir
|
||||||
source "$dir/../../Common/Scripts/wait-network.fish"
|
source "$dir/../../lib/wait-network.fish"
|
||||||
waitNetwork
|
waitNetwork
|
||||||
or exit
|
or exit
|
||||||
|
|
||||||
sudo systemctl enable --now nix-daemon
|
and source "$dir/../lib/software.fish"
|
||||||
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 \
|
||||||
yq
|
go-yq
|
||||||
end
|
end
|
||||||
|
|
||||||
source "$dir/../../Common/OS/install.fish"
|
source "$dir/../../Common/OS/install.fish"
|
||||||
|
|
|
@ -1,20 +1,22 @@
|
||||||
#!/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/../../Common/Scripts/config.fish"
|
source "$dir/../../lib/settings.fish"
|
||||||
|
|
||||||
function runChroot -S
|
function runChroot -S
|
||||||
arch-chroot $argv
|
arch-chroot $argv
|
||||||
end
|
end
|
||||||
|
|
||||||
function installValhallaDeps -S
|
function bootstrapSetup -S
|
||||||
pacstrap -K "$mountDir" fish git jq nix sudo tmux
|
pacstrap -K (getOSConfig fileSystems.rootDir) fish
|
||||||
end
|
end
|
||||||
|
|
||||||
function installDrivers -S
|
function installDrivers -S
|
||||||
if isOSEnabled hardware.surfaceBook
|
if isOSEnabled hardware.surfaceBook
|
||||||
pacstrap -K "$mountDir" linux-firmware-marvell
|
pacstrap -K (getOSConfig fileSystems.rootDir) linux-firmware-marvell
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -22,9 +24,30 @@ 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/../../Common/Scripts/hooks.fish"
|
source "$dir/../../lib/hooks.fish"
|
||||||
source "$dir/../../Common/Scripts/wait-network.fish"
|
source "$dir/../../lib/wait-network.fish"
|
||||||
|
set -l mountDir (getOSConfig fileSystems.rootDir)
|
||||||
|
|
||||||
waitNetwork
|
waitNetwork
|
||||||
and begin
|
and begin
|
||||||
|
@ -39,20 +62,12 @@ begin
|
||||||
timedatectl set-timezone "$timezone"
|
timedatectl set-timezone "$timezone"
|
||||||
end
|
end
|
||||||
|
|
||||||
and pacman-key --init
|
|
||||||
and pacman-key --populate
|
|
||||||
|
|
||||||
and pacstrap -K "$mountDir" \
|
|
||||||
base \
|
|
||||||
linux \
|
|
||||||
linux-firmware \
|
|
||||||
networkmanager \
|
|
||||||
man-db \
|
|
||||||
man-pages \
|
|
||||||
texinfo
|
|
||||||
|
|
||||||
and genfstab -U "$mountDir" >>"$mountDir/etc/fstab"
|
and genfstab -U "$mountDir" >>"$mountDir/etc/fstab"
|
||||||
and arch-chroot "$mountDir" systemctl enable NetworkManager
|
|
||||||
|
and if isProgramEnabled "networkmanager"
|
||||||
|
and pacstrap -K "$mountDir" networkmanager
|
||||||
|
arch-chroot "$mountDir" systemctl enable NetworkManager
|
||||||
|
end
|
||||||
|
|
||||||
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
|
||||||
|
@ -61,7 +76,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
|
||||||
|
@ -70,7 +85,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
|
||||||
|
|
||||||
|
@ -80,6 +95,8 @@ 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"
|
||||||
|
|
||||||
|
@ -95,16 +112,20 @@ begin
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function autologin -S
|
function autologin -S -V autologinConfig
|
||||||
set -l file "/etc/systemd/system/getty@tty1.service.d/autologin.conf"
|
set -l mountDir (getOSConfig fileSystems.rootDir)
|
||||||
arch-chroot "$mountDir" mkdir -p (dirname "$file")
|
arch-chroot "$mountDir" mkdir -p (dirname "$autologinConfig")
|
||||||
|
|
||||||
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 "$file" >/dev/null
|
end | arch-chroot "$mountDir" tee "$autologinConfig" >/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
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#!/bin/env fish
|
#!/bin/env fish
|
||||||
begin
|
begin
|
||||||
set -l dir (status dirname)
|
set -l dir (status dirname)
|
||||||
source "$dir/../../Scripts/software.fish"
|
source "$dir/../../lib/software.fish"
|
||||||
inherit "$dir/../../../Common/Software/aliae/main.fish"
|
inherit "$dir/../../../Common/Software/aliae/main.fish"
|
||||||
|
|
||||||
function installSW
|
function installSW
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#!/bin/env fish
|
#!/bin/env fish
|
||||||
begin
|
begin
|
||||||
set -l dir (status dirname)
|
set -l dir (status dirname)
|
||||||
source "$dir/../../Scripts/software.fish"
|
source "$dir/../../lib/software.fish"
|
||||||
|
|
||||||
function installSW
|
function installSW
|
||||||
pacinst base-devel
|
pacinst base-devel
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#!/bin/env fish
|
#!/bin/env fish
|
||||||
begin
|
begin
|
||||||
set -l dir (status dirname)
|
set -l dir (status dirname)
|
||||||
source "$dir/../../Scripts/software.fish"
|
source "$dir/../../lib/software.fish"
|
||||||
inherit "$dir/../../../Common/Software/brave/main.fish"
|
inherit "$dir/../../../Common/Software/brave/main.fish"
|
||||||
|
|
||||||
function installSW
|
function installSW
|
||||||
|
|
19
scripts/Arch/Software/btrfs/main.fish
Executable file
19
scripts/Arch/Software/btrfs/main.fish
Executable file
|
@ -0,0 +1,19 @@
|
||||||
|
#!/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
|
|
@ -1,7 +1,7 @@
|
||||||
#!/bin/env fish
|
#!/bin/env fish
|
||||||
begin
|
begin
|
||||||
set -l dir (status dirname)
|
set -l dir (status dirname)
|
||||||
source "$dir/../../Scripts/software.fish"
|
source "$dir/../../lib/software.fish"
|
||||||
inherit "$dir/../../../Common/Software/docker/main.fish"
|
inherit "$dir/../../../Common/Software/docker/main.fish"
|
||||||
|
|
||||||
function installSW
|
function installSW
|
||||||
|
@ -10,6 +10,8 @@ begin
|
||||||
docker-compose \
|
docker-compose \
|
||||||
docker-buildx \
|
docker-buildx \
|
||||||
docker-scan
|
docker-scan
|
||||||
|
|
||||||
|
installSWBase $argv
|
||||||
end
|
end
|
||||||
|
|
||||||
runInstaller $argv
|
runInstaller $argv
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#!/bin/env fish
|
#!/bin/env fish
|
||||||
begin
|
begin
|
||||||
set -l dir (status dirname)
|
set -l dir (status dirname)
|
||||||
source "$dir/../../Scripts/software.fish"
|
source "$dir/../../lib/software.fish"
|
||||||
inherit "$dir/../../../Common/Software/firefox/main.fish"
|
inherit "$dir/../../../Common/Software/firefox/main.fish"
|
||||||
|
|
||||||
function installSW -V dir
|
function installSW -V dir
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#!/bin/env fish
|
#!/bin/env fish
|
||||||
begin
|
begin
|
||||||
set -l dir (status dirname)
|
set -l dir (status dirname)
|
||||||
source "$dir/../../Scripts/software.fish"
|
source "$dir/../../lib/software.fish"
|
||||||
inherit "$dir/../../../Common/Software/git/main.fish"
|
inherit "$dir/../../../Common/Software/git/main.fish"
|
||||||
|
|
||||||
function installSW
|
function installSW
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#!/bin/env fish
|
#!/bin/env fish
|
||||||
begin
|
begin
|
||||||
set -l dir (status dirname)
|
set -l dir (status dirname)
|
||||||
source "$dir/../../Scripts/software.fish"
|
source "$dir/../../lib/software.fish"
|
||||||
inherit "$dir/../../../Common/Software/grub/main.fish"
|
inherit "$dir/../../../Common/Software/grub/main.fish"
|
||||||
|
|
||||||
function installSW -V dir
|
function installSW -V dir
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#!/bin/env fish
|
#!/bin/env fish
|
||||||
begin
|
begin
|
||||||
set -l dir (status dirname)
|
set -l dir (status dirname)
|
||||||
source "$dir/../../Scripts/software.fish"
|
source "$dir/../../lib/software.fish"
|
||||||
|
|
||||||
function installSW
|
function installSW
|
||||||
yayinst \
|
yayinst \
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#!/bin/env fish
|
#!/bin/env fish
|
||||||
begin
|
begin
|
||||||
set -l dir (status dirname)
|
set -l dir (status dirname)
|
||||||
source "$dir/../../Scripts/software.fish"
|
source "$dir/../../lib/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
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#!/bin/env fish
|
#!/bin/env fish
|
||||||
begin
|
begin
|
||||||
set -l dir (status dirname)
|
set -l dir (status dirname)
|
||||||
source "$dir/../../Scripts/software.fish"
|
source "$dir/../../lib/software.fish"
|
||||||
|
|
||||||
function installSW
|
function installSW
|
||||||
yayinst \
|
yayinst \
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#!/bin/env fish
|
#!/bin/env fish
|
||||||
begin
|
begin
|
||||||
set -l dir (status dirname)
|
set -l dir (status dirname)
|
||||||
source "$dir/../../Scripts/software.fish"
|
source "$dir/../../lib/software.fish"
|
||||||
inherit "$dir/../../../Common/Software/minegrub-theme/main.fish"
|
inherit "$dir/../../../Common/Software/minegrub-theme/main.fish"
|
||||||
|
|
||||||
function installSW
|
function installSW
|
||||||
|
|
23
scripts/Arch/Software/nginx/main.fish
Executable file
23
scripts/Arch/Software/nginx/main.fish
Executable file
|
@ -0,0 +1,23 @@
|
||||||
|
#!/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
|
|
@ -1,7 +1,7 @@
|
||||||
#!/bin/env fish
|
#!/bin/env fish
|
||||||
begin
|
begin
|
||||||
set -l dir (status dirname)
|
set -l dir (status dirname)
|
||||||
source "$dir/../../Scripts/software.fish"
|
source "$dir/../../lib/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 configure $argv
|
configureSWBase $argv
|
||||||
end
|
end
|
||||||
|
|
||||||
runInstaller $argv
|
runInstaller $argv
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#!/bin/env fish
|
#!/bin/env fish
|
||||||
begin
|
begin
|
||||||
set -l dir (status dirname)
|
set -l dir (status dirname)
|
||||||
source "$dir/../../Scripts/software.fish"
|
source "$dir/../../lib/software.fish"
|
||||||
|
|
||||||
function installSW
|
function installSW
|
||||||
yayinst nodejs-n
|
yayinst nodejs-n
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#!/bin/env fish
|
#!/bin/env fish
|
||||||
begin
|
begin
|
||||||
set -l dir (status dirname)
|
set -l dir (status dirname)
|
||||||
source "$dir/../../Scripts/software.fish"
|
source "$dir/../../lib/software.fish"
|
||||||
inherit "$dir/../../../Common/Software/nvidia-dkms/main.fish"
|
inherit "$dir/../../../Common/Software/nvidia-dkms/main.fish"
|
||||||
|
|
||||||
function installSW
|
function installSW
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#!/bin/env fish
|
#!/bin/env fish
|
||||||
begin
|
begin
|
||||||
set -l dir (status dirname)
|
set -l dir (status dirname)
|
||||||
source "$dir/../../Scripts/software.fish"
|
source "$dir/../../lib/software.fish"
|
||||||
inherit "$dir/../../../Common/Software/oh-my-posh/main.fish"
|
inherit "$dir/../../../Common/Software/oh-my-posh/main.fish"
|
||||||
|
|
||||||
function installSW
|
function installSW
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#!/bin/env fish
|
#!/bin/env fish
|
||||||
begin
|
begin
|
||||||
set -l dir (status dirname)
|
set -l dir (status dirname)
|
||||||
source "$dir/../../Scripts/software.fish"
|
source "$dir/../../lib/software.fish"
|
||||||
|
|
||||||
function installSW
|
function installSW
|
||||||
yayinst \
|
yayinst \
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#!/bin/env fish
|
#!/bin/env fish
|
||||||
begin
|
begin
|
||||||
set -l dir (status dirname)
|
set -l dir (status dirname)
|
||||||
source "$dir/../../Scripts/software.fish"
|
source "$dir/../../lib/software.fish"
|
||||||
|
|
||||||
function installSW
|
function installSW
|
||||||
configureSW
|
configureSW
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#!/bin/env fish
|
#!/bin/env fish
|
||||||
begin
|
begin
|
||||||
set -l dir (status dirname)
|
set -l dir (status dirname)
|
||||||
source "$dir/../../Scripts/software.fish"
|
source "$dir/../../lib/software.fish"
|
||||||
|
|
||||||
function installSW
|
function installSW
|
||||||
yayinst \
|
yayinst \
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#!/bin/env fish
|
#!/bin/env fish
|
||||||
begin
|
begin
|
||||||
set -l dir (status dirname)
|
set -l dir (status dirname)
|
||||||
source "$dir/../../Scripts/software.fish"
|
source "$dir/../../lib/software.fish"
|
||||||
|
|
||||||
function installSW
|
function installSW
|
||||||
yayinst \
|
yayinst \
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#!/bin/env fish
|
#!/bin/env fish
|
||||||
begin
|
begin
|
||||||
set -l dir (status dirname)
|
set -l dir (status dirname)
|
||||||
source "$dir/../../Scripts/software.fish"
|
source "$dir/../../lib/software.fish"
|
||||||
inherit "$dir/../../../Common/Software/powershell/main.fish"
|
inherit "$dir/../../../Common/Software/powershell/main.fish"
|
||||||
|
|
||||||
function installSW
|
function installSW
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#!/bin/env fish
|
#!/bin/env fish
|
||||||
begin
|
begin
|
||||||
set -l dir (status dirname)
|
set -l dir (status dirname)
|
||||||
source "$dir/../../Scripts/software.fish"
|
source "$dir/../../lib/software.fish"
|
||||||
inherit "$dir/../../../Common/Software/pyenv/main.fish"
|
inherit "$dir/../../../Common/Software/pyenv/main.fish"
|
||||||
|
|
||||||
function installSW
|
function installSW
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#!/bin/env fish
|
#!/bin/env fish
|
||||||
begin
|
begin
|
||||||
set -l dir (status dirname)
|
set -l dir (status dirname)
|
||||||
source "$dir/../../Scripts/software.fish"
|
source "$dir/../../lib/software.fish"
|
||||||
inherit "$dir/../../../Common/Software/rclone/main.fish"
|
inherit "$dir/../../../Common/Software/rclone/main.fish"
|
||||||
|
|
||||||
function installSW
|
function installSW
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#!/bin/env fish
|
#!/bin/env fish
|
||||||
begin
|
begin
|
||||||
set -l dir (status dirname)
|
set -l dir (status dirname)
|
||||||
source "$dir/../../Scripts/software.fish"
|
source "$dir/../../lib/software.fish"
|
||||||
|
|
||||||
function installSW
|
function installSW
|
||||||
# `git` version
|
# `git` version
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#!/bin/env fish
|
#!/bin/env fish
|
||||||
begin
|
begin
|
||||||
set -l dir (status dirname)
|
set -l dir (status dirname)
|
||||||
source "$dir/../../Scripts/software.fish"
|
source "$dir/../../lib/software.fish"
|
||||||
|
|
||||||
function installSW
|
function installSW
|
||||||
yayinst steam
|
yayinst steam
|
||||||
|
@ -9,7 +9,7 @@ begin
|
||||||
|
|
||||||
|
|
||||||
function configureSW -V dir
|
function configureSW -V dir
|
||||||
. "$dir/../../../Common/Scripts/config.fish"
|
. "$dir/../../../lib/settings.fish"
|
||||||
|
|
||||||
if isOSEnabled hidpi
|
if isOSEnabled hidpi
|
||||||
begin
|
begin
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#!/bin/env fish
|
#!/bin/env fish
|
||||||
begin
|
begin
|
||||||
set -l dir (status dirname)
|
set -l dir (status dirname)
|
||||||
source "$dir/../../Scripts/software.fish"
|
source "$dir/../../lib/software.fish"
|
||||||
|
|
||||||
function installSW
|
function installSW
|
||||||
pacinst sudo
|
pacinst sudo
|
||||||
|
|
14
scripts/Arch/Software/systemd-networkd/main.fish
Normal file
14
scripts/Arch/Software/systemd-networkd/main.fish
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
#!/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
|
|
@ -1,7 +1,7 @@
|
||||||
#!/bin/env fish
|
#!/bin/env fish
|
||||||
begin
|
begin
|
||||||
set -l dir (status dirname)
|
set -l dir (status dirname)
|
||||||
source "$dir/../../Scripts/software.fish"
|
source "$dir/../../lib/software.fish"
|
||||||
inherit "$dir/../../../Common/Software/vim/main.fish"
|
inherit "$dir/../../../Common/Software/vim/main.fish"
|
||||||
|
|
||||||
function installSW
|
function installSW
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#!/bin/env fish
|
#!/bin/env fish
|
||||||
begin
|
begin
|
||||||
set -l dir (status dirname)
|
set -l dir (status dirname)
|
||||||
source "$dir/../../Scripts/software.fish"
|
source "$dir/../../lib/software.fish"
|
||||||
inherit "$dir/../../../Common/Software/virt-manager/main.fish"
|
inherit "$dir/../../../Common/Software/virt-manager/main.fish"
|
||||||
|
|
||||||
function installSW
|
function installSW
|
||||||
|
|
|
@ -1,9 +1,11 @@
|
||||||
#!/bin/env fish
|
#!/bin/env fish
|
||||||
begin
|
begin
|
||||||
set -l dir (status dirname)
|
set -l dir (status dirname)
|
||||||
source "$dir/../../Scripts/software.fish"
|
source "$dir/../../lib/software.fish"
|
||||||
|
|
||||||
function setFlags -a user
|
function setFlags
|
||||||
|
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
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#!/bin/env fish
|
#!/bin/env fish
|
||||||
begin
|
begin
|
||||||
set -l dir (status dirname)
|
set -l dir (status dirname)
|
||||||
source "$dir/../../Scripts/software.fish"
|
source "$dir/../../lib/software.fish"
|
||||||
|
|
||||||
function installSW
|
function installSW
|
||||||
yayinst (
|
yayinst (
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#!/bin/env fish
|
#!/bin/env fish
|
||||||
begin
|
begin
|
||||||
set -l dir (status dirname)
|
set -l dir (status dirname)
|
||||||
source "$dir/../../Scripts/software.fish"
|
source "$dir/../../lib/software.fish"
|
||||||
|
|
||||||
function installSW
|
function installSW
|
||||||
set -l contextRoot (mktemp -d)
|
set -l contextRoot (mktemp -d)
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#!/bin/env fish
|
#!/bin/env fish
|
||||||
begin
|
begin
|
||||||
set -l dir (status dirname)
|
set -l dir (status dirname)
|
||||||
source "$dir/../../Scripts/software.fish"
|
source "$dir/../../lib/software.fish"
|
||||||
|
|
||||||
function installSW
|
function installSW
|
||||||
if not type -q yay
|
if not type -q yay
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#!/bin/env fish
|
#!/bin/env fish
|
||||||
begin
|
begin
|
||||||
set -l dir (status dirname)
|
set -l dir (status dirname)
|
||||||
source "$dir/../../Scripts/software.fish"
|
source "$dir/../../lib/software.fish"
|
||||||
inherit "$dir/../../../Common/Software/zoxide/main.fish"
|
inherit "$dir/../../../Common/Software/zoxide/main.fish"
|
||||||
|
|
||||||
function installSW
|
function installSW
|
||||||
|
|
11
scripts/Arch/lib/dependencies.fish
Normal file
11
scripts/Arch/lib/dependencies.fish
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
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
|
|
@ -1,6 +1,7 @@
|
||||||
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
|
||||||
|
@ -30,7 +31,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)
|
and for component in (getOSConfig hardware.components --json | jq '.[]' --raw-output0 | string split0 || true)
|
||||||
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
|
||||||
|
@ -70,6 +71,8 @@ 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
|
||||||
|
@ -79,6 +82,7 @@ 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
|
||||||
|
@ -145,10 +149,13 @@ 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 \
|
||||||
|
@ -198,7 +205,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
|
||||||
|
@ -282,7 +289,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
|
|
@ -1,7 +1,7 @@
|
||||||
#!/bin/env fish
|
#!/bin/env fish
|
||||||
begin
|
begin
|
||||||
set -l dir (status dirname)
|
set -l dir (status dirname)
|
||||||
source "$dir/../../Common/Scripts/software.fish"
|
source "$dir/../../lib/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
|
|
@ -1,7 +1,7 @@
|
||||||
#!/bin/env fish
|
#!/bin/env fish
|
||||||
begin
|
begin
|
||||||
set -l dir (status dirname)
|
set -l dir (status dirname)
|
||||||
source "$dir/../../Scripts/software.fish"
|
source "$dir/../../../lib/software.fish"
|
||||||
|
|
||||||
function configureSW -V dir
|
function configureSW -V dir
|
||||||
. "$dir/../../Software/plasma/input.fish"
|
. "$dir/../../Software/plasma/input.fish"
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#!/bin/env fish
|
#!/bin/env fish
|
||||||
begin
|
begin
|
||||||
set -l dir (status dirname)
|
set -l dir (status dirname)
|
||||||
source "$dir/../../Scripts/software.fish"
|
source "$dir/../../../lib/software.fish"
|
||||||
|
|
||||||
function configureSW -V dir
|
function configureSW -V dir
|
||||||
. "$dir/../../Software/plasma/input.fish"
|
. "$dir/../../Software/plasma/input.fish"
|
||||||
|
|
37
scripts/Common/OS/backup.fish
Normal file
37
scripts/Common/OS/backup.fish
Normal file
|
@ -0,0 +1,37 @@
|
||||||
|
#!/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
|
|
@ -1,34 +1,11 @@
|
||||||
#!/bin/env fish
|
#!/bin/env fish
|
||||||
set -l dir (status dirname)
|
set -l dir (status dirname)
|
||||||
source "$dir/../Scripts/config.fish"
|
source "$dir/../../lib/action.fish"
|
||||||
source "$dir/../Scripts/hooks.fish"
|
|
||||||
|
|
||||||
if [ (id -u) -eq 0 ]
|
function installAction -V dir
|
||||||
set -l name (getOSConfig setupUser.name)
|
source "$dir/../../lib/hooks.fish"
|
||||||
set -l sudoConfig "/etc/sudoers.d/PortValhalla"
|
source "$dir/../../lib/restoration.fish"
|
||||||
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
|
||||||
|
@ -37,6 +14,7 @@ else
|
||||||
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
|
||||||
|
|
||||||
|
@ -54,28 +32,29 @@ else
|
||||||
|
|
||||||
runHook initializeUsers || begin
|
runHook initializeUsers || begin
|
||||||
if [ -n "$deployScript" ]
|
if [ -n "$deployScript" ]
|
||||||
source "$dir/../Scripts/config.fish"
|
source "$dir/../../lib/settings.fish"
|
||||||
|
|
||||||
for name in (getUsers | jq '.[]' --raw-output0 | string split0)
|
for name in (getUsers | jq '.[]' --raw-output0 | string split0 || true)
|
||||||
echo "Configuring user `$name`..."
|
echo "Configuring user `$name`..."
|
||||||
and source $deployScript userConfig $name
|
and source $deployScript userConfig --user $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 systemctl reboot -i
|
and sudo systemctl reboot -i
|
||||||
end
|
end
|
||||||
|
|
||||||
|
runSetupUserAction installAction
|
||||||
|
|
|
@ -1,20 +1,17 @@
|
||||||
#!/bin/env fish
|
#!/bin/env fish
|
||||||
function runSetup
|
function runSetup
|
||||||
set -l dir (status dirname)
|
set -l dir (status dirname)
|
||||||
source "$dir/../Scripts/config.fish"
|
source "$dir/../../lib/action.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
|
||||||
|
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
|
if not type -q runChroot
|
||||||
function runChroot -S
|
function runChroot -S
|
||||||
|
@ -22,6 +19,12 @@ function runSetup
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if not type -q getAutologinDisableCommand
|
||||||
|
function getAutologinDisableCommand
|
||||||
|
echo "true"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
function getCloneFile -S -a path
|
function getCloneFile -S -a path
|
||||||
set -l relativeDir (realpath --relative-to "$projectRoot" "$dir")
|
set -l relativeDir (realpath --relative-to "$projectRoot" "$dir")
|
||||||
set -l relativePath (realpath --relative-to "$dir" "$path")
|
set -l relativePath (realpath --relative-to "$dir" "$path")
|
||||||
|
@ -42,45 +45,82 @@ function runSetup
|
||||||
"$argv"
|
"$argv"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
initBackupConfig --action restore
|
||||||
echo "Partitioning drives..."
|
echo "Partitioning drives..."
|
||||||
and getOSConfig partition.script >"$script"
|
|
||||||
|
begin
|
||||||
|
set -l script (mktemp)
|
||||||
|
chmod +x "$script"
|
||||||
|
and getOSConfig fileSystems.script >"$script"
|
||||||
and "$script"
|
and "$script"
|
||||||
and rm "$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
|
end
|
||||||
|
|
||||||
and echo "Installing dependencies..."
|
if [ -n "$VALHALLA_BACKUP_SERVER_KEY" ]
|
||||||
and runHook --force installValhallaDeps 'Please set up a function `installValhallaDeps` for installing `fish`, `git`, `jq`, `nix`, `sudo` and `tmux`.'
|
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 echo "Cloning project..."
|
||||||
and source "$dir/../../copy-repo.fish" "$mountDir$PROJECT_CLONE_ROOT"
|
and source "$dir/../../lib/copy-repo.fish" "$mountDir$PROJECT_CLONE_ROOT"
|
||||||
runChroot "$mountDir" git config --system --add safe.directory "$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 runHook setupOS
|
||||||
|
|
||||||
and echo "Preparing auto-login..."
|
and echo "Preparing auto-login..."
|
||||||
and runHook --force autologin "Please set up a function `autologin` for setting up autologin for the `root` user"
|
and runHook --force autologin "Please set up a function `autologin` for setting up autologin for the `root` user"
|
||||||
|
|
||||||
and begin
|
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)))
|
set -l script (string escape (getCloneFile (getInstallerScript)))
|
||||||
|
|
||||||
wrapScript (
|
printf "%s\n" \
|
||||||
|
"mv $profile $tmp" \
|
||||||
|
(wrapScript (
|
||||||
string join " " \
|
string join " " \
|
||||||
"INSTALLER_SCRIPT=$(string escape "$script")" \
|
(begin
|
||||||
"CONFIG_NAME=$(string escape "$CONFIG_NAME")" \
|
for var in \
|
||||||
(string escape $script))
|
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 | runChroot "$mountDir" tee /root/.bash_profile >/dev/null
|
function actionPostRun
|
||||||
|
echo "Setup finished!"
|
||||||
and echo "Setup finished!"
|
|
||||||
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 systemctl reboot
|
and systemctl reboot
|
||||||
|
end
|
||||||
|
|
||||||
|
runAction setupAction
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
#!/bin/env fish
|
#!/bin/env fish
|
||||||
set -l dir (status dirname)
|
set -l dir (status dirname)
|
||||||
source "$dir/../Scripts/config.fish"
|
source "$dir/../../lib/settings.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)
|
for name in (echo "$users" | jq '.[]' --raw-output0 | string split0 || true)
|
||||||
echo "Creating user `$name`..."
|
echo "Creating user `$name`..."
|
||||||
|
|
||||||
function getUserInfo -V name -a config
|
function getUserInfo -V name -a config
|
||||||
|
|
|
@ -1,100 +0,0 @@
|
||||||
#!/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
|
|
|
@ -1,6 +1,6 @@
|
||||||
. "$PSScriptRoot/Constants.ps1";
|
. "$PSScriptRoot/Constants.ps1";
|
||||||
. "$PSScriptRoot/../powershell/Profile.ps1";
|
. "$PSScriptRoot/../powershell/Profile.ps1";
|
||||||
. "$PSScriptRoot/../../Scripts/Software.ps1";
|
. "$PSScriptRoot/../../../lib/Software.ps1";
|
||||||
|
|
||||||
Start-SoftwareInstaller @args `
|
Start-SoftwareInstaller @args `
|
||||||
-Configurator {
|
-Configurator {
|
||||||
|
|
|
@ -27,7 +27,7 @@ $null = New-Module {
|
||||||
Value = "$Value";
|
Value = "$Value";
|
||||||
} `
|
} `
|
||||||
-User $User `
|
-User $User `
|
||||||
".alias |= [((. // [])[] | select(.name != env.Name))] + [{ name: env.Name, value: env.Value }]";
|
'.alias |= [((. // [])[] | select(.name != env(Name)))] + [{ "name": strenv(Name), "value": strenv(Value) }]';
|
||||||
}
|
}
|
||||||
|
|
||||||
<#
|
<#
|
||||||
|
@ -53,7 +53,7 @@ $null = New-Module {
|
||||||
Value = "$Value";
|
Value = "$Value";
|
||||||
} `
|
} `
|
||||||
-User $User `
|
-User $User `
|
||||||
".env |= [((. // [])[] | select(.name != env.Name))] + [{ name: env.Name, value: env.Value }]";
|
'.env |= [((. // [])[] | select(.name != env(Name)))] + [{ "name": strenv(Name), "value": strenv(Value) }]';
|
||||||
}
|
}
|
||||||
|
|
||||||
<#
|
<#
|
||||||
|
@ -92,7 +92,7 @@ $null = New-Module {
|
||||||
}
|
}
|
||||||
|
|
||||||
sudo @using:flags pwsh -CommandWithArgs 'Get-Content -Raw $args[0]' $using:path | Set-Content $file;
|
sudo @using:flags pwsh -CommandWithArgs 'Get-Content -Raw $args[0]' $using:path | Set-Content $file;
|
||||||
yq -yi $using:Script $file;
|
yq -i $using:Script $file;
|
||||||
sudo @using:flags pwsh -CommandWithArgs 'Set-Content $args[0] -Value $args[1]' $using:path (Get-Content -Raw $file);
|
sudo @using:flags pwsh -CommandWithArgs 'Set-Content $args[0] -Value $args[1]' $using:path (Get-Content -Raw $file);
|
||||||
Remove-Item $file;
|
Remove-Item $file;
|
||||||
} | Receive-Job -Wait;
|
} | Receive-Job -Wait;
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
#!/bin/env fish
|
#!/bin/env fish
|
||||||
begin
|
begin
|
||||||
set -l dir (status dirname)
|
set -l dir (status dirname)
|
||||||
source "$dir/../../Scripts/software.fish"
|
source "$dir/../../../lib/software.fish"
|
||||||
|
|
||||||
function configureSW -V dir
|
function configureSW -V dir
|
||||||
source "$dir/../bash/profile.fish"
|
source "$dir/../bash/profile.fish"
|
||||||
source "$dir/../fish/profile.fish"
|
source "$dir/../fish/profile.fish"
|
||||||
set -l file (pwsh -CommandWithArgs '. $args[0]; Get-GlobalConfigPath' "$dir/Constants.ps1")
|
set -l file (pwsh -NoProfile -CommandWithArgs '. $args[0]; Get-GlobalConfigPath' "$dir/Constants.ps1")
|
||||||
sudo install -Dm644 "$dir/aliae.yml" "$file"
|
sudo install -Dm644 "$dir/aliae.yml" "$file"
|
||||||
|
|
||||||
begin
|
begin
|
||||||
|
@ -42,8 +42,17 @@ begin
|
||||||
sudo -HE pwsh "$dir/Main.ps1" Configure
|
sudo -HE pwsh "$dir/Main.ps1" Configure
|
||||||
end
|
end
|
||||||
|
|
||||||
function userConfig -V dir -a user
|
function getBackupArgs
|
||||||
runPSUserConfig "$dir/Main.ps1" $user
|
printf "%s\n" --full-path "/etc/aliae/aliae.yml" /
|
||||||
|
end
|
||||||
|
|
||||||
|
function userConfig -V dir
|
||||||
|
runPSUserConfig "$dir/Main.ps1" $argv
|
||||||
|
end
|
||||||
|
|
||||||
|
function getUserBackupArgs
|
||||||
|
argparse -i "user=" -- $argv
|
||||||
|
printf "%s\n" --base-directory ~"$_flag_user" --hidden --exact-depth 1 --glob ".aliae.yaml"
|
||||||
end
|
end
|
||||||
|
|
||||||
runInstaller $argv
|
runInstaller $argv
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#!/bin/env fish
|
#!/bin/env fish
|
||||||
begin
|
begin
|
||||||
set -l dir (status dirname)
|
set -l dir (status dirname)
|
||||||
source "$dir/../../Scripts/software.fish"
|
source "$dir/../../../lib/software.fish"
|
||||||
|
|
||||||
function configureSW -V dir
|
function configureSW -V dir
|
||||||
begin
|
begin
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#!/bin/env fish
|
#!/bin/env fish
|
||||||
begin
|
begin
|
||||||
set -l dir (status dirname)
|
set -l dir (status dirname)
|
||||||
source "$dir/../../Scripts/profile-base.fish"
|
source "$dir/../../../lib/profile-base.fish"
|
||||||
|
|
||||||
function getBashStatements
|
function getBashStatements
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#!/bin/env fish
|
#!/bin/env fish
|
||||||
begin
|
begin
|
||||||
set -l dir (status dirname)
|
set -l dir (status dirname)
|
||||||
source "$dir/../../Scripts/software.fish"
|
source "$dir/../../../lib/software.fish"
|
||||||
|
|
||||||
function configureSW -V dir
|
function configureSW -V dir
|
||||||
set -l bin
|
set -l bin
|
||||||
|
|
|
@ -33,7 +33,7 @@ function installExtension -d "Installs a Chromium extension for the browser with
|
||||||
sudo chmod -R u+w "$extensionDir"
|
sudo chmod -R u+w "$extensionDir"
|
||||||
sudo mkdir -p "$policyDir"
|
sudo mkdir -p "$policyDir"
|
||||||
|
|
||||||
for manifest in (find "$policyDir" -name "*.json" -print0 | string split0)
|
for manifest in (find "$policyDir" -name "*.json" -print0 | string split0 || true)
|
||||||
if [ (cat "$manifest" | jq -r ".$property") = "$destination" ]
|
if [ (cat "$manifest" | jq -r ".$property") = "$destination" ]
|
||||||
sudo rm "$manifest"
|
sudo rm "$manifest"
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,14 +1,29 @@
|
||||||
#!/bin/env fish
|
#!/bin/env fish
|
||||||
begin
|
begin
|
||||||
set -l dir (status dirname)
|
set -l dir (status dirname)
|
||||||
source "$dir/../../Scripts/software.fish"
|
source "$dir/../../../lib/software.fish"
|
||||||
|
|
||||||
function configureSW -V dir
|
function configureSW -V dir
|
||||||
sudo systemctl enable --now docker
|
sudo systemctl enable --now docker
|
||||||
end
|
end
|
||||||
|
|
||||||
function userConfig -a name
|
function userConfig
|
||||||
sudo usermod -aG docker "$name"
|
argparse -i "user=" -- $argv
|
||||||
|
sudo usermod -aG docker "$_flag_user"
|
||||||
|
end
|
||||||
|
|
||||||
|
function installSWDependencies -V dir -V args
|
||||||
|
source "$dir/../../../lib/settings.fish"
|
||||||
|
set -la argv $args
|
||||||
|
argparse -i "name=" "user=" -- $argv
|
||||||
|
set -l services (getProgramConfig --name "$_flag_name" --json | jq '.services')
|
||||||
|
|
||||||
|
for service in (echo "$services" | jq '. // {} | keys[]' --raw-output0 | string split0 || true)
|
||||||
|
|
||||||
|
if echo "$services" | SERVICE=$service jq --exit-status ".[env.SERVICE].enable" >/dev/null
|
||||||
|
fish "$dir/services/$service/main.fish" $argv
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
runInstaller $argv
|
runInstaller $argv
|
||||||
|
|
|
@ -0,0 +1,6 @@
|
||||||
|
services:
|
||||||
|
anki:
|
||||||
|
image: yangchuansheng/anki-sync-server
|
||||||
|
restart: unless-stopped
|
||||||
|
volumes:
|
||||||
|
- ./data:/ankisyncdir
|
|
@ -0,0 +1,6 @@
|
||||||
|
services:
|
||||||
|
anki:
|
||||||
|
environment:
|
||||||
|
SYNC_USER1: scott:tiger
|
||||||
|
ports:
|
||||||
|
- 127.0.0.1:1337:8080
|
34
scripts/Common/Software/docker/services/anki-sync/main.fish
Executable file
34
scripts/Common/Software/docker/services/anki-sync/main.fish
Executable file
|
@ -0,0 +1,34 @@
|
||||||
|
#!/bin/env fish
|
||||||
|
begin
|
||||||
|
set -l name anki
|
||||||
|
set -l dir (status dirname)
|
||||||
|
set -l source "$dir/docker-compose.overrides.yml"
|
||||||
|
source "$dir/../service.fish"
|
||||||
|
|
||||||
|
function installSW -V dir -V source
|
||||||
|
set -l pw (nix-shell -p keepassxc --run "keepassxc-cli generate --length 32")
|
||||||
|
set -l userKey ".services.anki.environment.SYNC_USER1"
|
||||||
|
set -l user (yq "$userKey" "$source" | sed "s/:.*\$/:$pw/")
|
||||||
|
initializeServiceInstallation $argv
|
||||||
|
sudo cp "$dir/docker-compose.base.yml" (getServiceRoot $argv)
|
||||||
|
|
||||||
|
USER=$user yq "$userKey = env(USER)" "$source" |
|
||||||
|
sudo tee (getServiceOverrides $argv) >/dev/null
|
||||||
|
|
||||||
|
installDockerService $argv
|
||||||
|
end
|
||||||
|
|
||||||
|
function configureSW -V dir
|
||||||
|
configureDockerService $argv
|
||||||
|
end
|
||||||
|
|
||||||
|
function getServiceServers -V name
|
||||||
|
printf "$name" ""
|
||||||
|
end
|
||||||
|
|
||||||
|
function getServiceLocations -V name
|
||||||
|
printf "%s\0" "$name" /
|
||||||
|
end
|
||||||
|
|
||||||
|
runInstaller --force $argv
|
||||||
|
end
|
|
@ -0,0 +1,4 @@
|
||||||
|
include:
|
||||||
|
- path:
|
||||||
|
- docker-compose.base.yml
|
||||||
|
- docker-compose.overrides.yml
|
|
@ -0,0 +1 @@
|
||||||
|
data/
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue