]> git.immae.eu Git - perso/Immae/Config/Nix.git/blame - modules/private/system/dilion.nix
Add libvirt to dilion
[perso/Immae/Config/Nix.git] / modules / private / system / dilion.nix
CommitLineData
8a304ef4
IB
1{ privateFiles }:
2{ config, pkgs, ... }:
3{
4 boot.kernelPackages = pkgs.linuxPackages_latest;
5 myEnv = import "${privateFiles}/environment.nix" // { inherit privateFiles; };
6
7 networking = {
8 firewall.enable = false;
9 interfaces."eth0".ipv4.addresses = pkgs.lib.attrsets.mapAttrsToList
10 (n: ips: { address = ips.ip4; prefixLength = 32; })
11 (pkgs.lib.attrsets.filterAttrs (n: v: n != "main") config.hostEnv.ips);
12 interfaces."eth0".ipv6.addresses = pkgs.lib.flatten (pkgs.lib.attrsets.mapAttrsToList
13 (n: ips: map (ip: { address = ip; prefixLength = (if n == "main" && ip == pkgs.lib.head ips.ip6 then 64 else 128); }) (ips.ip6 or []))
14 config.hostEnv.ips);
15 };
16
17 myServices.ssh.modules = [ config.myServices.ssh.predefinedModules.regular ];
18 imports = builtins.attrValues (import ../..);
19
20 deployment = {
21 targetEnv = "hetzner";
22 hetzner = {
23 robotUser = config.myEnv.hetzner.user;
24 robotPass = config.myEnv.hetzner.pass;
25 mainIPv4 = config.hostEnv.ips.main.ip4;
26 partitions = ''
27 clearpart --all --initlabel --drives=sda,sdb,sdc,sdd
28
29 part swap --recommended --label=swap --fstype=swap --ondisk=sda
30
31 part raid.1 --grow --ondisk=sdc
32 part raid.2 --grow --ondisk=sdd
33
34 raid / --level=1 --device=md0 --fstype=ext4 --label=root raid.1 raid.2
35
36 part /nix --grow --label=nix --ondisk=sda
37 part /data --grow --label=data --ondisk=sdb
38 '';
39 };
40 };
41
42 programs.zsh.enable = true;
43
8bf83d7a
IB
44 users.users.backup = {
45 home = "/var/lib/backup";
46 createHome = true;
47 hashedPassword = "!";
48 isSystemUser = true;
49 shell = pkgs.bashInteractive;
50 openssh.authorizedKeys.keys = let
51 in
52 ["command=\"${pkgs.rrsync_sudo}/bin/rrsync /var/lib/backup/eldiron/\" ${config.myEnv.rsync_backup.ssh_key.public}"];
53 };
54 security.sudo.extraRules = [
55 {
56 commands = [
57 { command = "${pkgs.rsync}/bin/rsync"; options = [ "NOPASSWD" ]; }
58 ];
59 users = [ "backup" ];
60 runAs = "root";
61 }
62 ];
63
64 system.activationScripts.backup_home = ''
65 chown root:root /var/lib/backup
66 install -m 0750 -o backup -g root -d /var/lib/backup/eldiron
67 '';
68
7067c25c
IB
69 virtualisation.libvirtd.enable = true;
70 users.extraUsers.immae.extraGroups = [ "libvirtd" ];
71 systemd.services.libvirtd.postStart = ''
72 install -m 0770 -g libvirtd -d /var/lib/libvirt/images
73 '';
74
8a304ef4
IB
75 time.timeZone = "Europe/Paris";
76 nix = {
77 useSandbox = "relaxed";
78 extraOptions = ''
79 keep-outputs = true
80 keep-derivations = true
81 #Assumed in NUR
82 allow-import-from-derivation = true
83 '';
84 };
85
86 # This is equivalent to setting environment.sessionVariables.NIX_PATH
87 nix.nixPath = [
88 "home-manager=https://github.com/rycee/home-manager/archive/release-19.03.tar.gz"
89 "nixpkgs=https://nixos.org/channels/nixos-19.03/nixexprs.tar.xz"
90 ];
91
92 # This value determines the NixOS release with which your system is
93 # to be compatible, in order to avoid breaking some software such as
94 # database servers. You should change this only after NixOS release
95 # notes say you should.
96 # https://nixos.org/nixos/manual/release-notes.html
97 system.stateVersion = "19.03"; # Did you read the comment?
98}
99