From dd8b23f5a9f7d1663c16f6d5dd6e98fd9cf579f8 Mon Sep 17 00:00:00 2001 From: Pim Kunis Date: Mon, 13 Nov 2023 22:44:43 +0100 Subject: [PATCH] initial nixos-anywhere --- README.md | 4 +++ configuration.nix | 2 +- disk-config.nix | 55 ++++++++++++++++++++++++++++++++++++++ flake.nix | 6 +++-- hardware-configuration.nix | 20 +++++++------- 5 files changed, 74 insertions(+), 13 deletions(-) create mode 100644 disk-config.nix diff --git a/README.md b/README.md index b939dd7..0c6ba9b 100644 --- a/README.md +++ b/README.md @@ -5,6 +5,10 @@ Currently, only one physical server (named jefke) is implemented. ## Deployment +### NEW + +`nix run github:numtide/nixos-anywhere -- --flake .#hypervisor root@jefke.hyp` + ### Prerequisites Before a NixOS definition can be deployed, some prerequite preparational steps must be performed. diff --git a/configuration.nix b/configuration.nix index 47e479c..0758029 100644 --- a/configuration.nix +++ b/configuration.nix @@ -1,5 +1,5 @@ { pkgs, ... }: { - imports = [ ./hardware-configuration.nix ]; + imports = [ ./hardware-configuration.nix ./disk-config.nix ]; boot.loader = { systemd-boot.enable = true; diff --git a/disk-config.nix b/disk-config.nix new file mode 100644 index 0000000..19ed6a6 --- /dev/null +++ b/disk-config.nix @@ -0,0 +1,55 @@ +# Running system: + +# NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS +# nvme0n1 259:0 0 465,8G 0 disk +# ├─nvme0n1p1 259:1 0 512M 0 part /boot +# ├─nvme0n1p2 259:2 0 456,5G 0 part /nix/store +# │ / +# └─nvme0n1p3 259:3 0 8,8G 0 part [SWAP] + +# Filesystem 1K-blocks Used Available Use% Mounted on +# devtmpfs 809892 0 809892 0% /dev +# tmpfs 8098920 0 8098920 0% /dev/shm +# tmpfs 4049460 3988 4045472 1% /run +# tmpfs 8098920 456 8098464 1% /run/wrappers +# /dev/nvme0n1p2 469995160 17597168 428450100 4% / +# /dev/nvme0n1p1 523248 119660 403588 23% /boot +# tmpfs 1619784 0 1619784 0% /run/user/0 + +# Disk name: nvme0n1 +# disko template: simple-efi +# https://raw.githubusercontent.com/nix-community/disko/master/example/simple-efi.nix + +{ + disko.devices = { + disk = { + vdb = { + device = "/dev/nvme0n1"; + type = "disk"; + content = { + type = "gpt"; + partitions = { + ESP = { + type = "EF00"; + size = "500M"; + content = { + type = "filesystem"; + format = "vfat"; + mountpoint = "/boot"; + }; + }; + root = { + size = "100%"; + content = { + type = "filesystem"; + format = "ext4"; + mountpoint = "/"; + }; + }; + }; + }; + }; + }; + }; +} + diff --git a/flake.nix b/flake.nix index b1143c8..2a4f509 100644 --- a/flake.nix +++ b/flake.nix @@ -4,9 +4,11 @@ inputs = { nixpkgs.url = "github:nixos/nixpkgs/nixos-23.05"; deploy-rs.url = "github:serokell/deploy-rs"; + disko.url = "github:nix-community/disko"; + disko.inputs.nixpkgs.follows = "nixpkgs"; }; - outputs = { self, nixpkgs, deploy-rs, ... }: + outputs = { self, nixpkgs, deploy-rs, disko, ... }: let system = "x86_64-linux"; in { @@ -14,7 +16,7 @@ nixosConfigurations.hypervisor = nixpkgs.lib.nixosSystem { inherit system; - modules = [ ./configuration.nix ]; + modules = [ disko.nixosModules.disko ./configuration.nix ]; }; deploy = { diff --git a/hardware-configuration.nix b/hardware-configuration.nix index 37e8dd0..56e0248 100644 --- a/hardware-configuration.nix +++ b/hardware-configuration.nix @@ -7,18 +7,18 @@ boot.kernelModules = [ "kvm-intel" ]; boot.extraModulePackages = [ ]; - fileSystems."/" = { - device = "/dev/disk/by-uuid/b78f591c-c9b6-4dae-9837-56716d38990b"; - fsType = "ext4"; - }; + # fileSystems."/" = { + # device = "/dev/disk/by-uuid/b78f591c-c9b6-4dae-9837-56716d38990b"; + # fsType = "ext4"; + # }; - fileSystems."/boot" = { - device = "/dev/disk/by-uuid/6936-84C2"; - fsType = "vfat"; - }; + # fileSystems."/boot" = { + # device = "/dev/disk/by-uuid/6936-84C2"; + # fsType = "vfat"; + # }; - swapDevices = - [{ device = "/dev/disk/by-uuid/79fbd322-e58d-4e45-8969-06ef494cefea"; }]; + # swapDevices = + # [{ device = "/dev/disk/by-uuid/79fbd322-e58d-4e45-8969-06ef494cefea"; }]; networking.useDHCP = false;