[feat] Add some stuff for nix
This commit is contained in:
@@ -1,11 +1,9 @@
|
||||
.PHONY: run build genzai
|
||||
.PHONY: darwin build default
|
||||
default: build
|
||||
|
||||
darwin:
|
||||
nix run nix-darwin -- switch --flake ~/.local/share/dotfiles/config/nix
|
||||
|
||||
switch:
|
||||
home:
|
||||
nix run home-manager/master -- switch --flake ~/.local/share/dotfiles/config/nix
|
||||
build:
|
||||
nix run home-manager/master -- build --flake ~/.local/share/dotfiles/config/nix
|
||||
|
||||
genzai:
|
||||
nix build .#homeConfigurations.genzai
|
||||
|
||||
@@ -1,10 +1,38 @@
|
||||
{pkgs, ...}: {
|
||||
{
|
||||
pkgs,
|
||||
device,
|
||||
...
|
||||
}: {
|
||||
imports = [
|
||||
./yabai.nix
|
||||
./skhd.nix
|
||||
];
|
||||
|
||||
environment.systemPackages = with pkgs; [
|
||||
nix
|
||||
neovim
|
||||
];
|
||||
nix = {
|
||||
settings = {
|
||||
experimental-features = "nix-command flakes repl-flake";
|
||||
max-jobs = 8;
|
||||
trusted-users = ["root" "fs0c131y"];
|
||||
};
|
||||
extraOptions = ''
|
||||
build-users-group = nixbld
|
||||
extra-nix-path = nixpkgs=flake:nixpkgs
|
||||
'';
|
||||
package = pkgs.nix;
|
||||
};
|
||||
|
||||
programs.bash.enable = true;
|
||||
programs.zsh.enable = true;
|
||||
programs.fish.enable = true;
|
||||
|
||||
nixpkgs.hostPlatform = device.system;
|
||||
services.nix-daemon.enable = true;
|
||||
system.stateVersion = 4;
|
||||
|
||||
system.keyboard.enableKeyMapping = true;
|
||||
system.keyboard.remapCapsLockToControl = true;
|
||||
system.keyboard.swapLeftCommandAndLeftAlt = true;
|
||||
|
||||
@@ -16,13 +16,14 @@
|
||||
flake-utils.url = "github:numtide/flake-utils";
|
||||
};
|
||||
|
||||
outputs = {
|
||||
nixpkgs,
|
||||
home-manager,
|
||||
nix-darwin,
|
||||
flake-utils,
|
||||
...
|
||||
} @ inputs: let
|
||||
outputs =
|
||||
{ nixpkgs
|
||||
, home-manager
|
||||
, nix-darwin
|
||||
, flake-utils
|
||||
, ...
|
||||
} @ inputs:
|
||||
let
|
||||
devices = [
|
||||
{
|
||||
name = "mirai";
|
||||
@@ -47,10 +48,13 @@
|
||||
];
|
||||
linux = builtins.filter (x: x.system == "x86_64-linux") devices;
|
||||
darwin = builtins.filter (x: x.system == "aarch64-darwin") devices;
|
||||
in {
|
||||
homeConfigurations = builtins.listToAttrs (builtins.map (device: {
|
||||
in
|
||||
{
|
||||
homeConfigurations = builtins.listToAttrs (builtins.map
|
||||
(device: {
|
||||
name = device.user;
|
||||
value = let
|
||||
value =
|
||||
let
|
||||
pkgs = nixpkgs.legacyPackages.${device.system};
|
||||
overlays = [ inputs.neovim-nightly-overlay.overlay ];
|
||||
in
|
||||
@@ -66,68 +70,35 @@
|
||||
})
|
||||
linux);
|
||||
|
||||
darwinConfigurations = builtins.listToAttrs (builtins.map (device: {
|
||||
darwinConfigurations =
|
||||
builtins.listToAttrs
|
||||
(builtins.map
|
||||
(device: {
|
||||
name = device.name;
|
||||
value = let
|
||||
value =
|
||||
let
|
||||
pkgs = nixpkgs.legacyPackages.${device.system};
|
||||
in {
|
||||
"Uttarayans-MacBook-Pro" = nix-darwin.lib.darwinSystem {
|
||||
overlays = [ inputs.neovim-nightly-overlay.overlay ];
|
||||
in
|
||||
nix-darwin.lib.darwinSystem {
|
||||
inherit pkgs;
|
||||
modules = [
|
||||
home-manager.darwinModules.home-manager
|
||||
./darwin.nix
|
||||
({config, ...}: {
|
||||
home-manager.darwinModules.home-manager
|
||||
{
|
||||
home-manager = {
|
||||
users = {
|
||||
fs0c131y = {
|
||||
home = "/Users/${device.user}";
|
||||
stateVersion = "21.05";
|
||||
configuration = home-manager.configurations.fs0c131y;
|
||||
useGlobalPkgs = true;
|
||||
useUserPackages = true;
|
||||
extraSpecialArgs = {
|
||||
inherit device;
|
||||
inherit overlays;
|
||||
};
|
||||
users.${device.user}.imports = [ ./home.nix ];
|
||||
};
|
||||
};
|
||||
})
|
||||
}
|
||||
];
|
||||
};
|
||||
};
|
||||
})
|
||||
darwin);
|
||||
};
|
||||
}
|
||||
# "fs0c131y" = let
|
||||
# system = "x86_64-linux";
|
||||
# overlays = [inputs.neovim-nightly-overlay.overlay];
|
||||
# pkgs = nixpkgs.legacyPackages.${system};
|
||||
# in
|
||||
# home-manager.lib.homeManagerConfiguration
|
||||
# {
|
||||
# inherit pkgs;
|
||||
# modules = [
|
||||
# ./home.nix
|
||||
# {
|
||||
# nixpkgs.overlays = overlays;
|
||||
# }
|
||||
# ];
|
||||
# };
|
||||
# darwinConfigurations = let
|
||||
# system = "aarch64-darwin";
|
||||
# pkgs = nixpkgs.legacyPackages.${system};
|
||||
# in {
|
||||
# "Uttarayans-MacBook-Pro" = darwin.lib.darwinSystem {
|
||||
# modules = [
|
||||
# home-manager.darwinModules.home-manager
|
||||
# ./darwin.nix
|
||||
# ({config, ...}: {
|
||||
# home-manager = {
|
||||
# users = {
|
||||
# fs0c131y = {
|
||||
# home = "/Users/fs0c131y";
|
||||
# stateVersion = "21.05";
|
||||
# configuration = home-manager.configurations.fs0c131y;
|
||||
# };
|
||||
# };
|
||||
# };
|
||||
# })
|
||||
# ];
|
||||
# };
|
||||
# };
|
||||
|
||||
|
||||
@@ -1,12 +1,21 @@
|
||||
{
|
||||
config,
|
||||
pkgs,
|
||||
...
|
||||
}: let
|
||||
{ config
|
||||
, pkgs
|
||||
, lib
|
||||
, device
|
||||
, overlays
|
||||
, ...
|
||||
|
||||
}:
|
||||
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
|
||||
@@ -73,7 +82,7 @@ in
|
||||
};
|
||||
keychain = {
|
||||
enable = true;
|
||||
keys = ["id_ed25519"];
|
||||
# keys = [ "id_ed25519" ];
|
||||
enableFishIntegration = true;
|
||||
enableNushellIntegration = true;
|
||||
};
|
||||
@@ -128,15 +137,20 @@ in
|
||||
home = {
|
||||
# Home Manager needs a bit of information about you and the paths it should
|
||||
# manage.
|
||||
username = "fs0c131y";
|
||||
homeDirectory = "/home/fs0c131y";
|
||||
username = device.user;
|
||||
homeDirectory =
|
||||
if device.system == "x86-64-linux" then
|
||||
lib.mkForce "/home/${device.user}"
|
||||
else
|
||||
lib.mkForce "/Users/${device.user}";
|
||||
|
||||
|
||||
stateVersion = "23.11";
|
||||
|
||||
packages = [
|
||||
pkgs.macchina
|
||||
pkgs.alejandra
|
||||
pkgs.neovim-nightly
|
||||
# pkgs.neovim-nightly
|
||||
pkgs.cachix
|
||||
# # Adds the 'hello' command to your environment. It prints a friendly
|
||||
# # "Hello, world!" when run.
|
||||
|
||||
@@ -1,2 +1,9 @@
|
||||
substituters = https://cache.nixos.org https://nix-community.cachix.org
|
||||
trusted-public-keys = cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY= nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs=
|
||||
# Generated by https://github.com/DeterminateSystems/nix-installer.
|
||||
# See `/nix/nix-installer --version` for the version details.
|
||||
|
||||
build-users-group = nixbld
|
||||
experimental-features = nix-command flakes repl-flake
|
||||
bash-prompt-prefix = (nix:$name)\040
|
||||
max-jobs = auto
|
||||
extra-nix-path = nixpkgs=flake:nixpkgs
|
||||
upgrade-nix-store-path-url = https://install.determinate.systems/nix-upgrade/stable/universal
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
{
|
||||
pkgs,
|
||||
...
|
||||
{ pkgs
|
||||
, ...
|
||||
}:
|
||||
pkgs.writeShellScript "start-tmux" ''
|
||||
live_sessions=$(${pkgs.tmux}/bin/tmux list-sessions 2>/dev/null)
|
||||
@@ -14,15 +13,16 @@ pkgs.writeShellScript "start-tmux" ''
|
||||
exit 1
|
||||
fi
|
||||
IFS=$'\n'
|
||||
for live_session in $live_sessions;do
|
||||
for live_session in $live_sessions;
|
||||
do
|
||||
live_session_name=$(echo $live_session | ${pkgs.coreutils}/bin/cut -d: -f1)
|
||||
if [ -z "''\${all_sessions##*$live_session_name*}" ];then # see https://stackoverflow.com/questions/229551/how-to-check-if-a-string-contains-a-substring-in-bash
|
||||
all_sessions="$(echo "$all_sessions" | sed "s/$live_session_name/$live_session/g")"
|
||||
else
|
||||
all_sessions=$(echo -e "$all_sessions\n$live_session")
|
||||
# Okay I know this is ugly it is 5:13 my brain is not working
|
||||
all_sessions="$(echo -e "$all_sessions\n$live_session")"
|
||||
fi
|
||||
session=$(echo "''\$all_sessions" | fzf)
|
||||
done
|
||||
session=$(echo "''\$all_sessions" | ${pkgs.fzf}/bin/fzf)
|
||||
session_name=$(echo $session | cut -d: -f1)
|
||||
if [ -z "$session" ];then
|
||||
exit 0
|
||||
@@ -38,11 +38,12 @@ pkgs.writeShellScript "start-tmux" ''
|
||||
if [ -z "''\${session##*attached*}" ];then
|
||||
read -r -p "The session is already attached somewhere else. Attach it here too ? (y/N): " choice
|
||||
if [ "$choice" == "y" ] || [ "$choice" == "Y" ];then
|
||||
tmux attach-session -t$session_name
|
||||
${pkgs.tmux}/bin/tmux attach-session -t$session_name
|
||||
fi
|
||||
else
|
||||
tmux attach-session -t$session_name
|
||||
${pkgs.tmux}/bin/tmux attach-session -t$session_name
|
||||
fi
|
||||
done
|
||||
''
|
||||
|
||||
|
||||
|
||||
|
||||
77
config/nix/skhd.nix
Normal file
77
config/nix/skhd.nix
Normal file
@@ -0,0 +1,77 @@
|
||||
{...}: {
|
||||
services = {
|
||||
skhd = {
|
||||
enable = true;
|
||||
skhdConfig = ''
|
||||
# open terminal, blazingly fast compared to iTerm/Hyper
|
||||
# alt - return : /Applications/kitty.app/Contents/MacOS/kitty --single-instance -d ~
|
||||
alt - return : /Applications/WezTerm.app/Contents/MacOS/wezterm
|
||||
shift + alt - return: pkill mpv
|
||||
# alt + \ : pkill mpv
|
||||
|
||||
# open qutebrowser
|
||||
# alt + shift - return : ~/Scripts/qtb.sh
|
||||
|
||||
# open mpv
|
||||
alt - m : open -na /Applications/mpv.app $(pbpaste)
|
||||
|
||||
# close focused window
|
||||
# alt - w : yabai -m window --close
|
||||
|
||||
alt - d : open -na "$(ls /Applications /System/Applications/ /System/Applications/Utilities/ | choose)"
|
||||
|
||||
# focus window
|
||||
alt - h : yabai -m window --focus west
|
||||
alt - j : yabai -m window --focus south
|
||||
alt - k : yabai -m window --focus north
|
||||
alt - l : yabai -m window --focus east
|
||||
|
||||
# alt - j : yabai -m window --focus prev
|
||||
# alt - k : yabai -m window --focus next
|
||||
|
||||
# Float
|
||||
shift + alt - f: yabai -m window --toggle float
|
||||
alt - f: yabai -m window --toggle native-fullscreen
|
||||
|
||||
# swap window
|
||||
# shift + alt - h : yabai -m window --swap west
|
||||
# shift + alt - j : yabai -m window --swap south
|
||||
# shift + alt - k : yabai -m window --swap north
|
||||
# shift + alt - l : yabai -m window --swap east
|
||||
|
||||
# move window
|
||||
shift + alt - h : yabai -m window --warp west
|
||||
shift + alt - j : yabai -m window --warp south
|
||||
shift + alt - k : yabai -m window --warp north
|
||||
shift + alt - l : yabai -m window --warp east
|
||||
|
||||
# restart skhd
|
||||
shift + alt - r : pkill skhd
|
||||
|
||||
# fast focus desktop
|
||||
alt - 1 : yabai -m space --focus 1
|
||||
alt - 2 : yabai -m space --focus 2
|
||||
alt - 3 : yabai -m space --focus 3
|
||||
alt - 4 : yabai -m space --focus 4
|
||||
alt - 5 : yabai -m space --focus 5
|
||||
alt - 6 : yabai -m space --focus 6
|
||||
alt - 7 : yabai -m space --focus 7
|
||||
alt - 8 : yabai -m space --focus 8
|
||||
alt - 9 : yabai -m space --focus 9
|
||||
alt - 0 : yabai -m space --focus 10
|
||||
|
||||
# Move window to desktop
|
||||
shift + alt - 1 : yabai -m window --space 1
|
||||
shift + alt - 2 : yabai -m window --space 2
|
||||
shift + alt - 3 : yabai -m window --space 3
|
||||
shift + alt - 4 : yabai -m window --space 4
|
||||
shift + alt - 5 : yabai -m window --space 5
|
||||
shift + alt - 6 : yabai -m window --space 6
|
||||
shift + alt - 7 : yabai -m window --space 7
|
||||
shift + alt - 8 : yabai -m window --space 8
|
||||
shift + alt - 9 : yabai -m window --space 9
|
||||
shift + alt - 0 : yabai -m window --space 10
|
||||
'';
|
||||
};
|
||||
};
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
{pkgs, ...}: let
|
||||
{ pkgs, ... }:
|
||||
let
|
||||
tmux-super-fingers =
|
||||
pkgs.tmuxPlugins.mkTmuxPlugin
|
||||
{
|
||||
@@ -20,7 +21,8 @@
|
||||
tmux popup -d '#{pane_current_path}' -xC -yC -w$width -h$height -E "tmux attach -t scratch || tmux new -s scratch"
|
||||
fi
|
||||
'';
|
||||
in {
|
||||
in
|
||||
{
|
||||
programs.tmux = {
|
||||
enable = true;
|
||||
shell = "${pkgs.nushellFull}/bin/nu";
|
||||
@@ -38,15 +40,12 @@ in {
|
||||
plugin = tmuxPlugins.catppuccin;
|
||||
extraConfig = ''
|
||||
set -g @catppuccin_flavour 'mocha'
|
||||
set -g @catppuccin_window_tabs_enabled on
|
||||
set -g @catppuccin_status_modules_right ""
|
||||
set -g @catppuccin_status_modules_right "battery application session date_time"
|
||||
'';
|
||||
}
|
||||
{
|
||||
plugin = tmuxPlugins.battery;
|
||||
extraConfig = ''
|
||||
set -g @catppuccin_status_modules_right "application session user host date_time"
|
||||
set -g @catppuccin_status_modules_right "battery application session date_time"
|
||||
'';
|
||||
}
|
||||
];
|
||||
|
||||
44
config/nix/yabai.nix
Normal file
44
config/nix/yabai.nix
Normal file
@@ -0,0 +1,44 @@
|
||||
{...}: {
|
||||
services = {
|
||||
yabai = {
|
||||
enable = true;
|
||||
enableScriptingAddition = true;
|
||||
config = {
|
||||
mouse_follows_focus = "on";
|
||||
focus_follows_mouse = "on";
|
||||
window_origin_display = "default";
|
||||
window_placement = "second_child";
|
||||
window_topmost = "off";
|
||||
window_shadow = "on";
|
||||
window_opacity = "off";
|
||||
window_opacity_duration = "0.0";
|
||||
active_window_opacity = "1.0";
|
||||
normal_window_opacity = "0.90";
|
||||
window_border = "off";
|
||||
window_border_width = "6";
|
||||
active_window_border_color = "0xff775759";
|
||||
normal_window_border_color = "0xff555555";
|
||||
insert_feedback_color = "0xffd75f5f";
|
||||
split_ratio = "0.50";
|
||||
auto_balance = "off";
|
||||
mouse_modifier = "fn";
|
||||
mouse_action1 = "move";
|
||||
mouse_action2 = "resize";
|
||||
mouse_drop_action = "swap";
|
||||
layout = "bsp";
|
||||
top_padding = "5";
|
||||
bottom_padding = "5";
|
||||
left_padding = "5";
|
||||
right_padding = "5";
|
||||
window_gap = "06";
|
||||
};
|
||||
|
||||
extraConfig = ''
|
||||
yabai -m rule --add app='System Preferences' manage=off
|
||||
yabai -m rule --add app="choose" manage=off
|
||||
yabai -m rule --add app="barrier" manage=off
|
||||
yabai -m rule --add app="steam" manage=off
|
||||
'';
|
||||
};
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user