Created
April 21, 2023 14:46
-
-
Save voidus/00faa6dfa826e770a99d6c03cea39a85 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
description = "A basic nixos cloudinit image"; | |
inputs = { | |
nixpkgs.url = "github:nixos/nixpkgs"; | |
}; | |
outputs = { self, nixpkgs }: | |
let | |
system = "x86_64-linux"; | |
pkgs = nixpkgs.legacyPackages.${system}; | |
inherit (pkgs) lib; | |
baseModule = { lib, config, pkgs, ...}: { | |
nixpkgs.hostPlatform = "x86_64-linux"; | |
networking = { | |
hostName = "nixos-cloudinit"; | |
}; | |
fileSystems."/" = { | |
label = "nixos"; | |
fsType = "ext4"; | |
autoFormat = true; | |
}; | |
boot.loader.grub.device = "/dev/vda"; | |
services.cloud-init = { | |
enable = true; | |
config = '' | |
system_info: | |
distro: nixos | |
network: | |
renderers: [ 'networkd' ] | |
default_user: | |
name: ops | |
lock_passwd: true | |
groups: [wheel] | |
sudo: ["ALL=(ALL) NOPASSWD:ALL"] | |
shell: /bin/sh | |
users: | |
- default | |
preserve_hostname: false | |
ssh_pwauth: false | |
chpasswd: | |
expire: false | |
cloud_init_modules: | |
- migrator | |
- seed_random | |
- bootcmd | |
- write-files | |
- growpart | |
- resizefs | |
- update_hostname | |
- resolv_conf | |
- ca-certs | |
- rsyslog | |
- users-groups | |
cloud_config_modules: | |
- disk_setup | |
- mounts | |
- ssh-import-id | |
- set-passwords | |
- timezone | |
- disable-ec2-metadata | |
- runcmd | |
- ssh | |
cloud_final_modules: | |
- rightscale_userdata | |
- scripts-vendor | |
- scripts-per-once | |
- scripts-per-boot | |
- scripts-per-instance | |
- scripts-user | |
- ssh-authkey-fingerprints | |
- keys-to-console | |
- phone-home | |
- final-message | |
- power-state-change | |
''; | |
}; | |
services.openssh.enable = true; | |
}; | |
nixos = nixpkgs.lib.nixosSystem { | |
modules = [baseModule]; | |
}; | |
make-disk-image = import "${nixpkgs}/nixos/lib/make-disk-image.nix"; | |
in { | |
inherit pkgs; | |
image = make-disk-image { | |
inherit pkgs lib; | |
config = nixos.config; | |
name = "nixos-cloudinit"; | |
format = "qcow2-compressed"; | |
copyChannel = false; | |
}; | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment