From 7d42651c1cac2833d1a818bea88fedd05883d1cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kha=C3=AFs=20COLIN?= Date: Fri, 23 Aug 2024 10:20:05 +0200 Subject: [PATCH] refactor: move to a multi-machine configuration --- nixos/{configuration.nix => common.nix} | 60 ------------------- nixos/flake.nix | 26 +++++++- ...on.nix => hardware-configuration-t470.nix} | 0 nixos/hardware-configuration-void.nix | 39 ++++++++++++ nixos/t470.nix | 48 +++++++++++++++ nixos/void.nix | 12 ++++ 6 files changed, 123 insertions(+), 62 deletions(-) rename nixos/{configuration.nix => common.nix} (74%) rename nixos/{hardware-configuration.nix => hardware-configuration-t470.nix} (100%) create mode 100644 nixos/hardware-configuration-void.nix create mode 100644 nixos/t470.nix create mode 100644 nixos/void.nix diff --git a/nixos/configuration.nix b/nixos/common.nix similarity index 74% rename from nixos/configuration.nix rename to nixos/common.nix index 6d25ca0..6138308 100644 --- a/nixos/configuration.nix +++ b/nixos/common.nix @@ -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, ... }: { - imports = - [ # Include the results of the hardware scan. - ./hardware-configuration.nix - ./sourcehut.nix - ./snipeit.nix - ./borgbackup.nix - ]; - # Bootloader. boot.loader.systemd-boot.enable = 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 networking.networkmanager.enable = true; @@ -172,25 +143,6 @@ # 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 fonts = { 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 = { enable = true; useRoutingFeatures = "both"; @@ -240,12 +186,6 @@ # Enable the OpenSSH daemon. 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 documentation = { man = { diff --git a/nixos/flake.nix b/nixos/flake.nix index 318afd4..7cc0a45 100644 --- a/nixos/flake.nix +++ b/nixos/flake.nix @@ -49,10 +49,32 @@ system = "x86_64-linux"; in { - nixosConfigurations.nixos = nixpkgs.lib.nixosSystem { + nixosConfigurations.void = nixpkgs.lib.nixosSystem { inherit system; 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 = { diff --git a/nixos/hardware-configuration.nix b/nixos/hardware-configuration-t470.nix similarity index 100% rename from nixos/hardware-configuration.nix rename to nixos/hardware-configuration-t470.nix diff --git a/nixos/hardware-configuration-void.nix b/nixos/hardware-configuration-void.nix new file mode 100644 index 0000000..71591ff --- /dev/null +++ b/nixos/hardware-configuration-void.nix @@ -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..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; +} diff --git a/nixos/t470.nix b/nixos/t470.nix new file mode 100644 index 0000000..27c2a7e --- /dev/null +++ b/nixos/t470.nix @@ -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; +} diff --git a/nixos/void.nix b/nixos/void.nix new file mode 100644 index 0000000..92fb661 --- /dev/null +++ b/nixos/void.nix @@ -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. +}