From 746e099f9f1ba2cefc448523c87a3dbbb2f813cb Mon Sep 17 00:00:00 2001 From: uttarayan21 Date: Mon, 18 Nov 2024 21:05:18 +0530 Subject: [PATCH] feat: Added nixos remote device --- flake.nix | 1 + nixos/device.nix | 2 +- nixos/mirai/configuration.nix | 142 ++++++++++++++++++++++++++++++ nixos/mirai/mirai.nix | 38 ++++++++ nixos/{ => ryu}/configuration.nix | 5 +- nixos/{ => ryu}/ryu.nix | 0 6 files changed, 183 insertions(+), 5 deletions(-) create mode 100644 nixos/mirai/configuration.nix create mode 100644 nixos/mirai/mirai.nix rename nixos/{ => ryu}/configuration.nix (96%) rename nixos/{ => ryu}/ryu.nix (100%) diff --git a/flake.nix b/flake.nix index 593a4185..9ad3946d 100644 --- a/flake.nix +++ b/flake.nix @@ -119,6 +119,7 @@ system = "x86_64-linux"; user = "fs0c131y"; hasGui = false; # Don't wan't to run GUI apps on a headless server + isNix = true; isServer = true; } { diff --git a/nixos/device.nix b/nixos/device.nix index dea3cf33..2dcebaa7 100644 --- a/nixos/device.nix +++ b/nixos/device.nix @@ -19,7 +19,7 @@ builtins.listToAttrs (builtins.map (device: { [ nur.nixosModules.nur {nixpkgs.overlays = overlays;} - ./configuration.nix + ./${device.name}/configuration.nix home-manager.nixosModules.home-manager inputs.lanzaboote.nixosModules.lanzaboote inputs.musnix.nixosModules.musnix diff --git a/nixos/mirai/configuration.nix b/nixos/mirai/configuration.nix new file mode 100644 index 00000000..49f9b341 --- /dev/null +++ b/nixos/mirai/configuration.nix @@ -0,0 +1,142 @@ +{ + config, + lib, + pkgs, + ... +}: { + imports = [ + # Include the results of the hardware scan. + ./mirai.nix + ]; + + # Use the systemd-boot EFI boot loader. + boot.loader.systemd-boot.enable = true; + boot.loader.efi.canTouchEfiVariables = true; + + nix = { + settings = { + auto-optimise-store = true; + extra-experimental-features = "nix-command flakes auto-allocate-uids"; + trusted-users = ["root" "servius" "fs0c131y"]; + }; + extraOptions = '' + build-users-group = nixbld + extra-nix-path = nixpkgs=flake:nixpkgs + builders-use-substitutes = true + ''; + gc = { + automatic = true; + dates = "daily"; + options = "--delete-older-than +5"; + }; + package = pkgs.nixVersions.latest; + distributedBuilds = true; + }; + + users.users.fs0c131y = { + isNormalUser = true; + extraGroups = ["wheel"]; + }; + + nixpkgs.config.allowUnfree = true; + # networking.hostName = "nixos"; # Define your hostname. + # Pick only one of the below networking options. + # networking.wireless.enable = true; # Enables wireless support via wpa_supplicant. + # networking.networkmanager.enable = true; # Easiest to use and most distros use this by default. + + # Set your time zone. + time.timeZone = "Europe/Helsinki"; + + # Configure network proxy if necessary + # networking.proxy.default = "http://user:password@proxy:port/"; + # networking.proxy.noProxy = "127.0.0.1,localhost,internal.domain"; + + # Select internationalisation properties. + # i18n.defaultLocale = "en_US.UTF-8"; + # console = { + # font = "Lat2-Terminus16"; + # keyMap = "us"; + # useXkbConfig = true; # use xkb.options in tty. + # }; + + # Enable the X11 windowing system. + # services.xserver.enable = true; + + # Configure keymap in X11 + # services.xserver.xkb.layout = "us"; + # services.xserver.xkb.options = "eurosign:e,caps:escape"; + + # Enable CUPS to print documents. + # services.printing.enable = true; + + # Enable sound. + # hardware.pulseaudio.enable = true; + # OR + # services.pipewire = { + # enable = true; + # pulse.enable = true; + # }; + + # Enable touchpad support (enabled default in most desktopManager). + # services.libinput.enable = true; + + # Define a user account. Don't forget to set a password with ‘passwd’. + # users.users.alice = { + # isNormalUser = true; + # extraGroups = [ "wheel" ]; # Enable ‘sudo’ for the user. + # packages = with pkgs; [ + # firefox + # tree + # ]; + # }; + + # List packages installed in system profile. To search, run: + # $ nix search wget + # environment.systemPackages = with pkgs; [ + # vim # Do not forget to add an editor to edit configuration.nix! The Nano editor is also installed by default. + # wget + # ]; + + # Some programs need SUID wrappers, can be configured further or are + # started in user sessions. + # programs.mtr.enable = true; + # programs.gnupg.agent = { + # enable = true; + # enableSSHSupport = true; + # }; + + # List services that you want to enable: + + # Enable the OpenSSH daemon. + services.openssh.enable = true; + + # Open ports in the firewall. + # networking.firewall.allowedTCPPorts = [ ... ]; + # networking.firewall.allowedUDPPorts = [ ... ]; + # Or disable the firewall altogether. + # networking.firewall.enable = false; + + # Copy the NixOS configuration file and link it from the resulting system + # (/run/current-system/configuration.nix). This is useful in case you + # accidentally delete configuration.nix. + # system.copySystemConfiguration = true; + + # This option defines the first version of NixOS you have installed on this particular machine, + # and is used to maintain compatibility with application data (e.g. databases) created on older NixOS versions. + # + # Most users should NEVER change this value after the initial install, for any reason, + # even if you've upgraded your system to a new NixOS release. + # + # This value does NOT affect the Nixpkgs version your packages and OS are pulled from, + # so changing it will NOT upgrade your system - see https://nixos.org/manual/nixos/stable/#sec-upgrading for how + # to actually do that. + # + # This value being lower than the current NixOS release does NOT mean your system is + # out of date, out of support, or vulnerable. + # + # Do NOT change this value unless you have manually inspected all the changes it would make to your configuration, + # and migrated your data accordingly. + # + # For more information, see `man configuration.nix` or https://nixos.org/manual/nixos/stable/options#opt-system.stateVersion . + system.stateVersion = "24.11"; # Did you read the comment? +} diff --git a/nixos/mirai/mirai.nix b/nixos/mirai/mirai.nix new file mode 100644 index 00000000..5f377d53 --- /dev/null +++ b/nixos/mirai/mirai.nix @@ -0,0 +1,38 @@ +# 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 = [ "nvme" "xhci_pci" "ahci" ]; + boot.initrd.kernelModules = [ "dm-snapshot" ]; + boot.kernelModules = [ "kvm-amd" ]; + boot.extraModulePackages = [ ]; + + fileSystems."/" = + { device = "/dev/disk/by-uuid/8f805d1b-a469-4db8-9ee1-b98ea220714a"; + fsType = "ext4"; + }; + + fileSystems."/boot" = + { device = "/dev/disk/by-uuid/D840-A590"; + 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; + + nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux"; + hardware.cpu.amd.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware; +} diff --git a/nixos/configuration.nix b/nixos/ryu/configuration.nix similarity index 96% rename from nixos/configuration.nix rename to nixos/ryu/configuration.nix index 7eb08d2c..e188dac7 100644 --- a/nixos/configuration.nix +++ b/nixos/ryu/configuration.nix @@ -1,6 +1,3 @@ -# 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, device, @@ -159,7 +156,7 @@ # List services that you want to enable: # Enable the OpenSSH daemon. - # services.openssh.enable = true; + services.openssh.enable = true; # Open ports in the firewall. # networking.firewall.allowedTCPPorts = [ ... ]; diff --git a/nixos/ryu.nix b/nixos/ryu/ryu.nix similarity index 100% rename from nixos/ryu.nix rename to nixos/ryu/ryu.nix