From 6ef0dca25fed75a5cfc3f82f6e199128722c6c94 Mon Sep 17 00:00:00 2001 From: GHOSCHT <31184695+GHOSCHT@users.noreply.github.com> Date: Sat, 23 Dec 2023 22:05:10 +0100 Subject: [PATCH] Add multihost support --- flake.lock | 22 +++++----- flake.nix | 16 +++---- .../ghoscht/global/default.nix | 21 ++++++--- .../adalbert/default.nix | 9 ++-- hosts/adalbert/hardware-configuration.nix | 43 +++++++++++++++++++ nixos/hardware-configuration.nix | 10 ----- 6 files changed, 79 insertions(+), 42 deletions(-) rename home-manager/home.nix => home/ghoscht/global/default.nix (79%) rename nixos/configuration.nix => hosts/adalbert/default.nix (95%) create mode 100644 hosts/adalbert/hardware-configuration.nix delete mode 100644 nixos/hardware-configuration.nix diff --git a/flake.lock b/flake.lock index 05ed3b7..a7f5119 100644 --- a/flake.lock +++ b/flake.lock @@ -7,43 +7,43 @@ ] }, "locked": { - "lastModified": 1685599623, - "narHash": "sha256-Tob4CMOVHue0D3RzguDBCtUmX5ji2PsdbQDbIOIKvsc=", + "lastModified": 1703113038, + "narHash": "sha256-oxkyzjpD+mNT7arzU/zHrkNHLuY9tKwmnD2MNaZiSDw=", "owner": "nix-community", "repo": "home-manager", - "rev": "93db05480c0c0f30382d3e80779e8386dcb4f9dd", + "rev": "0c2353d5d930c3d93724df6858aef064a31b3c00", "type": "github" }, "original": { "owner": "nix-community", - "ref": "release-23.05", + "ref": "release-23.11", "repo": "home-manager", "type": "github" } }, "nixpkgs": { "locked": { - "lastModified": 1686431482, - "narHash": "sha256-oPVQ/0YP7yC2ztNsxvWLrV+f0NQ2QAwxbrZ+bgGydEM=", + "lastModified": 1703068421, + "narHash": "sha256-WSw5Faqlw75McIflnl5v7qVD/B3S2sLh+968bpOGrWA=", "owner": "nixos", "repo": "nixpkgs", - "rev": "d3bb401dcfc5a46ce51cdfb5762e70cc75d082d2", + "rev": "d65bceaee0fb1e64363f7871bc43dc1c6ecad99f", "type": "github" }, "original": { "owner": "nixos", - "ref": "nixos-23.05", + "ref": "nixos-23.11", "repo": "nixpkgs", "type": "github" } }, "nixpkgs-unstable": { "locked": { - "lastModified": 1686501370, - "narHash": "sha256-G0WuM9fqTPRc2URKP9Lgi5nhZMqsfHGrdEbrLvAPJcg=", + "lastModified": 1697059129, + "narHash": "sha256-9NJcFF9CEYPvHJ5ckE8kvINvI84SZZ87PvqMbH6pro0=", "owner": "nixos", "repo": "nixpkgs", - "rev": "75a5ebf473cd60148ba9aec0d219f72e5cf52519", + "rev": "5e4c2ada4fcd54b99d56d7bd62f384511a7e2593", "type": "github" }, "original": { diff --git a/flake.nix b/flake.nix index 61960d1..c3054b2 100644 --- a/flake.nix +++ b/flake.nix @@ -3,14 +3,14 @@ inputs = { # Nixpkgs - nixpkgs.url = "github:nixos/nixpkgs/nixos-23.05"; + nixpkgs.url = "github:nixos/nixpkgs/nixos-23.11"; # You can access packages and modules from different nixpkgs revs # at the same time. Here's an working example: nixpkgs-unstable.url = "github:nixos/nixpkgs/nixos-unstable"; # Also see the 'unstable-packages' overlay at 'overlays/default.nix'. # Home manager - home-manager.url = "github:nix-community/home-manager/release-23.05"; + home-manager.url = "github:nix-community/home-manager/release-23.11"; home-manager.inputs.nixpkgs.follows = "nixpkgs"; # TODO: Add any other flake you might need @@ -59,12 +59,10 @@ # NixOS configuration entrypoint # Available through 'nixos-rebuild --flake .#your-hostname' nixosConfigurations = { - # FIXME replace with your hostname - your-hostname = nixpkgs.lib.nixosSystem { + adalbert = nixpkgs.lib.nixosSystem { specialArgs = {inherit inputs outputs;}; modules = [ - # > Our main nixos configuration file < - ./nixos/configuration.nix + ./hosts/adalbert ]; }; }; @@ -72,13 +70,11 @@ # Standalone home-manager configuration entrypoint # Available through 'home-manager --flake .#your-username@your-hostname' homeConfigurations = { - # FIXME replace with your username@hostname - "your-username@your-hostname" = home-manager.lib.homeManagerConfiguration { + "ghoscht@adalbert" = home-manager.lib.homeManagerConfiguration { pkgs = nixpkgs.legacyPackages.x86_64-linux; # Home-manager requires 'pkgs' instance extraSpecialArgs = {inherit inputs outputs;}; modules = [ - # > Our main home-manager configuration file < - ./home-manager/home.nix + ./home/ghoscht/adalbert.nix ]; }; }; diff --git a/home-manager/home.nix b/home/ghoscht/global/default.nix similarity index 79% rename from home-manager/home.nix rename to home/ghoscht/global/default.nix index eedacc2..40b5907 100644 --- a/home-manager/home.nix +++ b/home/ghoscht/global/default.nix @@ -42,15 +42,27 @@ config = { # Disable if you don't want unfree packages allowUnfree = true; + permittedInsecurePackages = [ + "electron-24.8.6" #fixes Feishin & Webcord + ]; # Workaround for https://github.com/nix-community/home-manager/issues/2942 allowUnfreePredicate = _: true; }; }; - # TODO: Set your username + nix = { + package = lib.mkDefault pkgs.nix; + settings = { + experimental-features = ["nix-command" "flakes" "repl-flake"]; + warn-dirty = false; + }; + }; + home = { - username = "your-username"; - homeDirectory = "/home/your-username"; + username = lib.mkDefault "ghoscht"; + homeDirectory = lib.mkDefault "/home/${config.home.username}"; + # https://nixos.wiki/wiki/FAQ/When_do_I_update_stateVersion + stateVersion = "23.11"; }; # Add stuff for your user as you see fit: @@ -63,7 +75,4 @@ # Nicely reload system units when changing configs systemd.user.startServices = "sd-switch"; - - # https://nixos.wiki/wiki/FAQ/When_do_I_update_stateVersion - home.stateVersion = "23.05"; } diff --git a/nixos/configuration.nix b/hosts/adalbert/default.nix similarity index 95% rename from nixos/configuration.nix rename to hosts/adalbert/default.nix index c8b7600..7381192 100644 --- a/nixos/configuration.nix +++ b/hosts/adalbert/default.nix @@ -73,8 +73,7 @@ # FIXME: Add the rest of your current configuration - # TODO: Set your hostname - networking.hostName = "your-hostname"; + networking.hostName = "adalbert"; # TODO: This is just an example, be sure to use whatever bootloader you prefer boot.loader.systemd-boot.enable = true; @@ -82,11 +81,11 @@ # TODO: Configure your system-wide user settings (groups, etc), add more users as needed. users.users = { # FIXME: Replace with your username - your-username = { + ghoscht = { # TODO: You can set an initial password for your user. # If you do, you can skip setting a root password by passing '--no-root-passwd' to nixos-install. # Be sure to change it (using passwd) after rebooting! - initialPassword = "correcthorsebatterystaple"; + initialPassword = "yoi"; isNormalUser = true; openssh.authorizedKeys.keys = [ # TODO: Add your SSH public key(s) here, if you plan on using SSH to connect @@ -109,5 +108,5 @@ }; # https://nixos.wiki/wiki/FAQ/When_do_I_update_stateVersion - system.stateVersion = "23.05"; + system.stateVersion = "23.11"; } diff --git a/hosts/adalbert/hardware-configuration.nix b/hosts/adalbert/hardware-configuration.nix new file mode 100644 index 0000000..ab97b97 --- /dev/null +++ b/hosts/adalbert/hardware-configuration.nix @@ -0,0 +1,43 @@ +# 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" "usbhid" "usb_storage" "sd_mod"]; + boot.initrd.kernelModules = []; + boot.kernelModules = ["kvm-amd"]; + boot.extraModulePackages = []; + + fileSystems."/" = { + device = "/dev/disk/by-uuid/f9ba57fb-0b82-47e0-8189-7bbebc530e2b"; + fsType = "ext4"; + }; + + fileSystems."/boot" = { + device = "/dev/disk/by-uuid/BCF2-51D4"; + fsType = "vfat"; + }; + + swapDevices = [ + {device = "/dev/disk/by-uuid/4834fbc3-3feb-4b93-b11f-8b9bd054c5c1";} + ]; + + # 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.enp5s0.useDHCP = lib.mkDefault true; + + nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux"; + hardware.cpu.amd.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware; +} diff --git a/nixos/hardware-configuration.nix b/nixos/hardware-configuration.nix deleted file mode 100644 index dd00939..0000000 --- a/nixos/hardware-configuration.nix +++ /dev/null @@ -1,10 +0,0 @@ -# This is just an example, you should generate yours with nixos-generate-config and put it in here. -{ - fileSystems."/" = { - device = "/dev/sda1"; - fsType = "ext4"; - }; - - # Set your system kind (needed for flakes) - nixpkgs.hostPlatform = "x86_64-linux"; -}