-
Notifications
You must be signed in to change notification settings - Fork 0
/
default.nix
121 lines (107 loc) · 3.33 KB
/
default.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
# Global system configuration
{ config, lib, pkgs, ... }: {
imports = [
./sleep.nix
./xserver.nix
./users.nix
];
options.myme.machine = {
name = lib.mkOption {
type = lib.types.str;
default = "nixos";
description = "Machine name";
};
role = lib.mkOption {
type = lib.types.enum [ "desktop" "laptop" "server" ];
default = "desktop";
description = "Machine type";
};
flavor = lib.mkOption {
type = lib.types.enum [ "nixos" "generic" "wsl" ];
default = "nixos";
description = "Linux flavor";
};
};
config = lib.mkMerge [
# Defaults
{
# Man
documentation.man = {
enable = true;
generateCaches = true;
};
# Time
time.timeZone = "Europe/Oslo";
# System packages
environment.systemPackages = with pkgs; [ vim ];
# Mosh
programs.mosh.enable = true;
# SSH
services.openssh.enable = true;
# GnuPG - enable if enabled for any user
programs.gnupg.agent = {
enable = with builtins;
any (x: x)
(map (x: x.services.gpg-agent.enable) (attrValues config.home-manager.users));
enableSSHSupport = true;
};
# Nix
nix.package = pkgs.nixUnstable;
nix.extraOptions = "experimental-features = nix-command flakes";
# Defaults/compat from "22.05"
system.stateVersion = "22.05";
}
# Disable boot + networking for WSL
(lib.mkIf (config.myme.machine.flavor != "wsl") {
# Boot
boot.loader.systemd-boot.enable = true;
boot.loader.systemd-boot.configurationLimit = 30;
boot.loader.efi.canTouchEfiVariables = true;
boot.kernelPackages = pkgs.linuxPackages_latest;
# Network
# networking.hostName = config.myme.machine.name;
networking.networkmanager.enable = true;
networking.firewall.enable = true;
})
# Enable NixOS-WSL module
(lib.mkIf (config.myme.machine.flavor == "wsl") {
wsl = {
enable = true;
automountPath = "/mnt";
defaultUser = config.myme.machine.user.name;
startMenuLaunchers = false; # Done below to include Home Manager apps
};
# Copied from https://github.com/nix-community/NixOS-WSL/blob/69783cf56b2ada7e0e8cc8d17907a346e8bd97b7/modules/wsl-distro.nix#L111
system.activationScripts.copy-home-launchers = lib.stringAfter [ ] ''
cd "$(mktemp -d)"
for x in applications icons; do
echo "Copying /usr/share/$x"
${pkgs.rsync}/bin/rsync -ar $systemConfig/sw/share/$x/. ./$x
${pkgs.rsync}/bin/rsync -ar /etc/profiles/per-user/${config.myme.machine.user.name}/share/$x/. ./$x
mkdir -p /usr/share/$x
${pkgs.rsync}/bin/rsync -ar --delete ./$x/. /usr/share/$x
done
'';
})
(lib.mkIf (config.myme.machine.role != "server") {
# For GTK stuff
programs.dconf.enable = true;
# Enable sound.
sound.enable = true;
hardware.pulseaudio.enable = true;
})
# Laptop configs
(lib.mkIf (config.myme.machine.role == "laptop") {
# Backlight
services.illum.enable = true;
# Bluetooth
hardware.bluetooth.enable = true;
services.blueman.enable = true;
# Media keys
sound.mediaKeys = {
enable = true;
volumeStep = "1%";
};
})
];
}