add(common dir of system): configs for hardware, firmware, machine specific

This commit is contained in:
madmin 2024-06-19 15:09:21 +02:00
parent 6930f5c20f
commit d934c9ac18
7 changed files with 210 additions and 0 deletions

View File

@ -0,0 +1,9 @@
{
console = {
font = "Lat2-Terminus16";
keyMap = "us";
# useXkbConfig = true; # use xkb.options in tty.
};
}

View File

@ -0,0 +1,7 @@
{
imports = [
./time_locale.nix
./xorg_plasma.nix
./console.nix
];
}

View File

@ -0,0 +1,17 @@
{
time.timezone = "Europe/Paris";
i18n.defaultLocale = "en_GB.UTF-8";
i18n.extraLocaleSettings = {
LC_MESSAGES = "fr_FR.UTF-8";
LC_ADDRESS = "de_DE.UTF-8";
LC_IDENTIFICATION = "fr_FR.UTF-8";
LC_MEASUREMENT = "de_DE.UTF-8";
LC_MONETARY = "de_DE.UTF-8";
LC_NAME = "fr_FR.UTF-8";
LC_NUMERIC = "fr_FR.UTF-8";
LC_PAPER = "de_DE.UTF-8";
LC_TELEPHONE = "fr_FR.UTF-8";
LC_TIME = "fr_FR.UTF-8";
};
}

View File

@ -0,0 +1,17 @@
{
services.xserver = {
# Enable the X11 windowing system
enable = true;
# Enable Keymap
xkb = {
layout = "us";
variant = "qwerty";
# model = "thinkpad";
};
# KDE X
displayManager.sddm.enable = true;
displayManager.plasma5.enable = true;
};
}

View File

@ -0,0 +1,93 @@
# NOTE: ... is needed because dikso passes diskoFile
{
lib,
disk ? [ "/dev/vda" ],
withSwap ? true,
swapSize ? "16",
...
}:
{
disko.devices = {
disk = {
main = {
type = "disk";
device = "/dev/disk/by-id/nvme-eui.002538d211111953";
content = {
type = "gpt";
partitions = {
ESP = {
# name = "ESP";
priority = 1;
start = "1M";
end = "512M";
type = "EF00";
content = {
type = "filesystem";
format = "vfat";
mountpoint = "/boot";
mountOptions = [ "defaults" ];
};
};
luks = {
# name = "root";
size = "100%";
content = {
type = "luks";
name = "crypted";
# disable settings.keyFile if you want to use interactive password entry
# passwordFile = "/tmp/secret.key"; # Interactive
settings = {
allowDiscards = true;
# keyFile = "/tmp/secret.key";
};
# additionalKeyFiles = [ "/tmp/hdd.key" ];
content = {
type = "btrfs";
extraArgs = [ "-f" ]; # Override existing partition
# Subvolumes must set a mountpoint in order to be mounted,
# unless their parent is mounted
subvolumes = {
"@root" = {
mountpoint = "/";
mountOptions = [ "compress=zstd" "noatime" ];
};
"@home" = {
mountpoint = "/home";
mountOptions = [ "compress=zstd" ];
};
"@nix" = {
mountpoint = "/nix";
mountOptions = [ "compress=zstd" "noatime" ];
};
"@persist" = {
mountpoint = "/persist";
mountOptions = [ "compress=zstd" "noatime" ];
};
"@var-lib" = {
mountpoint = "/var/lib";
mountOptions = [ "compress=zstd" "noatime" ];
};
"@var-log" = {
mountpoint = "/var/log";
mountOptions = [ "compress=zstd" "noatime" ];
};
"@var-tmp" = {
mountpoint = "/var/tmp";
mountOptions = [ "compress=zstd" "noatime" ];
};
"@swap" = lib.mkIf withSwap {
mountpoint = "/.swapvol";
swap.swapfile.size = "${swapSize}G";
};
};
};
};
};
};
};
};
};
};
}

View File

@ -0,0 +1,6 @@
{
imports = [
./pipewire.nix
./boot
];
}

View File

@ -0,0 +1,61 @@
{ pkgs, inputs, config, lib, configVars, configLib, ... }:
let
ifTheyExist = groups: builtins.filter (group: builtins.hasAttr group config.users.groups) groups;
# sopsHashedPasswordFile = lib.optionalString (lib.hasAttr "sops-nix" inputs) config.sops.secrets."${configVars.username}/password".path;
pubKeys = lib.filesystem.listFilesRecursive (./keys);
# these are values we don't want to set if the environment is minimal. E.g. ISO or nixos-installer
# isMinimal is true in the nixos-installer/flake.nix
fullUserConfig = lib.optionalAttrs (!configVars.isMinimal)
{
users.users.${configVars.username} = {
# hashedPasswordFile = sopsHashedPasswordFile;
packages = [ pkgs.home-manager ];
};
# Import this user's personal/home configurations
home-manager.users.${configVars.username} = import (configLib.relativeToRoot "home/${configVars.username}/${config.networking.hostName}.nix");
};
in
{
config = lib.recursiveUpdate fullUserConfig
#this is the second argument to recursiveUpdate
{
users.mutableUsers = false; # Only allow declarative credentials; Required for sops
users.users.${configVars.username} = {
isNormalUser = true;
password = "nixos"; # Overridden if sops is working
extraGroups = [
"wheel"
] ++ ifTheyExist [
"audio"
"video"
"docker"
"git"
"networkmanager"
];
# These get placed into /etc/ssh/authorized_keys.d/<name> on nixos
openssh.authorizedKeys.keys = lib.lists.forEach pubKeys (key: builtins.readFile key);
shell = pkgs.zsh; # default shell
};
# Proper root use required for borg and some other specific operations
users.users.root = {
hashedPasswordFile = config.users.users.${configVars.username}.hashedPasswordFile;
password = lib.mkForce config.users.users.${configVars.username}.password;
# root's ssh keys are mainly used for remote deployment.
openssh.authorizedKeys.keys = config.users.users.${configVars.username}.openssh.authorizedKeys.keys;
};
# No matter what environment we are in we want these tools for root, and the user(s)
programs.zsh.enable = true;
programs.git.enable = true;
environment.systemPackages = [
pkgs.just
pkgs.rsync
];
};
}