From e1407c6468310f8532e6f49d68d6de20d2b23b73 Mon Sep 17 00:00:00 2001 From: m3tam3re Date: Tue, 1 Apr 2025 11:43:00 +0200 Subject: [PATCH] First --- configuration.nix | 48 +++++++++++++++++++++ disko-config.nix | 39 +++++++++++++++++ flake.lock | 85 ++++++++++++++++++++++++++++++++++++++ flake.nix | 54 ++++++++++++++++++++++++ hardware-configuration.nix | 29 +++++++++++++ 5 files changed, 255 insertions(+) create mode 100644 configuration.nix create mode 100644 disko-config.nix create mode 100644 flake.lock create mode 100644 flake.nix create mode 100644 hardware-configuration.nix diff --git a/configuration.nix b/configuration.nix new file mode 100644 index 0000000..7950aff --- /dev/null +++ b/configuration.nix @@ -0,0 +1,48 @@ +{ + lib, + pkgs, + isImageTarget, + ... +}: { + imports = lib.optionals (!isImageTarget) [ + ./hardware-configuration.nix + ./disko-config.nix + ]; + + # boot.loader.grub = { + # enable = true; + # device = "/dev/vda"; + # }; + + # Enable X server and Plasma 6 desktop environment + # services.xserver.enable = true; + services.desktopManager.plasma6.enable = true; + + # Enable SDDM + services.displayManager.sddm.enable = true; + + # Define the "nixos" user + users.users.nixos = { + isNormalUser = true; + extraGroups = ["wheel" "networkmanager"]; # "wheel" for sudo, "networkmanager" for networking + initialPassword = "nixos"; # Default password (changeable on first login) + }; + + # Allow passwordless sudo for the "wheel" group + security.sudo.wheelNeedsPassword = false; + + # Install essential packages + environment.systemPackages = with pkgs; [ + brave + vlc + ]; + + # Enable networking with NetworkManager + networking.networkmanager.enable = true; + + # Set the time zone (optional) + time.timeZone = "UTC"; + + # Specify the system state version + system.stateVersion = "23.05"; +} diff --git a/disko-config.nix b/disko-config.nix new file mode 100644 index 0000000..324d0aa --- /dev/null +++ b/disko-config.nix @@ -0,0 +1,39 @@ +{ + disko.devices = { + disk = { + main = { + type = "disk"; + device = "/dev/sda"; # CHANGE ME + content = { + type = "gpt"; + partitions = { + boot = { + size = "1M"; + type = "EF02"; # for GRUB MBR + priority = 1; + }; + esp = { + size = "512M"; + type = "EF00"; + content = { + type = "filesystem"; + format = "vfat"; + mountpoint = "/boot"; + mountOptions = ["defaults" "umask=0077"]; + }; + }; + root = { + size = "100%"; + content = { + type = "filesystem"; + format = "ext4"; + mountpoint = "/"; + mountOptions = ["noatime" "nodiratime" "discard"]; + }; + }; + }; + }; + }; + }; + }; +} diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..34a2f71 --- /dev/null +++ b/flake.lock @@ -0,0 +1,85 @@ +{ + "nodes": { + "disko": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1741786315, + "narHash": "sha256-VT65AE2syHVj6v/DGB496bqBnu1PXrrzwlw07/Zpllc=", + "owner": "nix-community", + "repo": "disko", + "rev": "0d8c6ad4a43906d14abd5c60e0ffe7b587b213de", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "disko", + "type": "github" + } + }, + "nixlib": { + "locked": { + "lastModified": 1736643958, + "narHash": "sha256-tmpqTSWVRJVhpvfSN9KXBvKEXplrwKnSZNAoNPf/S/s=", + "owner": "nix-community", + "repo": "nixpkgs.lib", + "rev": "1418bc28a52126761c02dd3d89b2d8ca0f521181", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "nixpkgs.lib", + "type": "github" + } + }, + "nixos-generators": { + "inputs": { + "nixlib": "nixlib", + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1742568034, + "narHash": "sha256-QaMEhcnscfF2MqB7flZr+sLJMMYZPnvqO4NYf9B4G38=", + "owner": "nix-community", + "repo": "nixos-generators", + "rev": "42ee229088490e3777ed7d1162cb9e9d8c3dbb11", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "nixos-generators", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1743315132, + "narHash": "sha256-6hl6L/tRnwubHcA4pfUUtk542wn2Om+D4UnDhlDW9BE=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "52faf482a3889b7619003c0daec593a1912fddc1", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "disko": "disko", + "nixos-generators": "nixos-generators", + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..a1e6cd1 --- /dev/null +++ b/flake.nix @@ -0,0 +1,54 @@ +{ + inputs = { + nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; + + nixos-generators = { + url = "github:nix-community/nixos-generators"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + disko = { + url = "github:nix-community/disko"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + }; + + outputs = { + nixpkgs, + nixos-generators, + ... + } @ inputs: { + nixosConfigurations = { + m3-zelda = nixpkgs.lib.nixosSystem { + modules = [ + ./configuration.nix + inputs.disko.nixosModules.disko + ]; + specialArgs = { + isImageTarget = false; + }; + }; + }; + packages.x86_64-linux = { + iso = nixos-generators.nixosGenerate { + system = "x86_64-linux"; + modules = [ + ./configuration.nix + ]; + specialArgs = { + isImageTarget = true; + }; + format = "iso"; + }; + qcow = nixos-generators.nixosGenerate { + system = "x86_64-linux"; + modules = [ + ./configuration.nix + ]; + specialArgs = { + isImageTarget = true; + }; + format = "qcow"; + }; + }; + }; +} diff --git a/hardware-configuration.nix b/hardware-configuration.nix new file mode 100644 index 0000000..7d3946a --- /dev/null +++ b/hardware-configuration.nix @@ -0,0 +1,29 @@ +# 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 + "/profiles/qemu-guest.nix") + ]; + + boot.initrd.availableKernelModules = ["ahci" "xhci_pci" "virtio_pci" "sr_mod" "virtio_blk"]; + boot.initrd.kernelModules = []; + boot.extraModulePackages = []; + + 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.enp1s0.useDHCP = lib.mkDefault true; + + nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux"; +}