[feat] More refactoring
This commit is contained in:
135
config/nix/darwin/configuration.nix
Normal file
135
config/nix/darwin/configuration.nix
Normal file
@@ -0,0 +1,135 @@
|
|||||||
|
{
|
||||||
|
pkgs,
|
||||||
|
...
|
||||||
|
}: {
|
||||||
|
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;
|
||||||
|
};
|
||||||
|
|
||||||
|
security.pam.enableSudoTouchIdAuth = true;
|
||||||
|
|
||||||
|
programs.bash.enable = true;
|
||||||
|
programs.zsh.enable = true;
|
||||||
|
programs.fish.enable = true;
|
||||||
|
|
||||||
|
services.nix-daemon.enable = true;
|
||||||
|
system.stateVersion = 4;
|
||||||
|
|
||||||
|
system.keyboard.enableKeyMapping = true;
|
||||||
|
system.keyboard.remapCapsLockToControl = true;
|
||||||
|
system.keyboard.swapLeftCommandAndLeftAlt = true;
|
||||||
|
system.keyboard.userKeyMapping = [
|
||||||
|
{
|
||||||
|
# Right Command to Option
|
||||||
|
HIDKeyboardModifierMappingSrc = 30064771303;
|
||||||
|
HIDKeyboardModifierMappingDst = 30064771302;
|
||||||
|
}
|
||||||
|
{
|
||||||
|
# Right Option to command
|
||||||
|
HIDKeyboardModifierMappingSrc = 30064771302;
|
||||||
|
HIDKeyboardModifierMappingDst = 30064771303;
|
||||||
|
}
|
||||||
|
];
|
||||||
|
}
|
||||||
|
# {
|
||||||
|
# description = "Example Darwin system flake";
|
||||||
|
# inputs = {
|
||||||
|
# nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
|
||||||
|
# # home-manager.url = "github:nix-community/home-manager/master";
|
||||||
|
# # home-manager.inputs.nixpkgs.follows = "nixpkgs";
|
||||||
|
# nix-darwin.url = "github:LnL7/nix-darwin";
|
||||||
|
# nix-darwin.inputs.nixpkgs.follows = "nixpkgs";
|
||||||
|
# };
|
||||||
|
# outputs = inputs @ {
|
||||||
|
# self,
|
||||||
|
# nix-darwin,
|
||||||
|
# nixpkgs,
|
||||||
|
# }: let
|
||||||
|
# configuration = {pkgs, ...}: {
|
||||||
|
# # List packages installed in system profile. To search by name, run:
|
||||||
|
# # $ nix-env -qaP | grep wget
|
||||||
|
# environment.systemPackages = with pkgs; [
|
||||||
|
# neovim
|
||||||
|
# bat
|
||||||
|
# ripgrep
|
||||||
|
# fd
|
||||||
|
# fish
|
||||||
|
# nushellFull
|
||||||
|
# tmux
|
||||||
|
# wezterm
|
||||||
|
# # yabai
|
||||||
|
# nerdfonts
|
||||||
|
# ];
|
||||||
|
# # Auto upgrade nix package and the daemon service.
|
||||||
|
# services.nix-daemon.enable = true;
|
||||||
|
# # nix.package = pkgs.nix;
|
||||||
|
# # Necessary for using flakes on this system.
|
||||||
|
# nix = {
|
||||||
|
# settings = {
|
||||||
|
# experimental-features = "nix-command flakes repl-flake";
|
||||||
|
# max-jobs = 8;
|
||||||
|
# };
|
||||||
|
# extraOptions = ''
|
||||||
|
# build-users-group = nixbld
|
||||||
|
# extra-nix-path = nixpkgs=flake:nixpkgs
|
||||||
|
# '';
|
||||||
|
# # keep-outputs = true
|
||||||
|
# # keep-derivations = true
|
||||||
|
# };
|
||||||
|
# # Create /etc/zshrc that loads the nix-darwin environment.
|
||||||
|
# # programs.zsh.enable = true; # default shell on catalina
|
||||||
|
# # programs.fish.enable = true;
|
||||||
|
# # Set Git commit hash for darwin-version.
|
||||||
|
# system.configurationRevision = self.rev or self.dirtyRev or null;
|
||||||
|
# system.keyboard.enableKeyMapping = true;
|
||||||
|
# system.keyboard.remapCapsLockToControl = true;
|
||||||
|
# system.keyboard.swapLeftCommandAndLeftAlt = true;
|
||||||
|
# system.keyboard.userKeyMapping = {
|
||||||
|
# # Right Command to Option
|
||||||
|
# HIDKeyboardModifierMappingSrc = 30064771303;
|
||||||
|
# HIDKeyboardModifierMappingDst = 30064771302;
|
||||||
|
# # Right Option to command
|
||||||
|
# HIDKeyboardModifierMappingSrc = 30064771302;
|
||||||
|
# HIDKeyboardModifierMappingDst = 30064771303;
|
||||||
|
# };
|
||||||
|
# fonts.fonts = [(pkgs.nerdfonts.override {fonts = ["Hasklig" "Hack"];})];
|
||||||
|
# system.defaults.finder.AppleShowAllExtensions = true;
|
||||||
|
# system.defaults.dock.autohide = true;
|
||||||
|
# # Used for backwards compatibility, please read the changelog before changing.
|
||||||
|
# # $ darwin-rebuild changelog
|
||||||
|
# system.stateVersion = 4;
|
||||||
|
# # The platform the configuration will be used on.
|
||||||
|
# nixpkgs.hostPlatform = "aarch64-darwin";
|
||||||
|
# nix.package = pkgs.nix;
|
||||||
|
# };
|
||||||
|
# in {
|
||||||
|
# # Build darwin flake using:
|
||||||
|
# # $ darwin-rebuild build --flake .#simple
|
||||||
|
# darwinConfigurations.Uttarayans-MacBook-Pro = nix-darwin.lib.darwinSystem {
|
||||||
|
# # system = "aarch64-darwin";
|
||||||
|
# pkgs = import nixpkgs {system = "aarch64-darwin";};
|
||||||
|
# modules = [configuration];
|
||||||
|
# };
|
||||||
|
# # Expose the package set, including overlays, for convenience.
|
||||||
|
# # darwinPackages = self.darwinConfigurations.Uttarayans-MacBook-Pro.pkgs;
|
||||||
|
# };
|
||||||
|
# }
|
||||||
|
|
||||||
@@ -1,137 +1,34 @@
|
|||||||
{
|
{
|
||||||
pkgs,
|
devices,
|
||||||
device,
|
inputs,
|
||||||
|
overlays,
|
||||||
|
home-manager,
|
||||||
|
nix-darwin,
|
||||||
...
|
...
|
||||||
}: {
|
}:
|
||||||
imports = [
|
builtins.listToAttrs
|
||||||
./yabai.nix
|
(builtins.map
|
||||||
./skhd.nix
|
(device: {
|
||||||
];
|
name = device.name;
|
||||||
|
value = nix-darwin.lib.darwinSystem {
|
||||||
environment.systemPackages = with pkgs; [
|
system = device.system;
|
||||||
nix
|
modules = [
|
||||||
neovim
|
{nixpkgs.overlays = overlays;}
|
||||||
];
|
./configuration.nix
|
||||||
nix = {
|
home-manager.darwinModules.home-manager
|
||||||
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;
|
|
||||||
};
|
|
||||||
|
|
||||||
security.pam.enableSudoTouchIdAuth = true;
|
|
||||||
|
|
||||||
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;
|
|
||||||
system.keyboard.userKeyMapping = [
|
|
||||||
{
|
{
|
||||||
# Right Command to Option
|
nixpkgs.config.allowUnfree = true;
|
||||||
HIDKeyboardModifierMappingSrc = 30064771303;
|
home-manager = {
|
||||||
HIDKeyboardModifierMappingDst = 30064771302;
|
useGlobalPkgs = true;
|
||||||
}
|
useUserPackages = true;
|
||||||
{
|
extraSpecialArgs = {
|
||||||
# Right Option to command
|
inherit inputs;
|
||||||
HIDKeyboardModifierMappingSrc = 30064771302;
|
inherit device;
|
||||||
HIDKeyboardModifierMappingDst = 30064771303;
|
};
|
||||||
|
users.${device.user}.imports = [../common/home.nix];
|
||||||
|
};
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
}
|
};
|
||||||
# {
|
})
|
||||||
# description = "Example Darwin system flake";
|
devices)
|
||||||
# inputs = {
|
|
||||||
# nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
|
|
||||||
# # home-manager.url = "github:nix-community/home-manager/master";
|
|
||||||
# # home-manager.inputs.nixpkgs.follows = "nixpkgs";
|
|
||||||
# nix-darwin.url = "github:LnL7/nix-darwin";
|
|
||||||
# nix-darwin.inputs.nixpkgs.follows = "nixpkgs";
|
|
||||||
# };
|
|
||||||
# outputs = inputs @ {
|
|
||||||
# self,
|
|
||||||
# nix-darwin,
|
|
||||||
# nixpkgs,
|
|
||||||
# }: let
|
|
||||||
# configuration = {pkgs, ...}: {
|
|
||||||
# # List packages installed in system profile. To search by name, run:
|
|
||||||
# # $ nix-env -qaP | grep wget
|
|
||||||
# environment.systemPackages = with pkgs; [
|
|
||||||
# neovim
|
|
||||||
# bat
|
|
||||||
# ripgrep
|
|
||||||
# fd
|
|
||||||
# fish
|
|
||||||
# nushellFull
|
|
||||||
# tmux
|
|
||||||
# wezterm
|
|
||||||
# # yabai
|
|
||||||
# nerdfonts
|
|
||||||
# ];
|
|
||||||
# # Auto upgrade nix package and the daemon service.
|
|
||||||
# services.nix-daemon.enable = true;
|
|
||||||
# # nix.package = pkgs.nix;
|
|
||||||
# # Necessary for using flakes on this system.
|
|
||||||
# nix = {
|
|
||||||
# settings = {
|
|
||||||
# experimental-features = "nix-command flakes repl-flake";
|
|
||||||
# max-jobs = 8;
|
|
||||||
# };
|
|
||||||
# extraOptions = ''
|
|
||||||
# build-users-group = nixbld
|
|
||||||
# extra-nix-path = nixpkgs=flake:nixpkgs
|
|
||||||
# '';
|
|
||||||
# # keep-outputs = true
|
|
||||||
# # keep-derivations = true
|
|
||||||
# };
|
|
||||||
# # Create /etc/zshrc that loads the nix-darwin environment.
|
|
||||||
# # programs.zsh.enable = true; # default shell on catalina
|
|
||||||
# # programs.fish.enable = true;
|
|
||||||
# # Set Git commit hash for darwin-version.
|
|
||||||
# system.configurationRevision = self.rev or self.dirtyRev or null;
|
|
||||||
# system.keyboard.enableKeyMapping = true;
|
|
||||||
# system.keyboard.remapCapsLockToControl = true;
|
|
||||||
# system.keyboard.swapLeftCommandAndLeftAlt = true;
|
|
||||||
# system.keyboard.userKeyMapping = {
|
|
||||||
# # Right Command to Option
|
|
||||||
# HIDKeyboardModifierMappingSrc = 30064771303;
|
|
||||||
# HIDKeyboardModifierMappingDst = 30064771302;
|
|
||||||
# # Right Option to command
|
|
||||||
# HIDKeyboardModifierMappingSrc = 30064771302;
|
|
||||||
# HIDKeyboardModifierMappingDst = 30064771303;
|
|
||||||
# };
|
|
||||||
# fonts.fonts = [(pkgs.nerdfonts.override {fonts = ["Hasklig" "Hack"];})];
|
|
||||||
# system.defaults.finder.AppleShowAllExtensions = true;
|
|
||||||
# system.defaults.dock.autohide = true;
|
|
||||||
# # Used for backwards compatibility, please read the changelog before changing.
|
|
||||||
# # $ darwin-rebuild changelog
|
|
||||||
# system.stateVersion = 4;
|
|
||||||
# # The platform the configuration will be used on.
|
|
||||||
# nixpkgs.hostPlatform = "aarch64-darwin";
|
|
||||||
# nix.package = pkgs.nix;
|
|
||||||
# };
|
|
||||||
# in {
|
|
||||||
# # Build darwin flake using:
|
|
||||||
# # $ darwin-rebuild build --flake .#simple
|
|
||||||
# darwinConfigurations.Uttarayans-MacBook-Pro = nix-darwin.lib.darwinSystem {
|
|
||||||
# # system = "aarch64-darwin";
|
|
||||||
# pkgs = import nixpkgs {system = "aarch64-darwin";};
|
|
||||||
# modules = [configuration];
|
|
||||||
# };
|
|
||||||
# # Expose the package set, including overlays, for convenience.
|
|
||||||
# # darwinPackages = self.darwinConfigurations.Uttarayans-MacBook-Pro.pkgs;
|
|
||||||
# };
|
|
||||||
# }
|
|
||||||
|
|
||||||
|
|||||||
@@ -63,7 +63,7 @@
|
|||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
mkDevice = {device, ...}: {
|
mkDevice = {device}: {
|
||||||
isLinux = !isNull (builtins.match ".*-linux" device.system);
|
isLinux = !isNull (builtins.match ".*-linux" device.system);
|
||||||
isNix =
|
isNix =
|
||||||
if (builtins.hasAttr "isNix" device)
|
if (builtins.hasAttr "isNix" device)
|
||||||
@@ -90,83 +90,19 @@
|
|||||||
anyrun-overlay
|
anyrun-overlay
|
||||||
];
|
];
|
||||||
in {
|
in {
|
||||||
nixosConfigurations =
|
nixosConfigurations = let
|
||||||
builtins.listToAttrs
|
devices = nixos_devices;
|
||||||
(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};
|
|
||||||
in
|
in
|
||||||
home-manager.lib.homeManagerConfiguration {
|
import ./nixos {inherit devices inputs nixpkgs home-manager overlays;};
|
||||||
inherit pkgs;
|
|
||||||
extraSpecialArgs = {
|
|
||||||
inherit inputs;
|
|
||||||
inherit device;
|
|
||||||
};
|
|
||||||
modules = [
|
|
||||||
{nixpkgs.overlays = overlays;}
|
|
||||||
./common/home.nix
|
|
||||||
];
|
|
||||||
};
|
|
||||||
})
|
|
||||||
linux_devices);
|
|
||||||
|
|
||||||
darwinConfigurations =
|
darwinConfigurations = let
|
||||||
builtins.listToAttrs
|
devices = darwin_devices;
|
||||||
(builtins.map
|
|
||||||
(device: {
|
|
||||||
name = device.name;
|
|
||||||
value = let
|
|
||||||
pkgs = nixpkgs.legacyPackages.${device.system};
|
|
||||||
in
|
in
|
||||||
nix-darwin.lib.darwinSystem {
|
import ./darwin {inherit devices inputs nixpkgs home-manager overlays nix-darwin;};
|
||||||
inherit pkgs;
|
|
||||||
modules = [
|
homeConfigurations = let
|
||||||
{nixpkgs.overlays = overlays;}
|
devices = linux_devices;
|
||||||
./darwin
|
in
|
||||||
home-manager.darwinModules.home-manager
|
import ./linux {inherit devices inputs nixpkgs home-manager overlays;};
|
||||||
{
|
|
||||||
home-manager = {
|
|
||||||
useGlobalPkgs = true;
|
|
||||||
useUserPackages = true;
|
|
||||||
extraSpecialArgs = {
|
|
||||||
inherit device;
|
|
||||||
};
|
|
||||||
users.${device.user}.imports = [./common/home.nix];
|
|
||||||
};
|
|
||||||
}
|
|
||||||
];
|
|
||||||
};
|
|
||||||
})
|
|
||||||
darwin_devices);
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
28
config/nix/linux/default.nix
Normal file
28
config/nix/linux/default.nix
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
{
|
||||||
|
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)
|
||||||
35
config/nix/nixos/default.nix
Normal file
35
config/nix/nixos/default.nix
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
{
|
||||||
|
nixpkgs,
|
||||||
|
devices,
|
||||||
|
inputs,
|
||||||
|
overlays,
|
||||||
|
home-manager,
|
||||||
|
...
|
||||||
|
}:
|
||||||
|
builtins.listToAttrs
|
||||||
|
(builtins.map
|
||||||
|
(device: {
|
||||||
|
name = device.name;
|
||||||
|
value = nixpkgs.lib.nixosSystem {
|
||||||
|
system = device.system;
|
||||||
|
specialArgs = {inherit device;};
|
||||||
|
modules = [
|
||||||
|
{nixpkgs.overlays = overlays;}
|
||||||
|
./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];
|
||||||
|
};
|
||||||
|
}
|
||||||
|
];
|
||||||
|
};
|
||||||
|
})
|
||||||
|
devices)
|
||||||
Reference in New Issue
Block a user