Initial commit
This commit is contained in:
commit
c153851ba4
3 changed files with 169 additions and 0 deletions
31
configuration.nix
Normal file
31
configuration.nix
Normal file
|
@ -0,0 +1,31 @@
|
|||
{
|
||||
modulesPath,
|
||||
lib,
|
||||
pkgs,
|
||||
...
|
||||
}:
|
||||
{
|
||||
imports = [
|
||||
(modulesPath + "/installer/scan/not-detected.nix")
|
||||
(modulesPath + "/profiles/qemu-guest.nix")
|
||||
./disk-config.nix
|
||||
];
|
||||
boot.loader.grub = {
|
||||
# no need to set devices, disko will add all devices that have a EF02 partition to the list already
|
||||
# devices = [ ];
|
||||
efiSupport = true;
|
||||
efiInstallAsRemovable = true;
|
||||
};
|
||||
services.openssh.enable = true;
|
||||
|
||||
environment.systemPackages = map lib.lowPrio [
|
||||
pkgs.curl
|
||||
pkgs.gitMinimal
|
||||
];
|
||||
|
||||
users.users.root.openssh.authorizedKeys.keys = [
|
||||
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIHDuOIycRP7Ney136ro/doWj1kttJUqmbGz6OC2nia09 michael.huebner@ptspaper.de"
|
||||
];
|
||||
|
||||
system.stateVersion = "24.05";
|
||||
}
|
57
disk-config.nix
Normal file
57
disk-config.nix
Normal file
|
@ -0,0 +1,57 @@
|
|||
# Example to create a bios compatible gpt partition
|
||||
{ lib, ... }:
|
||||
{
|
||||
disko.devices = {
|
||||
disk.disk1 = {
|
||||
device = lib.mkDefault "/dev/nvme0n1";
|
||||
type = "disk";
|
||||
content = {
|
||||
type = "gpt";
|
||||
partitions = {
|
||||
boot = {
|
||||
name = "boot";
|
||||
size = "1M";
|
||||
type = "EF02";
|
||||
};
|
||||
esp = {
|
||||
name = "ESP";
|
||||
size = "1G";
|
||||
type = "EF00";
|
||||
content = {
|
||||
type = "filesystem";
|
||||
format = "vfat";
|
||||
mountpoint = "/boot";
|
||||
};
|
||||
};
|
||||
root = {
|
||||
name = "root";
|
||||
size = "100%";
|
||||
content = {
|
||||
type = "lvm_pv";
|
||||
vg = "pool";
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
lvm_vg = {
|
||||
pool = {
|
||||
type = "lvm_vg";
|
||||
lvs = {
|
||||
root = {
|
||||
size = "100%FREE";
|
||||
content = {
|
||||
type = "filesystem";
|
||||
format = "ext4";
|
||||
mountpoint = "/";
|
||||
mountOptions = [
|
||||
"defaults"
|
||||
];
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
|
81
flake.nix
Normal file
81
flake.nix
Normal file
|
@ -0,0 +1,81 @@
|
|||
{
|
||||
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
|
||||
inputs.disko.url = "github:nix-community/disko";
|
||||
inputs.disko.inputs.nixpkgs.follows = "nixpkgs";
|
||||
inputs.nixos-facter-modules.url = "github:numtide/nixos-facter-modules";
|
||||
|
||||
outputs =
|
||||
{
|
||||
nixpkgs,
|
||||
disko,
|
||||
nixos-facter-modules,
|
||||
...
|
||||
}:
|
||||
{
|
||||
nixosConfigurations.hetzner-cloud = nixpkgs.lib.nixosSystem {
|
||||
system = "x86_64-linux";
|
||||
modules = [
|
||||
disko.nixosModules.disko
|
||||
./configuration.nix
|
||||
];
|
||||
};
|
||||
# tested with 2GB/2CPU droplet, 1GB droplets do not have enough RAM for kexec
|
||||
nixosConfigurations.digitalocean = nixpkgs.lib.nixosSystem {
|
||||
system = "x86_64-linux";
|
||||
modules = [
|
||||
disko.nixosModules.disko
|
||||
{ disko.devices.disk.disk1.device = "/dev/vda"; }
|
||||
{
|
||||
# do not use DHCP, as DigitalOcean provisions IPs using cloud-init
|
||||
networking.useDHCP = nixpkgs.lib.mkForce false;
|
||||
|
||||
services.cloud-init = {
|
||||
enable = true;
|
||||
network.enable = true;
|
||||
settings = {
|
||||
datasource_list = [ "ConfigDrive" ];
|
||||
datasource.ConfigDrive = { };
|
||||
};
|
||||
};
|
||||
}
|
||||
./configuration.nix
|
||||
];
|
||||
};
|
||||
nixosConfigurations.hetzner-cloud-aarch64 = nixpkgs.lib.nixosSystem {
|
||||
system = "aarch64-linux";
|
||||
modules = [
|
||||
disko.nixosModules.disko
|
||||
./configuration.nix
|
||||
];
|
||||
};
|
||||
|
||||
# Use this for all other targets
|
||||
# nixos-anywhere --flake .#generic --generate-hardware-config nixos-generate-config ./hardware-configuration.nix <hostname>
|
||||
nixosConfigurations.generic = nixpkgs.lib.nixosSystem {
|
||||
system = "x86_64-linux";
|
||||
modules = [
|
||||
disko.nixosModules.disko
|
||||
./configuration.nix
|
||||
./hardware-configuration.nix
|
||||
];
|
||||
};
|
||||
|
||||
# Slightly experimental: Like generic, but with nixos-facter (https://github.com/numtide/nixos-facter)
|
||||
# nixos-anywhere --flake .#generic-nixos-facter --generate-hardware-config nixos-facter facter.json <hostname>
|
||||
nixosConfigurations.generic-nixos-facter = nixpkgs.lib.nixosSystem {
|
||||
system = "x86_64-linux";
|
||||
modules = [
|
||||
disko.nixosModules.disko
|
||||
./configuration.nix
|
||||
nixos-facter-modules.nixosModules.facter
|
||||
{
|
||||
config.facter.reportPath =
|
||||
if builtins.pathExists ./facter.json then
|
||||
./facter.json
|
||||
else
|
||||
throw "Have you forgotten to run nixos-anywhere with `--generate-hardware-config nixos-facter ./facter.json`?";
|
||||
}
|
||||
];
|
||||
};
|
||||
};
|
||||
}
|
Loading…
Reference in a new issue