begin to modularise
This commit is contained in:
parent
bbd26675f8
commit
a1175ba492
10 changed files with 311 additions and 93 deletions
|
|
@ -1,4 +1,14 @@
|
|||
name: { nixpkgs, home-manager, system, user, hyprland, ... }:
|
||||
name:
|
||||
{ nixpkgs
|
||||
, home-manager
|
||||
, system
|
||||
, user
|
||||
, hyprland
|
||||
, laptop ? false
|
||||
, work ? false
|
||||
, displays ? []
|
||||
, ...
|
||||
}:
|
||||
|
||||
nixpkgs.lib.nixosSystem rec {
|
||||
inherit system;
|
||||
|
|
@ -11,10 +21,29 @@ nixpkgs.lib.nixosSystem rec {
|
|||
trusted-public-keys = [ "hyprland.cachix.org-1:a7pgxzMz7+chwVL3/pzj6jIBMioiJM7ypFP8PwtkuGc=" ];
|
||||
};
|
||||
}
|
||||
home-manager.nixosModules.home-manager
|
||||
{
|
||||
imports = [
|
||||
(import ./modules/scripts.nix { inherit user; })
|
||||
(import ./modules/editor.nix { inherit user; })
|
||||
(import ./modules/keyboard.nix { inherit user; })
|
||||
(import ./modules/display.nix { inherit user; })
|
||||
(import ./modules/work.nix { inherit user; })
|
||||
];
|
||||
keyboard.dvorak.enable = laptop;
|
||||
displays = if laptop then {
|
||||
enable = true;
|
||||
displays = [{
|
||||
name = "eDP-1";
|
||||
scaling = 1.2;
|
||||
}];
|
||||
}
|
||||
else displays;
|
||||
roles.work.enable = work;
|
||||
}
|
||||
../system/global/system.nix
|
||||
../system/${name}/system.nix
|
||||
../system/${name}/hardware.nix
|
||||
home-manager.nixosModules.home-manager
|
||||
{
|
||||
home-manager.useGlobalPkgs = true;
|
||||
home-manager.useUserPackages = true;
|
||||
|
|
|
|||
82
lib/modules/display.nix
Normal file
82
lib/modules/display.nix
Normal file
|
|
@ -0,0 +1,82 @@
|
|||
{ user }: { lib, pkgs, config, ... }:
|
||||
with lib;
|
||||
let
|
||||
cfg = config.displays;
|
||||
|
||||
renderDisplaysForHyprland = displays:
|
||||
"# === DISPLAY MODULE ===\n"
|
||||
+ concatStringsSep "\n" (map displayHyprlandSetting displays);
|
||||
|
||||
displayHyprlandSetting = display:
|
||||
"monitor = " + display.name +
|
||||
", " + resToString display.resolution +
|
||||
", " + display.position +
|
||||
", " + toString display.scaling;
|
||||
|
||||
resolutionType = types.submodule ({ x, y, freq, ... }:
|
||||
{
|
||||
options = {
|
||||
x = mkOption {
|
||||
description = "x";
|
||||
type = types.int;
|
||||
default = 0;
|
||||
};
|
||||
y = mkOption {
|
||||
description = "y";
|
||||
type = types.int;
|
||||
default = 0;
|
||||
};
|
||||
freq = mkOption {
|
||||
description = "frequency";
|
||||
type = types.int;
|
||||
default = 0;
|
||||
};
|
||||
};
|
||||
});
|
||||
displayType = types.submodule
|
||||
({ ... }: {
|
||||
options = {
|
||||
name = mkOption {
|
||||
description = "name of the display";
|
||||
};
|
||||
scaling = mkOption {
|
||||
type = types.float;
|
||||
default = 1.0;
|
||||
};
|
||||
resolution = mkOption {
|
||||
description = "res";
|
||||
type = resolutionType;
|
||||
default = { };
|
||||
};
|
||||
position = mkOption {
|
||||
description = "XxY";
|
||||
default = "auto";
|
||||
};
|
||||
};
|
||||
});
|
||||
|
||||
resToString = res:
|
||||
if res.x == 0 || res.y == 0 || res.freq == 0
|
||||
then "preferred"
|
||||
else "${toString res.x}x${toString res.y}@${toString res.freq}";
|
||||
in
|
||||
{
|
||||
options.displays =
|
||||
{
|
||||
enable = mkEnableOption "manage displays";
|
||||
displays = mkOption {
|
||||
type = types.listOf displayType;
|
||||
default = [ ];
|
||||
};
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
home-manager.users.${user}.imports = [
|
||||
{
|
||||
wayland.windowManager.hyprland.extraConfig = mkIf (cfg.displays != [ ])
|
||||
(renderDisplaysForHyprland cfg.displays);
|
||||
}
|
||||
];
|
||||
};
|
||||
}
|
||||
|
||||
49
lib/modules/editor.nix
Normal file
49
lib/modules/editor.nix
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
{ user }: { lib, pkgs, config, ... }:
|
||||
with lib;
|
||||
let
|
||||
editor = config.programs.editor;
|
||||
terminal = "foot";
|
||||
menu = "wofi --show dmenu";
|
||||
in
|
||||
{
|
||||
options.programs = {
|
||||
editor = {
|
||||
enable = mkEnableOption "editor";
|
||||
package = mkPackageOption pkgs "vscodium" {
|
||||
default = pkgs.vscodium;
|
||||
example = "pkgs.vscode";
|
||||
};
|
||||
command = mkOption {
|
||||
default = "/bin/codium";
|
||||
};
|
||||
neovim = mkEnableOption "neovim mode";
|
||||
};
|
||||
};
|
||||
|
||||
config = mkIf editor.enable {
|
||||
home-manager.users.${user}.imports = [{
|
||||
programs.vscode = {
|
||||
enable = true;
|
||||
package = editor.package;
|
||||
};
|
||||
}];
|
||||
|
||||
programs.scripts = [{
|
||||
name = "open-code";
|
||||
text = ''
|
||||
code_dir=~/Documents/code
|
||||
cd $code_dir
|
||||
repo=$({ ls && echo clone-repo; } | ${menu})
|
||||
case $repo in
|
||||
clone-repo)
|
||||
url=$(wl-paste)
|
||||
${terminal} -e -- git clone "$url" ;;
|
||||
*) [ -e "$repo" ] && ${editor.package}${editor.command} $repo ;;
|
||||
esac
|
||||
'';
|
||||
install = false;
|
||||
hotkey = "C";
|
||||
}];
|
||||
};
|
||||
|
||||
}
|
||||
24
lib/modules/keyboard.nix
Normal file
24
lib/modules/keyboard.nix
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
{ user }: { lib, pkgs, config, ... }:
|
||||
with lib;
|
||||
{
|
||||
options.keyboard = {
|
||||
dvorak = {
|
||||
enable = mkEnableOption "use a good keyboard layout on a qwerty keyboard";
|
||||
};
|
||||
};
|
||||
|
||||
config = mkIf config.keyboard.dvorak.enable {
|
||||
home-manager.users.${user}.imports = [
|
||||
{
|
||||
wayland.windowManager.hyprland.extraConfig = ''
|
||||
# === KEYBOARD MODULE ===
|
||||
input {
|
||||
kb_variant = dvorak
|
||||
}
|
||||
'';
|
||||
}
|
||||
];
|
||||
services.xserver.xkbVariant = "dvorak";
|
||||
};
|
||||
|
||||
}
|
||||
52
lib/modules/scripts.nix
Normal file
52
lib/modules/scripts.nix
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
{ user }: { lib, pkgs, config, ... }:
|
||||
with lib;
|
||||
let
|
||||
scripts = config.programs.scripts;
|
||||
|
||||
scriptType = types.submodule ({...}: {
|
||||
options = {
|
||||
name = mkOption {
|
||||
description = "name of the executable";
|
||||
};
|
||||
text = mkOption {
|
||||
description = "the text of the script";
|
||||
};
|
||||
hotkey = mkOption {
|
||||
description = "the key that run this script";
|
||||
default = "";
|
||||
};
|
||||
install = mkOption {
|
||||
type = types.bool;
|
||||
default = true;
|
||||
};
|
||||
};
|
||||
});
|
||||
|
||||
scriptToPackage = script: pkgs.writeShellScriptBin script.name script.text;
|
||||
installScripts = scripts: (map scriptToPackage (filter ( s: s.install ) scripts));
|
||||
|
||||
bindScript = script: if script.hotkey != "" then ''
|
||||
bind = SUPER, ${script.hotkey}, exec, ${scriptToPackage script}/bin/${script.name}
|
||||
'' else "";
|
||||
|
||||
bindScripts = scripts:
|
||||
"# === USER SCRIPTS MODULE ===\n"
|
||||
+ concatStringsSep "\n" (map bindScript scripts);
|
||||
|
||||
in
|
||||
{
|
||||
options.programs = {
|
||||
scripts = mkOption {
|
||||
type = types.listOf scriptType;
|
||||
default = [];
|
||||
};
|
||||
};
|
||||
|
||||
config = {
|
||||
home-manager.users.${user}.imports = [{
|
||||
home.packages = installScripts scripts;
|
||||
wayland.windowManager.hyprland.extraConfig = bindScripts scripts;
|
||||
}];
|
||||
};
|
||||
|
||||
}
|
||||
71
lib/modules/work.nix
Normal file
71
lib/modules/work.nix
Normal file
|
|
@ -0,0 +1,71 @@
|
|||
{ user }: { lib, pkgs, config, ... }:
|
||||
with lib;
|
||||
{
|
||||
options.roles.work = {
|
||||
enable = mkEnableOption "work packages";
|
||||
};
|
||||
|
||||
config = mkIf config.roles.work.enable {
|
||||
|
||||
home-manager.users.${user}.imports = [{
|
||||
|
||||
home.packages = with pkgs; [
|
||||
onedrive
|
||||
kubectl
|
||||
awscli2
|
||||
docker-compose
|
||||
minikube
|
||||
kubernetes-helm
|
||||
ansible
|
||||
thunderbird
|
||||
(import ../mkapp.nix "slack" {
|
||||
inherit pkgs;
|
||||
desktopName = "Slack";
|
||||
app-id = "mpagibdhafmlkgpemeicgogjnhclenoc";
|
||||
browser = "${brave}/opt/brave.com/brave/brave-browser";
|
||||
})
|
||||
(import ../mkapp.nix "teams" {
|
||||
inherit pkgs;
|
||||
browser = "${brave}/opt/brave.com/brave/brave-browser";
|
||||
app-id = "cifhbcnohmdccbgoicgdjpfamggdegmo";
|
||||
desktopName = "Microsoft Teams";
|
||||
})
|
||||
(pkgs.writeShellScriptBin "my-editor" ''
|
||||
${pkgs.vscode}/bin/code --ozone-platform-hint=auto --enable-features=WaylandWindowDecorations $@
|
||||
'')
|
||||
];
|
||||
|
||||
gtk.gtk3.bookmarks = [
|
||||
"file:///home/tristan/OneDrive/Documents/ OneDrive"
|
||||
];
|
||||
|
||||
programs.vscode = {
|
||||
extensions = with pkgs; [
|
||||
vscode-extensions.ms-azuretools.vscode-docker
|
||||
];
|
||||
userSettings = {
|
||||
"aws.telemetry" = false;
|
||||
"gitlens.telemetry.enabled" = false;
|
||||
};
|
||||
};
|
||||
|
||||
}];
|
||||
|
||||
programs.editor = {
|
||||
enable = true;
|
||||
package = pkgs.vscode;
|
||||
command = "/bin/code";
|
||||
};
|
||||
|
||||
nixpkgs.config.allowUnfreePredicate = pkg: builtins.elem (lib.getName pkg) [
|
||||
# nonfree vscode required for dev containers
|
||||
"vscode"
|
||||
];
|
||||
|
||||
networking = {
|
||||
networkmanager = {
|
||||
plugins = [ pkgs.networkmanager-openvpn ];
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue