Compare commits
8 Commits
e72e19b7e8
...
kexec_luks
| Author | SHA1 | Date | |
|---|---|---|---|
| b7549e63f5 | |||
| 306ce8bc3f | |||
| b5dd983ba3 | |||
| 832894edfc | |||
| feb6270952 | |||
| b4dd2d4a92 | |||
| 38c2e5aece | |||
| 0ef689b750 |
2
TODO.md
2
TODO.md
@@ -73,6 +73,8 @@
|
|||||||
- offsite backup yubikey, pw db, and ssh key with /secrets access
|
- offsite backup yubikey, pw db, and ssh key with /secrets access
|
||||||
|
|
||||||
### Misc
|
### Misc
|
||||||
|
- for automated kernel upgrades on luks systems, need to kexec with initrd that contains luks key
|
||||||
|
- https://github.com/flowztul/keyexec/blob/master/etc/default/kexec-cryptroot
|
||||||
- https://github.com/pop-os/system76-scheduler
|
- https://github.com/pop-os/system76-scheduler
|
||||||
- improve email a little bit https://helloinbox.email
|
- improve email a little bit https://helloinbox.email
|
||||||
- remap razer keys https://github.com/sezanzeb/input-remapper
|
- remap razer keys https://github.com/sezanzeb/input-remapper
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
{ config, lib, ... }:
|
{ config, pkgs, lib, ... }:
|
||||||
|
|
||||||
# Modify auto-update so that it pulls a flake
|
# Modify auto-update so that it pulls a flake
|
||||||
|
|
||||||
@@ -6,10 +6,20 @@ let
|
|||||||
cfg = config.system.autoUpgrade;
|
cfg = config.system.autoUpgrade;
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
config = lib.mkIf cfg.enable {
|
config = lib.mkIf cfg.enable (lib.mkMerge [
|
||||||
system.autoUpgrade = {
|
{
|
||||||
flake = "git+https://git.neet.dev/zuckerberg/nix-config.git";
|
system.autoUpgrade = {
|
||||||
flags = [ "--recreate-lock-file" "--no-write-lock-file" ]; # ignore lock file, just pull the latest
|
flake = "git+https://git.neet.dev/zuckerberg/nix-config.git";
|
||||||
};
|
flags = [ "--recreate-lock-file" "--no-write-lock-file" ]; # ignore lock file, just pull the latest
|
||||||
};
|
|
||||||
|
# dates = "03:40";
|
||||||
|
# kexecWindow = lib.mkDefault { lower = "01:00"; upper = "05:00"; };
|
||||||
|
# randomizedDelaySec = "45min";
|
||||||
|
};
|
||||||
|
|
||||||
|
system.autoUpgrade.allowKexec = lib.mkDefault true;
|
||||||
|
|
||||||
|
luks.enableKexec = cfg.allowKexec && builtins.length config.luks.devices > 0;
|
||||||
|
}
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,6 +5,8 @@
|
|||||||
./firmware.nix
|
./firmware.nix
|
||||||
./efi.nix
|
./efi.nix
|
||||||
./bios.nix
|
./bios.nix
|
||||||
|
./kexec-luks.nix
|
||||||
|
./luks.nix
|
||||||
./remote-luks-unlock.nix
|
./remote-luks-unlock.nix
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|||||||
121
common/boot/kexec-luks.nix
Normal file
121
common/boot/kexec-luks.nix
Normal file
@@ -0,0 +1,121 @@
|
|||||||
|
# Allows kexec'ing as an alternative to rebooting for machines that
|
||||||
|
# have luks encrypted partitions that need to be mounted at boot.
|
||||||
|
# These luks partitions will be automatically unlocked, no password,
|
||||||
|
# or any interaction needed whatsoever.
|
||||||
|
|
||||||
|
# This is accomplished by fetching the luks key(s) while the system is running,
|
||||||
|
# then building a temporary initrd that contains the luks key(s), and kexec'ing.
|
||||||
|
|
||||||
|
{ config, lib, pkgs, ... }:
|
||||||
|
|
||||||
|
{
|
||||||
|
options.luks = {
|
||||||
|
enableKexec = lib.mkEnableOption "Enable support for transparent passwordless kexec while using luks";
|
||||||
|
};
|
||||||
|
|
||||||
|
config = lib.mkIf config.luks.enableKexec {
|
||||||
|
luks.fallbackToPassword = true;
|
||||||
|
luks.disableKeyring = true;
|
||||||
|
|
||||||
|
boot.initrd.luks.devices = lib.listToAttrs
|
||||||
|
(builtins.map
|
||||||
|
(item:
|
||||||
|
{
|
||||||
|
name = item;
|
||||||
|
value = {
|
||||||
|
masterKeyFile = "/etc/${item}.key";
|
||||||
|
};
|
||||||
|
})
|
||||||
|
config.luks.deviceNames);
|
||||||
|
|
||||||
|
systemd.services.prepare-luks-kexec-image = {
|
||||||
|
description = "Prepare kexec automatic LUKS unlock on kexec reboot without a password";
|
||||||
|
|
||||||
|
wantedBy = [ "kexec.target" ];
|
||||||
|
unitConfig.DefaultDependencies = false;
|
||||||
|
serviceConfig.Type = "oneshot";
|
||||||
|
|
||||||
|
path = with pkgs; [ file kexec-tools coreutils-full cpio findutils gzip xz zstd lvm2 xxd gawk ];
|
||||||
|
|
||||||
|
# based on https://github.com/flowztul/keyexec
|
||||||
|
script = ''
|
||||||
|
system=/nix/var/nix/profiles/system
|
||||||
|
old_initrd=$(readlink -f "$system/initrd")
|
||||||
|
|
||||||
|
umask 0077
|
||||||
|
CRYPTROOT_TMPDIR="$(mktemp -d --tmpdir=/dev/shm)"
|
||||||
|
|
||||||
|
cleanup() {
|
||||||
|
shred -fu "$CRYPTROOT_TMPDIR/initrd_contents/etc/"*.key || true
|
||||||
|
shred -fu "$CRYPTROOT_TMPDIR/new_initrd" || true
|
||||||
|
shred -fu "$CRYPTROOT_TMPDIR/secret/"* || true
|
||||||
|
rm -rf "$CRYPTROOT_TMPDIR"
|
||||||
|
}
|
||||||
|
# trap cleanup INT TERM EXIT
|
||||||
|
|
||||||
|
mkdir -p "$CRYPTROOT_TMPDIR"
|
||||||
|
cd "$CRYPTROOT_TMPDIR"
|
||||||
|
|
||||||
|
# Determine the compression type of the initrd image
|
||||||
|
compression=$(file -b --mime-type "$old_initrd" | awk -F'/' '{print $2}')
|
||||||
|
|
||||||
|
# Decompress the initrd image based on its compression type
|
||||||
|
case "$compression" in
|
||||||
|
gzip)
|
||||||
|
gunzip -c "$old_initrd" > initrd.cpio
|
||||||
|
;;
|
||||||
|
xz)
|
||||||
|
unxz -c "$old_initrd" > initrd.cpio
|
||||||
|
;;
|
||||||
|
zstd)
|
||||||
|
zstd -d -c "$old_initrd" > initrd.cpio
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo "Unsupported compression type: $compression"
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
# Extract the contents of the cpio archive
|
||||||
|
mkdir -p initrd_contents
|
||||||
|
cd initrd_contents
|
||||||
|
cpio -idv < ../initrd.cpio
|
||||||
|
|
||||||
|
# Generate keys and add them to the extracted initrd filesystem
|
||||||
|
luksDeviceNames=(${builtins.concatStringsSep " " config.luks.deviceNames})
|
||||||
|
for item in "''${luksDeviceNames[@]}"; do
|
||||||
|
dmsetup --showkeys table "$item" | cut -d ' ' -f5 | xxd -ps -g1 -r > "./etc/$item.key"
|
||||||
|
done
|
||||||
|
|
||||||
|
# Add normal initrd secrets too
|
||||||
|
${lib.concatStringsSep "\n" (lib.mapAttrsToList (dest: source:
|
||||||
|
let source' = if source == null then dest else builtins.toString source; in
|
||||||
|
''
|
||||||
|
mkdir -p $(dirname "./${dest}")
|
||||||
|
cp -a ${source'} "./${dest}"
|
||||||
|
''
|
||||||
|
) config.boot.initrd.secrets)
|
||||||
|
}
|
||||||
|
|
||||||
|
# Create a new cpio archive with the modified contents
|
||||||
|
find . | cpio -o -H newc -v > ../new_initrd.cpio
|
||||||
|
|
||||||
|
# Compress the new cpio archive using the original compression type
|
||||||
|
cd ..
|
||||||
|
case "$compression" in
|
||||||
|
gzip)
|
||||||
|
gunzip -c new_initrd.cpio > new_initrd
|
||||||
|
;;
|
||||||
|
xz)
|
||||||
|
unxz -c new_initrd.cpio > new_initrd
|
||||||
|
;;
|
||||||
|
zstd)
|
||||||
|
zstd -c new_initrd.cpio > new_initrd
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
kexec --load "$system/kernel" --append "init=$system/init ${builtins.concatStringsSep " " config.boot.kernelParams}" --initrd "$CRYPTROOT_TMPDIR/new_initrd"
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
74
common/boot/luks.nix
Normal file
74
common/boot/luks.nix
Normal file
@@ -0,0 +1,74 @@
|
|||||||
|
# Makes it a little easier to configure luks partitions for boot
|
||||||
|
# Additionally, this solves a circular dependency between kexec luks
|
||||||
|
# and NixOS's luks module.
|
||||||
|
|
||||||
|
{ config, lib, ... }:
|
||||||
|
|
||||||
|
let
|
||||||
|
cfg = config.luks;
|
||||||
|
|
||||||
|
deviceCount = builtins.length cfg.devices;
|
||||||
|
|
||||||
|
deviceMap = lib.imap
|
||||||
|
(i: item: {
|
||||||
|
device = item;
|
||||||
|
name =
|
||||||
|
if deviceCount == 1 then "enc-pv"
|
||||||
|
else "enc-pv${builtins.toString (i + 1)}";
|
||||||
|
})
|
||||||
|
cfg.devices;
|
||||||
|
in
|
||||||
|
{
|
||||||
|
options.luks = {
|
||||||
|
devices = lib.mkOption {
|
||||||
|
type = lib.types.listOf lib.types.str;
|
||||||
|
default = [ ];
|
||||||
|
};
|
||||||
|
|
||||||
|
allowDiscards = lib.mkOption {
|
||||||
|
type = lib.types.bool;
|
||||||
|
default = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
fallbackToPassword = lib.mkEnableOption
|
||||||
|
"Fallback to interactive passphrase prompt if the cannot be found.";
|
||||||
|
|
||||||
|
disableKeyring = lib.mkEnableOption
|
||||||
|
"When opening LUKS2 devices, don't use the kernel keyring";
|
||||||
|
|
||||||
|
# set automatically, don't touch
|
||||||
|
deviceNames = lib.mkOption {
|
||||||
|
type = lib.types.listOf lib.types.str;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
config = lib.mkMerge [
|
||||||
|
{
|
||||||
|
assertions = [
|
||||||
|
{
|
||||||
|
assertion = deviceCount == builtins.length (builtins.attrNames config.boot.initrd.luks.devices);
|
||||||
|
message = ''
|
||||||
|
All luks devices must be specified using `luks.devices` not `boot.initrd.luks.devices`.
|
||||||
|
'';
|
||||||
|
}
|
||||||
|
];
|
||||||
|
}
|
||||||
|
(lib.mkIf (deviceCount != 0) {
|
||||||
|
luks.deviceNames = builtins.map (device: device.name) deviceMap;
|
||||||
|
|
||||||
|
boot.initrd.luks.devices = lib.listToAttrs (
|
||||||
|
builtins.map
|
||||||
|
(item:
|
||||||
|
{
|
||||||
|
name = item.name;
|
||||||
|
value = {
|
||||||
|
device = item.device;
|
||||||
|
allowDiscards = cfg.allowDiscards;
|
||||||
|
fallbackToPassword = cfg.fallbackToPassword;
|
||||||
|
disableKeyring = cfg.disableKeyring;
|
||||||
|
};
|
||||||
|
})
|
||||||
|
deviceMap);
|
||||||
|
})
|
||||||
|
];
|
||||||
|
}
|
||||||
@@ -33,11 +33,6 @@ in
|
|||||||
};
|
};
|
||||||
|
|
||||||
config = lib.mkIf cfg.enable {
|
config = lib.mkIf cfg.enable {
|
||||||
# boot.initrd.luks.devices.${cfg.device.name} = {
|
|
||||||
# device = cfg.device.path;
|
|
||||||
# allowDiscards = cfg.device.allowDiscards;
|
|
||||||
# };
|
|
||||||
|
|
||||||
# Unlock LUKS disk over ssh
|
# Unlock LUKS disk over ssh
|
||||||
boot.initrd.network.enable = true;
|
boot.initrd.network.enable = true;
|
||||||
boot.initrd.kernelModules = cfg.kernelModules;
|
boot.initrd.kernelModules = cfg.kernelModules;
|
||||||
|
|||||||
@@ -13,13 +13,6 @@ in
|
|||||||
];
|
];
|
||||||
|
|
||||||
options.machines = {
|
options.machines = {
|
||||||
# For some reason (presumably a bug), using the best value of "../../machines"
|
|
||||||
# as the path causes nix to search for invalid paths for flake imports but *not*
|
|
||||||
# secrets.nix for agenix.
|
|
||||||
machinesPath = lib.mkOption {
|
|
||||||
type = lib.types.path;
|
|
||||||
default = ../..;
|
|
||||||
};
|
|
||||||
|
|
||||||
hosts = lib.mkOption {
|
hosts = lib.mkOption {
|
||||||
type = lib.types.attrsOf
|
type = lib.types.attrsOf
|
||||||
@@ -194,15 +187,14 @@ in
|
|||||||
})
|
})
|
||||||
(propertiesFiles dir);
|
(propertiesFiles dir);
|
||||||
propertiesFiles = dir:
|
propertiesFiles = dir:
|
||||||
lib.foldl (lib.mergeAttrs) { } (propertiesFiles' dir "");
|
lib.foldl (lib.mergeAttrs) { } (propertiesFiles' dir);
|
||||||
propertiesFiles' = dir: dirName:
|
propertiesFiles' = dir:
|
||||||
let
|
let
|
||||||
dirContents = builtins.readDir dir;
|
propFiles = lib.filter (p: baseNameOf p == "properties.nix") (lib.filesystem.listFilesRecursive dir);
|
||||||
dirPaths = lib.filter (path: dirContents.${path} == "directory") (lib.attrNames dirContents);
|
dirName = path: builtins.baseNameOf (builtins.dirOf path);
|
||||||
propFiles = builtins.map (p: "${dir}/${p}") (lib.filter (path: path == "properties.nix") (lib.attrNames dirContents));
|
|
||||||
in
|
in
|
||||||
lib.concatMap (d: propertiesFiles' "${dir}/${d}" d) dirPaths ++ builtins.map (p: { "${dirName}" = p; }) propFiles;
|
builtins.map (p: { "${dirName p}" = p; }) propFiles;
|
||||||
in
|
in
|
||||||
properties config.machines.machinesPath;
|
properties ../../machines;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,6 @@
|
|||||||
|
|
||||||
{ nixpkgs ? import <nixpkgs> { }
|
{ nixpkgs ? import <nixpkgs> { }
|
||||||
, assertionsModule ? <nixpkgs/nixos/modules/misc/assertions.nix>
|
, assertionsModule ? <nixpkgs/nixos/modules/misc/assertions.nix>
|
||||||
, machinesPath ? null
|
|
||||||
}:
|
}:
|
||||||
|
|
||||||
{
|
{
|
||||||
@@ -11,11 +10,6 @@
|
|||||||
modules = [
|
modules = [
|
||||||
./default.nix
|
./default.nix
|
||||||
assertionsModule
|
assertionsModule
|
||||||
{
|
|
||||||
config = nixpkgs.lib.mkIf (machinesPath != null) {
|
|
||||||
machines.machinesPath = machinesPath;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
];
|
];
|
||||||
}).config.machines;
|
}).config.machines;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,45 +17,6 @@ in
|
|||||||
alsa.support32Bit = true;
|
alsa.support32Bit = true;
|
||||||
pulse.enable = true;
|
pulse.enable = true;
|
||||||
jack.enable = true;
|
jack.enable = true;
|
||||||
|
|
||||||
# use the example session manager (no others are packaged yet so this is enabled by default,
|
|
||||||
# no need to redefine it in your config for now)
|
|
||||||
#media-session.enable = true;
|
|
||||||
|
|
||||||
config.pipewire = {
|
|
||||||
"context.objects" = [
|
|
||||||
{
|
|
||||||
# A default dummy driver. This handles nodes marked with the "node.always-driver"
|
|
||||||
# properyty when no other driver is currently active. JACK clients need this.
|
|
||||||
factory = "spa-node-factory";
|
|
||||||
args = {
|
|
||||||
"factory.name" = "support.node.driver";
|
|
||||||
"node.name" = "Dummy-Driver";
|
|
||||||
"priority.driver" = 8000;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
{
|
|
||||||
factory = "adapter";
|
|
||||||
args = {
|
|
||||||
"factory.name" = "support.null-audio-sink";
|
|
||||||
"node.name" = "Microphone-Proxy";
|
|
||||||
"node.description" = "Microphone";
|
|
||||||
"media.class" = "Audio/Source/Virtual";
|
|
||||||
"audio.position" = "MONO";
|
|
||||||
};
|
|
||||||
}
|
|
||||||
{
|
|
||||||
factory = "adapter";
|
|
||||||
args = {
|
|
||||||
"factory.name" = "support.null-audio-sink";
|
|
||||||
"node.name" = "Main-Output-Proxy";
|
|
||||||
"node.description" = "Main Output";
|
|
||||||
"media.class" = "Audio/Sink";
|
|
||||||
"audio.position" = "FL,FR";
|
|
||||||
};
|
|
||||||
}
|
|
||||||
];
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
|
||||||
users.users.googlebot.extraGroups = [ "audio" ];
|
users.users.googlebot.extraGroups = [ "audio" ];
|
||||||
|
|||||||
@@ -10,6 +10,7 @@
|
|||||||
./matrix.nix
|
./matrix.nix
|
||||||
./zerobin.nix
|
./zerobin.nix
|
||||||
./gitea.nix
|
./gitea.nix
|
||||||
|
./gitea-runner.nix
|
||||||
./privatebin/privatebin.nix
|
./privatebin/privatebin.nix
|
||||||
./radio.nix
|
./radio.nix
|
||||||
./samba.nix
|
./samba.nix
|
||||||
|
|||||||
98
common/server/gitea-runner.nix
Normal file
98
common/server/gitea-runner.nix
Normal file
@@ -0,0 +1,98 @@
|
|||||||
|
{ config, pkgs, lib, ... }:
|
||||||
|
|
||||||
|
let
|
||||||
|
cfg = config.services.gitea-runner;
|
||||||
|
in
|
||||||
|
{
|
||||||
|
options.services.gitea-runner = {
|
||||||
|
enable = lib.mkEnableOption "Enables gitea runner";
|
||||||
|
dataDir = lib.mkOption {
|
||||||
|
default = "/var/lib/gitea-runner";
|
||||||
|
type = lib.types.str;
|
||||||
|
description = lib.mdDoc "gitea runner data directory.";
|
||||||
|
};
|
||||||
|
instanceUrl = lib.mkOption {
|
||||||
|
type = lib.types.str;
|
||||||
|
};
|
||||||
|
registrationTokenFile = lib.mkOption {
|
||||||
|
type = lib.types.path;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
config = lib.mkIf cfg.enable {
|
||||||
|
virtualisation.docker.enable = true;
|
||||||
|
|
||||||
|
users.users.gitea-runner = {
|
||||||
|
description = "Gitea Runner Service";
|
||||||
|
home = cfg.dataDir;
|
||||||
|
useDefaultShell = true;
|
||||||
|
group = "gitea-runner";
|
||||||
|
isSystemUser = true;
|
||||||
|
createHome = true;
|
||||||
|
extraGroups = [
|
||||||
|
"docker" # allow creating docker containers
|
||||||
|
];
|
||||||
|
};
|
||||||
|
users.groups.gitea-runner = { };
|
||||||
|
|
||||||
|
# registration token
|
||||||
|
services.gitea-runner.registrationTokenFile = "/run/agenix/gitea-runner-registration-token";
|
||||||
|
age.secrets.gitea-runner-registration-token = {
|
||||||
|
file = ../../secrets/gitea-runner-registration-token.age;
|
||||||
|
owner = "gitea-runner";
|
||||||
|
};
|
||||||
|
|
||||||
|
systemd.services.gitea-runner = {
|
||||||
|
description = "Gitea Runner";
|
||||||
|
|
||||||
|
serviceConfig = {
|
||||||
|
WorkingDirectory = cfg.dataDir;
|
||||||
|
User = "gitea-runner";
|
||||||
|
Group = "gitea-runner";
|
||||||
|
};
|
||||||
|
|
||||||
|
requires = [ "network-online.target" ];
|
||||||
|
after = [ "network.target" "network-online.target" ];
|
||||||
|
wantedBy = [ "multi-user.target" ];
|
||||||
|
|
||||||
|
path = with pkgs; [ gitea-actions-runner ];
|
||||||
|
|
||||||
|
# based on https://gitea.com/gitea/act_runner/src/branch/main/run.sh
|
||||||
|
script = ''
|
||||||
|
. ${cfg.registrationTokenFile}
|
||||||
|
|
||||||
|
if [[ ! -s .runner ]]; then
|
||||||
|
try=$((try + 1))
|
||||||
|
success=0
|
||||||
|
|
||||||
|
LOGFILE="$(mktemp)"
|
||||||
|
|
||||||
|
# The point of this loop is to make it simple, when running both act_runner and gitea in docker,
|
||||||
|
# for the act_runner to wait a moment for gitea to become available before erroring out. Within
|
||||||
|
# the context of a single docker-compose, something similar could be done via healthchecks, but
|
||||||
|
# this is more flexible.
|
||||||
|
while [[ $success -eq 0 ]] && [[ $try -lt ''${10:-10} ]]; do
|
||||||
|
act_runner register \
|
||||||
|
--instance "${cfg.instanceUrl}" \
|
||||||
|
--token "$GITEA_RUNNER_REGISTRATION_TOKEN" \
|
||||||
|
--name "${config.networking.hostName}" \
|
||||||
|
--no-interactive > $LOGFILE 2>&1
|
||||||
|
|
||||||
|
cat $LOGFILE
|
||||||
|
|
||||||
|
cat $LOGFILE | grep 'Runner registered successfully' > /dev/null
|
||||||
|
if [[ $? -eq 0 ]]; then
|
||||||
|
echo "SUCCESS"
|
||||||
|
success=1
|
||||||
|
else
|
||||||
|
echo "Waiting to retry ..."
|
||||||
|
sleep 5
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
|
||||||
|
exec act_runner daemon
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
@@ -39,6 +39,9 @@ in
|
|||||||
USER = "robot@runyan.org";
|
USER = "robot@runyan.org";
|
||||||
FROM = "no-reply@neet.dev";
|
FROM = "no-reply@neet.dev";
|
||||||
};
|
};
|
||||||
|
actions = {
|
||||||
|
ENABLED = true;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
mailerPasswordFile = "/run/agenix/robots-email-pw";
|
mailerPasswordFile = "/run/agenix/robots-email-pw";
|
||||||
};
|
};
|
||||||
|
|||||||
48
flake.lock
generated
48
flake.lock
generated
@@ -8,11 +8,11 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1675176355,
|
"lastModified": 1682101079,
|
||||||
"narHash": "sha256-Qjxh5cmN56siY97mzmBLI1+cdjXSPqmfPVsKxBvHmwI=",
|
"narHash": "sha256-MdAhtjrLKnk2uiqun1FWABbKpLH090oeqCSiWemtuck=",
|
||||||
"owner": "ryantm",
|
"owner": "ryantm",
|
||||||
"repo": "agenix",
|
"repo": "agenix",
|
||||||
"rev": "b7ffcfe77f817d9ee992640ba1f270718d197f28",
|
"rev": "2994d002dcff5353ca1ac48ec584c7f6589fe447",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
@@ -117,11 +117,11 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1674127017,
|
"lastModified": 1682063650,
|
||||||
"narHash": "sha256-QO1xF7stu5ZMDLbHN30LFolMAwY6TVlzYvQoUs1RD68=",
|
"narHash": "sha256-VaDHh2z6xlnTHaONlNVHP7qEMcK5rZ8Js3sT6mKb2XY=",
|
||||||
"owner": "serokell",
|
"owner": "serokell",
|
||||||
"repo": "deploy-rs",
|
"repo": "deploy-rs",
|
||||||
"rev": "8c9ea9605eed20528bf60fae35a2b613b901fd77",
|
"rev": "c2ea4e642dc50fd44b537e9860ec95867af30d39",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
@@ -147,12 +147,15 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"flake-utils": {
|
"flake-utils": {
|
||||||
|
"inputs": {
|
||||||
|
"systems": "systems"
|
||||||
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1667395993,
|
"lastModified": 1681202837,
|
||||||
"narHash": "sha256-nuEHfE/LcWyuSWnS8t12N1wc105Qtau+/OdUAjtQ0rA=",
|
"narHash": "sha256-H+Rh19JDwRtpVPAWp64F+rlEtxUWBAQW28eAi3SRSzg=",
|
||||||
"owner": "numtide",
|
"owner": "numtide",
|
||||||
"repo": "flake-utils",
|
"repo": "flake-utils",
|
||||||
"rev": "5aed5285a952e0b949eb3ba02c12fa4fcfef535f",
|
"rev": "cfacdce06f30d2b68473a46042957675eebb3401",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
@@ -168,11 +171,11 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1677382901,
|
"lastModified": 1681591833,
|
||||||
"narHash": "sha256-2idFWlTVG+qUZkU2/W50amGSIxmN56igIkMAXKbv4S4=",
|
"narHash": "sha256-lW+xOELafAs29yw56FG4MzNOFkh8VHC/X/tRs1wsGn8=",
|
||||||
"owner": "Mic92",
|
"owner": "Mic92",
|
||||||
"repo": "nix-index-database",
|
"repo": "nix-index-database",
|
||||||
"rev": "4306fa7c12e098360439faac1a2e6b8e509ec97c",
|
"rev": "68ec961c51f48768f72d2bbdb396ce65a316677e",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
@@ -183,11 +186,11 @@
|
|||||||
},
|
},
|
||||||
"nixpkgs": {
|
"nixpkgs": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1677823547,
|
"lastModified": 1682133240,
|
||||||
"narHash": "sha256-xD2qco8Pw8HAXgjf9OSi2H2N20WaTrtvgcl21525kVE=",
|
"narHash": "sha256-s6yRsI/7V+k/+rckp0+/2cs/UXnea3SEfMpy95QiGcc=",
|
||||||
"owner": "NixOS",
|
"owner": "NixOS",
|
||||||
"repo": "nixpkgs",
|
"repo": "nixpkgs",
|
||||||
"rev": "78c4d33c16092e535bc4ba1284ba49e3e138483a",
|
"rev": "8dafae7c03d6aa8c2ae0a0612fbcb47e994e3fb8",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
@@ -304,6 +307,21 @@
|
|||||||
"type": "gitlab"
|
"type": "gitlab"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"systems": {
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1681028828,
|
||||||
|
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
|
||||||
|
"owner": "nix-systems",
|
||||||
|
"repo": "default",
|
||||||
|
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "nix-systems",
|
||||||
|
"repo": "default",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
"utils": {
|
"utils": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1605370193,
|
"lastModified": 1605370193,
|
||||||
|
|||||||
19
flake.nix
19
flake.nix
@@ -55,7 +55,7 @@
|
|||||||
{
|
{
|
||||||
nixosConfigurations =
|
nixosConfigurations =
|
||||||
let
|
let
|
||||||
modules = system: with inputs; [
|
modules = system: hostname: with inputs; [
|
||||||
./common
|
./common
|
||||||
simple-nixos-mailserver.nixosModule
|
simple-nixos-mailserver.nixosModule
|
||||||
agenix.nixosModules.default
|
agenix.nixosModules.default
|
||||||
@@ -63,9 +63,13 @@
|
|||||||
archivebox.nixosModule
|
archivebox.nixosModule
|
||||||
nix-index-database.nixosModules.nix-index
|
nix-index-database.nixosModules.nix-index
|
||||||
({ lib, ... }: {
|
({ lib, ... }: {
|
||||||
config.environment.systemPackages = [
|
config = {
|
||||||
agenix.packages.${system}.agenix
|
environment.systemPackages = [
|
||||||
];
|
agenix.packages.${system}.agenix
|
||||||
|
];
|
||||||
|
|
||||||
|
networking.hostName = hostname;
|
||||||
|
};
|
||||||
|
|
||||||
# because nixos specialArgs doesn't work for containers... need to pass in inputs a different way
|
# because nixos specialArgs doesn't work for containers... need to pass in inputs a different way
|
||||||
options.inputs = lib.mkOption { default = inputs; };
|
options.inputs = lib.mkOption { default = inputs; };
|
||||||
@@ -73,9 +77,9 @@
|
|||||||
})
|
})
|
||||||
];
|
];
|
||||||
|
|
||||||
mkSystem = system: nixpkgs: path:
|
mkSystem = system: nixpkgs: path: hostname:
|
||||||
let
|
let
|
||||||
allModules = modules system;
|
allModules = modules system hostname;
|
||||||
|
|
||||||
# allow patching nixpkgs, remove this hack once this is solved: https://github.com/NixOS/nix/issues/3920
|
# allow patching nixpkgs, remove this hack once this is solved: https://github.com/NixOS/nix/issues/3920
|
||||||
patchedNixpkgsSrc = nixpkgs.legacyPackages.${system}.applyPatches {
|
patchedNixpkgsSrc = nixpkgs.legacyPackages.${system}.applyPatches {
|
||||||
@@ -83,6 +87,7 @@
|
|||||||
src = nixpkgs;
|
src = nixpkgs;
|
||||||
patches = [
|
patches = [
|
||||||
inputs.nixpkgs-hostapd-pr
|
inputs.nixpkgs-hostapd-pr
|
||||||
|
./patches/kexec-luks.patch
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
patchedNixpkgs = nixpkgs.lib.fix (self: (import "${patchedNixpkgsSrc}/flake.nix").outputs { self = nixpkgs; });
|
patchedNixpkgs = nixpkgs.lib.fix (self: (import "${patchedNixpkgsSrc}/flake.nix").outputs { self = nixpkgs; });
|
||||||
@@ -99,7 +104,7 @@
|
|||||||
in
|
in
|
||||||
nixpkgs.lib.mapAttrs
|
nixpkgs.lib.mapAttrs
|
||||||
(hostname: cfg:
|
(hostname: cfg:
|
||||||
mkSystem cfg.arch nixpkgs cfg.configurationPath)
|
mkSystem cfg.arch nixpkgs cfg.configurationPath hostname)
|
||||||
machines;
|
machines;
|
||||||
|
|
||||||
packages =
|
packages =
|
||||||
|
|||||||
@@ -5,5 +5,10 @@
|
|||||||
./hardware-configuration.nix
|
./hardware-configuration.nix
|
||||||
];
|
];
|
||||||
|
|
||||||
networking.hostName = "phil";
|
services.gitea-runner = {
|
||||||
|
enable = true;
|
||||||
|
instanceUrl = "https://git.neet.dev";
|
||||||
|
};
|
||||||
|
|
||||||
|
system.autoUpgrade.enable = true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,25 +20,22 @@
|
|||||||
boot.kernelModules = [ ];
|
boot.kernelModules = [ ];
|
||||||
boot.extraModulePackages = [ ];
|
boot.extraModulePackages = [ ];
|
||||||
|
|
||||||
boot.initrd.luks.devices."enc-pv" = {
|
luks.devices = [ "/dev/disk/by-uuid/d26c1820-4c39-4615-98c2-51442504e194" ];
|
||||||
device = "/dev/disk/by-uuid/9f1727c7-1e95-47b9-9807-8f38531eed47";
|
|
||||||
allowDiscards = true;
|
|
||||||
};
|
|
||||||
|
|
||||||
fileSystems."/" =
|
fileSystems."/" =
|
||||||
{
|
{
|
||||||
device = "/dev/mapper/vg-root";
|
device = "/dev/disk/by-uuid/851bfde6-93cd-439e-9380-de28aa87eda9";
|
||||||
fsType = "btrfs";
|
fsType = "btrfs";
|
||||||
};
|
};
|
||||||
|
|
||||||
fileSystems."/boot" =
|
fileSystems."/boot" =
|
||||||
{
|
{
|
||||||
device = "/dev/disk/by-uuid/EC6B-53AA";
|
device = "/dev/disk/by-uuid/F185-C4E5";
|
||||||
fsType = "vfat";
|
fsType = "vfat";
|
||||||
};
|
};
|
||||||
|
|
||||||
swapDevices =
|
swapDevices =
|
||||||
[{ device = "/dev/disk/by-uuid/b916094f-cf2a-4be7-b8f1-674ba6473061"; }];
|
[{ device = "/dev/disk/by-uuid/d809e3a1-3915-405a-a200-4429c5efdf87"; }];
|
||||||
|
|
||||||
networking.interfaces.enp0s6.useDHCP = lib.mkDefault true;
|
networking.interfaces.enp0s6.useDHCP = lib.mkDefault true;
|
||||||
|
|
||||||
|
|||||||
@@ -8,12 +8,13 @@
|
|||||||
|
|
||||||
systemRoles = [
|
systemRoles = [
|
||||||
"server"
|
"server"
|
||||||
|
"gitea-runner"
|
||||||
];
|
];
|
||||||
|
|
||||||
hostKey = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIBlOs6mTZCSJL/XM6NysHN0ZNQAyj2GEwBV2Ze6NxRmr";
|
hostKey = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIBlgRPpuUkZqe8/lHugRPm/m2vcN9psYhh5tENHZt9I2";
|
||||||
|
|
||||||
remoteUnlock = {
|
remoteUnlock = {
|
||||||
hostKey = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIAqy9X/m67oXJBX+OMdIqpiLONYc5aQ2nHeEPAaj/vgN";
|
hostKey = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIK0RodotOXLMy/w70aa096gaNqPBnfgiXR5ZAH4+wGzd";
|
||||||
clearnetHost = "unlock.phil.neet.dev";
|
clearnetHost = "unlock.phil.neet.dev";
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,9 +5,10 @@
|
|||||||
./hardware-configuration.nix
|
./hardware-configuration.nix
|
||||||
];
|
];
|
||||||
|
|
||||||
networking.hostName = "ponyo";
|
|
||||||
|
|
||||||
system.autoUpgrade.enable = true;
|
system.autoUpgrade.enable = true;
|
||||||
|
# I want to manually trigger kexec updates for now on ponyo
|
||||||
|
system.autoUpgrade.allowKexec = false;
|
||||||
|
luks.enableKexec = true;
|
||||||
|
|
||||||
# p2p mesh network
|
# p2p mesh network
|
||||||
services.tailscale.exitNode = true;
|
services.tailscale.exitNode = true;
|
||||||
|
|||||||
@@ -19,12 +19,15 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
remoteLuksUnlock.enable = true;
|
remoteLuksUnlock.enable = true;
|
||||||
boot.initrd.luks.devices."enc-pv".device = "/dev/disk/by-uuid/4cc36be4-dbff-4afe-927d-69bf4637bae2";
|
|
||||||
boot.initrd.luks.devices."enc-pv2".device = "/dev/disk/by-uuid/e52b01b3-81c8-4bb2-ae7e-a3d9c793cb00"; # expanded disk
|
luks.devices = [
|
||||||
|
"/dev/disk/by-uuid/4cc36be4-dbff-4afe-927d-69bf4637bae2"
|
||||||
|
"/dev/disk/by-uuid/e52b01b3-81c8-4bb2-ae7e-a3d9c793cb00"
|
||||||
|
];
|
||||||
|
|
||||||
fileSystems."/" =
|
fileSystems."/" =
|
||||||
{
|
{
|
||||||
device = "/dev/mapper/enc-pv";
|
device = "/dev/mapper/enc-pv1";
|
||||||
fsType = "btrfs";
|
fsType = "btrfs";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -5,8 +5,6 @@
|
|||||||
./hardware-configuration.nix
|
./hardware-configuration.nix
|
||||||
];
|
];
|
||||||
|
|
||||||
networking.hostName = "ray";
|
|
||||||
|
|
||||||
# for luks onlock over tor
|
# for luks onlock over tor
|
||||||
services.tor.enable = true;
|
services.tor.enable = true;
|
||||||
services.tor.client.enable = true;
|
services.tor.client.enable = true;
|
||||||
|
|||||||
@@ -36,10 +36,7 @@
|
|||||||
|
|
||||||
# disks
|
# disks
|
||||||
remoteLuksUnlock.enable = true;
|
remoteLuksUnlock.enable = true;
|
||||||
boot.initrd.luks.devices."enc-pv" = {
|
luks.devices = [ "/dev/disk/by-uuid/c1822e5f-4137-44e1-885f-954e926583ce" ];
|
||||||
device = "/dev/disk/by-uuid/c1822e5f-4137-44e1-885f-954e926583ce";
|
|
||||||
allowDiscards = true;
|
|
||||||
};
|
|
||||||
fileSystems."/" =
|
fileSystems."/" =
|
||||||
{
|
{
|
||||||
device = "/dev/vg/root";
|
device = "/dev/vg/root";
|
||||||
@@ -59,7 +56,4 @@
|
|||||||
};
|
};
|
||||||
swapDevices =
|
swapDevices =
|
||||||
[{ device = "/dev/vg/swap"; }];
|
[{ device = "/dev/vg/swap"; }];
|
||||||
|
|
||||||
# high-resolution display
|
|
||||||
hardware.video.hidpi.enable = lib.mkDefault true;
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,8 +11,6 @@
|
|||||||
# https://github.com/skogsbrus/os/blob/master/sys/router.nix
|
# https://github.com/skogsbrus/os/blob/master/sys/router.nix
|
||||||
# http://trac.gateworks.com/wiki/wireless/wifi
|
# http://trac.gateworks.com/wiki/wireless/wifi
|
||||||
|
|
||||||
networking.hostName = "router";
|
|
||||||
|
|
||||||
system.autoUpgrade.enable = true;
|
system.autoUpgrade.enable = true;
|
||||||
|
|
||||||
services.tailscale.exitNode = true;
|
services.tailscale.exitNode = true;
|
||||||
|
|||||||
@@ -32,7 +32,7 @@
|
|||||||
|
|
||||||
# disks
|
# disks
|
||||||
remoteLuksUnlock.enable = true;
|
remoteLuksUnlock.enable = true;
|
||||||
boot.initrd.luks.devices."enc-pv".device = "/dev/disk/by-uuid/9b090551-f78e-45ca-8570-196ed6a4af0c";
|
luks.devices = [ "/dev/disk/by-uuid/9b090551-f78e-45ca-8570-196ed6a4af0c" ];
|
||||||
fileSystems."/" =
|
fileSystems."/" =
|
||||||
{
|
{
|
||||||
device = "/dev/disk/by-uuid/421c82b9-d67c-4811-8824-8bb57cb10fce";
|
device = "/dev/disk/by-uuid/421c82b9-d67c-4811-8824-8bb57cb10fce";
|
||||||
|
|||||||
@@ -5,8 +5,6 @@
|
|||||||
./hardware-configuration.nix
|
./hardware-configuration.nix
|
||||||
];
|
];
|
||||||
|
|
||||||
networking.hostName = "s0";
|
|
||||||
|
|
||||||
system.autoUpgrade.enable = true;
|
system.autoUpgrade.enable = true;
|
||||||
|
|
||||||
services.iperf3.enable = true;
|
services.iperf3.enable = true;
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
];
|
];
|
||||||
|
|
||||||
# boot
|
# boot
|
||||||
efi.enable = true;
|
boot.loader.systemd-boot.enable = true;
|
||||||
boot.initrd.availableKernelModules = [ "xhci_pci" "ahci" "nvme" "usb_storage" "uas" "sd_mod" "rtsx_pci_sdmmc" ];
|
boot.initrd.availableKernelModules = [ "xhci_pci" "ahci" "nvme" "usb_storage" "uas" "sd_mod" "rtsx_pci_sdmmc" ];
|
||||||
boot.initrd.kernelModules = [ ];
|
boot.initrd.kernelModules = [ ];
|
||||||
boot.kernelModules = [ "kvm-intel" ];
|
boot.kernelModules = [ "kvm-intel" ];
|
||||||
@@ -25,10 +25,12 @@
|
|||||||
|
|
||||||
# luks
|
# luks
|
||||||
remoteLuksUnlock.enable = true;
|
remoteLuksUnlock.enable = true;
|
||||||
boot.initrd.luks.devices."enc-pv1".device = "/dev/disk/by-uuid/d52e99a9-8825-4d0a-afc1-8edbef7e0a86";
|
luks.devices = [
|
||||||
boot.initrd.luks.devices."enc-pv2".device = "/dev/disk/by-uuid/f7275585-7760-4230-97de-36704b9a2aa3";
|
"/dev/disk/by-uuid/d52e99a9-8825-4d0a-afc1-8edbef7e0a86"
|
||||||
boot.initrd.luks.devices."enc-pv3".device = "/dev/disk/by-uuid/5d1002b8-a0ed-4a1c-99f5-24b8816d9e38";
|
"/dev/disk/by-uuid/f7275585-7760-4230-97de-36704b9a2aa3"
|
||||||
boot.initrd.luks.devices."enc-pv4".device = "/dev/disk/by-uuid/e2c7402a-e72c-4c4a-998f-82e4c10187bc";
|
"/dev/disk/by-uuid/5d1002b8-a0ed-4a1c-99f5-24b8816d9e38"
|
||||||
|
"/dev/disk/by-uuid/e2c7402a-e72c-4c4a-998f-82e4c10187bc"
|
||||||
|
];
|
||||||
|
|
||||||
# mounts
|
# mounts
|
||||||
fileSystems."/" =
|
fileSystems."/" =
|
||||||
|
|||||||
264
patches/kexec-luks.patch
Normal file
264
patches/kexec-luks.patch
Normal file
@@ -0,0 +1,264 @@
|
|||||||
|
diff --git a/nixos/modules/system/boot/luksroot.nix b/nixos/modules/system/boot/luksroot.nix
|
||||||
|
index b8f36538e70..cc320a04c70 100644
|
||||||
|
--- a/nixos/modules/system/boot/luksroot.nix
|
||||||
|
+++ b/nixos/modules/system/boot/luksroot.nix
|
||||||
|
@@ -146,6 +146,7 @@ let
|
||||||
|
csopen = "cryptsetup luksOpen ${dev.device} ${dev.name}"
|
||||||
|
+ optionalString dev.allowDiscards " --allow-discards"
|
||||||
|
+ optionalString dev.bypassWorkqueues " --perf-no_read_workqueue --perf-no_write_workqueue"
|
||||||
|
+ + optionalString dev.disableKeyring " --disable-keyring"
|
||||||
|
+ optionalString (dev.header != null) " --header=${dev.header}";
|
||||||
|
cschange = "cryptsetup luksChangeKey ${dev.device} ${optionalString (dev.header != null) "--header=${dev.header}"}";
|
||||||
|
fido2luksCredentials = dev.fido2.credentials ++ optional (dev.fido2.credential != null) dev.fido2.credential;
|
||||||
|
@@ -243,6 +244,26 @@ let
|
||||||
|
do_open_passphrase
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
+ '' else if (dev.masterKeyFile != null) then ''
|
||||||
|
+ if wait_target "key file" ${dev.masterKeyFile}; then
|
||||||
|
+ ${csopen} --master-key-file=${dev.masterKeyFile}
|
||||||
|
+ cs_status=$?
|
||||||
|
+ if [ $cs_status -ne 0 ]; then
|
||||||
|
+ echo "Key File ${dev.masterKeyFile} failed!"
|
||||||
|
+ if ! try_empty_passphrase; then
|
||||||
|
+ ${if dev.fallbackToPassword then "echo" else "die"} "${dev.masterKeyFile} is unavailable"
|
||||||
|
+ echo " - failing back to interactive password prompt"
|
||||||
|
+ do_open_passphrase
|
||||||
|
+ fi
|
||||||
|
+ fi
|
||||||
|
+ else
|
||||||
|
+ # If the key file never shows up we should also try the empty passphrase
|
||||||
|
+ if ! try_empty_passphrase; then
|
||||||
|
+ ${if dev.fallbackToPassword then "echo" else "die"} "${dev.masterKeyFile} is unavailable"
|
||||||
|
+ echo " - failing back to interactive password prompt"
|
||||||
|
+ do_open_passphrase
|
||||||
|
+ fi
|
||||||
|
+ fi
|
||||||
|
'' else ''
|
||||||
|
if ! try_empty_passphrase; then
|
||||||
|
do_open_passphrase
|
||||||
|
@@ -625,6 +646,15 @@ in
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
+ masterKeyFile = mkOption {
|
||||||
|
+ default = null;
|
||||||
|
+ type = types.nullOr types.str;
|
||||||
|
+ description = lib.mdDoc ''
|
||||||
|
+ The name of the file (can be a raw device or a partition) that
|
||||||
|
+ should be used as the master decryption key for the encrypted device.
|
||||||
|
+ '';
|
||||||
|
+ };
|
||||||
|
+
|
||||||
|
tryEmptyPassphrase = mkOption {
|
||||||
|
default = false;
|
||||||
|
type = types.bool;
|
||||||
|
@@ -700,6 +730,15 @@ in
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
+ disableKeyring = mkOption {
|
||||||
|
+ default = false;
|
||||||
|
+ type = types.bool;
|
||||||
|
+ description = lib.mdDoc ''
|
||||||
|
+ Disables using the kernel keyring for LUKS2 disks.
|
||||||
|
+ This is already the default behavior for LUKS1
|
||||||
|
+ '';
|
||||||
|
+ };
|
||||||
|
+
|
||||||
|
fallbackToPassword = mkOption {
|
||||||
|
default = false;
|
||||||
|
type = types.bool;
|
||||||
|
diff --git a/nixos/modules/tasks/auto-upgrade.nix b/nixos/modules/tasks/auto-upgrade.nix
|
||||||
|
index 29e3e313336..050bf09c208 100644
|
||||||
|
--- a/nixos/modules/tasks/auto-upgrade.nix
|
||||||
|
+++ b/nixos/modules/tasks/auto-upgrade.nix
|
||||||
|
@@ -4,7 +4,8 @@ with lib;
|
||||||
|
|
||||||
|
let cfg = config.system.autoUpgrade;
|
||||||
|
|
||||||
|
-in {
|
||||||
|
+in
|
||||||
|
+{
|
||||||
|
|
||||||
|
options = {
|
||||||
|
|
||||||
|
@@ -22,7 +23,7 @@ in {
|
||||||
|
};
|
||||||
|
|
||||||
|
operation = mkOption {
|
||||||
|
- type = types.enum ["switch" "boot"];
|
||||||
|
+ type = types.enum [ "switch" "boot" ];
|
||||||
|
default = "switch";
|
||||||
|
example = "boot";
|
||||||
|
description = lib.mdDoc ''
|
||||||
|
@@ -86,14 +87,14 @@ in {
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
- allowReboot = mkOption {
|
||||||
|
+ allowKexec = mkOption {
|
||||||
|
default = false;
|
||||||
|
type = types.bool;
|
||||||
|
description = lib.mdDoc ''
|
||||||
|
- Reboot the system into the new generation instead of a switch
|
||||||
|
+ kexec the system into the new generation instead of a switch
|
||||||
|
if the new generation uses a different kernel, kernel modules
|
||||||
|
or initrd than the booted system.
|
||||||
|
- See {option}`rebootWindow` for configuring the times at which a reboot is allowed.
|
||||||
|
+ See {option}`kexecWindow` for configuring the times at which a kexec is allowed.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
@@ -109,25 +110,25 @@ in {
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
- rebootWindow = mkOption {
|
||||||
|
+ kexecWindow = mkOption {
|
||||||
|
description = lib.mdDoc ''
|
||||||
|
Define a lower and upper time value (in HH:MM format) which
|
||||||
|
- constitute a time window during which reboots are allowed after an upgrade.
|
||||||
|
- This option only has an effect when {option}`allowReboot` is enabled.
|
||||||
|
- The default value of `null` means that reboots are allowed at any time.
|
||||||
|
+ constitute a time window during which kexecs are allowed after an upgrade.
|
||||||
|
+ This option only has an effect when {option}`allowKexec` is enabled.
|
||||||
|
+ The default value of `null` means that kexecs are allowed at any time.
|
||||||
|
'';
|
||||||
|
default = null;
|
||||||
|
example = { lower = "01:00"; upper = "05:00"; };
|
||||||
|
type = with types; nullOr (submodule {
|
||||||
|
options = {
|
||||||
|
lower = mkOption {
|
||||||
|
- description = lib.mdDoc "Lower limit of the reboot window";
|
||||||
|
+ description = lib.mdDoc "Lower limit of the kexec window";
|
||||||
|
type = types.strMatching "[[:digit:]]{2}:[[:digit:]]{2}";
|
||||||
|
example = "01:00";
|
||||||
|
};
|
||||||
|
|
||||||
|
upper = mkOption {
|
||||||
|
- description = lib.mdDoc "Upper limit of the reboot window";
|
||||||
|
+ description = lib.mdDoc "Upper limit of the kexec window";
|
||||||
|
type = types.strMatching "[[:digit:]]{2}:[[:digit:]]{2}";
|
||||||
|
example = "05:00";
|
||||||
|
};
|
||||||
|
@@ -165,12 +166,12 @@ in {
|
||||||
|
}];
|
||||||
|
|
||||||
|
system.autoUpgrade.flags = (if cfg.flake == null then
|
||||||
|
- [ "--no-build-output" ] ++ optionals (cfg.channel != null) [
|
||||||
|
- "-I"
|
||||||
|
- "nixpkgs=${cfg.channel}/nixexprs.tar.xz"
|
||||||
|
- ]
|
||||||
|
- else
|
||||||
|
- [ "--flake ${cfg.flake}" ]);
|
||||||
|
+ [ "--no-build-output" ] ++ optionals (cfg.channel != null) [
|
||||||
|
+ "-I"
|
||||||
|
+ "nixpkgs=${cfg.channel}/nixexprs.tar.xz"
|
||||||
|
+ ]
|
||||||
|
+ else
|
||||||
|
+ [ "--flake ${cfg.flake}" ]);
|
||||||
|
|
||||||
|
systemd.services.nixos-upgrade = {
|
||||||
|
description = "NixOS Upgrade";
|
||||||
|
@@ -195,54 +196,56 @@ in {
|
||||||
|
config.programs.ssh.package
|
||||||
|
];
|
||||||
|
|
||||||
|
- script = let
|
||||||
|
- nixos-rebuild = "${config.system.build.nixos-rebuild}/bin/nixos-rebuild";
|
||||||
|
- date = "${pkgs.coreutils}/bin/date";
|
||||||
|
- readlink = "${pkgs.coreutils}/bin/readlink";
|
||||||
|
- shutdown = "${config.systemd.package}/bin/shutdown";
|
||||||
|
- upgradeFlag = optional (cfg.channel == null) "--upgrade";
|
||||||
|
- in if cfg.allowReboot then ''
|
||||||
|
- ${nixos-rebuild} boot ${toString (cfg.flags ++ upgradeFlag)}
|
||||||
|
- booted="$(${readlink} /run/booted-system/{initrd,kernel,kernel-modules})"
|
||||||
|
- built="$(${readlink} /nix/var/nix/profiles/system/{initrd,kernel,kernel-modules})"
|
||||||
|
-
|
||||||
|
- ${optionalString (cfg.rebootWindow != null) ''
|
||||||
|
- current_time="$(${date} +%H:%M)"
|
||||||
|
-
|
||||||
|
- lower="${cfg.rebootWindow.lower}"
|
||||||
|
- upper="${cfg.rebootWindow.upper}"
|
||||||
|
-
|
||||||
|
- if [[ "''${lower}" < "''${upper}" ]]; then
|
||||||
|
- if [[ "''${current_time}" > "''${lower}" ]] && \
|
||||||
|
- [[ "''${current_time}" < "''${upper}" ]]; then
|
||||||
|
- do_reboot="true"
|
||||||
|
+ script =
|
||||||
|
+ let
|
||||||
|
+ nixos-rebuild = "${config.system.build.nixos-rebuild}/bin/nixos-rebuild";
|
||||||
|
+ date = "${pkgs.coreutils}/bin/date";
|
||||||
|
+ readlink = "${pkgs.coreutils}/bin/readlink";
|
||||||
|
+ systemctl_kexec = "${config.systemd.package}/bin/systemctl kexec";
|
||||||
|
+ upgradeFlag = optional (cfg.channel == null) "--upgrade";
|
||||||
|
+ in
|
||||||
|
+ if cfg.allowKexec then ''
|
||||||
|
+ ${nixos-rebuild} boot ${toString (cfg.flags ++ upgradeFlag)}
|
||||||
|
+ booted="$(${readlink} /run/booted-system/{initrd,kernel,kernel-modules})"
|
||||||
|
+ built="$(${readlink} /nix/var/nix/profiles/system/{initrd,kernel,kernel-modules})"
|
||||||
|
+
|
||||||
|
+ ${optionalString (cfg.kexecWindow != null) ''
|
||||||
|
+ current_time="$(${date} +%H:%M)"
|
||||||
|
+
|
||||||
|
+ lower="${cfg.kexecWindow.lower}"
|
||||||
|
+ upper="${cfg.kexecWindow.upper}"
|
||||||
|
+
|
||||||
|
+ if [[ "''${lower}" < "''${upper}" ]]; then
|
||||||
|
+ if [[ "''${current_time}" > "''${lower}" ]] && \
|
||||||
|
+ [[ "''${current_time}" < "''${upper}" ]]; then
|
||||||
|
+ do_kexec="true"
|
||||||
|
+ else
|
||||||
|
+ do_kexec="false"
|
||||||
|
+ fi
|
||||||
|
else
|
||||||
|
- do_reboot="false"
|
||||||
|
+ # lower > upper, so we are crossing midnight (e.g. lower=23h, upper=6h)
|
||||||
|
+ # we want to reboot if cur > 23h or cur < 6h
|
||||||
|
+ if [[ "''${current_time}" < "''${upper}" ]] || \
|
||||||
|
+ [[ "''${current_time}" > "''${lower}" ]]; then
|
||||||
|
+ do_kexec="true"
|
||||||
|
+ else
|
||||||
|
+ do_kexec="false"
|
||||||
|
+ fi
|
||||||
|
fi
|
||||||
|
+ ''}
|
||||||
|
+
|
||||||
|
+ if [ "''${booted}" = "''${built}" ]; then
|
||||||
|
+ ${nixos-rebuild} ${cfg.operation} ${toString cfg.flags}
|
||||||
|
+ ${optionalString (cfg.kexecWindow != null) ''
|
||||||
|
+ elif [ "''${do_kexec}" != true ]; then
|
||||||
|
+ echo "Outside of configured kexec window, skipping."
|
||||||
|
+ ''}
|
||||||
|
else
|
||||||
|
- # lower > upper, so we are crossing midnight (e.g. lower=23h, upper=6h)
|
||||||
|
- # we want to reboot if cur > 23h or cur < 6h
|
||||||
|
- if [[ "''${current_time}" < "''${upper}" ]] || \
|
||||||
|
- [[ "''${current_time}" > "''${lower}" ]]; then
|
||||||
|
- do_reboot="true"
|
||||||
|
- else
|
||||||
|
- do_reboot="false"
|
||||||
|
- fi
|
||||||
|
+ ${systemctl_kexec}
|
||||||
|
fi
|
||||||
|
- ''}
|
||||||
|
-
|
||||||
|
- if [ "''${booted}" = "''${built}" ]; then
|
||||||
|
- ${nixos-rebuild} ${cfg.operation} ${toString cfg.flags}
|
||||||
|
- ${optionalString (cfg.rebootWindow != null) ''
|
||||||
|
- elif [ "''${do_reboot}" != true ]; then
|
||||||
|
- echo "Outside of configured reboot window, skipping."
|
||||||
|
- ''}
|
||||||
|
- else
|
||||||
|
- ${shutdown} -r +1
|
||||||
|
- fi
|
||||||
|
- '' else ''
|
||||||
|
- ${nixos-rebuild} ${cfg.operation} ${toString (cfg.flags ++ upgradeFlag)}
|
||||||
|
- '';
|
||||||
|
+ '' else ''
|
||||||
|
+ ${nixos-rebuild} ${cfg.operation} ${toString (cfg.flags ++ upgradeFlag)}
|
||||||
|
+ '';
|
||||||
|
|
||||||
|
startAt = cfg.dates;
|
||||||
|
|
||||||
BIN
secrets/gitea-runner-registration-token.age
Normal file
BIN
secrets/gitea-runner-registration-token.age
Normal file
Binary file not shown.
@@ -1,8 +1,6 @@
|
|||||||
let
|
let
|
||||||
lib = (import <nixpkgs> { }).lib;
|
lib = (import <nixpkgs> { }).lib;
|
||||||
sshKeys = (import ../common/machine-info/moduleless.nix {
|
sshKeys = (import ../common/machine-info/moduleless.nix { }).machines.ssh;
|
||||||
machinesPath = ../machines;
|
|
||||||
}).machines.ssh;
|
|
||||||
|
|
||||||
# add userkeys to all roles so that I can r/w the secrets from my personal computers
|
# add userkeys to all roles so that I can r/w the secrets from my personal computers
|
||||||
roles = lib.mapAttrs (role: hosts: hosts ++ sshKeys.userKeys) sshKeys.hostKeysByRole;
|
roles = lib.mapAttrs (role: hosts: hosts ++ sshKeys.userKeys) sshKeys.hostKeysByRole;
|
||||||
@@ -20,6 +18,9 @@ with roles;
|
|||||||
"hashed-robots-email-pw.age".publicKeys = email-server;
|
"hashed-robots-email-pw.age".publicKeys = email-server;
|
||||||
"robots-email-pw.age".publicKeys = gitea;
|
"robots-email-pw.age".publicKeys = gitea;
|
||||||
|
|
||||||
|
# gitea
|
||||||
|
"gitea-runner-registration-token.age".publicKeys = gitea-runner;
|
||||||
|
|
||||||
# vpn
|
# vpn
|
||||||
"iodine.age".publicKeys = iodine;
|
"iodine.age".publicKeys = iodine;
|
||||||
"pia-login.age".publicKeys = pia;
|
"pia-login.age".publicKeys = pia;
|
||||||
|
|||||||
Reference in New Issue
Block a user