Compare commits
No commits in common. "b63959f307ce6d568ed988901921bd99f726dde6" and "4ff7b8e18fec24c8a2205dcc4ab4d550edd005b1" have entirely different histories.
b63959f307
...
4ff7b8e18f
6 changed files with 128 additions and 121 deletions
|
@ -7,14 +7,7 @@
|
||||||
let
|
let
|
||||||
inherit (lib) nixosSystem;
|
inherit (lib) nixosSystem;
|
||||||
inherit (lib.attrsets) mapAttrs;
|
inherit (lib.attrsets) mapAttrs;
|
||||||
inherit (cfg.lib.modules) forAllUsers';
|
|
||||||
cfg = config.flake;
|
cfg = config.flake;
|
||||||
globalCfg = {
|
|
||||||
useGlobalPkgs = true;
|
|
||||||
useUserPackages = true;
|
|
||||||
sharedModules = [ cfg.modules.homeManager.default ];
|
|
||||||
users = forAllUsers' (name: _: cfg.homes.${name});
|
|
||||||
};
|
|
||||||
hosts = cfg.manifest.hosts or { };
|
hosts = cfg.manifest.hosts or { };
|
||||||
mkConfigurations =
|
mkConfigurations =
|
||||||
class: hosts:
|
class: hosts:
|
||||||
|
@ -22,11 +15,13 @@ let
|
||||||
name: value:
|
name: value:
|
||||||
if class == "nixos" then
|
if class == "nixos" then
|
||||||
nixosSystem {
|
nixosSystem {
|
||||||
specialArgs.hostName = name;
|
specialArgs = {
|
||||||
|
inherit inputs;
|
||||||
|
inherit (cfg) manifest;
|
||||||
|
hostName = name;
|
||||||
|
};
|
||||||
modules = [
|
modules = [
|
||||||
cfg.modules.nixos.default
|
cfg.modules.nixos.default
|
||||||
inputs.home-manager.nixosModules.home-manager
|
|
||||||
{ home-manager = globalCfg; }
|
|
||||||
(value.extraCfg or { })
|
(value.extraCfg or { })
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
@ -35,6 +30,5 @@ let
|
||||||
) hosts;
|
) hosts;
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
imports = [ inputs.home-manager.flakeModules.home-manager ];
|
|
||||||
flake.nixosConfigurations = mkConfigurations "nixos" hosts.nixos;
|
flake.nixosConfigurations = mkConfigurations "nixos" hosts.nixos;
|
||||||
}
|
}
|
||||||
|
|
18
nix/modules/home-manager.nix
Normal file
18
nix/modules/home-manager.nix
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
{ inputs, config, ... }:
|
||||||
|
let
|
||||||
|
inherit (cfg.lib.modules) forAllUsers';
|
||||||
|
cfg = config.flake;
|
||||||
|
hm = inputs.home-manager;
|
||||||
|
globalCfg = {
|
||||||
|
useGlobalPkgs = true;
|
||||||
|
useUserPackages = true;
|
||||||
|
extraSpecialArgs = { inherit (cfg) manifest; };
|
||||||
|
sharedModules = [ cfg.modules.homeManager.default ];
|
||||||
|
users = forAllUsers' (name: _: cfg.homes.${name});
|
||||||
|
};
|
||||||
|
in
|
||||||
|
{
|
||||||
|
imports = [ hm.flakeModules.home-manager ];
|
||||||
|
flake.modules.nixos.default.imports = [ hm.nixosModules.home-manager ];
|
||||||
|
flake.modules.nixos.default.config.home-manager = globalCfg;
|
||||||
|
}
|
|
@ -1,100 +0,0 @@
|
||||||
{
|
|
||||||
config,
|
|
||||||
lib,
|
|
||||||
inputs,
|
|
||||||
...
|
|
||||||
}:
|
|
||||||
let
|
|
||||||
inherit (lib.modules) mkMerge mkIf mkAfter;
|
|
||||||
in
|
|
||||||
{
|
|
||||||
flake.modules.nixos.default =
|
|
||||||
{ hostName, ... }:
|
|
||||||
let
|
|
||||||
inherit (config.flake.manifest.hosts.nixos.${hostName}.machine) root;
|
|
||||||
in
|
|
||||||
{
|
|
||||||
imports = [ inputs.disko.nixosModules.disko ];
|
|
||||||
config = mkMerge [
|
|
||||||
{
|
|
||||||
# BTRFS - may add more later on
|
|
||||||
boot.initrd.kernelModules = [ "dm-snapshot" ];
|
|
||||||
disko.devices.disk.main = {
|
|
||||||
device = root.drive;
|
|
||||||
content.type = "gpt";
|
|
||||||
content.partitions = {
|
|
||||||
boot = {
|
|
||||||
name = "boot";
|
|
||||||
size = "1M";
|
|
||||||
type = "EF02";
|
|
||||||
};
|
|
||||||
esp = {
|
|
||||||
name = "ESP";
|
|
||||||
size = "500M";
|
|
||||||
type = "EF00";
|
|
||||||
content = {
|
|
||||||
type = "filesystem";
|
|
||||||
format = "vfat";
|
|
||||||
mountpoint = "/boot";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
swap = {
|
|
||||||
size = "4G";
|
|
||||||
content = {
|
|
||||||
type = "swap";
|
|
||||||
resumeDevice = true;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
root = {
|
|
||||||
name = "root";
|
|
||||||
size = "100%";
|
|
||||||
content = {
|
|
||||||
type = "lvm_pv";
|
|
||||||
vg = "root_vg";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
disko.devices.lvm_vg.root_vg = {
|
|
||||||
type = "lvm_vg";
|
|
||||||
lvs.root = {
|
|
||||||
size = "100%FREE";
|
|
||||||
content = {
|
|
||||||
type = "btrfs";
|
|
||||||
extraArgs = [ "-f" ];
|
|
||||||
subvolumes = {
|
|
||||||
"/root".mountpoint = "/";
|
|
||||||
"/persist" = {
|
|
||||||
mountpoint = "/persist";
|
|
||||||
mountOptions = [
|
|
||||||
"subvol=persist"
|
|
||||||
"noatime"
|
|
||||||
];
|
|
||||||
};
|
|
||||||
"/nix" = {
|
|
||||||
mountpoint = "/nix";
|
|
||||||
mountOptions = [
|
|
||||||
"subvol=nix"
|
|
||||||
"noatime"
|
|
||||||
];
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
}
|
|
||||||
# Ephemeral by default - assumes btrfs
|
|
||||||
(mkIf (config.flake.manifest.hosts.nixos.${hostName}.machine.root.ephemeral or true) {
|
|
||||||
boot.initrd.postDeviceCommands = mkAfter ''
|
|
||||||
mkdir /btrfs_tmp
|
|
||||||
mount /dev/root_vg/root /btrfs_tmp
|
|
||||||
|
|
||||||
if [[ -e /btrfs_tmp/root ]]; then
|
|
||||||
btrfs subvolume delete "/btrfs_tmp/root"
|
|
||||||
fi
|
|
||||||
'';
|
|
||||||
})
|
|
||||||
];
|
|
||||||
};
|
|
||||||
}
|
|
75
nix/modules/machine/root/drive.nix
Normal file
75
nix/modules/machine/root/drive.nix
Normal file
|
@ -0,0 +1,75 @@
|
||||||
|
{ config, inputs, ... }:
|
||||||
|
{
|
||||||
|
flake.modules.nixos.default =
|
||||||
|
{ hostName, ... }:
|
||||||
|
{
|
||||||
|
imports = [ inputs.disko.nixosModules.disko ];
|
||||||
|
boot.initrd.kernelModules = [ "dm-snapshot" ];
|
||||||
|
# BTRFS - may add more later on
|
||||||
|
disko.devices.disk.main = {
|
||||||
|
device = config.flake.manifest.hosts.nixos.${hostName}.machine.root.drive;
|
||||||
|
type = "disk";
|
||||||
|
content.type = "gpt";
|
||||||
|
content.partitions = {
|
||||||
|
boot = {
|
||||||
|
name = "boot";
|
||||||
|
size = "1M";
|
||||||
|
type = "EF02";
|
||||||
|
};
|
||||||
|
esp = {
|
||||||
|
name = "ESP";
|
||||||
|
size = "500M";
|
||||||
|
type = "EF00";
|
||||||
|
content = {
|
||||||
|
type = "filesystem";
|
||||||
|
format = "vfat";
|
||||||
|
mountpoint = "/boot";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
swap = {
|
||||||
|
size = "4G";
|
||||||
|
content = {
|
||||||
|
type = "swap";
|
||||||
|
resumeDevice = true;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
root = {
|
||||||
|
name = "root";
|
||||||
|
size = "100%";
|
||||||
|
content = {
|
||||||
|
type = "lvm_pv";
|
||||||
|
vg = "root_vg";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
disko.devices.lvm_vg.root_vg = {
|
||||||
|
type = "lvm_vg";
|
||||||
|
lvs.root = {
|
||||||
|
size = "100%FREE";
|
||||||
|
content = {
|
||||||
|
type = "btrfs";
|
||||||
|
extraArgs = [ "-f" ];
|
||||||
|
subvolumes = {
|
||||||
|
"/root".mountpoint = "/";
|
||||||
|
"/persist" = {
|
||||||
|
mountpoint = "/persist";
|
||||||
|
mountOptions = [
|
||||||
|
"subvol=persist"
|
||||||
|
"noatime"
|
||||||
|
];
|
||||||
|
};
|
||||||
|
"/nix" = {
|
||||||
|
mountpoint = "/nix";
|
||||||
|
mountOptions = [
|
||||||
|
"subvol=nix"
|
||||||
|
"noatime"
|
||||||
|
];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
30
nix/modules/machine/root/ephemeral.nix
Normal file
30
nix/modules/machine/root/ephemeral.nix
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
{ config, lib, ... }:
|
||||||
|
let
|
||||||
|
inherit (lib.modules) mkMerge mkIf mkAfter;
|
||||||
|
in
|
||||||
|
{
|
||||||
|
flake.modules.nixos.default =
|
||||||
|
{ hostName, ... }:
|
||||||
|
{
|
||||||
|
config = mkMerge [
|
||||||
|
# Ephemeral by default - assumes btrfs
|
||||||
|
(mkIf (config.flake.manifest.hosts.nixos.${hostName}.machine.root.ephemeral or true) {
|
||||||
|
boot.initrd.postDeviceCommands = mkAfter ''
|
||||||
|
mkdir /btrfs_tmp
|
||||||
|
mount /dev/root_vg/root /btrfs_tmp
|
||||||
|
|
||||||
|
if [[ -e /btrfs_tmp/root ]]; then
|
||||||
|
btrfs subvolume delete "/btrfs_tmp/root"
|
||||||
|
fi
|
||||||
|
'';
|
||||||
|
persistFiles = [
|
||||||
|
#TODO: move to ssh config
|
||||||
|
"/etc/ssh/ssh_host_ed25519_key"
|
||||||
|
"/etc/ssh/ssh_host_ed25519_key.pub"
|
||||||
|
"/etc/ssh/ssh_host_rsa_key"
|
||||||
|
"/etc/ssh/ssh_host_rsa_key.pub"
|
||||||
|
];
|
||||||
|
})
|
||||||
|
];
|
||||||
|
};
|
||||||
|
}
|
|
@ -1,10 +0,0 @@
|
||||||
{
|
|
||||||
flake.modules.nixos.default = {
|
|
||||||
persistFiles = [
|
|
||||||
"/etc/ssh/ssh_host_ed25519_key"
|
|
||||||
"/etc/ssh/ssh_host_ed25519_key.pub"
|
|
||||||
"/etc/ssh/ssh_host_rsa_key"
|
|
||||||
"/etc/ssh/ssh_host_rsa_key.pub"
|
|
||||||
];
|
|
||||||
};
|
|
||||||
}
|
|
Loading…
Add table
Add a link
Reference in a new issue