[feat] Add all nix config with device gates

This commit is contained in:
Uttarayan Mondal
2024-02-19 19:14:09 +05:30
parent 935043e290
commit 0fc1c8b054
14 changed files with 135 additions and 177 deletions

View File

@@ -3,8 +3,7 @@
default: nixos default: nixos
darwin: darwin:
# nix run nix-darwin -- switch --flake ~/.local/share/dotfiles/config/nix nix run nix-darwin -- switch --flake . --show-trace
nix run nix-darwin -- switch --flake .
home: home:
nix --extra-experimental-features "nix-command flakes" run home-manager/master -- switch --flake . nix --extra-experimental-features "nix-command flakes" run home-manager/master -- switch --flake .

View File

@@ -1 +1 @@
{pkgs, ...}: {programs.firefox = {enable = pkgs.stdenv.isLinux;};} { device, ... }: { programs.firefox = { enable = device.isLinux; }; }

View File

@@ -1,10 +1,5 @@
{ { config, pkgs, lib, device, ... }:
config, let
pkgs,
lib,
device,
...
}: let
start-tmux = (import ../scripts/start-tmux.nix) pkgs; start-tmux = (import ../scripts/start-tmux.nix) pkgs;
# https://mipmip.github.io/home-manager-option-search/ # https://mipmip.github.io/home-manager-option-search/
in { in {
@@ -12,12 +7,10 @@ in {
# Include the results of the hardware scan. # Include the results of the hardware scan.
./tmux.nix ./tmux.nix
./wezterm.nix ./wezterm.nix
./firefox.nix ] ++ (if device.isLinux then [
../linux/hyprland.nix ../linux
../linux/gtk.nix ] else
../linux/anyrun.nix [ ]);
../linux/ironbar.nix
];
home.packages = with pkgs; home.packages = with pkgs;
[ [
@@ -38,46 +31,25 @@ in {
clang clang
# neovim-nightly # neovim-nightly
neovim neovim
(nerdfonts.override {fonts = ["Hasklig"];}) (nerdfonts.override { fonts = [ "Hasklig" ]; })
mpv mpv
] ++ (if device.isLinux then [
# # 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 handlr-regex
gnome.nautilus
webcord-vencord webcord-vencord
spotify spotify
spotify-player spotify-player
lsof lsof
wl-clipboard wl-clipboard
yubikey-personalization
ncpamixer ncpamixer
yubikey-agent
(pkgs.writeShellApplication { (pkgs.writeShellApplication {
name = "xdg-open"; name = "xdg-open";
runtimeInputs = [handlr-regex]; runtimeInputs = [ handlr-regex ];
text = '' text = ''
handlr open "$@" handlr open "$@"
''; '';
}) })
] ] else
else [] [ ]);
);
xdg.enable = true; xdg.enable = true;
@@ -109,7 +81,7 @@ in {
nushell = { nushell = {
enable = true; enable = true;
shellAliases = {"cd" = "z";}; shellAliases = { "cd" = "z"; };
package = pkgs.nushellFull; package = pkgs.nushellFull;
configFile.text = '' configFile.text = ''
$env.config = { $env.config = {
@@ -144,12 +116,6 @@ in {
enableFishIntegration = true; enableFishIntegration = true;
tmux.enableShellIntegration = true; tmux.enableShellIntegration = true;
}; };
# keychain = {
# enable = pkgs.isLinux;
# keys = [ "id_ed25519" ];
# enableFishIntegration = true;
# enableNushellIntegration = true;
# };
yazi = { yazi = {
enable = true; enable = true;
enableFishIntegration = true; enableFishIntegration = true;
@@ -157,7 +123,7 @@ in {
}; };
# Let Home Manager install and manage itself. # Let Home Manager install and manage itself.
home-manager = {enable = true;}; home-manager = { enable = true; };
}; };
fonts.fontconfig.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 # Home Manager needs a bit of information about you and the paths it should
# manage. # manage.
username = device.user; username = device.user;
homeDirectory = homeDirectory = if device.isMac then
if device.isMac lib.mkForce "/Users/${device.user}"
then lib.mkForce "/Users/${device.user}" else
else lib.mkForce "/home/${device.user}"; lib.mkForce "/home/${device.user}";
stateVersion = "23.11"; stateVersion = "23.11";

View File

@@ -105,17 +105,17 @@
# overlays = [ anyrun-overlay ]; # overlays = [ anyrun-overlay ];
in { in {
nixosConfigurations = let devices = nixos_devices; nixosConfigurations = let devices = nixos_devices;
in import ./nixos { in import ./nixos/device.nix {
inherit devices inputs nixpkgs home-manager overlays; inherit devices inputs nixpkgs home-manager overlays;
}; };
darwinConfigurations = let devices = darwin_devices; darwinConfigurations = let devices = darwin_devices;
in import ./darwin { in import ./darwin/device.nix {
inherit devices inputs nixpkgs home-manager overlays nix-darwin; inherit devices inputs nixpkgs home-manager overlays nix-darwin;
}; };
homeConfigurations = let devices = linux_devices; homeConfigurations = let devices = linux_devices;
in import ./linux { in import ./linux/device.nix {
inherit devices inputs nixpkgs home-manager overlays; inherit devices inputs nixpkgs home-manager overlays;
}; };
}; };

View File

@@ -1,20 +1,12 @@
{ { inputs, pkgs, osConfig, ... }: {
inputs, imports = [ inputs.anyrun.nixosModules.home-manager ];
pkgs,
osConfig,
...
}: {
imports =
if pkgs.stdenv.isLinux
then [inputs.anyrun.nixosModules.home-manager]
else [];
programs.anyrun = { programs.anyrun = {
enable = pkgs.stdenv.isLinux; enable = true;
config = { config = {
plugins = with inputs.anyrun.packages.${pkgs.system}; [ plugins = with inputs.anyrun.packages.${pkgs.system}; [
inputs.anyrun-nixos-options.packages.${pkgs.system}.default inputs.anyrun-nixos-options.packages.${pkgs.system}.default
inputs.anyrun-hyprwin.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 # rink
applications applications
websearch websearch
@@ -23,10 +15,10 @@
symbols symbols
kidex kidex
]; ];
x = {fraction = 0.5;}; x = { fraction = 0.5; };
y = {fraction = 0.3;}; y = { fraction = 0.3; };
height = {absolute = 0;}; height = { absolute = 0; };
width = {absolute = 1000;}; width = { absolute = 1000; };
showResultsImmediately = true; showResultsImmediately = true;
maxEntries = 10; maxEntries = 10;
layer = "overlay"; layer = "overlay";
@@ -34,11 +26,9 @@
extraConfigFiles = { extraConfigFiles = {
"nixos-options.ron".text = let "nixos-options.ron".text = let
nixos-options = nixos-options = osConfig.system.build.manual.optionsJSON
osConfig.system.build.manual.optionsJSON
+ "/share/doc/nixos/options.json"; + "/share/doc/nixos/options.json";
hm-options = hm-options = inputs.home-manager.packages.${pkgs.system}.docs-json
inputs.home-manager.packages.${pkgs.system}.docs-json
+ "/share/doc/home-manager/options.json"; + "/share/doc/home-manager/options.json";
# or alternatively if you wish to read any other documentation options, such as home-manager # 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 # get the docs-json package from the home-manager flake
@@ -50,9 +40,10 @@
# ":nall" = [nixos-options hm-options some-other-option]; # ":nall" = [nixos-options hm-options some-other-option];
# }; # };
options = builtins.toJSON { options = builtins.toJSON {
":nix" = [nixos-options]; ":nix" = [ nixos-options ];
":hm" = [hm-options]; ":hm" = [ hm-options ];
}; };
in '' in ''
Config( Config(
options: ${options}, options: ${options},

View File

@@ -1,17 +1,9 @@
{ devices, inputs, overlays, home-manager, ... }: { pkgs, ... }: {
builtins.listToAttrs (builtins.map (device: { imports = [
name = device.user; ../common/firefox.nix
value = let ../linux/hyprland.nix
pkgs = import inputs.nixpkgs { ../linux/gtk.nix
inherit overlays; ../linux/anyrun.nix
system = device.system; ../linux/ironbar.nix
}; ];
in home-manager.lib.homeManagerConfiguration { }
inherit pkgs;
extraSpecialArgs = {
inherit inputs;
inherit device;
};
modules = [ ../common/home.nix ];
};
}) devices)

View File

@@ -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)

View File

@@ -1,4 +1,4 @@
{pkgs, ...}: { { pkgs, ... }: {
foot = { foot = {
enable = pkgs.stdenv.isLinux; enable = pkgs.stdenv.isLinux;
server.enable = true; server.enable = true;

View File

@@ -1,13 +1,14 @@
{pkgs, ...}: { { pkgs, ... }: {
programs.gtk = { programs = {
enable = pkgs.stdenv.isLinux; gtk = {
enable = true;
theme = { theme = {
name = "Catppuccin-Mocha-Standard-Mauve-Dark"; name = "Catppuccin-Mocha-Standard-Mauve-Dark";
package = pkgs.catppuccin-gtk.override { package = pkgs.catppuccin-gtk.override {
variant = "mocha"; variant = "mocha";
size = "standard"; size = "standard";
accents = ["mauve"]; accents = [ "mauve" ];
tweaks = ["normal"]; tweaks = [ "normal" ];
}; };
}; };
@@ -19,8 +20,9 @@
}; };
}; };
gtk3.extraConfig = {gtk-application-prefer-dark-theme = 1;}; gtk3.extraConfig = { gtk-application-prefer-dark-theme = 1; };
gtk4.extraConfig = {gtk-application-prefer-dark-theme = 1;}; gtk4.extraConfig = { gtk-application-prefer-dark-theme = 1; };
};
}; };
} }

View File

@@ -1,6 +1,6 @@
{ pkgs, ... }: { { ... }: {
wayland.windowManager.hyprland = { wayland.windowManager.hyprland = {
enable = pkgs.stdenv.isLinux; enable = true;
settings = { settings = {
monitor = [ monitor = [
",preferred,auto,auto" ",preferred,auto,auto"

View File

@@ -1,25 +1,18 @@
{ { inputs, ... }: {
pkgs, imports = [ inputs.ironbar.homeManagerModules.default ];
inputs,
...
}: {
imports =
if pkgs.stdenv.isLinux
then [inputs.ironbar.homeManagerModules.default]
else [];
programs.ironbar = { programs.ironbar = {
enable = pkgs.stdenv.isLinux; enable = true;
config.monitors = { config.monitors = {
HDMI-A-2 = { HDMI-A-2 = {
position = "bottom"; position = "bottom";
start = [ start = [
{ {
type = "launcher"; type = "launcher";
favourites = ["firefox" "discord"]; favourites = [ "firefox" "discord" ];
show_names = false; show_names = false;
show_icons = true; show_icons = true;
} }
{type = "focused";} { type = "focused"; }
]; ];
end = [ end = [
{ {
@@ -32,7 +25,7 @@
type = "music"; type = "music";
player_type = "mpris"; player_type = "mpris";
} }
{type = "clock";} { type = "clock"; }
]; ];
}; };
DP-1 = { DP-1 = {
@@ -57,10 +50,9 @@
# networks= 3; # networks= 3;
}; };
} }
{type = "tray";} { type = "tray"; }
]; ];
start = [ start = [{
{
type = "workspaces"; type = "workspaces";
name_map = { name_map = {
"1" = "icon:code"; "1" = "icon:code";
@@ -74,10 +66,9 @@
"9" = "icon:monodoc"; "9" = "icon:monodoc";
"10" = "icon:spotify"; "10" = "icon:spotify";
}; };
favorites = ["1" "2" "3" "4" "5" "6" "7" "8" "9" "10"]; favorites = [ "1" "2" "3" "4" "5" "6" "7" "8" "9" "10" ];
all_monitors = true; all_monitors = true;
} }];
];
}; };
}; };
style = '' style = ''