From 5c44e12cf978b0ae4a05dd7f282daeb14b80ddfe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20R=C3=B6ger?= Date: Sun, 7 Apr 2024 21:38:22 +0200 Subject: [PATCH] add vm draft --- flake.nix | 12 ++++ hosts/vm/configuration.nix | 79 ++++++++++++++++++++++++++ hosts/vm/hardware-configuration.nix | 35 ++++++++++++ modules/desktop/x11-plasma-lightdm.nix | 21 +++++++ 4 files changed, 147 insertions(+) create mode 100644 hosts/vm/configuration.nix create mode 100644 hosts/vm/hardware-configuration.nix create mode 100644 modules/desktop/x11-plasma-lightdm.nix diff --git a/flake.nix b/flake.nix index e9faa13..9e115e6 100644 --- a/flake.nix +++ b/flake.nix @@ -24,6 +24,18 @@ } ]; }; + vm = nixpkgs.lib.nixosSystem { + system = "x86_64-linux"; + specialArgs = {inherit inputs;}; + modules = [ + ./hosts/vm/configuration.nix + home-manager.nixosModules.home-manager { + home-manager.useGlobalPkgs = true; + home-manager.useUserPackages = true; + home-manager.users.jonas = import ./home/jonas.home.nix; + } + ]; + }; }; }; } diff --git a/hosts/vm/configuration.nix b/hosts/vm/configuration.nix new file mode 100644 index 0000000..e7c4087 --- /dev/null +++ b/hosts/vm/configuration.nix @@ -0,0 +1,79 @@ +# 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’). + +{ config, pkgs, inputs, ... }: + +{ + imports = + [ # Include the results of the hardware scan. + ./hardware-configuration.nix + inputs.home-manager.nixosModules.home-manager + ../../modules/system/boot.nix + ../../modules/system/console.nix + ../../modules/system/localization.nix + ../../modules/system/network.nix + ../../modules/hardware/bluetooth.nix + ../../modules/hardware/printing.nix + ../../modules/hardware/sound.nix + ../../modules/desktop/x11-plasma-lightdm.nix + ../../modules/services/docker.nix + ]; + + nix.settings.experimental-features = [ "nix-command" "flakes" ]; + + # Enable touchpad support (enabled default in most desktopManager). + # services.xserver.libinput.enable = true; + + # Define a user account. Don't forget to set a password with ‘passwd’. + users.users.jonas = { + isNormalUser = true; + description = "Jonas"; + extraGroups = [ "networkmanager" "wheel" ]; + packages = with pkgs; [ ]; + }; + users.defaultUserShell = pkgs.zsh; + + programs.zsh.enable = true; + + # Allow unfree packages + nixpkgs.config.allowUnfree = true; + + # List packages installed in system profile. To search, run: + # $ nix search wget + environment.systemPackages = with pkgs; [ + docker + git + ranger + vim + 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; + + # This value determines the NixOS release from which the default + # settings for stateful data, like file locations and database versions + # on your system were taken. It‘s perfectly fine and recommended to leave + # this value at the release version of the first install of this system. + # Before changing this value read the documentation for this option + # (e.g. man configuration.nix or on https://nixos.org/nixos/options.html). + system.stateVersion = "23.11"; # Did you read the comment? + +} diff --git a/hosts/vm/hardware-configuration.nix b/hosts/vm/hardware-configuration.nix new file mode 100644 index 0000000..c0c3be1 --- /dev/null +++ b/hosts/vm/hardware-configuration.nix @@ -0,0 +1,35 @@ +# 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 = [ ]; + + boot.initrd.availableKernelModules = [ "sd_mod" "sr_mod" ]; + boot.initrd.kernelModules = [ ]; + boot.kernelModules = [ ]; + boot.extraModulePackages = [ ]; + + fileSystems."/" = + { device = "/dev/disk/by-uuid/0bbdc54a-243c-4b40-8566-c12adff1417a"; + fsType = "ext4"; + }; + + fileSystems."/boot" = + { device = "/dev/disk/by-uuid/5DE9-BA20"; + fsType = "vfat"; + }; + + 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.eth0.useDHCP = lib.mkDefault true; + + nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux"; + virtualisation.hypervGuest.enable = true; +} diff --git a/modules/desktop/x11-plasma-lightdm.nix b/modules/desktop/x11-plasma-lightdm.nix new file mode 100644 index 0000000..c9be99c --- /dev/null +++ b/modules/desktop/x11-plasma-lightdm.nix @@ -0,0 +1,21 @@ +{ config, ... }: + +{ + # Enable the X11 windowing system. + services.xserver.enable = true; + + # Configure keymap in X11 + services.xserver = { + layout = "de"; + xkbVariant = ""; + }; + + # Enable the KDE Plasma Desktop Environment. + services.xserver.displayManager.lightdm.enable = true; + services.xserver.desktopManager.plasma5.enable = true; + + # Enable automatic login for the user. + services.xserver.displayManager.autoLogin.enable = true; + services.xserver.displayManager.autoLogin.user = "jonas"; + +}