refactor: move to a multi-machine configuration

This commit is contained in:
Khaïs COLIN 2024-08-23 10:20:05 +02:00
parent ded2acef35
commit 7d42651c1c
6 changed files with 123 additions and 62 deletions

View file

@ -1,38 +1,9 @@
# Edit this configuration file to define what should be installed on
# your system. Help is available in the configuration.nix(5) man page
# and in the NixOS manual (accessible by running nixos-help).
{ pkgs, ... }: { pkgs, ... }:
{ {
imports =
[ # Include the results of the hardware scan.
./hardware-configuration.nix
./sourcehut.nix
./snipeit.nix
./borgbackup.nix
];
# Bootloader. # Bootloader.
boot.loader.systemd-boot.enable = true; boot.loader.systemd-boot.enable = true;
boot.loader.efi.canTouchEfiVariables = true; boot.loader.efi.canTouchEfiVariables = true;
networking.hostName = "nixos"; # Define your hostname.
networking.extraHosts = ''
127.0.0.1 sourcehut.nixos.local
127.0.0.1 meta.sourcehut.nixos.local
127.0.0.1 man.sourcehut.nixos.local
127.0.0.1 git.sourcehut.nixos.local
127.0.0.1 snipe-it.nixos.local
127.0.0.1 inventree.nixos.local
'';
# networking.wireless.enable = true; # Enables wireless support via wpa_supplicant.
# Configure network proxy if necessary
# networking.proxy.default = "http://user:password@proxy:port/";
# networking.proxy.noProxy = "127.0.0.1,localhost,internal.domain";
# Enable networking # Enable networking
networking.networkmanager.enable = true; networking.networkmanager.enable = true;
@ -172,25 +143,6 @@
# enableSSHSupport = true; # enableSSHSupport = true;
# }; # };
# automount smb music share
fileSystems."/home/khais/Music" = {
device = "//void/Music";
fsType = "cifs";
options = let
# prevent hanging when network is not reachable
automount_opts = "x-systemd.automount,noauto,x-systemd.idle-timeout=60,x-systemd.device-timeout=5s,x-systemd.mount-timeout=5s";
in [ "${automount_opts},credentials=/etc/nixos/secrets/music.smb" ];
};
fileSystems."/home/khais/Books" = {
device = "//void/Books";
fsType = "cifs";
options = let
# prevent hanging when network is not reachable
automount_opts = "x-systemd.automount,noauto,x-systemd.idle-timeout=60,x-systemd.device-timeout=5s,x-systemd.mount-timeout=5s";
in [ "${automount_opts},credentials=/etc/nixos/secrets/books.smb" ];
};
# font configuration # font configuration
fonts = { fonts = {
packages = with pkgs; [ packages = with pkgs; [
@ -207,12 +159,6 @@
}; };
}; };
# fingerprint sensor setup
services.open-fprintd.enable = true;
services.python-validity.enable = true;
# List services that you want to enable:
services.tailscale = { services.tailscale = {
enable = true; enable = true;
useRoutingFeatures = "both"; useRoutingFeatures = "both";
@ -240,12 +186,6 @@
# Enable the OpenSSH daemon. # Enable the OpenSSH daemon.
services.openssh.enable = true; services.openssh.enable = true;
# Open ports in the firewall.
networking.firewall.allowedTCPPorts = [ 80 443 ];
networking.firewall.allowedUDPPorts = [ 80 443 ];
# Or disable the firewall altogether.
# networking.firewall.enable = false;
# enable manpages documentation # enable manpages documentation
documentation = { documentation = {
man = { man = {

View file

@ -49,10 +49,32 @@
system = "x86_64-linux"; system = "x86_64-linux";
in in
{ {
nixosConfigurations.nixos = nixpkgs.lib.nixosSystem { nixosConfigurations.void = nixpkgs.lib.nixosSystem {
inherit system; inherit system;
modules = [ modules = [
./configuration.nix ./void.nix
home-manager.nixosModules.home-manager {
home-manager = {
useGlobalPkgs = true;
useUserPackages = true;
users.khais = ./home.nix;
extraSpecialArgs = {
nixvim = nixvim.packages.${system}.default;
river-shifttags = river-shifttags.packages.${system}.default;
breezex-cursor = breezex-cursor.packages.${system}.default;
};
};
}
stylix.nixosModules.stylix
./stylix.nix
];
};
nixosConfigurations.t470 = nixpkgs.lib.nixosSystem {
inherit system;
modules = [
./t470.nix
home-manager.nixosModules.home-manager { home-manager.nixosModules.home-manager {
home-manager = { home-manager = {

View file

@ -0,0 +1,39 @@
# Do not modify this file! It was generated by nixos-generate-config
# and may be overwritten by future invocations. Please make changes
# to /etc/nixos/configuration.nix instead.
{ config, lib, pkgs, modulesPath, ... }:
{
imports =
[ (modulesPath + "/installer/scan/not-detected.nix")
];
boot.initrd.availableKernelModules = [ "xhci_pci" "ahci" "nvme" "usb_storage" "usbhid" "sd_mod" "sr_mod" ];
boot.initrd.kernelModules = [ ];
boot.kernelModules = [ "kvm-intel" ];
boot.extraModulePackages = [ ];
fileSystems."/" =
{ device = "/dev/disk/by-uuid/29ecd09f-8852-4582-a78a-ec1aa1e7b2b9";
fsType = "ext4";
};
fileSystems."/boot" =
{ device = "/dev/disk/by-uuid/E135-9F42";
fsType = "vfat";
options = [ "fmask=0022" "dmask=0022" ];
};
swapDevices = [ ];
# Enables DHCP on each ethernet and wireless interface. In case of scripted networking
# (the default) this is the recommended approach. When using systemd-networkd it's
# still possible to use this option, but it's recommended to use it in conjunction
# with explicit per-interface declarations with `networking.interfaces.<interface>.useDHCP`.
networking.useDHCP = lib.mkDefault true;
# networking.interfaces.enp6s0.useDHCP = lib.mkDefault true;
# networking.interfaces.wlo1.useDHCP = lib.mkDefault true;
nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux";
hardware.cpu.intel.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware;
}

48
nixos/t470.nix Normal file
View file

@ -0,0 +1,48 @@
# Edit this configuration file to define what should be installed on
# your system. Help is available in the configuration.nix(5) man page
# and in the NixOS manual (accessible by running nixos-help).
{ pkgs, ... }:
{
imports = [
./hardware-configuration-t470.nix
./sourcehut.nix
./snipeit.nix
./borgbackup.nix
];
networking.hostName = "t470"; # Define your hostname.
networking.extraHosts = ''
127.0.0.1 sourcehut.nixos.local
127.0.0.1 meta.sourcehut.nixos.local
127.0.0.1 man.sourcehut.nixos.local
127.0.0.1 git.sourcehut.nixos.local
127.0.0.1 snipe-it.nixos.local
127.0.0.1 inventree.nixos.local
'';
# automount smb music share
fileSystems."/home/khais/Music" = {
device = "//void/Music";
fsType = "cifs";
options = let
# prevent hanging when network is not reachable
automount_opts = "x-systemd.automount,noauto,x-systemd.idle-timeout=60,x-systemd.device-timeout=5s,x-systemd.mount-timeout=5s";
in [ "${automount_opts},credentials=/etc/nixos/secrets/music.smb" ];
};
fileSystems."/home/khais/Books" = {
device = "//void/Books";
fsType = "cifs";
options = let
# prevent hanging when network is not reachable
automount_opts = "x-systemd.automount,noauto,x-systemd.idle-timeout=60,x-systemd.device-timeout=5s,x-systemd.mount-timeout=5s";
in [ "${automount_opts},credentials=/etc/nixos/secrets/books.smb" ];
};
# fingerprint sensor setup
services.open-fprintd.enable = true;
services.python-validity.enable = true;
}

12
nixos/void.nix Normal file
View file

@ -0,0 +1,12 @@
# Edit this configuration file to define what should be installed on
# your system. Help is available in the configuration.nix(5) man page
# and in the NixOS manual (accessible by running nixos-help).
{
imports = [
./hardware-configuration-void.nix
./common.nix
];
networking.hostName = "void"; # Define your hostname.
}