-
Notifications
You must be signed in to change notification settings - Fork 6
/
vm.nix
134 lines (116 loc) · 3.49 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
130
131
132
133
134
let
sources = import ./nix/sources.nix {};
newNixpkgs = import sources.nixpkgs {};
reflex-platform = import sources.reflex-platform {};
inherit (reflex-platform) nixpkgs;
inherit (nixpkgs) pkgs;
workshop-pkg = import ./. {};
reflex-workshop-assets = import ./content {};
reflex-workshop = newNixpkgs.lib.cleanSourceWith {
src = ./.;
name = "reflex-workshop-source";
filter = newNixpkgs.lib.cleanSourceFilter;
};
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
]);
nixpkgsSrc =
let
json = builtins.fromJSON
(builtins.readFile "${sources.reflex-platform.outPath}/nixpkgs/github.json");
in builtins.fetchTarball {
inherit (json) sha256;
url = "https://github.com/${json.owner}/${json.repo}/archive/${json.rev}.tar.gz";
};
workshop-vm-config = {
imports = [ "${nixpkgsSrc}/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 "${nixpkgsSrc}/lib").hydraJob;
workshop-vm = hydraJob ((import "${nixpkgsSrc}/nixos/lib/eval-config.nix" {
modules = [ workshop-vm-config ];
}).config.system.build.virtualBoxOVA);
in
workshop-vm