Skip to content

Instantly share code, notes, and snippets.

@LnL7

LnL7/mkimage.nix Secret

Last active April 3, 2018 20:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save LnL7/b2e1ca26de142514ea2f541716e0ee9c to your computer and use it in GitHub Desktop.
Save LnL7/b2e1ca26de142514ea2f541716e0ee9c to your computer and use it in GitHub Desktop.
with (import <nixpkgs> {}).pkgs;
let
key = "ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAtq8LpgrnFQWpIcK5YdrQNzu22sPrbkHKD83g8v/s7Nu3Omb7h5TLBOZ6DYPSorGMKGjDFqo0witXRagWq95HaA9epFXmhJlO3NTxyTAzIZSzql+oJkqszNpmYY09L00EIplE/YKXPlY2a+sGx3CdJxbglGfTcqf0J2DW4wO2ikZSOXRiLEbztyDwc+TNwYJ3WtzTFWhG/9hbbHGZtpwQl6X5l5d2Mhl2tlKJ/zQYWV1CVXLSyKhkb4cQPkL05enguCQgijuI/WsUE6pqdl4ypziXGjlHAfH+zO06s6EDMQYr50xgYRuCBicF86GF8/fOuDJS5CJ8/FWr16fiWLa2Aw== tom@leto";
config = (import <nixpkgs/nixos> { configuration = {
fileSystems."/".device = "/dev/disk/by-label/nixos";
boot.loader.grub.device = "/dev/sda";
users.users.root = {
openssh.authorizedKeys.keys = [ key ];
};
users.extraUsers.tom = {
description = "tom";
createHome = true;
useDefaultShell = true;
home = "/home/tom";
password = "tom";
extraGroups = [ "wheel" ];
openssh.authorizedKeys.keys = [ key ];
};
services.openssh.enable = true;
networking.networkmanager = {
enable = true;
insertNameservers = [ "8.8.8.8" ];
};
};
}).config;
in
import <nixpkgs/nixos/lib/make-disk-image.nix> {
inherit config pkgs lib;
partitioned = true;
diskSize = 2048;
format = "qcow2";
configFile = pkgs.writeText "configuration.nix" ''
# nothing
'';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment