{ config, pkgs, ... }: let
    packages = (import ../lib/packages.nix) { config = config.nixpkgs.config; };
    callPackageFile = path: (import path) packages;
in {
    imports = [
        (callPackageFile ../profiles/system/base.nix)

        (callPackageFile ../profiles/environment/graphical-environment.nix)
        (callPackageFile ../profiles/environment/xfce4.nix)
        (callPackageFile ../profiles/environment/common-software.nix)

        (callPackageFile ../profiles/system/efi-boot.nix)
        (callPackageFile ../profiles/system/networked.nix)
        (callPackageFile ../profiles/system/printing.nix)
        (callPackageFile ../profiles/system/scanning.nix)
        (callPackageFile ../profiles/system/amd.nix)
        (callPackageFile ../profiles/system/pulseaudio.nix)
        (callPackageFile ../profiles/system/virtualization.nix)

        (callPackageFile ../profiles/software/elasticsearch.nix)
        (callPackageFile ../profiles/software/couchdb.nix)

        (callPackageFile ../profiles/software/games.nix)
        (callPackageFile ../profiles/software/guake.nix)
        (callPackageFile ../profiles/software/synergy.nix)
        (callPackageFile ../profiles/software/workrave.nix)
    ];

    services.xserver = {
        xrandrHeads = [
            "DFP6"
            "CRT1"
        ];
    };

    networking = {
        hostName = "desktop-home";

        firewall = { # FIXME: abstract this out...
            allowedTCPPorts = [
                25565      # Minecraft
            ];

            allowedUDPPorts = [
                34197      # Factorio
            ];
        };
    };

    users.extraUsers.sven = {
        isNormalUser = true;
        uid = 1000;
        extraGroups = ["libvirtd"];
    };

    users.groups = {
        davfs2 = {};
    };

    users.extraUsers.davfs2 = {
        isNormalUser = true;
    };

    boot = {
        kernelModules = [ "tun" "virtio" "nbd" ];
        kernelPackages = pkgs.linuxPackages_4_4;
    };

    fileSystems = [
        {
            mountPoint = "/mnt/storage1";
            device = "/dev/disk/by-uuid/f7b13747-f465-4600-9928-d7bf0720df1a";
        }
        {
            mountPoint = "/mnt/storage2";
            device = "/dev/disk/by-uuid/71cc55ca-7fc7-40c2-9dee-9e6216959d15";
        }
        {
            mountPoint = "/mnt/temp";
            device = "/dev/disk/by-uuid/6251105f-2b32-40de-859b-1654d6d1037e";
        }
        {
            mountPoint = "/mnt/opensuse";
            device = "/dev/disk/by-uuid/02a65154-3d26-4077-8942-c48337a3f9a2";
        }
    ];

    environment = {
        systemPackages = with packages; [
			nixpkgs.blueman
			nixpkgs.nixops
			nixpkgs.oraclejre8
			myNixpkgs.technic-launcher
			myNixpkgs.ftb-launcher
        ];

        etc = {
            "synergy-server.conf" = {
                text = ''
                    section: screens
                        desktop:

                        laptop:

                    end

                    section: links
                        desktop:
                            left = laptop
                        laptop:
                            right = desktop
                    end

                    section: aliases
                        desktop:
                            192.168.178.60
                            desktop-home
                        laptop:
                            192.168.178.41
                            linux-o82e.site
                    end
                '';
            };
        };

        pathsToLink = [
            "/lib/rustlib/src"
        ];
    };

    hardware.bluetooth.enable = true;
    hardware.pulseaudio.extraConfig = ''
        load-module module-loopback
        load-module module-combine-sink sink_name=all
    '';

    networking.extraHosts = ''
        127.0.0.1 im-project.im
    '';

    /*networking.wireguard = {
      wg0 = {
        ips = [ "192.168.20.4/24" ];
        privateKey = "yAnz5TF+lXXJte14tji3zlMNq+hd2rYUIgJBgB3fBmk=";
        peers = [
          { allowedIPs = [ "192.168.20.1/32" ];
            publicKey  = "xTIBA5rboUvnH4htodjb6e697QjLERt1NAB4mZqp8Dg=";
            endpoint   = "demo.wireguard.io:12913"; }
        ];
      };
    };*/

    nix.useSandbox = true;
}
