/
vm.nix
130 lines (111 loc) · 3.3 KB
/
vm.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
{ oldNixpkgs ? <nixpkgs>}:
let
reflex-platform = import ../deps/reflex-platform {};
nixpkgs = reflex-platform.nixpkgs;
pkgs = nixpkgs.pkgs;
workshop-pkg = import ../. {};
reflex-workshop-assets = import ../content {};
reflex-workshop = pkgs.stdenv.mkDerivation {
name = "reflex-workshop-source";
src = pkgs.lib.cleanSource ../.;
phases = ["installPhase"];
installPhase = ''
mkdir $out
cp -r $src/* $out/
'';
};
tools = with pkgs; [
utillinux
coreutils
binutils
pkgconfig
wmctrl
gitAndTools.gitFull
chromium
ag
emacs
vim
gnome3.gedit
reflex-workshop-assets
reflex-workshop
];
haskell-tools = reflex-platform.ghc.ghcWithPackages (hp: with hp; [
Cabal
cabal-install
ghcid
hlint
hasktags
hindent
hoogle
stylish-haskell
# (nixpkgs.haskell.lib.justStaticExecutables ghc-mod)
workshop-pkg
]);
workshop-vm-config = {
imports = [ "${oldNixpkgs}/nixos/modules/virtualisation/virtualbox-image.nix" ];
virtualbox = {
baseImageSize = 15 * 1024;
memorySize = 3 * 1024;
vmName = "Reflex workshop (NixOS)";
vmDerivationName = "nixos-ova-reflex-workshop";
vmFileName = "reflex-workshop.ova";
};
services.xserver = {
enable = true;
displayManager.sddm = {
enable = true;
autoLogin = {
enable = true;
relogin = true;
user = "workshop";
};
};
desktopManager.xfce.enable = true;
libinput.enable = true; # for touchpad support on many laptops
};
users.extraUsers.workshop = {
isNormalUser = true;
description = "Workshop user";
extraGroups = [ "wheel" ];
password = "workshop";
uid = 1000;
};
environment.systemPackages =
tools ++ [haskell-tools];
# environment.variables.WORKSHOP_ASSETS = $reflex-workshop-assets;
systemd.services.workshop-setup = {
description = "Setup workshop";
serviceConfig.Type = "oneshot";
serviceConfig.RemainAfterExit = true;
wantedBy = [ "multi-user.target" ];
script = ''
if [ ! -e /home/workshop/reflex-workshop ]; then
cp -rT "${reflex-workshop}/" /home/workshop/reflex-workshop
chmod -R u+w /home/workshop/reflex-workshop
ln -s "${reflex-workshop-assets}" /home/workshop/reflex-workshop/assets
chown -R workshop:users /home/workshop/reflex-workshop
fi
'';
};
systemd.services.hoogle-setup = {
description = "Setup hoogle";
serviceConfig.Type = "oneshot";
serviceConfig.RemainAfterExit = true;
wantedBy = [ "multi-user.target" ];
environment = { HOME = "/home/workshop"; };
path = [haskell-tools];
script = ''
if [ ! -e /home/workshop/.hoogle-setup ]; then
hoogle generate --local
touch /home/workshop/.hoogle-setup
fi
hoogle server -p 9090 --local
'';
};
};
hydraJob = (import "${oldNixpkgs}/lib").hydraJob;
workshop-vm = hydraJob ((import "${oldNixpkgs}/nixos/lib/eval-config.nix" {
modules = [ workshop-vm-config ];
}).config.system.build.virtualBoxOVA);
in
workshop-vm