feat: NixOS | add disko and hashed password for user

This commit is contained in:
2025-01-31 16:49:54 +05:00
parent 6b844a28da
commit e885306bf0
4 changed files with 83 additions and 28 deletions

View File

@@ -6,26 +6,40 @@
home-manager.url = "github:nix-community/home-manager/release-24.11"; home-manager.url = "github:nix-community/home-manager/release-24.11";
home-manager.inputs.nixpkgs.follows = "nixpkgs"; home-manager.inputs.nixpkgs.follows = "nixpkgs";
hyprland.url = "github:hyprwm/Hyprland"; hyprland.url = "github:hyprwm/Hyprland";
# Disko
disko.url = "github:nix-community/disko";
disko.inputs.nixpkgs.follows = "nixpkgs";
}; };
outputs = { outputs = {
self, self,
nixpkgs, nixpkgs,
home-manager, home-manager,
disko,
... ...
} @ inputs: } @ inputs:
let let
system = "x86_64-linux"; system = "x86_64-linux";
host = "rihla"; host = "rihla";
user = "shahab"; user = "shahab";
lib = nixpkgs.lib;
pkgs = nixpkgs.legacyPackages.${system}; pkgs = nixpkgs.legacyPackages.${system};
in { in {
nixosConfigurations = { nixosConfigurations = {
"${host}" = nixpkgs.lib.nixosSystem { "${host}" = nixpkgs.lib.nixosSystem {
inherit system; inherit system;
modules = [ ./nixos/configuration.nix ]; modules = [
specialArgs = { inherit inputs; }; disko.nixosModules.disko
./nixos/configuration.nix
./nixos/disko-config.nix
./nixos/hardware-configuration.nix
];
specialArgs = {
inherit inputs;
meta = {
hostname = host;
};
};
}; };
}; };

View File

@@ -2,7 +2,7 @@
# your system. Help is available in the configuration.nix(5) man page # your system. Help is available in the configuration.nix(5) man page
# and in the NixOS manual (accessible by running nixos-help). # and in the NixOS manual (accessible by running nixos-help).
{ inputs, config, pkgs, ... }: { inputs, hostname, pkgs, ... }:
{ {
imports = imports =
@@ -18,7 +18,7 @@
hardware.bluetooth.enable = true; hardware.bluetooth.enable = true;
hardware.bluetooth.powerOnBoot = true; hardware.bluetooth.powerOnBoot = true;
networking.hostName = "rihla"; # Define your hostname. networking.hostName = hostname; # Define your hostname.
# networking.wireless.enable = true; # Enables wireless support via wpa_supplicant. # networking.wireless.enable = true; # Enables wireless support via wpa_supplicant.
# Configure network proxy if necessary # Configure network proxy if necessary
@@ -136,6 +136,7 @@
isNormalUser = true; isNormalUser = true;
description = "Shahab Dogar"; description = "Shahab Dogar";
extraGroups = [ "networkmanager" "wheel" "input" "libvirtd" ]; extraGroups = [ "networkmanager" "wheel" "input" "libvirtd" ];
hashedPassword = "$6$.ZlYnf2cZph4tCbM$E/JJUDirRV8MZrgX4Rh.Pi1q95tev1ZxcKjPA1I.uURv56qoWcC39MJWO9S2T5MlkPVbSLGiM8Ihfz9mERImo/";
}; };
# Allow unfree packages # Allow unfree packages

61
nixos/disko-config.nix Normal file
View File

@@ -0,0 +1,61 @@
{
disko.devices = {
disk = {
vdb = {
type = "disk";
device = "/dev/nvme0n1";
content = {
type = "gpt";
partitions = {
ESP = {
priority = 1;
name = "ESP";
start = "1M";
end = "128M";
type = "EF00";
content = {
type = "filesystem";
format = "vfat";
mountpoint = "/boot";
};
};
luks = {
size = "100%";
content = {
name = "crypted";
type = "luks";
askPassword = true;
content = {
type = "btrfs";
extraArgs = ["-L" "nixos" "-f"];
subvolumes = {
"/root" = {
mountpoint = "/";
mountOptions = ["subvol=root" "compress=zstd" "noatime"];
};
"/home" = {
mountpoint = "/home";
mountOptions = ["subvol=home" "compress=zstd" "noatime"];
};
"/nix" = {
mountpoint = "/nix";
mountOptions = ["subvol=nix" "compress=zstd" "noatime"];
};
"/log" = {
mountpoint = "/var/log";
mountOptions = ["subvol=log" "compress=zstd" "noatime"];
};
"/swap" = {
mountpoint = "/swap";
swap.swapfile.size = "64G";
};
};
};
};
};
};
};
};
};
};
}

View File

@@ -1,37 +1,16 @@
# Do not modify this file! It was generated by nixos-generate-config # Do not modify this file! It was generated by nixos-generate-config
# and may be overwritten by future invocations. Please make changes # and may be overwritten by future invocations. Please make changes
# to /etc/nixos/configuration.nix instead. # to /etc/nixos/configuration.nix instead.
{ config, lib, pkgs, modulesPath, ... }: { config, lib, modulesPath, ... }:
{ {
imports = imports = [ (modulesPath + "/installer/scan/not-detected.nix") ];
[ (modulesPath + "/installer/scan/not-detected.nix")
];
boot.initrd.availableKernelModules = [ "nvme" "xhci_pci" "thunderbolt" "usb_storage" "sd_mod" ]; boot.initrd.availableKernelModules = [ "nvme" "xhci_pci" "thunderbolt" "usb_storage" "sd_mod" ];
boot.initrd.kernelModules = [ ]; boot.initrd.kernelModules = [ ];
boot.kernelModules = [ "kvm-amd" ]; boot.kernelModules = [ "kvm-amd" ];
boot.extraModulePackages = [ ]; boot.extraModulePackages = [ ];
fileSystems."/" =
{ device = "/dev/disk/by-uuid/76272a47-955b-4bda-82ec-50418f8210f9";
fsType = "ext4";
};
boot.initrd.luks.devices = {
"luks-d35c44b6-3e25-4e0a-a439-95a786f17cd8".device = "/dev/disk/by-uuid/d35c44b6-3e25-4e0a-a439-95a786f17cd8";
"luks-15c96eaf-c225-4a27-873e-94ed67b04037".device = "/dev/disk/by-uuid/15c96eaf-c225-4a27-873e-94ed67b04037";
};
fileSystems."/boot" =
{ device = "/dev/disk/by-uuid/4B7B-782A";
fsType = "vfat";
options = [ "fmask=0077" "dmask=0077" ];
};
swapDevices =
[ { device = "/dev/disk/by-uuid/5b377538-3a2e-4ac9-ba53-a63b65b0f48b"; } ];
# Enables DHCP on each ethernet and wireless interface. In case of scripted networking # 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 # (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 # still possible to use this option, but it's recommended to use it in conjunction