From 0fc1c8b054a838eb343ac08db3a37c043b87c5b0 Mon Sep 17 00:00:00 2001 From: Uttarayan Mondal Date: Mon, 19 Feb 2024 19:14:09 +0530 Subject: [PATCH] [feat] Add all nix config with device gates --- config/nix/Makefile | 3 +- config/nix/common/firefox.nix | 2 +- config/nix/common/home.nix | 94 ++++++------------- config/nix/darwin/{default.nix => device.nix} | 0 config/nix/flake.nix | 6 +- config/nix/linux/anyrun.nix | 47 ++++------ config/nix/linux/default.nix | 26 ++--- config/nix/linux/device.nix | 17 ++++ config/nix/linux/foot.nix | 2 +- config/nix/linux/gtk.nix | 42 +++++---- config/nix/linux/hyprland.nix | 4 +- config/nix/linux/ironbar.nix | 57 +++++------ config/nix/nixos/configuration.nix | 12 +-- config/nix/nixos/{default.nix => device.nix} | 0 14 files changed, 135 insertions(+), 177 deletions(-) rename config/nix/darwin/{default.nix => device.nix} (100%) create mode 100644 config/nix/linux/device.nix rename config/nix/nixos/{default.nix => device.nix} (100%) diff --git a/config/nix/Makefile b/config/nix/Makefile index 1d66804f..69cdcd22 100644 --- a/config/nix/Makefile +++ b/config/nix/Makefile @@ -3,8 +3,7 @@ default: nixos darwin: - # nix run nix-darwin -- switch --flake ~/.local/share/dotfiles/config/nix - nix run nix-darwin -- switch --flake . + nix run nix-darwin -- switch --flake . --show-trace home: nix --extra-experimental-features "nix-command flakes" run home-manager/master -- switch --flake . diff --git a/config/nix/common/firefox.nix b/config/nix/common/firefox.nix index 653e0537..09799a74 100644 --- a/config/nix/common/firefox.nix +++ b/config/nix/common/firefox.nix @@ -1 +1 @@ -{pkgs, ...}: {programs.firefox = {enable = pkgs.stdenv.isLinux;};} +{ device, ... }: { programs.firefox = { enable = device.isLinux; }; } diff --git a/config/nix/common/home.nix b/config/nix/common/home.nix index 5bf7cbcf..b6352a3c 100644 --- a/config/nix/common/home.nix +++ b/config/nix/common/home.nix @@ -1,10 +1,5 @@ -{ - config, - pkgs, - lib, - device, - ... -}: let +{ config, pkgs, lib, device, ... }: +let start-tmux = (import ../scripts/start-tmux.nix) pkgs; # https://mipmip.github.io/home-manager-option-search/ in { @@ -12,12 +7,10 @@ in { # Include the results of the hardware scan. ./tmux.nix ./wezterm.nix - ./firefox.nix - ../linux/hyprland.nix - ../linux/gtk.nix - ../linux/anyrun.nix - ../linux/ironbar.nix - ]; + ] ++ (if device.isLinux then [ + ../linux + ] else + [ ]); home.packages = with pkgs; [ @@ -38,46 +31,25 @@ in { clang # neovim-nightly neovim - (nerdfonts.override {fonts = ["Hasklig"];}) + (nerdfonts.override { fonts = [ "Hasklig" ]; }) mpv - - # # 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}!" - # '') - ] - ++ ( - if device.isLinux - then - with pkgs; [ - handlr-regex - gnome.nautilus - webcord-vencord - spotify - spotify-player - lsof - wl-clipboard - yubikey-personalization - ncpamixer - yubikey-agent - (pkgs.writeShellApplication { - name = "xdg-open"; - runtimeInputs = [handlr-regex]; - text = '' - handlr open "$@" - ''; - }) - ] - else [] - ); + ] ++ (if device.isLinux then [ + handlr-regex + webcord-vencord + spotify + spotify-player + lsof + wl-clipboard + ncpamixer + (pkgs.writeShellApplication { + name = "xdg-open"; + runtimeInputs = [ handlr-regex ]; + text = '' + handlr open "$@" + ''; + }) + ] else + [ ]); xdg.enable = true; @@ -109,7 +81,7 @@ in { nushell = { enable = true; - shellAliases = {"cd" = "z";}; + shellAliases = { "cd" = "z"; }; package = pkgs.nushellFull; configFile.text = '' $env.config = { @@ -144,12 +116,6 @@ in { enableFishIntegration = true; tmux.enableShellIntegration = true; }; - # keychain = { - # enable = pkgs.isLinux; - # keys = [ "id_ed25519" ]; - # enableFishIntegration = true; - # enableNushellIntegration = true; - # }; yazi = { enable = true; enableFishIntegration = true; @@ -157,7 +123,7 @@ in { }; # Let Home Manager install and manage itself. - home-manager = {enable = true;}; + home-manager = { enable = true; }; }; fonts.fontconfig.enable = true; @@ -165,10 +131,10 @@ in { # Home Manager needs a bit of information about you and the paths it should # manage. username = device.user; - homeDirectory = - if device.isMac - then lib.mkForce "/Users/${device.user}" - else lib.mkForce "/home/${device.user}"; + homeDirectory = if device.isMac then + lib.mkForce "/Users/${device.user}" + else + lib.mkForce "/home/${device.user}"; stateVersion = "23.11"; diff --git a/config/nix/darwin/default.nix b/config/nix/darwin/device.nix similarity index 100% rename from config/nix/darwin/default.nix rename to config/nix/darwin/device.nix diff --git a/config/nix/flake.nix b/config/nix/flake.nix index c63c12eb..90068d7b 100644 --- a/config/nix/flake.nix +++ b/config/nix/flake.nix @@ -105,17 +105,17 @@ # overlays = [ anyrun-overlay ]; in { nixosConfigurations = let devices = nixos_devices; - in import ./nixos { + in import ./nixos/device.nix { inherit devices inputs nixpkgs home-manager overlays; }; darwinConfigurations = let devices = darwin_devices; - in import ./darwin { + in import ./darwin/device.nix { inherit devices inputs nixpkgs home-manager overlays nix-darwin; }; homeConfigurations = let devices = linux_devices; - in import ./linux { + in import ./linux/device.nix { inherit devices inputs nixpkgs home-manager overlays; }; }; diff --git a/config/nix/linux/anyrun.nix b/config/nix/linux/anyrun.nix index adfed0fc..b5408998 100644 --- a/config/nix/linux/anyrun.nix +++ b/config/nix/linux/anyrun.nix @@ -1,20 +1,12 @@ -{ - inputs, - pkgs, - osConfig, - ... -}: { - imports = - if pkgs.stdenv.isLinux - then [inputs.anyrun.nixosModules.home-manager] - else []; +{ inputs, pkgs, osConfig, ... }: { + imports = [ inputs.anyrun.nixosModules.home-manager ]; programs.anyrun = { - enable = pkgs.stdenv.isLinux; + enable = true; config = { plugins = with inputs.anyrun.packages.${pkgs.system}; [ inputs.anyrun-nixos-options.packages.${pkgs.system}.default inputs.anyrun-hyprwin.packages.${pkgs.system}.default - # inputs.anyrun-rink.packages.${pkgs.system}.default + inputs.anyrun-rink.packages.${pkgs.system}.default # rink applications websearch @@ -23,10 +15,10 @@ symbols kidex ]; - x = {fraction = 0.5;}; - y = {fraction = 0.3;}; - height = {absolute = 0;}; - width = {absolute = 1000;}; + x = { fraction = 0.5; }; + y = { fraction = 0.3; }; + height = { absolute = 0; }; + width = { absolute = 1000; }; showResultsImmediately = true; maxEntries = 10; layer = "overlay"; @@ -34,11 +26,9 @@ extraConfigFiles = { "nixos-options.ron".text = let - nixos-options = - osConfig.system.build.manual.optionsJSON + nixos-options = osConfig.system.build.manual.optionsJSON + "/share/doc/nixos/options.json"; - hm-options = - inputs.home-manager.packages.${pkgs.system}.docs-json + hm-options = inputs.home-manager.packages.${pkgs.system}.docs-json + "/share/doc/home-manager/options.json"; # or alternatively if you wish to read any other documentation options, such as home-manager # get the docs-json package from the home-manager flake @@ -50,9 +40,10 @@ # ":nall" = [nixos-options hm-options some-other-option]; # }; options = builtins.toJSON { - ":nix" = [nixos-options]; - ":hm" = [hm-options]; + ":nix" = [ nixos-options ]; + ":hm" = [ hm-options ]; }; + in '' Config( options: ${options}, @@ -89,12 +80,12 @@ "rink.ron".text = '' Config( currency: Some("${ - builtins.toFile "currency.units" '' - !category currencies "Currencies" - usd USD - inr INR - '' - }"), + builtins.toFile "currency.units" '' + !category currencies "Currencies" + usd USD + inr INR + '' + }"), ) ''; }; diff --git a/config/nix/linux/default.nix b/config/nix/linux/default.nix index e6f0bb58..76a5b26f 100644 --- a/config/nix/linux/default.nix +++ b/config/nix/linux/default.nix @@ -1,17 +1,9 @@ -{ devices, inputs, overlays, home-manager, ... }: -builtins.listToAttrs (builtins.map (device: { - name = device.user; - value = let - pkgs = import inputs.nixpkgs { - inherit overlays; - system = device.system; - }; - in home-manager.lib.homeManagerConfiguration { - inherit pkgs; - extraSpecialArgs = { - inherit inputs; - inherit device; - }; - modules = [ ../common/home.nix ]; - }; -}) devices) +{ pkgs, ... }: { + imports = [ + ../common/firefox.nix + ../linux/hyprland.nix + ../linux/gtk.nix + ../linux/anyrun.nix + ../linux/ironbar.nix + ]; +} diff --git a/config/nix/linux/device.nix b/config/nix/linux/device.nix new file mode 100644 index 00000000..e6f0bb58 --- /dev/null +++ b/config/nix/linux/device.nix @@ -0,0 +1,17 @@ +{ devices, inputs, overlays, home-manager, ... }: +builtins.listToAttrs (builtins.map (device: { + name = device.user; + value = let + pkgs = import inputs.nixpkgs { + inherit overlays; + system = device.system; + }; + in home-manager.lib.homeManagerConfiguration { + inherit pkgs; + extraSpecialArgs = { + inherit inputs; + inherit device; + }; + modules = [ ../common/home.nix ]; + }; +}) devices) diff --git a/config/nix/linux/foot.nix b/config/nix/linux/foot.nix index 8eac1d35..c5d8f840 100644 --- a/config/nix/linux/foot.nix +++ b/config/nix/linux/foot.nix @@ -1,4 +1,4 @@ -{pkgs, ...}: { +{ pkgs, ... }: { foot = { enable = pkgs.stdenv.isLinux; server.enable = true; diff --git a/config/nix/linux/gtk.nix b/config/nix/linux/gtk.nix index 7636e2aa..6fb8d426 100644 --- a/config/nix/linux/gtk.nix +++ b/config/nix/linux/gtk.nix @@ -1,26 +1,28 @@ -{pkgs, ...}: { - programs.gtk = { - enable = pkgs.stdenv.isLinux; - theme = { - name = "Catppuccin-Mocha-Standard-Mauve-Dark"; - package = pkgs.catppuccin-gtk.override { - variant = "mocha"; - size = "standard"; - accents = ["mauve"]; - tweaks = ["normal"]; +{ pkgs, ... }: { + programs = { + gtk = { + enable = true; + theme = { + name = "Catppuccin-Mocha-Standard-Mauve-Dark"; + package = pkgs.catppuccin-gtk.override { + variant = "mocha"; + size = "standard"; + accents = [ "mauve" ]; + tweaks = [ "normal" ]; + }; }; - }; - iconTheme = { - name = "Papirus-Dark"; - package = pkgs.catppuccin-papirus-folders.override { - accent = "mauve"; - flavor = "mocha"; + iconTheme = { + name = "Papirus-Dark"; + package = pkgs.catppuccin-papirus-folders.override { + accent = "mauve"; + flavor = "mocha"; + }; }; + + gtk3.extraConfig = { gtk-application-prefer-dark-theme = 1; }; + + gtk4.extraConfig = { gtk-application-prefer-dark-theme = 1; }; }; - - gtk3.extraConfig = {gtk-application-prefer-dark-theme = 1;}; - - gtk4.extraConfig = {gtk-application-prefer-dark-theme = 1;}; }; } diff --git a/config/nix/linux/hyprland.nix b/config/nix/linux/hyprland.nix index 079e0cbc..cc4c32c7 100644 --- a/config/nix/linux/hyprland.nix +++ b/config/nix/linux/hyprland.nix @@ -1,6 +1,6 @@ -{ pkgs, ... }: { +{ ... }: { wayland.windowManager.hyprland = { - enable = pkgs.stdenv.isLinux; + enable = true; settings = { monitor = [ ",preferred,auto,auto" diff --git a/config/nix/linux/ironbar.nix b/config/nix/linux/ironbar.nix index 74e1d694..2ca3bb81 100644 --- a/config/nix/linux/ironbar.nix +++ b/config/nix/linux/ironbar.nix @@ -1,25 +1,18 @@ -{ - pkgs, - inputs, - ... -}: { - imports = - if pkgs.stdenv.isLinux - then [inputs.ironbar.homeManagerModules.default] - else []; +{ inputs, ... }: { + imports = [ inputs.ironbar.homeManagerModules.default ]; programs.ironbar = { - enable = pkgs.stdenv.isLinux; + enable = true; config.monitors = { HDMI-A-2 = { position = "bottom"; start = [ { type = "launcher"; - favourites = ["firefox" "discord"]; + favourites = [ "firefox" "discord" ]; show_names = false; show_icons = true; } - {type = "focused";} + { type = "focused"; } ]; end = [ { @@ -32,7 +25,7 @@ type = "music"; player_type = "mpris"; } - {type = "clock";} + { type = "clock"; } ]; }; DP-1 = { @@ -57,27 +50,25 @@ # networks= 3; }; } - {type = "tray";} - ]; - start = [ - { - type = "workspaces"; - name_map = { - "1" = "icon:code"; - "2" = ""; - "3" = "icon:chrome"; - "4" = "icon:discord"; - "5" = "icon:steam"; - "6" = "icon:misc"; - "7" = "icon:misc"; - "8" = "icon:docky"; - "9" = "icon:monodoc"; - "10" = "icon:spotify"; - }; - favorites = ["1" "2" "3" "4" "5" "6" "7" "8" "9" "10"]; - all_monitors = true; - } + { type = "tray"; } ]; + start = [{ + type = "workspaces"; + name_map = { + "1" = "icon:code"; + "2" = ""; + "3" = "icon:chrome"; + "4" = "icon:discord"; + "5" = "icon:steam"; + "6" = "icon:misc"; + "7" = "icon:misc"; + "8" = "icon:docky"; + "9" = "icon:monodoc"; + "10" = "icon:spotify"; + }; + favorites = [ "1" "2" "3" "4" "5" "6" "7" "8" "9" "10" ]; + all_monitors = true; + }]; }; }; style = '' diff --git a/config/nix/nixos/configuration.nix b/config/nix/nixos/configuration.nix index f3d9a05a..8f186c2c 100644 --- a/config/nix/nixos/configuration.nix +++ b/config/nix/nixos/configuration.nix @@ -9,12 +9,12 @@ environment.etc = { "wireplumber/bluetooth.lua.d/51-bluez-config.lua".text = '' - bluez_monitor.properties = { - ["bluez5.enable-sbc-xq"] = true, - ["bluez5.enable-msbc"] = true, - ["bluez5.enable-hw-volume"] = true, - ["bluez5.headset-roles"] = "[ hsp_hs hsp_ag hfp_hf hfp_ag ]" - } + bluez_monitor.properties = { + ["bluez5.enable-sbc-xq"] = true, + ["bluez5.enable-msbc"] = true, + ["bluez5.enable-hw-volume"] = true, + ["bluez5.headset-roles"] = "[ hsp_hs hsp_ag hfp_hf hfp_ag ]" + } ''; }; diff --git a/config/nix/nixos/default.nix b/config/nix/nixos/device.nix similarity index 100% rename from config/nix/nixos/default.nix rename to config/nix/nixos/device.nix