mirror of
https://github.com/Swarsel/.dotfiles.git
synced 2025-12-06 09:07:21 +01:00
feat: build configurations dynamically for arch
This commit is contained in:
parent
d187cdf35f
commit
c3b8102546
45 changed files with 289 additions and 210 deletions
53
hosts/nixos/x86_64-linux/hotel/default.nix
Normal file
53
hosts/nixos/x86_64-linux/hotel/default.nix
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
{ self, config, pkgs, lib, minimal, ... }:
|
||||
let
|
||||
mainUser = "demo";
|
||||
in
|
||||
{
|
||||
|
||||
imports = [
|
||||
./hardware-configuration.nix
|
||||
./disk-config.nix
|
||||
{
|
||||
_module.args.diskDevice = config.swarselsystems.rootDisk;
|
||||
}
|
||||
];
|
||||
|
||||
environment.variables = {
|
||||
WLR_RENDERER_ALLOW_SOFTWARE = 1;
|
||||
};
|
||||
|
||||
services.qemuGuest.enable = true;
|
||||
|
||||
boot = {
|
||||
loader.systemd-boot.enable = lib.mkForce true;
|
||||
loader.efi.canTouchEfiVariables = true;
|
||||
kernelPackages = lib.mkDefault pkgs.linuxPackages_latest;
|
||||
};
|
||||
|
||||
networking = {
|
||||
hostName = "hotel";
|
||||
firewall.enable = true;
|
||||
};
|
||||
|
||||
swarselsystems = {
|
||||
info = "~SwarselSystems~ demo host";
|
||||
wallpaper = self + /files/wallpaper/lenovowp.png;
|
||||
isImpermanence = true;
|
||||
isCrypted = true;
|
||||
isSecureBoot = false;
|
||||
isSwap = true;
|
||||
swapSize = "4G";
|
||||
rootDisk = "/dev/vda";
|
||||
isBtrfs = false;
|
||||
inherit mainUser;
|
||||
isLinux = true;
|
||||
isPublic = true;
|
||||
isNixos = true;
|
||||
};
|
||||
|
||||
} // lib.optionalAttrs (!minimal) {
|
||||
swarselprofiles = {
|
||||
hotel = true;
|
||||
minimal = true;
|
||||
};
|
||||
}
|
||||
128
hosts/nixos/x86_64-linux/hotel/disk-config.nix
Normal file
128
hosts/nixos/x86_64-linux/hotel/disk-config.nix
Normal file
|
|
@ -0,0 +1,128 @@
|
|||
# NOTE: ... is needed because dikso passes diskoFile
|
||||
{ lib
|
||||
, pkgs
|
||||
, config
|
||||
, diskDevice ? config.swarselsystem.rootDisk
|
||||
, ...
|
||||
}:
|
||||
let
|
||||
type = "btrfs";
|
||||
extraArgs = [ "-L" "nixos" "-f" ]; # force overwrite
|
||||
subvolumes = {
|
||||
"/root" = {
|
||||
mountpoint = "/";
|
||||
mountOptions = [
|
||||
"subvol=root"
|
||||
"compress=zstd"
|
||||
"noatime"
|
||||
];
|
||||
};
|
||||
"/home" = lib.mkIf config.swarselsystems.isImpermanence {
|
||||
mountpoint = "/home";
|
||||
mountOptions = [
|
||||
"subvol=home"
|
||||
"compress=zstd"
|
||||
"noatime"
|
||||
];
|
||||
};
|
||||
"/persist" = lib.mkIf config.swarselsystems.isImpermanence {
|
||||
mountpoint = "/persist";
|
||||
mountOptions = [
|
||||
"subvol=persist"
|
||||
"compress=zstd"
|
||||
"noatime"
|
||||
];
|
||||
};
|
||||
"/log" = lib.mkIf config.swarselsystems.isImpermanence {
|
||||
mountpoint = "/var/log";
|
||||
mountOptions = [
|
||||
"subvol=log"
|
||||
"compress=zstd"
|
||||
"noatime"
|
||||
];
|
||||
};
|
||||
"/nix" = {
|
||||
mountpoint = "/nix";
|
||||
mountOptions = [
|
||||
"subvol=nix"
|
||||
"compress=zstd"
|
||||
"noatime"
|
||||
];
|
||||
};
|
||||
"/swap" = lib.mkIf config.swarselsystems.isSwap {
|
||||
mountpoint = "/.swapvol";
|
||||
swap.swapfile.size = config.swarselsystems.swapSize;
|
||||
};
|
||||
};
|
||||
in
|
||||
{
|
||||
disko.devices = {
|
||||
disk = {
|
||||
disk0 = {
|
||||
type = "disk";
|
||||
device = diskDevice;
|
||||
content = {
|
||||
type = "gpt";
|
||||
partitions = {
|
||||
ESP = {
|
||||
priority = 1;
|
||||
name = "ESP";
|
||||
size = "512M";
|
||||
type = "EF00";
|
||||
content = {
|
||||
type = "filesystem";
|
||||
format = "vfat";
|
||||
mountpoint = "/boot";
|
||||
mountOptions = [ "defaults" ];
|
||||
};
|
||||
};
|
||||
root = lib.mkIf (!config.swarselsystems.isCrypted) {
|
||||
size = "100%";
|
||||
content = {
|
||||
inherit type subvolumes extraArgs;
|
||||
postCreateHook = lib.mkIf config.swarselsystems.isImpermanence ''
|
||||
MNTPOINT=$(mktemp -d)
|
||||
mount "/dev/disk/by-label/nixos" "$MNTPOINT" -o subvolid=5
|
||||
trap 'umount $MNTPOINT; rm -rf $MNTPOINT' EXIT
|
||||
btrfs subvolume snapshot -r $MNTPOINT/root $MNTPOINT/root-blank
|
||||
'';
|
||||
};
|
||||
};
|
||||
luks = lib.mkIf config.swarselsystems.isCrypted {
|
||||
size = "100%";
|
||||
content = {
|
||||
type = "luks";
|
||||
name = "cryptroot";
|
||||
passwordFile = "/tmp/disko-password"; # this is populated by bootstrap.sh
|
||||
settings = {
|
||||
allowDiscards = true;
|
||||
# https://github.com/hmajid2301/dotfiles/blob/a0b511c79b11d9b4afe2a5e2b7eedb2af23e288f/systems/x86_64-linux/framework/disks.nix#L36
|
||||
crypttabExtraOpts = [
|
||||
"fido2-device=auto"
|
||||
"token-timeout=10"
|
||||
];
|
||||
};
|
||||
content = {
|
||||
inherit type subvolumes extraArgs;
|
||||
postCreateHook = lib.mkIf config.swarselsystems.isImpermanence ''
|
||||
MNTPOINT=$(mktemp -d)
|
||||
mount "/dev/mapper/cryptroot" "$MNTPOINT" -o subvolid=5
|
||||
trap 'umount $MNTPOINT; rm -rf $MNTPOINT' EXIT
|
||||
btrfs subvolume snapshot -r $MNTPOINT/root $MNTPOINT/root-blank
|
||||
'';
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
fileSystems."/persist".neededForBoot = lib.mkIf config.swarselsystems.isImpermanence true;
|
||||
fileSystems."/home".neededForBoot = lib.mkIf config.swarselsystems.isImpermanence true;
|
||||
|
||||
environment.systemPackages = [
|
||||
pkgs.yubikey-manager
|
||||
];
|
||||
}
|
||||
29
hosts/nixos/x86_64-linux/hotel/hardware-configuration.nix
Normal file
29
hosts/nixos/x86_64-linux/hotel/hardware-configuration.nix
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
# Do not modify this file! It was generated by ‘nixos-generate-config’
|
||||
# and may be overwritten by future invocations. Please make changes
|
||||
# to /etc/nixos/configuration.nix instead.
|
||||
{ lib, modulesPath, ... }:
|
||||
|
||||
{
|
||||
imports =
|
||||
[
|
||||
(modulesPath + "/profiles/qemu-guest.nix")
|
||||
];
|
||||
|
||||
boot = {
|
||||
initrd.availableKernelModules = [ "ahci" "xhci_pci" "virtio_pci" "sr_mod" "virtio_blk" ];
|
||||
initrd.kernelModules = [ ];
|
||||
kernelModules = [ "kvm-amd" ];
|
||||
extraModulePackages = [ ];
|
||||
};
|
||||
|
||||
swapDevices = [ ];
|
||||
|
||||
# Enables DHCP on each ethernet and wireless interface. In case of scripted networking
|
||||
# (the default) this is the recommended approach. When using systemd-networkd it's
|
||||
# still possible to use this option, but it's recommended to use it in conjunction
|
||||
# with explicit per-interface declarations with `networking.interfaces.<interface>.useDHCP`.
|
||||
networking.useDHCP = lib.mkDefault true;
|
||||
# networking.interfaces.enp1s0.useDHCP = lib.mkDefault true;
|
||||
|
||||
nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux";
|
||||
}
|
||||
2
hosts/nixos/x86_64-linux/hotel/options-home.nix
Normal file
2
hosts/nixos/x86_64-linux/hotel/options-home.nix
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
_:
|
||||
{ }
|
||||
2
hosts/nixos/x86_64-linux/hotel/options.nix
Normal file
2
hosts/nixos/x86_64-linux/hotel/options.nix
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
_:
|
||||
{ }
|
||||
Loading…
Add table
Add a link
Reference in a new issue