diff --git a/config/nix/Makefile b/config/nix/Makefile index eb9843d3..13aaf8e3 100644 --- a/config/nix/Makefile +++ b/config/nix/Makefile @@ -1,10 +1,13 @@ -.PHONY: darwin home default +.PHONY: darwin home default nixos -default: home +default: nixos darwin: - nix run nix-darwin -- switch --flake ~/.local/share/dotfiles/config/nix + # nix run nix-darwin -- switch --flake ~/.local/share/dotfiles/config/nix + nix run nix-darwin -- switch --flake . home: - nix run home-manager/master -- switch --flake ~/.local/share/dotfiles/config/nix + nix --extra-experimental-features "nix-command flakes" run home-manager/master -- switch --flake . +nixos: + nixos-rebuild switch --flake . diff --git a/config/nix/common/firefox.nix b/config/nix/common/firefox.nix new file mode 100644 index 00000000..8476da43 --- /dev/null +++ b/config/nix/common/firefox.nix @@ -0,0 +1,5 @@ +{...}: { + programs.firefox = { + enable = true; + }; +} diff --git a/config/nix/common/home.nix b/config/nix/common/home.nix index 34e54516..de9ee2e5 100644 --- a/config/nix/common/home.nix +++ b/config/nix/common/home.nix @@ -3,30 +3,70 @@ pkgs, lib, device, - # overlays, + inputs, ... }: let start-tmux = (import ../scripts/start-tmux.nix) pkgs; in # https://mipmip.github.io/home-manager-option-search/ { - #nixpkgs.overlays = [ - # (self: super: { - # neovim-nightly = overlays.neovim-nightly; - # }) - #]; imports = [ # Include the results of the hardware scan. ./tmux.nix ./wezterm.nix ../linux/hyprland.nix + ./firefox.nix + inputs.anyrun.nixosModules.home-manager ]; - xdg = { - enable = true; - }; + home.packages = with pkgs; [ + nodejs + nix-index + yubikey-personalization + macchina + ripgrep + fd + alejandra + dust + eza + cachix + rustup + cmake + fzf + anyrun + clang + ncpamixer + neovim-nightly + yubikey-agent + (nerdfonts.override {fonts = ["Hasklig"];}) + mpv + # # Adds the 'hello' command to your environment. It prints a friendly + # # "Hello, world!" when run. + # pkgs.hello + + # # It is sometimes useful to fine-tune packages, for example, by applying + # # overrides. You can do that directly here, just don't forget the + # # parentheses. Maybe you want to install Nerd Fonts with a limited number of + # # fonts? + # (pkgs.nerdfonts.override { fonts = [ "FantasqueSansMono" ]; }) + + # # You can also create simple shell scripts directly inside your + # # configuration. For example, this adds a command 'my-hello' to your + # # environment: + # (pkgs.writeShellScriptBin "my-hello" '' + # echo "Hello, ${config.home.username}!" + # '') + ]; + + xdg.enable = true; programs = { + git = { + enable = true; + userName = "uttarayan21"; + userEmail = "email@uttarayan.me"; + }; + nix-index.enableFishIntegration = true; fish = { enable = true; shellAbbrs = { @@ -39,10 +79,9 @@ in t = "${start-tmux}"; }; shellInit = '' - fnm env | source + set fish_greeting ''; interactiveShellInit = '' - set fish_greeting ${pkgs.macchina.outPath}/bin/macchina ''; }; @@ -134,59 +173,100 @@ in }; }; + anyrun = { + enable = true; + config = { + plugins = with inputs.anyrun.packages.${pkgs.system}; [ + rink + applications + websearch + shell + translate + symbols + ]; + x = {fraction = 0.5;}; + y = {fraction = 0.3;}; + height = {absolute = 0;}; + width = {absolute = 1000;}; + showResultsImmediately = true; + layer = "overlay"; + }; + + extraConfigFiles = { + "shell.ron".text = '' + Config( + prefix: "", + shell: None, + ) + ''; + "handlr.ron".text = '' + Config( + prefix: "", + log: None, + ) + ''; + "websearch.ron".text = '' + Config( + prefix: "?" + engines: [Google, DuckDuckGo] + ) + ''; + }; + + extraCss = '' + window { + color: #ffffff; + background-color: rgba(15, 15, 15, .2); + border-color: #000000; + } + + entry { + color: #ffffff; + background-color: rgba(40, 40, 40, .98); + padding: 14px; + font-size: 30px; + border-color: #000000; + border-radius: 10px; + } + + #plugin { + color: #efefef; + border-color: #000000; + border-color: #000000; + border-radius: 5px; + } + + #main { + color: #efefef; + border-color: #000000; + border-color: #000000; + border-radius: 5px; + } + ''; + }; + # Let Home Manager install and manage itself. home-manager = { enable = true; }; }; + fonts.fontconfig.enable = true; home = { # Home Manager needs a bit of information about you and the paths it should # manage. username = device.user; homeDirectory = - if !isNull (builtins.match ".*-darwin" device.system) + if device.isMac then lib.mkForce "/Users/${device.user}" else lib.mkForce "/home/${device.user}"; stateVersion = "23.11"; - packages = with pkgs; [ - macchina - ripgrep - fd - fnm - alejandra - dust - eza - cachix - rustup - cmake - # neovim-nightly - (nerdfonts.override {fonts = ["Hasklig"];}) - mpv - - # # Adds the 'hello' command to your environment. It prints a friendly - # # "Hello, world!" when run. - # pkgs.hello - - # # It is sometimes useful to fine-tune packages, for example, by applying - # # overrides. You can do that directly here, just don't forget the - # # parentheses. Maybe you want to install Nerd Fonts with a limited number of - # # fonts? - # (pkgs.nerdfonts.override { fonts = [ "FantasqueSansMono" ]; }) - - # # You can also create simple shell scripts directly inside your - # # configuration. For example, this adds a command 'my-hello' to your - # # environment: - # (pkgs.writeShellScriptBin "my-hello" '' - # echo "Hello, ${config.home.username}!" - # '') - ]; - file = { ".config/tmux/sessions".source = ../../tmux/sessions; - ".config/nvim".source = ../../nvim; + ".config/nvim/lua".source = ../../nvim/lua; + ".config/nvim/init.lua".source = ../../nvim/init.lua; # # You can also set the file content immediately. # ".gradle/gradle.properties".text = '' diff --git a/config/nix/flake.lock b/config/nix/flake.lock index b5cfe46e..308c4569 100644 --- a/config/nix/flake.lock +++ b/config/nix/flake.lock @@ -1,5 +1,26 @@ { "nodes": { + "anyrun": { + "inputs": { + "flake-parts": "flake-parts", + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1701453400, + "narHash": "sha256-hI9+KBShsSfvWX7bmRa/1VI20WGat3lDXmbceMZzMS4=", + "owner": "Kirottu", + "repo": "anyrun", + "rev": "e14da6c37337ffa3ee1bc66965d58ef64c1590e5", + "type": "github" + }, + "original": { + "owner": "Kirottu", + "repo": "anyrun", + "type": "github" + } + }, "flake-compat": { "flake": false, "locked": { @@ -17,6 +38,27 @@ } }, "flake-parts": { + "inputs": { + "nixpkgs-lib": [ + "anyrun", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1696343447, + "narHash": "sha256-B2xAZKLkkeRFG5XcHHSXXcP7To9Xzr59KXeZiRf4vdQ=", + "owner": "hercules-ci", + "repo": "flake-parts", + "rev": "c9afaba3dfa4085dbd2ccb38dfade5141e33d9d4", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "flake-parts", + "type": "github" + } + }, + "flake-parts_2": { "inputs": { "nixpkgs-lib": [ "neovim-nightly-overlay", @@ -37,7 +79,7 @@ "type": "github" } }, - "flake-parts_2": { + "flake-parts_3": { "inputs": { "nixpkgs-lib": [ "neovim-nightly-overlay", @@ -95,7 +137,7 @@ }, "hercules-ci-effects": { "inputs": { - "flake-parts": "flake-parts_2", + "flake-parts": "flake-parts_3", "nixpkgs": [ "neovim-nightly-overlay", "nixpkgs" @@ -122,11 +164,11 @@ ] }, "locked": { - "lastModified": 1707919853, - "narHash": "sha256-qxmBGDzutuJ/tsX4gp+Mr7fjxOZBbeT9ixhS5o4iFOw=", + "lastModified": 1708031129, + "narHash": "sha256-EH20hJfNnc1/ODdDVat9B7aKm0B95L3YtkIRwKLvQG8=", "owner": "nix-community", "repo": "home-manager", - "rev": "043ba285c6dc20f36441d48525402bcb9743c498", + "rev": "3d6791b3897b526c82920a2ab5f61d71985b3cf8", "type": "github" }, "original": { @@ -145,11 +187,11 @@ }, "locked": { "dir": "contrib", - "lastModified": 1707941489, - "narHash": "sha256-S5KG+iYMFVHIEfeXSWYei2jcHs6kOfhM1pUoVQ9G/Lw=", + "lastModified": 1708127071, + "narHash": "sha256-z6z7evR8VBCqM5JGKvRU6oHvdD41j/X+369QiYTzWAk=", "owner": "neovim", "repo": "neovim", - "rev": "d09957e0a06f350443c750d9838b5f1016c0cccc", + "rev": "5fd1bac65ed07310eda5fd976b651cc493002849", "type": "github" }, "original": { @@ -162,17 +204,17 @@ "neovim-nightly-overlay": { "inputs": { "flake-compat": "flake-compat", - "flake-parts": "flake-parts", + "flake-parts": "flake-parts_2", "hercules-ci-effects": "hercules-ci-effects", "neovim-flake": "neovim-flake", "nixpkgs": "nixpkgs" }, "locked": { - "lastModified": 1707955468, - "narHash": "sha256-ZVka2bcB1AQTiVWqp2yH9Rnsd4Tvpcf5NXXzJIp7QNE=", + "lastModified": 1708128234, + "narHash": "sha256-NR/X3NlzS4G5XY2ZkdfXdPyEDU0OZdcF+2tElSbm5RI=", "owner": "nix-community", "repo": "neovim-nightly-overlay", - "rev": "0b6b4afc71e14d7f17f4e4a367ce271b9d398432", + "rev": "957f6857d74f012760dac4437cc03e6475c69d81", "type": "github" }, "original": { @@ -203,11 +245,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1707877513, - "narHash": "sha256-sp0w2apswd3wv0sAEF7StOGHkns3XUQaO5erhWFZWXk=", + "lastModified": 1708093448, + "narHash": "sha256-gohEm3/NVyu7WINFhRf83yJH8UM2ie/KY9Iw3VN6fiE=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "89653a03e0915e4a872788d10680e7eec92f8600", + "rev": "c7763249f02b7786b4ca36e13a4d7365cfba162f", "type": "github" }, "original": { @@ -219,11 +261,11 @@ }, "nixpkgs_2": { "locked": { - "lastModified": 1707689078, - "narHash": "sha256-UUGmRa84ZJHpGZ1WZEBEUOzaPOWG8LZ0yPg1pdDF/yM=", + "lastModified": 1708118438, + "narHash": "sha256-kk9/0nuVgA220FcqH/D2xaN6uGyHp/zoxPNUmPCMmEE=", "owner": "nixos", "repo": "nixpkgs", - "rev": "f9d39fb9aff0efee4a3d5f4a6d7c17701d38a1d8", + "rev": "5863c27340ba4de8f83e7e3c023b9599c3cb3c80", "type": "github" }, "original": { @@ -235,6 +277,7 @@ }, "root": { "inputs": { + "anyrun": "anyrun", "flake-utils": "flake-utils", "home-manager": "home-manager", "neovim-nightly-overlay": "neovim-nightly-overlay", diff --git a/config/nix/flake.nix b/config/nix/flake.nix index d033b6b6..71d7a01b 100644 --- a/config/nix/flake.nix +++ b/config/nix/flake.nix @@ -2,33 +2,46 @@ description = "Home Manager configuration of fs0c131y"; inputs = { - # Specify the source of Home Manager and Nixpkgs. nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; + home-manager = { url = "github:nix-community/home-manager"; inputs.nixpkgs.follows = "nixpkgs"; }; + nix-darwin = { url = "github:LnL7/nix-darwin"; inputs.nixpkgs.follows = "nixpkgs"; }; neovim-nightly-overlay.url = "github:nix-community/neovim-nightly-overlay"; - # flake-utils.url = "github:numtide/flake-utils"; + anyrun = { + url = "github:Kirottu/anyrun"; + inputs.nixpkgs.follows = "nixpkgs"; + }; }; outputs = { nixpkgs, + # nixos, home-manager, nix-darwin, flake-utils, + anyrun, + neovim-nightly-overlay, ... } @ inputs: let - devices = [ + config_devices = [ { name = "mirai"; system = "x86_64-linux"; user = "fs0c131y"; } + { + name = "ryu"; + system = "x86_64-linux"; + user = "servius"; + isNix = true; + } { name = "genzai"; system = "x86_64-linux"; @@ -45,15 +58,69 @@ user = "deck"; } ]; - linux = builtins.filter (x: x.system == "x86_64-linux") devices; - darwin = builtins.filter (x: x.system == "aarch64-darwin") devices; + + mkDevice = {device, ...}: { + isLinux = !isNull (builtins.match ".*-linux" device.system); + isNix = + if (builtins.hasAttr "isNix" device) + then device.isNix + else false; + isMac = !isNull (builtins.match ".*-darwin" device.system); + system = device.system; + name = device.name; + user = device.user; + }; + + devices = builtins.map (device: mkDevice {inherit device;}) config_devices; + + nixos_devices = builtins.filter (x: x.isNix) devices; + linux_devices = builtins.filter (x: x.isLinux) devices; + darwin_devices = builtins.filter (x: x.isMac) devices; + + anyrun-overlay = final: prev: { + anyrun = inputs.anyrun.packages.${prev.system}.anyrun; + }; + overlays = [ + inputs.neovim-nightly-overlay.overlay + anyrun-overlay + # inputs.anyrun.overlays + ]; in { + nixosConfigurations = + builtins.listToAttrs + (builtins.map + (device: { + name = device.name; + value = nixpkgs.lib.nixosSystem { + system = device.system; + # system.packages = [anyrun.packages.${device.system}.anyrun]; + specialArgs = {inherit device;}; + modules = [ + {nixpkgs.overlays = overlays;} + ./nixos/configuration.nix + home-manager.nixosModules.home-manager + { + nixpkgs.config.allowUnfree = true; + home-manager = { + useGlobalPkgs = true; + useUserPackages = true; + extraSpecialArgs = { + inherit inputs; + inherit device; + }; + users.${device.user}.imports = [./common/home.nix]; + }; + } + ]; + }; + }) + nixos_devices); + homeConfigurations = builtins.listToAttrs (builtins.map (device: { name = device.user; value = let pkgs = nixpkgs.legacyPackages.${device.system}; - overlays = [inputs.neovim-nightly-overlay.overlay]; in home-manager.lib.homeManagerConfiguration { inherit pkgs; @@ -61,6 +128,7 @@ inherit device; }; modules = [ + {nixpkgs.overlays = overlays;} ./common/home.nix { nixpkgs.overlays = overlays; @@ -68,7 +136,7 @@ ]; }; }) - linux); + linux_devices); darwinConfigurations = builtins.listToAttrs @@ -77,15 +145,14 @@ name = device.name; value = let pkgs = nixpkgs.legacyPackages.${device.system}; - overlays = [inputs.neovim-nightly-overlay.overlay]; in nix-darwin.lib.darwinSystem { inherit pkgs; modules = [ + {nixpkgs.overlays = overlays;} ./darwin home-manager.darwinModules.home-manager { - nixpkgs.overlays = overlays; home-manager = { useGlobalPkgs = true; useUserPackages = true; @@ -98,6 +165,6 @@ ]; }; }) - darwin); + darwin_devices); }; } diff --git a/config/nix/nixos/configuration.nix b/config/nix/nixos/configuration.nix new file mode 100644 index 00000000..35254240 --- /dev/null +++ b/config/nix/nixos/configuration.nix @@ -0,0 +1,129 @@ +# 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’). +{ + config, + pkgs, + ... +}: { + imports = [ + # Include the results of the hardware scan. + ./hardware-configuration.nix + ]; + + # Bootloader. + boot.loader.systemd-boot.enable = true; + boot.loader.efi.canTouchEfiVariables = true; + + networking.hostName = "ryu"; # Define your hostname. + # networking.wireless.enable = true; # Enables wireless support via wpa_supplicant. + + services.udev.packages = [pkgs.yubikey-personalization pkgs.yubikey-personalization-gui]; + services.yubikey-agent.enable = true; + + # 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/Kolkata"; + + i18n.supportedLocales = [ + "en_US.UTF-8/UTF-8" + ]; + + # 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"; + }; + + # Configure keymap in X11 + services.xserver.xkb = { + layout = "us"; + variant = ""; + }; + + # Define a user account. Don't forget to set a password with ‘passwd’. + users.users.servius = { + isNormalUser = true; + description = "Uttarayan"; + extraGroups = ["networkmanager" "wheel"]; + }; + + # Allow unfree packages + nixpkgs.config.allowUnfree = true; + + fonts.fontconfig.enable = true; + fonts.fontDir.enable = true; + + # 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 + hyprland + foot + git + fish + nushellFull + (pkgs.wrapFirefox (pkgs.firefox-unwrapped.override {pipewireSupport = true;}) {}) + gnumake + python3 + (nerdfonts.override {fonts = ["FiraCode" "Hasklig"];}) + ]; + + programs = { + hyprland.enable = true; + yubikey-touch-detector.enable = true; + hyprland.xwayland.enable = true; + }; + + security.rtkit.enable = true; + services.pipewire = { + enable = true; + alsa.enable = true; + alsa.support32Bit = true; + pulse.enable = true; + }; + + # 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. 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.11"; # Did you read the comment? + nix.settings.extra-experimental-features = "nix-command flakes"; +} diff --git a/config/nix/nixos/hardware-configuration.nix b/config/nix/nixos/hardware-configuration.nix new file mode 100644 index 00000000..36c5f1f8 --- /dev/null +++ b/config/nix/nixos/hardware-configuration.nix @@ -0,0 +1,38 @@ +# 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 = [ "vmd" "xhci_pci" "ahci" "nvme" "usbhid" "usb_storage" "sd_mod" ]; + boot.initrd.kernelModules = [ ]; + boot.kernelModules = [ "kvm-intel" ]; + boot.extraModulePackages = [ ]; + + fileSystems."/" = + { device = "/dev/disk/by-uuid/bcaa8c53-6c04-43e0-bf2a-97d8c0f572d9"; + fsType = "ext4"; + }; + + fileSystems."/boot" = + { device = "/dev/disk/by-uuid/4E27-DAC0"; + fsType = "vfat"; + }; + + 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.eno1.useDHCP = lib.mkDefault true; + # networking.interfaces.wlp4s0.useDHCP = lib.mkDefault true; + + nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux"; + hardware.cpu.intel.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware; +} diff --git a/config/nvim/init.lua b/config/nvim/init.lua index 18ce623d..6a42d2a6 100644 --- a/config/nvim/init.lua +++ b/config/nvim/init.lua @@ -91,13 +91,14 @@ vim.o.completeopt = 'menu,menuone,noselect' -- } -- vim.g.rooter_manual_only = 1 -local fnm_dir = os.getenv("FNM_DIR") or "/Users/fs0c131y/Library/Application Support/fnm" +-- local fnm_dir = os.getenv("FNM_DIR") or "/Users/fs0c131y/Library/Application Support/fnm" -if vim.fn.has('win32') == 1 then - vim.g.copilot_node_command = fnm_dir .. "/node-versions/v17.9.1/installation/node.exe" -else - vim.g.copilot_node_command = fnm_dir .. "/node-versions/v17.9.1/installation/bin/node" -end +-- if vim.fn.has('win32') == 1 then + -- vim.g.copilot_node_command = fnm_dir .. "/node-versions/v17.9.1/installation/node.exe" +-- else +-- vim.g.copilot_node_command = fnm_dir .. "/node-versions/v17.9.1/installation/bin/node" +-- end +vim.g.copilot_node_command = "node" vim.g.copilot_no_tab_map = true