From dad139cd5b4d575d29aa5b3ace3003fc51332c10 Mon Sep 17 00:00:00 2001 From: Shubham Saini Date: Mon, 25 Sep 2023 03:25:31 -0700 Subject: init --- .gitignore | 1 + flake.lock | 49 ++++++++++++++++++ flake.nix | 32 ++++++++++++ home.nix | 79 ++++++++++++++++++++++++++++ hosts/oracle/configuration.nix | 91 +++++++++++++++++++++++++++++++++ hosts/oracle/hardware-configuration.nix | 42 +++++++++++++++ 6 files changed, 294 insertions(+) create mode 100644 .gitignore create mode 100644 flake.lock create mode 100644 flake.nix create mode 100644 home.nix create mode 100644 hosts/oracle/configuration.nix create mode 100644 hosts/oracle/hardware-configuration.nix diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..b2be92b --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +result diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..4bf0850 --- /dev/null +++ b/flake.lock @@ -0,0 +1,49 @@ +{ + "nodes": { + "home-manager": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1695108154, + "narHash": "sha256-gSg7UTVtls2yO9lKtP0yb66XBHT1Fx5qZSZbGMpSn2c=", + "owner": "nix-community", + "repo": "home-manager", + "rev": "07682fff75d41f18327a871088d20af2710d4744", + "type": "github" + }, + "original": { + "owner": "nix-community", + "ref": "release-23.05", + "repo": "home-manager", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1695559356, + "narHash": "sha256-kXZ1pUoImD9OEbPCwpTz4tHsNTr4CIyIfXb3ocuR8sI=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "261abe8a44a7e8392598d038d2e01f7b33cf26d0", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-23.05", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "home-manager": "home-manager", + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..7f3d0b9 --- /dev/null +++ b/flake.nix @@ -0,0 +1,32 @@ +{ + description = "My nix config"; + inputs = { + nixpkgs.url = "github:nixos/nixpkgs/nixos-23.05"; + + home-manager = { + url = "github:nix-community/home-manager/release-23.05"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + }; + + outputs = { self, nixpkgs, home-manager, ... }: { + nixosConfigurations = { + oracle = nixpkgs.lib.nixosSystem { + system = "x86_64-linux"; + modules = [ + { + imports = [ ./hosts/oracle/configuration.nix ]; + } + home-manager.nixosModules.home-manager + { + home-manager.useGlobalPkgs = true; + home-manager.useUserPackages = true; + home-manager.users.shubh = { + imports = [ ./home.nix ]; + }; + } + ]; + }; + }; + }; +} diff --git a/home.nix b/home.nix new file mode 100644 index 0000000..7de67a9 --- /dev/null +++ b/home.nix @@ -0,0 +1,79 @@ +{ config, pkgs, ... }: + +{ + home.username = "shubh"; + home.homeDirectory = "/home/shubh"; + + # You should not change this value, even if you update Home Manager. If you do + # want to update the value, then make sure to first check the Home Manager + # release notes. + home.stateVersion = "23.05"; + + home.packages = with pkgs; [ + git + unzip + wget + gnupg + pinentry + wl-clipboard + pass + tmux + fzf + firefox + libreoffice-qt + # (pkgs.nerdfonts.override { fonts = [ "FantasqueSansMono" ]; }) + ]; + + programs.home-manager.enable = true; + programs.zsh = { + enable = true; + enableCompletion = true; + shellAliases = { + ll = "ls -l"; + v = "nvim"; + o = "xdg-open"; + t = "tmux"; + update = "sudo nixos-rebuild switch --flake ~/nix"; + }; + history = { + size = 10000; + path = "${config.xdg.dataHome}/zsh/history"; + }; + oh-my-zsh = { + enable = true; + plugins = [ "git" "kubectl" "sudo" ]; + theme = "robbyrussell"; + }; + }; + programs.fzf = { + enable = true; + enableZshIntegration = true; + defaultOptions = [ "--height 40%" "--layout=reverse" "--border" ]; + }; + programs.git = { + enable = true; + userEmail = "me@ubh.sh"; + userName = "Shubham Saini"; + signing = { + key = "E0404DDE4BCF9DB5"; + signByDefault = true; + }; + }; + + services.gpg-agent = { + enable = true; + pinentryFlavor = "qt"; + }; + + xdg = { + userDirs = { + enable = true; + desktop = "\$HOME/desktop"; + documents = "\$HOME/docs"; + download = "\$HOME/downloads"; + pictures = "\$HOME/pics"; + music = "\$HOME/music"; + videos = "\$HOME/vids"; + }; + }; +} diff --git a/hosts/oracle/configuration.nix b/hosts/oracle/configuration.nix new file mode 100644 index 0000000..500906b --- /dev/null +++ b/hosts/oracle/configuration.nix @@ -0,0 +1,91 @@ +{ config, pkgs, ... }: + +{ + imports = + [ + ./hardware-configuration.nix + ]; + + boot.loader.systemd-boot.enable = true; + boot.loader.efi.canTouchEfiVariables = true; + + # swap on luks + boot.initrd.secrets = { + "/crypto_keyfile.bin" = null; + }; + boot.initrd.luks.devices."luks-5cbabb1a-ed3b-44da-b4c0-894c2265d8c0".device = "/dev/disk/by-uuid/5cbabb1a-ed3b-44da-b4c0-894c2265d8c0"; + boot.initrd.luks.devices."luks-5cbabb1a-ed3b-44da-b4c0-894c2265d8c0".keyFile = "/crypto_keyfile.bin"; + + networking.hostName = "oracle"; + networking.networkmanager.enable = true; + + time.timeZone = "America/Vancouver"; + i18n.defaultLocale = "en_CA.UTF-8"; + sound.enable = true; + hardware.pulseaudio.enable = false; + hardware.bluetooth.enable = true; + security.rtkit.enable = true; + programs.zsh.enable = true; + + users.users.shubh = { + isNormalUser = true; + shell = pkgs.zsh; + extraGroups = [ "networkmanager" "wheel" "docker" ]; + }; + + nixpkgs.config.allowUnfree = true; + + environment.systemPackages = with pkgs; [ + neovim + git + interception-tools + ]; + + services = { + xserver = { + enable = true; + layout = "us"; + displayManager = { + sddm.enable = true; + defaultSession = "plasmawayland"; + }; + desktopManager.plasma5.enable = true; + libinput.enable = true; + }; + pipewire = { + enable = true; + alsa.enable = true; + alsa.support32Bit = true; + pulse.enable = true; + }; + interception-tools = { + enable = true; + plugins = with pkgs; [ + interception-tools-plugins.caps2esc + ]; + udevmonConfig = '' + - JOB: "intercept -g $DEVNODE | caps2esc | uinput -d $DEVNODE" + - JOB: "${pkgs.interception-tools}/bin/intercept -g $DEVNODE | ${pkgs.interception-tools-plugins.caps2esc}/bin/caps2esc | ${pkgs.interception-tools}/bin/uinput -d $DEVNODE" + DEVICE: + EVENTS: + EV_KEY: [KEY_CAPSLOCK, KEY_ESC] + ''; + }; + }; + virtualisation.docker.enable = true; + + nix = { + extraOptions = '' + experimental-features = nix-command flakes + ''; + }; + + # 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.05"; # Did you read the comment? + +} diff --git a/hosts/oracle/hardware-configuration.nix b/hosts/oracle/hardware-configuration.nix new file mode 100644 index 0000000..1d57a92 --- /dev/null +++ b/hosts/oracle/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" "usb_storage" "sd_mod" ]; + boot.initrd.kernelModules = [ ]; + boot.kernelModules = [ "kvm-amd" ]; + boot.extraModulePackages = [ ]; + + fileSystems."/" = + { device = "/dev/disk/by-uuid/84cae4ab-2829-4af1-9fe8-1a57128b1fa1"; + fsType = "ext4"; + }; + + boot.initrd.luks.devices."luks-8bf40ec5-be29-41f3-97c8-ed6a6beec6d3".device = "/dev/disk/by-uuid/8bf40ec5-be29-41f3-97c8-ed6a6beec6d3"; + + fileSystems."/boot" = + { device = "/dev/disk/by-uuid/2B72-E7BD"; + fsType = "vfat"; + }; + + swapDevices = + [ { device = "/dev/disk/by-uuid/3815a775-9072-4703-ab1d-267fe1287bf8"; } + ]; + + # 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.enp2s0.useDHCP = lib.mkDefault true; + # networking.interfaces.wlp3s0.useDHCP = lib.mkDefault true; + + nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux"; + hardware.cpu.amd.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware; +} -- cgit v1.2.3