Pull out more host settings to common

This commit is contained in:
Oystein Kristoffer Tveit 2022-06-02 16:33:21 +02:00
parent 00709602b3
commit e72231e80a
4 changed files with 93 additions and 93 deletions

View File

@ -1,42 +1,27 @@
{ pkgs, config, inputs, secrets, ... }: { pkgs, config, inputs, secrets, ... }:
let let
inherit (pkgs) lib; inherit (pkgs) lib;
# inherit (specialArgs) machineVars; inherit (specialArgs) machineVars;
# inherit (config) machineVars; # inherit (config) machineVars;
# has_graphics = !config.machineVars.headless; # has_graphics = !config.machineVars.headless;
in { in {
time.timeZone = "Europe/Oslo";
i18n.defaultLocale = "en_US.UTF-8";
nixpkgs.config = { nixpkgs.config = {
allowUnfree = true; allowUnfree = true;
}; };
console = {
font = "Lat2-Terminus16";
keyMap = "us";
};
networking = {
useDHCP = false;
nameservers = [
"1.1.1.1"
"8.8.8.8"
];
};
nix = { nix = {
package = pkgs.nixFlakes; package = pkgs.nixFlakes;
distributedBuilds = machineVars.hostname != "Tsuki";
binaryCaches = [
"https://cache.nixos.org/"
];
extraOptions = '' extraOptions = ''
experimental-features = nix-command flakes experimental-features = nix-command flakes
builders-use-substitutes = true builders-use-substitutes = true
''; '';
distributedBuilds = (config.networking.hostName != "Tsuki"); trustedUsers = [ "h7x4" ];
binaryCaches = [
"https://cache.nixos.org/"
];
buildMachines = [ buildMachines = [
{ {
@ -53,6 +38,40 @@ in {
mandatoryFeatures = []; mandatoryFeatures = [];
} }
]; ];
# registry = {
# };
};
time.timeZone = "Europe/Oslo";
console = {
font = "Lat2-Terminus16";
keyMap = "us";
};
networking = {
useDHCP = false;
nameservers = [
"1.1.1.1"
"8.8.8.8"
];
};
i18n = {
defaultLocale = "en_US.UTF-8";
inputMethod = lib.mkIf (!machineVars.headless) {
enabled = "fcitx";
fcitx.engines = with pkgs.fcitx-engines; [ mozc ];
};
# inputMethod = {
# enabled = "fcitx5";
# fcitx5.addons = with pkgs; [
# fcitx5-mozc
# fcitx5-gtk
# ];
# };
}; };
environment = { environment = {
@ -73,6 +92,12 @@ in {
dash dash
]; ];
systemPackages = with pkgs; [
wget
] ++ (lib.optionals (!machineVars.headless) [
haskellPackages.xmobar
]);
etc = { etc = {
# TODO: move this out of etc, and reference it directly in sudo config. # TODO: move this out of etc, and reference it directly in sudo config.
sudoLecture = { sudoLecture = {
@ -99,6 +124,18 @@ in {
in concatStringsSep "\n" sortedUnique; in concatStringsSep "\n" sortedUnique;
}; };
}; };
shellAliases.fixDisplay = let
inherit (config.machineVars) screens headless fixDisplayCommand;
screenToArgs = screen: with screen;
"--output ${name} --mode ${resolution}"
+ (lib.optionalString (frequency != null) " --rate ${frequency}");
screenArgs = lib.concatStringsSep " " (lib.mapAttrsToList screenToArgs screens);
in lib.mkIf (!headless)
(lib.mkMerge [
"xrandr ${screenArgs}"
(lib.mkIf (fixDisplayCommand != null) fixDisplayCommand)
]);
}; };
fonts = { fonts = {
@ -123,6 +160,7 @@ in {
noto-fonts-cjk-sans noto-fonts-cjk-sans
noto-fonts-cjk-serif noto-fonts-cjk-serif
noto-fonts-emoji noto-fonts-emoji
ocr-a
open-sans open-sans
source-han-sans source-han-sans
source-sans source-sans
@ -142,19 +180,26 @@ in {
}; };
}; };
users.users.h7x4 = { users = {
isNormalUser = true; users.h7x4 = {
shell = pkgs.zsh; isNormalUser = true;
extraGroups = [ shell = pkgs.zsh;
"wheel"
"networkmanager" extraGroups = [
"docker" "wheel"
"audio" "networkmanager"
"video" "docker"
"disk" "disk"
"libvirtd" "audio"
"input" "video"
]; "libvirtd"
"input"
];
};
groups = {
adbusers.members = [ "h7x4" ];
};
}; };
home-manager = { home-manager = {
@ -189,7 +234,7 @@ in {
}; };
xserver = { xserver = {
# TODO: What is going on here? # TODO: What is going on here?
# For some reason, this leads to infinite recursion. # For some reason, this leads to infinite recursion.
# This needs to be fixed! # This needs to be fixed!
# Same with `displayManager.lightdm.enable` # Same with `displayManager.lightdm.enable`
@ -268,18 +313,6 @@ in {
}; };
}; };
environment.shellAliases.fixDisplay = let
inherit (config.machineVars) screens headless fixDisplayCommand;
screenToArgs = screen: with screen;
"--output ${name} --mode ${resolution}"
+ (lib.optionalString (frequency != null) " --rate ${frequency}");
screenArgs = lib.concatStringsSep " " (lib.mapAttrsToList screenToArgs screens);
in lib.mkIf (!headless)
(lib.mkMerge [
"xrandr ${screenArgs}"
(lib.mkIf (fixDisplayCommand != null) fixDisplayCommand)
]);
system.extraDependencies = system.extraDependencies =
lib.optionals (config.machineVars.development) (with pkgs; [ lib.optionals (config.machineVars.development) (with pkgs; [
asciidoc asciidoc

View File

@ -9,7 +9,7 @@ in {
]; ];
# TODO: See ../common.nix # TODO: See ../common.nix
services.xserver.enable = true; services.xserver.enable = true;
services.xserver.displayManager.lightdm.enable = true; services.xserver.displayManager.lightdm.enable = true;
machineVars = { machineVars = {
@ -59,21 +59,6 @@ in {
# }; # };
}; };
i18n = {
inputMethod = {
enabled = "fcitx";
fcitx.engines = with pkgs.fcitx-engines; [ mozc ];
};
# inputMethod = {
# enabled = "fcitx5";
# fcitx5.addons = with pkgs; [
# fcitx5-mozc
# fcitx5-gtk
# ];
# };
};
services = { services = {
openssh.enable = true; openssh.enable = true;
printing.enable = true; printing.enable = true;
@ -85,11 +70,6 @@ in {
}; };
}; };
hardware.bluetooth.enable = true; hardware.bluetooth.enable = false;
virtualisation = {
docker.enable = true;
# libvirtd.enable = true;
};
} }

View File

@ -14,7 +14,7 @@
development = true; development = true;
creative = true; creative = true;
dataDrives = let dataDrives = let
main = "/data"; main = "/data";
in { in {
drives = { inherit main; }; drives = { inherit main; };
@ -51,27 +51,16 @@
networking = { networking = {
hostName = "kasei"; hostName = "kasei";
networkmanager.enable = true; networkmanager.enable = true;
interfaces.wlp5s0.useDHCP = true; interfaces.wlp2s0f0u7u3.useDHCP = true;
interfaces.wlp2s0f0u4.useDHCP = true;
firewall.enable = true; firewall.enable = true;
}; };
i18n = { environment = {
inputMethod = { shellAliases = {
enabled = "fcitx"; fixscreen = "xrandr --output DP-4 --mode 1920x1080 --pos 0x0 -r 144 --output DVI-D-1 --primary --mode 1920x1080 --pos 1920x0 -r 60";
fcitx.engines = with pkgs.fcitx-engines; [ mozc ];
}; };
# inputMethod = {
# enabled = "fcitx5";
# fcitx5.addons = with pkgs; [
# fcitx5-mozc
# fcitx5-gtk
# ];
# };
}; };
services = { services = {
openssh.enable = true; openssh.enable = true;
printing.enable = true; printing.enable = true;
@ -81,6 +70,7 @@
# "*/5 * * * * root date >> /tmp/cron.log" # "*/5 * * * * root date >> /tmp/cron.log"
]; ];
}; };
};
hardware.bluetooth.enable = true; hardware.bluetooth.enable = true;

View File

@ -29,7 +29,7 @@
machineVars = { machineVars = {
headless = true; headless = true;
dataDrives = let dataDrives = let
momiji = "/data2"; momiji = "/data2";
in { in {
drives = { drives = {
@ -80,11 +80,9 @@
}; };
}; };
users.groups.media = {}; users = {
groups.media = {};
users.users = { users.media = {
h7x4.extraGroups = [ "media" ];
media = {
isSystemUser = true; isSystemUser = true;
group = "media"; group = "media";
}; };
@ -92,6 +90,5 @@
virtualisation = { virtualisation = {
docker.enable = true; docker.enable = true;
libvirtd.enable = true;
}; };
} }