mirror of
https://github.com/CHN-beta/nixos.git
synced 2026-01-12 07:29:23 +08:00
modules.model: init
This commit is contained in:
@@ -4,6 +4,7 @@ inputs:
|
||||
{
|
||||
nixos =
|
||||
{
|
||||
model.type = "desktop";
|
||||
system =
|
||||
{
|
||||
fileSystems =
|
||||
@@ -54,7 +55,6 @@ inputs:
|
||||
[ "options iwlwifi power_save=0" "options iwlmvm power_scheme=1" "options iwlwifi uapsd_disable=1" ];
|
||||
};
|
||||
sysctl.laptop-mode = 5;
|
||||
gui.enable = true;
|
||||
};
|
||||
hardware =
|
||||
{
|
||||
|
||||
@@ -4,11 +4,12 @@ inputs:
|
||||
{
|
||||
nixos =
|
||||
{
|
||||
model.type = "server";
|
||||
system =
|
||||
{
|
||||
fileSystems =
|
||||
{
|
||||
mount = let inherit (inputs.config.nixos.system.cluster) clusterName nodeName; in
|
||||
mount = let inherit (inputs.config.nixos.model.cluster) clusterName nodeName; in
|
||||
{
|
||||
vfat."/dev/disk/by-partlabel/${clusterName}-${nodeName}-boot" = "/boot";
|
||||
btrfs."/dev/disk/by-partlabel/${clusterName}-${nodeName}-root" =
|
||||
@@ -17,7 +18,6 @@ inputs:
|
||||
swap = [ "/nix/swap/swap" ];
|
||||
rollingRootfs = {};
|
||||
};
|
||||
gui.enable = true;
|
||||
};
|
||||
hardware.cpus = [ "intel" ];
|
||||
services =
|
||||
|
||||
@@ -4,6 +4,7 @@ inputs:
|
||||
{
|
||||
nixos =
|
||||
{
|
||||
model.cluster.nodeType = "master";
|
||||
system =
|
||||
{
|
||||
nixpkgs.march = "cascadelake";
|
||||
@@ -12,7 +13,6 @@ inputs:
|
||||
eno145 = { ip = "192.168.1.10"; mask = 24; gateway = "192.168.1.1"; };
|
||||
eno146 = { ip = "192.168.178.1"; mask = 24; };
|
||||
};
|
||||
cluster.nodeType = "master";
|
||||
};
|
||||
services =
|
||||
{
|
||||
|
||||
@@ -4,12 +4,12 @@ inputs:
|
||||
{
|
||||
nixos =
|
||||
{
|
||||
model.cluster.nodeType = "worker";
|
||||
system =
|
||||
{
|
||||
nixpkgs.march = "broadwell";
|
||||
networking.networkd.static.eno2 =
|
||||
{ ip = "192.168.178.2"; mask = 24; gateway = "192.168.178.1"; dns = "192.168.178.1"; };
|
||||
cluster.nodeType = "worker";
|
||||
fileSystems.mount.nfs."192.168.178.1:/home" = "/home";
|
||||
};
|
||||
services.beesd.instances.root = { device = "/"; hashTableSizeMB = 256; threads = 4; };
|
||||
|
||||
@@ -4,6 +4,7 @@ inputs:
|
||||
{
|
||||
nixos =
|
||||
{
|
||||
model.cluster.nodeType = "worker";
|
||||
system =
|
||||
{
|
||||
nixpkgs.march = "broadwell";
|
||||
@@ -12,7 +13,6 @@ inputs:
|
||||
br0 = { ip = "192.168.1.12"; mask = 24; gateway = "192.168.1.1"; dns = "192.168.1.1"; };
|
||||
eno2 = { ip = "192.168.178.3"; mask = 24; };
|
||||
};
|
||||
cluster.nodeType = "worker";
|
||||
fileSystems.mount =
|
||||
{
|
||||
nfs."192.168.178.1:/home" = "/home";
|
||||
|
||||
@@ -4,12 +4,12 @@ inputs:
|
||||
{
|
||||
nixos =
|
||||
{
|
||||
model.cluster.nodeType = "worker";
|
||||
system =
|
||||
{
|
||||
nixpkgs.march = "broadwell";
|
||||
networking.networkd.static.eno2 =
|
||||
{ ip = "192.168.178.4"; mask = 24; gateway = "192.168.178.1"; dns = "192.168.178.1"; };
|
||||
cluster.nodeType = "worker";
|
||||
fileSystems.mount.nfs."192.168.178.1:/home" = "/home";
|
||||
};
|
||||
services.beesd.instances.root = { device = "/"; hashTableSizeMB = 256; threads = 4; };
|
||||
|
||||
@@ -5,6 +5,7 @@ inputs:
|
||||
{
|
||||
nixos =
|
||||
{
|
||||
model.type = "desktop";
|
||||
system =
|
||||
{
|
||||
fileSystems =
|
||||
@@ -26,7 +27,6 @@ inputs:
|
||||
nixpkgs.march = "skylake";
|
||||
nix = { substituters = [ "https://nix-store.chn.moe?priority=100" ]; githubToken.enable = true; };
|
||||
kernel = { variant = "xanmod-latest"; patches = [ "surface" "hibernate-progress" ]; };
|
||||
gui.enable = true;
|
||||
};
|
||||
hardware = { cpus = [ "intel" ]; gpu.type = "intel"; };
|
||||
services =
|
||||
|
||||
@@ -4,6 +4,7 @@ inputs:
|
||||
{
|
||||
nixos =
|
||||
{
|
||||
model.type = "server";
|
||||
system =
|
||||
{
|
||||
fileSystems =
|
||||
@@ -47,7 +48,6 @@ inputs:
|
||||
forwardCompat = false;
|
||||
};
|
||||
};
|
||||
gui = { enable = true; preferred = false; autoStart = true; };
|
||||
nix.remote.slave.enable = true;
|
||||
};
|
||||
hardware = { cpus = [ "amd" ]; gpu.type = "nvidia"; };
|
||||
|
||||
@@ -4,6 +4,7 @@ inputs:
|
||||
{
|
||||
nixos =
|
||||
{
|
||||
model.type = "server";
|
||||
system =
|
||||
{
|
||||
fileSystems =
|
||||
@@ -40,7 +41,6 @@ inputs:
|
||||
forwardCompat = false;
|
||||
};
|
||||
};
|
||||
gui = { enable = true; preferred = false; autoStart = true; };
|
||||
nix =
|
||||
{
|
||||
marches =
|
||||
|
||||
@@ -15,7 +15,7 @@ builtins.listToAttrs
|
||||
config =
|
||||
{
|
||||
nixpkgs.overlays = [ inputs.self.overlays.default ];
|
||||
nixos.system.networking.hostname = system;
|
||||
nixos.model.hostname = system;
|
||||
};
|
||||
}
|
||||
../modules
|
||||
@@ -38,7 +38,7 @@ builtins.listToAttrs
|
||||
config =
|
||||
{
|
||||
nixpkgs.overlays = [ inputs.self.overlays.default ];
|
||||
nixos.system.cluster = { clusterName = "srv1"; nodeName = node; };
|
||||
nixos.model.cluster = { clusterName = "srv1"; nodeName = node; };
|
||||
};
|
||||
}
|
||||
../modules
|
||||
|
||||
@@ -42,6 +42,6 @@ inputs:
|
||||
];
|
||||
};
|
||||
})
|
||||
./hardware ./packages ./system ./virtualization ./services ./bugs ./user
|
||||
./hardware ./packages ./system ./virtualization ./services ./bugs ./user ./model.nix
|
||||
];
|
||||
}
|
||||
|
||||
@@ -4,18 +4,15 @@ inputs:
|
||||
options.nixos.hardware =
|
||||
let
|
||||
inherit (inputs.lib) mkOption types;
|
||||
default = if inputs.config.nixos.system.gui.enable then {} else null;
|
||||
default = if builtins.elem inputs.config.nixos.model.type [ "desktop" "server" ] then {} else null;
|
||||
in
|
||||
{
|
||||
bluetooth = mkOption { type = types.nullOr (types.submodule {}); inherit default; };
|
||||
joystick = mkOption { type = types.nullOr (types.submodule {}); inherit default; };
|
||||
printer = mkOption { type = types.nullOr (types.submodule {}); inherit default; };
|
||||
sound = mkOption { type = types.nullOr (types.submodule {}); inherit default; };
|
||||
};
|
||||
config = let inherit (inputs.config.nixos) hardware; in inputs.lib.mkMerge
|
||||
[
|
||||
# bluetooth
|
||||
(inputs.lib.mkIf (hardware.bluetooth != null) { hardware.bluetooth.enable = true; })
|
||||
# joystick
|
||||
(inputs.lib.mkIf (hardware.joystick != null) { hardware = { xone.enable = true; xpadneo.enable = true; }; })
|
||||
# printer
|
||||
|
||||
33
modules/model.nix
Normal file
33
modules/model.nix
Normal file
@@ -0,0 +1,33 @@
|
||||
inputs:
|
||||
{
|
||||
options.nixos.model = let inherit (inputs.lib) mkOption types; in
|
||||
{
|
||||
hostname = mkOption { type = types.nonEmptyStr; };
|
||||
type = mkOption { type = types.enum [ "minimal" "desktop" "server" ]; default = "minimal"; };
|
||||
# not implemented yet
|
||||
# private = mkOption { type = types.bool; };
|
||||
cluster = mkOption
|
||||
{
|
||||
type = types.nullOr (types.submodule { options =
|
||||
{
|
||||
clusterName = mkOption { type = types.nonEmptyStr; };
|
||||
nodeName = mkOption { type = types.nonEmptyStr; };
|
||||
nodeType = mkOption { type = types.enum [ "master" "worker" ]; default = "worker"; };
|
||||
};});
|
||||
default = null;
|
||||
};
|
||||
};
|
||||
config = let inherit (inputs.config.nixos) model; in inputs.lib.mkMerge
|
||||
[
|
||||
{ networking.hostName = model.hostname; }
|
||||
(inputs.lib.mkIf (model.cluster != null)
|
||||
{ nixos.model.hostname = "${model.cluster.clusterName}-${model.cluster.nodeName}"; })
|
||||
# TODO: remove it
|
||||
{
|
||||
systemd.services = inputs.lib.mkIf (model.cluster.nodeType or null == "worker") (builtins.listToAttrs
|
||||
(builtins.map
|
||||
(user: { name = "home-manager-${inputs.utils.escapeSystemdPath user}"; value.enable = false; })
|
||||
inputs.config.nixos.user.users));
|
||||
}
|
||||
];
|
||||
}
|
||||
@@ -3,7 +3,7 @@ inputs:
|
||||
options.nixos.packages.chromium = let inherit (inputs.lib) mkOption types; in mkOption
|
||||
{
|
||||
type = types.nullOr (types.submodule {});
|
||||
default = if inputs.config.nixos.system.gui.enable then {} else null;
|
||||
default = if builtins.elem inputs.config.nixos.model.type [ "desktop" "server" ] then {} else null;
|
||||
};
|
||||
config = let inherit (inputs.config.nixos.packages) chromium; in inputs.lib.mkIf (chromium != null)
|
||||
{
|
||||
|
||||
@@ -3,7 +3,7 @@ inputs:
|
||||
options.nixos.packages.desktop = let inherit (inputs.lib) mkOption types; in mkOption
|
||||
{
|
||||
type = types.nullOr (types.submodule {});
|
||||
default = if inputs.config.nixos.system.gui.enable then {} else null;
|
||||
default = if builtins.elem inputs.config.nixos.model.type [ "desktop" "server" ] then {} else null;
|
||||
};
|
||||
config = let inherit (inputs.config.nixos.packages) desktop; in inputs.lib.mkIf (desktop != null)
|
||||
{
|
||||
|
||||
@@ -3,7 +3,7 @@ inputs:
|
||||
options.nixos.packages.firefox = let inherit (inputs.lib) mkOption types; in mkOption
|
||||
{
|
||||
type = types.nullOr (types.submodule {});
|
||||
default = if inputs.config.nixos.system.gui.enable then {} else null;
|
||||
default = if builtins.elem inputs.config.nixos.model.type [ "desktop" "server" ] then {} else null;
|
||||
};
|
||||
config = let inherit (inputs.config.nixos.packages) firefox; in inputs.lib.mkIf (firefox != null)
|
||||
{
|
||||
|
||||
@@ -3,7 +3,7 @@ inputs:
|
||||
options.nixos.packages.flatpak = let inherit (inputs.lib) mkOption types; in mkOption
|
||||
{
|
||||
type = types.nullOr (types.submodule {});
|
||||
default = if inputs.config.nixos.system.gui.enable then {} else null;
|
||||
default = if builtins.elem inputs.config.nixos.model.type [ "desktop" "server" ] then {} else null;
|
||||
};
|
||||
config = let inherit (inputs.config.nixos.packages) flatpak; in inputs.lib.mkIf (flatpak != null)
|
||||
{
|
||||
|
||||
@@ -3,7 +3,7 @@ inputs:
|
||||
options.nixos.packages.lammps = let inherit (inputs.lib) mkOption types; in mkOption
|
||||
{
|
||||
type = types.nullOr (types.submodule {});
|
||||
default = if inputs.config.nixos.system.gui.enable then {} else null;
|
||||
default = if builtins.elem inputs.config.nixos.model.type [ "desktop" "server" ] then {} else null;
|
||||
};
|
||||
config = let inherit (inputs.config.nixos.packages) lammps; in inputs.lib.mkIf (lammps != null)
|
||||
{
|
||||
|
||||
@@ -4,7 +4,7 @@ inputs:
|
||||
{
|
||||
type = types.nullOr (types.submodule {});
|
||||
default =
|
||||
if inputs.config.nixos.system.gui.enable
|
||||
if (builtins.elem inputs.config.nixos.model.type [ "desktop" "server" ])
|
||||
&& (let inherit (inputs.config.nixos.system.nixpkgs) cuda; in cuda.enable && cuda.capabilities != null)
|
||||
then {}
|
||||
else null;
|
||||
|
||||
@@ -3,7 +3,7 @@ inputs:
|
||||
options.nixos.packages.steam = let inherit (inputs.lib) mkOption types; in mkOption
|
||||
{
|
||||
type = types.nullOr (types.submodule {});
|
||||
default = if inputs.config.nixos.system.gui.enable then {} else null;
|
||||
default = if builtins.elem inputs.config.nixos.model.type [ "desktop" "server" ] then {} else null;
|
||||
};
|
||||
config = let inherit (inputs.config.nixos.packages) steam; in inputs.lib.mkIf (steam != null)
|
||||
{
|
||||
|
||||
@@ -3,7 +3,7 @@ inputs:
|
||||
options.nixos.packages.vasp = let inherit (inputs.lib) mkOption types; in mkOption
|
||||
{
|
||||
type = types.nullOr (types.submodule {});
|
||||
default = if inputs.config.nixos.system.gui.enable then {} else null;
|
||||
default = if builtins.elem inputs.config.nixos.model.type [ "desktop" "server" ] then {} else null;
|
||||
};
|
||||
# TODO: add more options to correctly configure VASP
|
||||
config = let inherit (inputs.config.nixos.packages) vasp; in inputs.lib.mkIf (vasp != null)
|
||||
|
||||
@@ -3,7 +3,7 @@ inputs:
|
||||
options.nixos.packages.vscode = let inherit (inputs.lib) mkOption types; in mkOption
|
||||
{
|
||||
type = types.nullOr (types.submodule {});
|
||||
default = if inputs.config.nixos.system.gui.enable then {} else null;
|
||||
default = if builtins.elem inputs.config.nixos.model.type [ "desktop" "server" ] then {} else null;
|
||||
};
|
||||
config = let inherit (inputs.config.nixos.packages) vscode; in inputs.lib.mkIf (vscode != null)
|
||||
{
|
||||
|
||||
@@ -3,7 +3,7 @@ inputs:
|
||||
options.nixos.packages.winapps = let inherit (inputs.lib) mkOption types; in mkOption
|
||||
{
|
||||
type = types.nullOr (types.submodule {});
|
||||
default = if inputs.config.nixos.system.gui.enable then {} else null;
|
||||
default = if builtins.elem inputs.config.nixos.model.type [ "desktop" "server" ] then {} else null;
|
||||
};
|
||||
config = let inherit (inputs.config.nixos.packages) winapps; in inputs.lib.mkIf (winapps != null)
|
||||
{
|
||||
|
||||
@@ -4,7 +4,7 @@ inputs:
|
||||
options.nixos.services = let inherit (inputs.lib) mkOption types; in
|
||||
{
|
||||
smartd.enable = mkOption { type = types.bool; default = false; };
|
||||
noisetorch.enable = mkOption { type = types.bool; default = inputs.config.nixos.system.gui.preferred; };
|
||||
noisetorch.enable = mkOption { type = types.bool; default = inputs.config.nixos.model.type == "desktop"; };
|
||||
};
|
||||
config =
|
||||
let
|
||||
|
||||
@@ -3,7 +3,7 @@ inputs:
|
||||
options.nixos.services.nixseparatedebuginfo = let inherit (inputs.lib) mkOption types; in mkOption
|
||||
{
|
||||
type = types.nullOr (types.submodule {});
|
||||
default = if inputs.config.nixos.system.gui.enable then {} else null;
|
||||
default = if builtins.elem inputs.config.nixos.model.type [ "desktop" "server" ] then {} else null;
|
||||
};
|
||||
config =
|
||||
let inherit (inputs.config.nixos.services) nixseparatedebuginfo; in inputs.lib.mkIf (nixseparatedebuginfo != {})
|
||||
|
||||
@@ -127,7 +127,7 @@ inputs:
|
||||
TaskPlugin=task/affinity,task/cgroup
|
||||
'';
|
||||
extraConfigPaths =
|
||||
let gpus = slurm.node.${inputs.config.nixos.system.networking.hostname}.gpus or null;
|
||||
let gpus = slurm.node.${inputs.config.nixos.model.hostname}.gpus or null;
|
||||
in inputs.lib.mkIf (gpus != null)
|
||||
(
|
||||
let gpuString = builtins.concatStringsSep "\n" (builtins.map
|
||||
@@ -141,7 +141,7 @@ inputs:
|
||||
systemd =
|
||||
{
|
||||
services.slurmd.environment =
|
||||
let gpus = slurm.node.${inputs.config.nixos.system.networking.hostname}.gpus or null;
|
||||
let gpus = slurm.node.${inputs.config.nixos.model.hostname}.gpus or null;
|
||||
in inputs.lib.mkIf (gpus != null)
|
||||
{
|
||||
CUDA_PATH = "${inputs.pkgs.cudatoolkit}";
|
||||
@@ -159,7 +159,7 @@ inputs:
|
||||
in { allowedTCPPorts = config; allowedUDPPorts = config; };
|
||||
}
|
||||
# master 配置
|
||||
(inputs.lib.mkIf (slurm.master == inputs.config.nixos.system.networking.hostname)
|
||||
(inputs.lib.mkIf (slurm.master == inputs.config.nixos.model.hostname)
|
||||
{
|
||||
services.slurm =
|
||||
{
|
||||
|
||||
@@ -493,7 +493,7 @@ inputs:
|
||||
chat = inputs.config.sops.secrets."telegram/chat".path;
|
||||
in
|
||||
''
|
||||
message='${inputs.config.nixos.system.networking.hostname} xray:\n'
|
||||
message='${inputs.config.nixos.model.hostname} xray:\n'
|
||||
for i in {0..${toString ((builtins.length userList) - 1)}}
|
||||
do
|
||||
upload_bytes=$(${xray} api stats --server=127.0.0.1:6149 \
|
||||
|
||||
@@ -1,21 +0,0 @@
|
||||
inputs:
|
||||
{
|
||||
options.nixos.system.cluster = let inherit (inputs.lib) mkOption types; in mkOption
|
||||
{
|
||||
type = types.nullOr (types.submodule { options =
|
||||
{
|
||||
clusterName = mkOption { type = types.nonEmptyStr; };
|
||||
nodeName = mkOption { type = types.nonEmptyStr; };
|
||||
nodeType = mkOption { type = types.enum [ "master" "worker" ]; default = "worker"; };
|
||||
};});
|
||||
default = null;
|
||||
};
|
||||
config = let inherit (inputs.config.nixos.system) cluster; in inputs.lib.mkIf (cluster != null)
|
||||
{
|
||||
nixos.system.networking.hostname = "${cluster.clusterName}-${cluster.nodeName}";
|
||||
# 作为从机时,home-manager 需要被禁用
|
||||
systemd.services = inputs.lib.mkIf (cluster.nodeType == "worker") (builtins.listToAttrs (builtins.map
|
||||
(user: { name = "home-manager-${inputs.utils.escapeSystemdPath user}"; value.enable = false; })
|
||||
inputs.config.nixos.user.users));
|
||||
};
|
||||
}
|
||||
@@ -17,7 +17,7 @@ inputs:
|
||||
supportedFilesystems = [ "ntfs" "nfs" "nfsv4" ];
|
||||
# consoleLogLevel = 7;
|
||||
};
|
||||
hardware.enableAllFirmware = true;
|
||||
hardware = { enableAllFirmware = true; bluetooth.enable = true; };
|
||||
environment =
|
||||
{
|
||||
sessionVariables = rec
|
||||
|
||||
@@ -3,7 +3,7 @@ inputs:
|
||||
options.nixos.services.fontconfig = let inherit (inputs.lib) mkOption types; in mkOption
|
||||
{
|
||||
type = types.nullOr (types.submodule {});
|
||||
default = if inputs.config.nixos.system.gui.enable then {} else null;
|
||||
default = if builtins.elem inputs.config.nixos.model.type [ "desktop" "server" ] then {} else null;
|
||||
};
|
||||
config = let inherit (inputs.config.nixos.services) fontconfig; in inputs.lib.mkIf (fontconfig != null)
|
||||
{
|
||||
|
||||
@@ -1,46 +1,39 @@
|
||||
inputs:
|
||||
{
|
||||
options.nixos.system.gui = let inherit (inputs.lib) mkOption types; in
|
||||
{
|
||||
enable = mkOption { type = types.bool; default = false; };
|
||||
preferred = mkOption { type = types.bool; default = inputs.config.nixos.system.gui.enable; };
|
||||
autoStart = mkOption { type = types.bool; default = inputs.config.nixos.system.gui.preferred; };
|
||||
};
|
||||
config = let inherit (inputs.config.nixos.system) gui; in inputs.lib.mkIf gui.enable
|
||||
{
|
||||
services =
|
||||
config = inputs.lib.mkMerge
|
||||
[
|
||||
# enable gui
|
||||
(inputs.lib.mkIf (builtins.elem inputs.config.nixos.model.type [ "desktop" "server" ])
|
||||
{
|
||||
displayManager =
|
||||
services =
|
||||
{
|
||||
sddm = { enable = inputs.lib.mkDefault true; wayland.enable = true; theme = "breeze"; };
|
||||
defaultSession = "plasma";
|
||||
displayManager =
|
||||
{
|
||||
sddm = { enable = inputs.lib.mkDefault true; wayland.enable = true; theme = "breeze"; };
|
||||
defaultSession = "plasma";
|
||||
};
|
||||
desktopManager.plasma6.enable = true;
|
||||
xserver.enable = true;
|
||||
};
|
||||
desktopManager.plasma6.enable = true;
|
||||
xserver.enable = true;
|
||||
};
|
||||
systemd.services.display-manager.enable = inputs.lib.mkDefault gui.autoStart;
|
||||
environment =
|
||||
{
|
||||
sessionVariables =
|
||||
environment =
|
||||
{
|
||||
GTK_USE_PORTAL = "1";
|
||||
NIXOS_OZONE_WL = inputs.lib.mkIf gui.preferred "1";
|
||||
};
|
||||
plasma6.excludePackages = inputs.lib.mkIf (!gui.preferred) [ inputs.pkgs.kdePackages.plasma-nm ];
|
||||
persistence = let inherit (inputs.config.nixos.system) impermanence; in inputs.lib.mkIf impermanence.enable
|
||||
{
|
||||
"${impermanence.root}".directories =
|
||||
sessionVariables.GTK_USE_PORTAL = "1";
|
||||
persistence."${inputs.config.nixos.system.impermanence.root}".directories =
|
||||
[{ directory = "/var/lib/sddm"; user = "sddm"; group = "sddm"; mode = "0700"; }];
|
||||
};
|
||||
};
|
||||
xdg.portal.extraPortals = builtins.map (p: inputs.pkgs."xdg-desktop-portal-${p}") [ "gtk" "wlr" ];
|
||||
i18n.inputMethod =
|
||||
{
|
||||
enable = true;
|
||||
type = "fcitx5";
|
||||
fcitx5.addons = builtins.map (p: inputs.pkgs."fcitx5-${p}")
|
||||
[ "rime" "chinese-addons" "mozc" "nord" "material-color" ];
|
||||
};
|
||||
programs.dconf.enable = true;
|
||||
};
|
||||
xdg.portal.extraPortals = builtins.map (p: inputs.pkgs."xdg-desktop-portal-${p}") [ "gtk" "wlr" ];
|
||||
i18n.inputMethod =
|
||||
{
|
||||
enable = true;
|
||||
type = "fcitx5";
|
||||
fcitx5.addons = builtins.map (p: inputs.pkgs."fcitx5-${p}")
|
||||
[ "rime" "chinese-addons" "mozc" "nord" "material-color" ];
|
||||
};
|
||||
programs.dconf.enable = true;
|
||||
})
|
||||
# prefer gui or not
|
||||
(inputs.localLib.mkConditional (builtins.elem inputs.config.nixos.model.type [ "desktop" ])
|
||||
{ environment.sessionVariables.NIXOS_OZONE_WL = "1"; }
|
||||
{ environment.plasma6.excludePackages = [ inputs.pkgs.kdePackages.plasma-nm ]; })
|
||||
];
|
||||
}
|
||||
|
||||
@@ -2,7 +2,6 @@ inputs:
|
||||
{
|
||||
options.nixos.system.networking = let inherit (inputs.lib) mkOption types; in
|
||||
{
|
||||
hostname = mkOption { type = types.nonEmptyStr; };
|
||||
networkManager.enable = mkOption
|
||||
{ type = types.bool; default = inputs.config.nixos.system.networking.networkd == null; };
|
||||
networkd = mkOption
|
||||
@@ -30,7 +29,6 @@ inputs:
|
||||
[
|
||||
# general config
|
||||
{
|
||||
networking.hostName = networking.hostname;
|
||||
boot.kernel.sysctl =
|
||||
{
|
||||
"net.core.rmem_max" = 67108864;
|
||||
|
||||
@@ -11,11 +11,11 @@ inputs:
|
||||
{
|
||||
defaultSopsFile =
|
||||
let deviceDir =
|
||||
if (inputs.config.nixos.system.cluster == null) then
|
||||
"${inputs.topInputs.self}/devices/${inputs.config.nixos.system.networking.hostname}"
|
||||
if (inputs.config.nixos.model.cluster == null) then
|
||||
"${inputs.topInputs.self}/devices/${inputs.config.nixos.model.hostname}"
|
||||
else
|
||||
"${inputs.topInputs.self}/devices/${inputs.config.nixos.system.cluster.clusterName}"
|
||||
+ "/${inputs.config.nixos.system.cluster.nodeName}";
|
||||
"${inputs.topInputs.self}/devices/${inputs.config.nixos.model.cluster.clusterName}"
|
||||
+ "/${inputs.config.nixos.model.cluster.nodeName}";
|
||||
in inputs.lib.mkMerge
|
||||
[
|
||||
(inputs.lib.mkIf (builtins.pathExists "${deviceDir}/secrets.yaml") "${deviceDir}/secrets.yaml")
|
||||
|
||||
@@ -36,7 +36,7 @@ inputs:
|
||||
"wireguard.surface" "xmupc1" "wireguard.xmupc1" "xmupc2" "wireguard.xmupc2"
|
||||
]));
|
||||
extraConfig =
|
||||
inputs.lib.mkIf (builtins.elem inputs.config.nixos.system.networking.hostname [ "pc" "surface" ])
|
||||
inputs.lib.mkIf (builtins.elem inputs.config.nixos.model.hostname [ "pc" "surface" ])
|
||||
''
|
||||
IdentityFile ~/.ssh/id_rsa
|
||||
IdentityFile ~/.ssh/id_ed25519_sk
|
||||
@@ -55,7 +55,7 @@ inputs:
|
||||
(builtins.map
|
||||
(system:
|
||||
{
|
||||
name = system.config.nixos.system.networking.hostname;
|
||||
name = system.config.nixos.model.hostname;
|
||||
value = system.config.nixos.system.fileSystems.luks.manual;
|
||||
})
|
||||
(builtins.attrValues inputs.topInputs.self.nixosConfigurations));
|
||||
@@ -88,7 +88,7 @@ inputs:
|
||||
};
|
||||
environment.persistence =
|
||||
let inherit (inputs.config.nixos.system) impermanence;
|
||||
in inputs.lib.mkIf (inputs.config.nixos.system.cluster.nodeType or null != "worker" && impermanence.enable)
|
||||
in inputs.lib.mkIf (inputs.config.nixos.model.cluster.nodeType or null != "worker" && impermanence.enable)
|
||||
{
|
||||
# TODO: make copy or soft link of files
|
||||
"${impermanence.persistence}".users.chn =
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
inputs:
|
||||
{
|
||||
config = inputs.lib.mkIf inputs.config.nixos.system.gui.enable
|
||||
config = inputs.lib.mkIf (builtins.elem inputs.config.nixos.model.type [ "desktop" "server" ])
|
||||
{
|
||||
home-manager.users.chn.config.home.file =
|
||||
let
|
||||
@@ -64,10 +64,10 @@ inputs:
|
||||
name = ".config/autostart/${programs.${file}.fileName}";
|
||||
value.source = programs.${file}.path;
|
||||
})
|
||||
(devices.${inputs.config.nixos.system.networking.hostname} or []));
|
||||
(devices.${inputs.config.nixos.model.hostname} or []));
|
||||
environment.persistence =
|
||||
let impermanence = inputs.config.nixos.system.impermanence;
|
||||
in inputs.lib.mkIf (inputs.config.nixos.system.cluster.nodeType or null != "worker" && impermanence.enable)
|
||||
in inputs.lib.mkIf (inputs.config.nixos.model.cluster.nodeType or null != "worker" && impermanence.enable)
|
||||
{
|
||||
"${impermanence.root}".users.chn.directories = [ ".config/autostart" ];
|
||||
};
|
||||
|
||||
@@ -69,7 +69,7 @@ inputs:
|
||||
};
|
||||
environment.persistence =
|
||||
let impermanence = inputs.config.nixos.system.impermanence;
|
||||
in inputs.lib.mkIf (inputs.config.nixos.system.cluster.nodeType or null != "worker" && impermanence.enable)
|
||||
in inputs.lib.mkIf (inputs.config.nixos.model.cluster.nodeType or null != "worker" && impermanence.enable)
|
||||
{ "${impermanence.root}".users.chn.directories = [ ".local/share/konsole" ".local/share/yakuake" ]; };
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
inputs:
|
||||
{
|
||||
config = inputs.lib.mkIf inputs.config.nixos.system.gui.enable
|
||||
config = inputs.lib.mkIf (builtins.elem inputs.config.nixos.model.type [ "desktop" "server" ])
|
||||
{
|
||||
home-manager.users.chn.config.programs.plasma =
|
||||
{
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
inputs:
|
||||
{
|
||||
config = inputs.lib.mkIf inputs.config.nixos.system.gui.enable
|
||||
config = inputs.lib.mkIf (builtins.elem inputs.config.nixos.model.type [ "desktop" "server" ])
|
||||
{
|
||||
home-manager.users.chn.config =
|
||||
{
|
||||
|
||||
@@ -7,7 +7,7 @@ inputs:
|
||||
{
|
||||
pc = "${nixos-wallpaper}/pixiv-117612023.png";
|
||||
surface = "${nixos-wallpaper}/fanbox-6682738.png";
|
||||
}.${inputs.config.nixos.system.networking.hostname} or "${nixos-wallpaper}/pixiv-96734339-x2.png";
|
||||
}.${inputs.config.nixos.model.hostname} or "${nixos-wallpaper}/pixiv-96734339-x2.png";
|
||||
in
|
||||
{
|
||||
# "plasma-org.kde.plasma.desktop-appletsrc" =
|
||||
|
||||
@@ -3,7 +3,7 @@ inputs:
|
||||
config = inputs.lib.mkIf
|
||||
(
|
||||
(builtins.elem "chn" inputs.config.nixos.user.users)
|
||||
&& (builtins.elem inputs.config.nixos.system.networking.hostname [ "pc" "surface" ])
|
||||
&& (builtins.elem inputs.config.nixos.model.hostname [ "pc" "surface" ])
|
||||
)
|
||||
{
|
||||
home-manager.users.chn = homeInputs:
|
||||
|
||||
@@ -89,7 +89,7 @@ inputs:
|
||||
(name: { inherit name; value.imports = user.sharedModules; })
|
||||
user.users);
|
||||
environment.persistence."${inputs.config.nixos.system.impermanence.persistence}".directories =
|
||||
inputs.lib.mkIf (inputs.config.nixos.system.cluster.nodeType or null != "worker") (builtins.map
|
||||
inputs.lib.mkIf (inputs.config.nixos.model.cluster.nodeType or null != "worker") (builtins.map
|
||||
(user: { directory = "/home/${user}"; inherit user; group = user; mode = "0700"; })
|
||||
(builtins.filter (user: user != "chn") user.users));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user