From 61da988c22ace47370d6657b89b479dfb682b0b5 Mon Sep 17 00:00:00 2001 From: Mikhail Klementev Date: Sat, 30 Jun 2018 08:39:47 +0000 Subject: [PATCH] Move from ISO to Nix Qemu vms --- .gitignore | 1 + README.md | 33 +++++++++++++++++++++++++++++---- base.nix | 25 +++++++++++++++++++++++++ chromium-config.nix | 5 +++++ chromium.nix | 30 ++++++------------------------ 5 files changed, 66 insertions(+), 28 deletions(-) create mode 100644 base.nix create mode 100644 chromium-config.nix diff --git a/.gitignore b/.gitignore index b2be92b..87a3018 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ result +*.qcow2 diff --git a/README.md b/README.md index 1bc8bd8..adc1931 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,32 @@ -# build +# Nix app vms - $ nix-build '' -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 '' -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 diff --git a/base.nix b/base.nix new file mode 100644 index 0000000..09ab74f --- /dev/null +++ b/base.nix @@ -0,0 +1,25 @@ +{ + imports = [ + + ]; + + 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; + }; +} diff --git a/chromium-config.nix b/chromium-config.nix new file mode 100644 index 0000000..c5a5013 --- /dev/null +++ b/chromium-config.nix @@ -0,0 +1,5 @@ +{config, ...}: +{ + config.networking.hostName = "chromium"; + config.virtualisation.memorySize = 2048; +} diff --git a/chromium.nix b/chromium.nix index 17d5714..8b0f5a7 100644 --- a/chromium.nix +++ b/chromium.nix @@ -1,29 +1,11 @@ -{config, pkgs, ...}: +{pkgs, ...}: { imports = [ - + + + ]; - 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 &"; }