initial commit

This commit is contained in:
2024-11-09 11:52:23 +05:00
commit 6bef6874b7
11 changed files with 437 additions and 0 deletions

48
flake.lock generated Normal file
View File

@@ -0,0 +1,48 @@
{
"nodes": {
"home-manager": {
"inputs": {
"nixpkgs": [
"nixpkgs"
]
},
"locked": {
"lastModified": 1730837930,
"narHash": "sha256-0kZL4m+bKBJUBQse0HanewWO0g8hDdCvBhudzxgehqc=",
"owner": "nix-community",
"repo": "home-manager",
"rev": "2f607e07f3ac7e53541120536708e824acccfaa8",
"type": "github"
},
"original": {
"owner": "nix-community",
"repo": "home-manager",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1730785428,
"narHash": "sha256-Zwl8YgTVJTEum+L+0zVAWvXAGbWAuXHax3KzuejaDyo=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "4aa36568d413aca0ea84a1684d2d46f55dbabad7",
"type": "github"
},
"original": {
"owner": "nixos",
"ref": "nixos-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"root": {
"inputs": {
"home-manager": "home-manager",
"nixpkgs": "nixpkgs"
}
}
},
"root": "root",
"version": 7
}

37
flake.nix Normal file
View File

@@ -0,0 +1,37 @@
{
description = "My NixOS system flake";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
home-manager.url = "github:nix-community/home-manager";
home-manager.inputs.nixpkgs.follows = "nixpkgs";
};
outputs = {
self,
nixpkgs,
home-manager,
...
}:
let
system = "x86_64-linux";
host = "rihla";
user = "shahab";
lib = nixpkgs.lib;
pkgs = nixpkgs.legacyPackages.${system};
in {
nixosConfigurations = {
"${host}" = nixpkgs.lib.nixosSystem {
inherit system;
modules = [ ./nixos/configuration.nix ];
};
};
homeConfigurations = {
"${user}" = home-manager.lib.homeManagerConfiguration {
inherit pkgs;
modules = [ ./home-manager/home.nix ];
};
};
};
}

View File

@@ -0,0 +1,21 @@
{ config, pkgs, font, ... }:
{
programs.alacritty = {
enable = true;
settings = {
env = {
"TERM" = "alacritty";
};
terminal.shell.program = "zsh";
font = {
size = 12;
normal.family = font;
bold.family = font;
italic.family = font;
};
};
};
}

View File

@@ -0,0 +1,25 @@
{ config, lib, pkgs, userName, userEmail, ... }:
{
programs.git = {
package = pkgs.gitAndTools.gitFull;
enable = true;
userName = userName;
userEmail = userEmail;
extraConfig = {
gpg = {
format = "ssh";
};
"gpg \"ssh\"" = {
program = "${lib.getExe' pkgs._1password-gui "op-ssh-sign"}";
};
commit = {
gpgsign = true;
};
user = {
signingKey = "~/.ssh/id_ed25519.pub";
};
};
};
}

View File

@@ -0,0 +1,5 @@
{ config, pkgs, ... }:
{
programs.neovim.enable = true;
}

View File

@@ -0,0 +1,10 @@
{ config, pkgs, ... }:
let
onePassPath = "~/.1password/agent.sock";
in {
programs.ssh = {
enable = true;
extraConfig = "IdentityAgent ${onePassPath}";
};
}

View File

@@ -0,0 +1,5 @@
{ config, pkgs, ... }:
{
programs.starship.enable = true;
}

View File

@@ -0,0 +1,25 @@
{ config, pkgs, ... }:
{
programs.zsh = {
enable = true;
enableCompletion = true;
autosuggestion.enable = true;
syntaxHighlighting.enable = true;
shellAliases = {
update = "sudo nixos-rebuild switch --flake ~/.dotfiles && home-manager switch --flake ~/.dotfiles";
".." = "cd ..";
ls = "exa";
vim = "nvim";
grep = "rg";
du = "dust";
rm = "rip";
};
history = {
size = 10000;
path = "${config.xdg.dataHome}/zsh/history";
};
};
}

73
home-manager/home.nix Normal file
View File

@@ -0,0 +1,73 @@
# This is your home-manager configuration file
# Use this to configure your home environment (it replaces ~/.config/nixpkgs/home.nix)
{
inputs,
outputs,
lib,
config,
pkgs,
...
}:
let
# Be sure to actually install the font first!
font = "ComicCodeLigatures";
username = "shahab";
email = "shahab@dogar.dev";
fullName = "Shahab Dogar";
in
{
# You can import other home-manager modules here
imports = [
# Custom import to configure font
(import ./configs/alacritty.nix { inherit pkgs config; font = font; })
# Custom import for username and email
(import ./configs/git.nix { inherit pkgs config lib; userEmail = email; userName = fullName; })
./configs/ssh.nix
./configs/nvim.nix
./configs/starship.nix
./configs/zsh.nix
];
nixpkgs = {
# Configure your nixpkgs instance
config = {
# Disable if you don't want unfree packages
allowUnfree = true;
# Workaround for https://github.com/nix-community/home-manager/issues/2942
allowUnfreePredicate = _: true;
};
};
home = {
# https://nixos.wiki/wiki/FAQ/When_do_I_update_stateVersion
stateVersion = "24.05";
username = username;
homeDirectory = "/home/${username}";
sessionVariables = {
EDITOR = "nvim";
NIXOS_OZONE_WL = "1";
};
packages = with pkgs; [
neofetch
mission-center
discord
eza
ripgrep
rm-improved
dust
firefox
gh
];
};
# Enable home-manager
programs.home-manager.enable = true;
# Nicely reload system units when changing configs
systemd.user.startServices = "sd-switch";
}

146
nixos/configuration.nix Normal file
View File

@@ -0,0 +1,146 @@
# 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).
{ inputs, config, pkgs, ... }:
{
imports =
[ # Include the results of the hardware scan.
./hardware-configuration.nix
];
# Bootloader.
boot.loader.grub.enable = true;
boot.loader.grub.device = "/dev/sda";
boot.loader.grub.useOSProber = true;
networking.hostName = "rihla"; # Define your hostname.
# networking.wireless.enable = true; # Enables wireless support via wpa_supplicant.
# Configure network proxy if necessary
# networking.proxy.default = "http://user:password@proxy:port/";
# networking.proxy.noProxy = "127.0.0.1,localhost,internal.domain";
# Enable networking
networking.networkmanager.enable = true;
# Set your time zone.
time.timeZone = "Asia/Karachi";
# Select internationalisation properties.
i18n.defaultLocale = "en_US.UTF-8";
i18n.extraLocaleSettings = {
LC_ADDRESS = "en_US.UTF-8";
LC_IDENTIFICATION = "en_US.UTF-8";
LC_MEASUREMENT = "en_US.UTF-8";
LC_MONETARY = "en_US.UTF-8";
LC_NAME = "en_US.UTF-8";
LC_NUMERIC = "en_US.UTF-8";
LC_PAPER = "en_US.UTF-8";
LC_TELEPHONE = "en_US.UTF-8";
LC_TIME = "en_US.UTF-8";
};
# Enable flakes
nix.settings.experimental-features = [ "nix-command" "flakes" ];
# Enable the X11 windowing system.
services.xserver.enable = true;
# Enable the GNOME Desktop Environment.
services.xserver.displayManager.gdm.enable = true;
services.xserver.desktopManager.gnome.enable = true;
# Configure keymap in X11
services.xserver.xkb = {
layout = "us";
variant = "";
};
# Enable CUPS to print documents.
services.printing.enable = true;
# Enable sound with pipewire.
hardware = {
pulseaudio.enable = false;
graphics.enable = true;
};
security.rtkit.enable = true;
services.pipewire = {
enable = true;
alsa.enable = true;
alsa.support32Bit = true;
pulse.enable = true;
# If you want to use JACK applications, uncomment this
#jack.enable = true;
# use the example session manager (no others are packaged yet so this is enabled by default,
# no need to redefine it in your config for now)
#media-session.enable = true;
};
# 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.shahab = {
shell = pkgs.zsh;
# Only do this if you have already configured zsh in home manager
ignoreShellProgramCheck = true;
isNormalUser = true;
description = "Shahab Dogar";
extraGroups = [ "networkmanager" "wheel" ];
};
# Allow unfree packages
nixpkgs.config.allowUnfree = true;
# List packages installed in system profile. To search, run:
# $ nix search wget
environment.systemPackages = with pkgs; [
neovim
git
pciutils
unzip
];
programs._1password.enable = true;
programs._1password-gui = {
enable = true;
# Certain features, including CLI integration and system authentication support,
# require enabling PolKit integration on some desktop environments (e.g. Plasma).
polkitPolicyOwners = [ "shahab" ];
};
# 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. Its 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 = "24.05"; # Did you read the comment?
}

View File

@@ -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 = [ "uhci_hcd" "ehci_pci" "ahci" "usbhid" "ums_realtek" "usb_storage" "sd_mod" "sr_mod" ];
boot.initrd.kernelModules = [ ];
boot.kernelModules = [ "wl" ];
boot.extraModulePackages = [ config.boot.kernelPackages.broadcom_sta ];
fileSystems."/" =
{ device = "/dev/disk/by-uuid/11f84937-8f7c-4645-88ba-92b2e5d7b03f";
fsType = "ext4";
};
boot.initrd.luks.devices."luks-71ce195a-833b-489f-bd3b-2d56a4b1b427".device = "/dev/disk/by-uuid/71ce195a-833b-489f-bd3b-2d56a4b1b427";
fileSystems."/boot" =
{ device = "/dev/disk/by-uuid/FB56-88FA";
fsType = "vfat";
options = [ "fmask=0022" "dmask=0022" ];
};
swapDevices =
[ { device = "/dev/disk/by-uuid/2a783d2b-85cf-47e3-845f-c8a13f8791b7"; }
];
# 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.<interface>.useDHCP`.
networking.useDHCP = lib.mkDefault true;
# networking.interfaces.enp9s0.useDHCP = lib.mkDefault true;
nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux";
hardware.cpu.intel.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware;
}