From 5288417f6f6449b305c075c20dbf5ab40b2c6de9 Mon Sep 17 00:00:00 2001 From: Mohammad Rafiq Date: Sat, 22 Feb 2025 10:17:38 +0800 Subject: [PATCH] build: init initial nixos config test --- flake.nix | 37 ++++++++++ hosts/hekate/configuration.nix | 92 +++++++++++++++++++++++++ hosts/hekate/default.nix | 8 +++ hosts/hekate/hardware-configuration.nix | 42 +++++++++++ users/rafiq/home.nix | 17 +++++ 5 files changed, 196 insertions(+) create mode 100644 flake.nix create mode 100644 hosts/hekate/configuration.nix create mode 100644 hosts/hekate/default.nix create mode 100644 hosts/hekate/hardware-configuration.nix create mode 100644 users/rafiq/home.nix diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..565dc68 --- /dev/null +++ b/flake.nix @@ -0,0 +1,37 @@ +{ + description = "a minimal NixOS config using flake and home-manager"; + + # Declare dependencies + inputs = { + nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; + nixpkgs-stable.url = "github:nixos/nixpkgs/nixos-24.11"; + + home-manager = { + url = "github:nix-community/home-manager"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + }; + + outputs = inputs @ { + self, + nixpkgs, + home-manager, + ... + }: { + nixosConfigurations = { + hekate = nixpkgs.lib.nixosSystem { + modules = [ + ./hosts/hekate + + home-manager.nixosModules.home-manager + { + home-manager.useGlobalPkgs = true; + home-manager.useUserPackages = true; + + home-manager.users.rafiq = import ./users/rafiq/home.nix; + } + ]; + }; + }; + }; +} diff --git a/hosts/hekate/configuration.nix b/hosts/hekate/configuration.nix new file mode 100644 index 0000000..6ca3f41 --- /dev/null +++ b/hosts/hekate/configuration.nix @@ -0,0 +1,92 @@ +# Edit this configuration file to define what should be installed on +# your system. Help is available in the configuration.nix(5) man page, on +# https://search.nixos.org/options and in the NixOS manual (`nixos-help`). + +{ config, lib, pkgs, ... }: + +{ + imports = + [ # Include the results of the hardware scan. + ./hardware-configuration.nix + ]; + + # Use the systemd-boot EFI boot loader. + boot.loader.systemd-boot.enable = true; + boot.loader.efi.canTouchEfiVariables = true; + + networking.hostName = "hekate"; # Define your hostname. + networking.networkmanager.enable = true; # Easiest to use and most distros use this by default. + + # Set your time zone. + time.timeZone = "Asia/Singapore"; + + i18n.defaultLocale = "en_US.UTF-8"; + console = { + font = "Lat2-Terminus32"; + 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; + + # Define a user account. Don't forget to set a password with ‘passwd’. + users.users.rafiq. = { + isNormalUser = true; + extraGroups = [ "networkmanager" "wheel" ]; # Enable ‘sudo’ for the user. + }; + + # 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 + git + ]; + + # 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/hosts/hekate/default.nix b/hosts/hekate/default.nix new file mode 100644 index 0000000..8c73acc --- /dev/null +++ b/hosts/hekate/default.nix @@ -0,0 +1,8 @@ +# automatically called by flake.nix +{ config, pkgs, lib, ... }: + +{ + imports = [ + ./configuration.nix + ]; +} diff --git a/hosts/hekate/hardware-configuration.nix b/hosts/hekate/hardware-configuration.nix new file mode 100644 index 0000000..344113b --- /dev/null +++ b/hosts/hekate/hardware-configuration.nix @@ -0,0 +1,42 @@ +# 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" "usbhid" ]; + boot.initrd.kernelModules = [ ]; + boot.kernelModules = [ "kvm-amd" ]; + boot.extraModulePackages = [ ]; + + fileSystems."/" = + { device = "/dev/disk/by-uuid/98672de4-5c33-44e5-a79e-e512a2e0c7c0"; + fsType = "ext4"; + }; + + fileSystems."/boot" = + { device = "/dev/disk/by-uuid/D25D-5694"; + fsType = "vfat"; + options = [ "fmask=0077" "dmask=0077" ]; + }; + + swapDevices = + [ { device = "/dev/disk/by-uuid/b4a0eab4-93f4-430a-83c8-66b9459185a8"; } + ]; + + # 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.docker0.useDHCP = lib.mkDefault true; + # networking.interfaces.enp12s0.useDHCP = lib.mkDefault true; + # networking.interfaces.wlp13s0.useDHCP = lib.mkDefault true; + + nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux"; + hardware.cpu.amd.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware; +} diff --git a/users/rafiq/home.nix b/users/rafiq/home.nix new file mode 100644 index 0000000..cd639ee --- /dev/null +++ b/users/rafiq/home.nix @@ -0,0 +1,17 @@ +{ config, pkgs, ... }: + +{ + home.username = "rafiq"; + home.homeDirectory = "/home/rafiq"; + + home.stateVersion = "24.11" + + programs.home-manager.enable = true; + + # Git Configuration + programs.git = { + enable = true; + userName = "Mohammad Rafiq"; + userEmail = "mohammadrafiq567@gmail.com"; + }; +}