Skip to content

Instantly share code, notes, and snippets.

@AriRexouium
Last active June 20, 2024 22:55
Show Gist options
  • Save AriRexouium/343ded98fdf5814ce13006ecddcb7b28 to your computer and use it in GitHub Desktop.
Save AriRexouium/343ded98fdf5814ce13006ecddcb7b28 to your computer and use it in GitHub Desktop.
nixos-anywhere
{ modulesPath, config, lib, pkgs, ... }: {
imports = [
(modulesPath + "/installer/scan/not-detected.nix")
(modulesPath + "/profiles/qemu-guest.nix")
./disk-config.nix
];
system.stateVersion = "24.05";
boot.loader.grub = {
efiSupport = true;
efiInstallAsRemovable = true;
};
users.users.root.openssh.authorizedKeys.keys = [
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIJVovMdf6giShd8J+UAkgAkJQ+UxmOK8yj96wmAQXFVr ari@vultr"
];
environment.systemPackages = with pkgs; [
aria
neovim
];
services.openssh.enable = true;
}
# https://github.com/nix-community/nixos-anywhere-examples/blob/9c0b066220ec82974c83c1f86fe39036a9036f80/disk-config.nix
# Example to create a bios compatible gpt partition
{ lib, ... }: {
disko.devices = {
disk.disk1 = {
device = lib.mkDefault "/dev/sda";
type = "disk";
content = {
type = "gpt";
partitions = {
boot = {
name = "boot";
size = "1M";
type = "EF02";
};
esp = {
name = "ESP";
size = "500M";
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 = "btrfs";
extraArgs = [ "-f" ];
subvolumes = {
"@" = {
mountpoint = "/";
mountOptions = [ "compress=zstd" ];
};
"@home" = {
mountpoint = "/home";
mountOptions = [ "compress=zstd" ];
};
"@nix" = {
mountpoint = "/nix";
mountOptions = [ "compress=zstd" "noatime" ];
};
"@swap" = {
mountpoint = "/.swap";
mountOptions = [ "noatime" ];
swap.swapfile.size = lib.mkDefault "8G";
};
};
};
};
};
};
};
};
}
{
"nodes": {
"disko": {
"inputs": {
"nixpkgs": [
"nixpkgs"
]
},
"locked": {
"lastModified": 1718846788,
"narHash": "sha256-9dtXYtEkmXoUJV+PGLqscqF7qTn4AIhAKpFWRFU2NYs=",
"owner": "nix-community",
"repo": "disko",
"rev": "e1174d991944a01eaaa04bc59c6281edca4c0e6e",
"type": "github"
},
"original": {
"owner": "nix-community",
"repo": "disko",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1718717462,
"narHash": "sha256-qddfQLMaWR2gxfEzUM/zFZVK6H1kTv9WBQSBQxbP3MU=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "938aa157bbd6e3c6fd7dcb77998b1f92c2ad1631",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixos-24.05",
"repo": "nixpkgs",
"type": "github"
}
},
"root": {
"inputs": {
"disko": "disko",
"nixpkgs": "nixpkgs"
}
}
},
"root": "root",
"version": 7
}
# https://github.com/nix-community/nixos-anywhere-examples/blob/9c0b066220ec82974c83c1f86fe39036a9036f80/flake.nix
{
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-24.05";
inputs.disko.url = "github:nix-community/disko";
inputs.disko.inputs.nixpkgs.follows = "nixpkgs";
outputs = { nixpkgs, disko, ... }: {
nixosConfigurations.hetzner-cloud = nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
modules = [
{ nix.nixPath = [ "nixpkgs=${nixpkgs}" ]; }
disko.nixosModules.disko
./configuration.nix
];
};
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment