Skip to content

Commit

Permalink
hcloud: add base image GENERATE_IMAGE.md
Browse files Browse the repository at this point in the history
  • Loading branch information
mkg20001 committed Apr 2, 2024
1 parent 9e45ba8 commit 63b1001
Show file tree
Hide file tree
Showing 5 changed files with 107 additions and 4 deletions.
21 changes: 21 additions & 0 deletions GENERATE_IMAGE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Hcloud

- Create new VM:
- location: falkenstein
- image: ubuntu 22.04
- type: shared x86
- use smallest node type (first in list)
- networking: v4 + v6
- ssh keys: pick your own
- name: nixos-image
- copy ipv4
- run:

```
nix run github:nix-community/nixos-anywhere -- --no-reboot --flake .#hcloud root@IPV4
```

- wait until finished
- shutdown machine
- create snapshot, nixos-base-image
- delete machine
27 changes: 24 additions & 3 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 17 additions & 1 deletion flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@
inputs.nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable";
inputs.nix-unify.url = "github:mgit-at/nix-unify/master";
inputs.nix-unify.inputs.nixpkgs.follows = "nixpkgs";
inputs.disko.url = "github:nix-community/disko";
inputs.disko.inputs.nixpkgs.follows = "nixpkgs";

outputs = { self, nixpkgs, nix-unify }@inputs: with nixpkgs.lib; let
outputs = { self, nixpkgs, nix-unify, disko }@inputs: with nixpkgs.lib; let
supportedSystems = [ "x86_64-linux" "aarch64-linux" ];
forAllSystems = f: nixpkgs.lib.genAttrs supportedSystems (system: f system);
in {
Expand Down Expand Up @@ -100,5 +102,19 @@
ansibleDevShell = pkgs.mkAnsibleDevShell {};
}
);

nixosConfigurations.hcloud = inputs.nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
specialArgs.inputs = inputs;
modules = self.nixosModules.default ++ [
./os/hcloud/configuration.nix
({
users.users.root.password = "mgitsetup";
services.openssh.settings.PermitRootLogin = "yes";
nixpkgs.overlays = [ self.overlays.default ];
networking.useDHCP = nixpkgs.lib.mkForce true;
})
];
};
};
}
18 changes: 18 additions & 0 deletions os/hcloud/configuration.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{ inputs, modulesPath, ... }:
{
imports = [
(modulesPath + "/profiles/qemu-guest.nix")

inputs.disko.nixosModules.disko
./disko.nix
({
_module.args.disks = [ "/dev/sda" ];
})
];

# boot.loader.grub.device = "/dev/sda";
boot.initrd.availableKernelModules = [ "ata_piix" "uhci_hcd" "xen_blkfront" "vmw_pvscsi" ];
boot.initrd.kernelModules = [ "nvme" ];

boot.cleanTmpDir = true;
}
27 changes: 27 additions & 0 deletions os/hcloud/disko.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
disko.devices = {
disk = {
main = {
type = "disk";
device = "/dev/sda";
content = {
type = "gpt";
partitions = {
boot = {
size = "1M";
type = "EF02"; # for grub MBR
};
root = {
size = "100%";
content = {
type = "filesystem";
format = "ext4";
mountpoint = "/";
};
};
};
};
};
};
};
}

0 comments on commit 63b1001

Please sign in to comment.