Move from ISO to Nix Qemu vms
This commit is contained in:
parent
bce6cfad0f
commit
61da988c22
1
.gitignore
vendored
1
.gitignore
vendored
@ -1 +1,2 @@
|
||||
result
|
||||
*.qcow2
|
||||
|
33
README.md
33
README.md
@ -1,7 +1,32 @@
|
||||
# build
|
||||
# Nix app vms
|
||||
|
||||
$ nix-build '<nixpkgs/nixos>' -A config.system.build.isoImage -I nixos-config=chromium.nix
|
||||
## Install Nix package manager
|
||||
|
||||
# run
|
||||
$ su -c 'mkdir -m 0755 /nix && chown user /nix'
|
||||
$ curl https://nixos.org/nix/install | sh
|
||||
|
||||
## Create VM
|
||||
|
||||
$ NIX_PATH=$NIX_PATH:. nix-build '<nixpkgs/nixos>' -A config.system.build.vm -I nixos-config=chromium.nix
|
||||
$ ln -s
|
||||
these derivations will be built:
|
||||
/nix/store/alsxfss45f61015qk0fi147iidl3hj7h-system-path.drv
|
||||
/nix/store/y4r9v7x4wh2pa1slrv0jw97bzax19ssv-dbus-1.drv
|
||||
...
|
||||
these paths will be fetched (80.31 MiB download, 341.86 MiB unpacked):
|
||||
/nix/store/2bqrxp8j4ax2ka5car249bb8jdnh3rvm-adwaita-icon-theme-3.28.0
|
||||
/nix/store/rrxkl46g4dc8140ykh9i0clswvfqmz1g-chromium-67.0.3396.87-sandbox
|
||||
...
|
||||
building '/nix/store/sbxmqqi3wmpf9n79a0mncrvb302xwh4n-nixos-vm.drv'...
|
||||
/nix/store/7zgnq9xw9i7ybvjg0d3h2ank5g5nya5p-nixos-vm
|
||||
|
||||
## Run application
|
||||
|
||||
For last built application (result is a symbolic link):
|
||||
|
||||
$ ./result/bin/run-chromium-vm
|
||||
|
||||
Or by full path:
|
||||
|
||||
$ /nix/store/*/bin/run-chromium-vm
|
||||
|
||||
$ qemu-system-x86_64 -smp 2 -m 1024 -enable-kvm -sandbox on -cdrom result/iso/nixos-*-linux.iso
|
||||
|
25
base.nix
Normal file
25
base.nix
Normal file
@ -0,0 +1,25 @@
|
||||
{
|
||||
imports = [
|
||||
<nixpkgs/nixos/modules/virtualisation/qemu-vm.nix>
|
||||
];
|
||||
|
||||
system.nixos.stateVersion = "18.03";
|
||||
|
||||
services.xserver = {
|
||||
enable = true;
|
||||
desktopManager.xterm.enable = false;
|
||||
displayManager.slim = {
|
||||
enable = true;
|
||||
defaultUser = "user";
|
||||
autoLogin = true;
|
||||
};
|
||||
windowManager.xmonad.enable = true;
|
||||
windowManager.default = "xmonad";
|
||||
};
|
||||
|
||||
users.extraUsers.user = {
|
||||
isNormalUser = true;
|
||||
extraGroups = [ "audio" ];
|
||||
createHome = true;
|
||||
};
|
||||
}
|
5
chromium-config.nix
Normal file
5
chromium-config.nix
Normal file
@ -0,0 +1,5 @@
|
||||
{config, ...}:
|
||||
{
|
||||
config.networking.hostName = "chromium";
|
||||
config.virtualisation.memorySize = 2048;
|
||||
}
|
30
chromium.nix
30
chromium.nix
@ -1,29 +1,11 @@
|
||||
{config, pkgs, ...}:
|
||||
{pkgs, ...}:
|
||||
{
|
||||
imports = [
|
||||
<nixpkgs/nixos/modules/installer/cd-dvd/installation-cd-minimal.nix>
|
||||
<nixpkgs/nixos/modules/virtualisation/qemu-vm.nix>
|
||||
<chromium-config.nix>
|
||||
<base.nix>
|
||||
];
|
||||
|
||||
environment.systemPackages = with pkgs; [
|
||||
chromium
|
||||
];
|
||||
|
||||
services.xserver = {
|
||||
enable = true;
|
||||
desktopManager.xterm.enable = false;
|
||||
displayManager.slim = {
|
||||
enable = true;
|
||||
defaultUser = "user";
|
||||
autoLogin = true;
|
||||
};
|
||||
displayManager.sessionCommands = "while [ 1 ]; do ${pkgs.chromium}/bin/chromium; done &";
|
||||
windowManager.xmonad.enable = true;
|
||||
windowManager.default = "xmonad";
|
||||
};
|
||||
|
||||
users.extraUsers.user = {
|
||||
isNormalUser = true;
|
||||
extraGroups = [ "audio" ];
|
||||
createHome = true;
|
||||
};
|
||||
environment.systemPackages = [ pkgs.chromium ];
|
||||
services.xserver.displayManager.sessionCommands = "while [ 1 ]; do ${pkgs.chromium}/bin/chromium; done &";
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user