Refactor flake.nix and add key remaps script

- Refactor `flake.nix` to simplify the `outputs` section and remove redundant configurations
- Update `lsp.nix` to use hostname for NixOS and Home Manager configurations.
- Add `key-remaps.nix` script to `dwm` configuration and update `xinitrc.nix` to include it in autostart.
- Comment out non-functional `displayManager.sessionCommands` in `citadel/default.nix`.
This commit is contained in:
Sam 2024-10-24 15:14:34 +01:00
parent bd3f24056e
commit 8242c29cf7
6 changed files with 103 additions and 108 deletions

171
flake.nix
View File

@ -53,107 +53,84 @@
nix-secrets = { nix-secrets = {
url = "git+ssh://git@git.bitlab21.com/sam/nix-secrets.git"; url = "git+ssh://git@git.bitlab21.com/sam/nix-secrets.git";
inputs = { }; inputs = {};
}; };
}; };
outputs = outputs = {
{ self self,
, nixpkgs nixpkgs,
, home-manager home-manager,
, ... ...
} @ inputs: } @ inputs: let
let inherit (self) outputs;
inherit (self) outputs; systems = [
systems = [ "x86_64-linux"
"x86_64-linux" ];
]; forAllSystems = nixpkgs.lib.genAttrs systems;
forAllSystems = nixpkgs.lib.genAttrs systems; inherit (nixpkgs) lib;
inherit (nixpkgs) lib; configVars = import ./vars {inherit inputs lib;};
configVars = import ./vars { inherit inputs lib; }; specialArgs = {
specialArgs = { inherit
inherit inputs
inputs outputs
outputs configVars
configVars ;
; }; };
in in {
{ packages = forAllSystems (system: import ./pkgs nixpkgs.legacyPackages.${system});
packages = forAllSystems (system: import ./pkgs nixpkgs.legacyPackages.${system}); overlays = import ./overlays {inherit inputs;};
#formatter = forAllSystems (system: nixpkgs.legacyPackages.${system}.alejandra); nixosModules = import ./modules/nixos;
overlays = import ./overlays { inherit inputs; }; homeManagerModules = import ./modules/home-manager;
nixosModules = import ./modules/nixos;
homeManagerModules = import ./modules/home-manager;
# System level configs
# System level configs nixosConfigurations = {
nixosConfigurations = { bootstrap = nixpkgs.lib.nixosSystem {
nixdev = nixpkgs.lib.nixosSystem { inherit specialArgs;
inherit specialArgs; modules = [
modules = [ ./hosts/bootstrap
./hosts/nixdev ];
home-manager.nixosModules.home-manager };
{ sparky = nixpkgs.lib.nixosSystem {
home-manager.extraSpecialArgs = specialArgs; inherit specialArgs;
} modules = [
]; ./hosts/sparky
}; home-manager.nixosModules.home-manager
fileserver = nixpkgs.lib.nixosSystem { {
inherit specialArgs; home-manager.extraSpecialArgs = specialArgs;
modules = [ }
./hosts/fileserver ];
home-manager.nixosModules.home-manager };
{ semita = nixpkgs.lib.nixosSystem {
home-manager.extraSpecialArgs = specialArgs; inherit specialArgs;
} modules = [
]; ./hosts/semita
}; home-manager.nixosModules.home-manager
bootstrap = nixpkgs.lib.nixosSystem { {
inherit specialArgs; home-manager.extraSpecialArgs = specialArgs;
modules = [ }
./hosts/bootstrap ];
]; };
}; merlin = nixpkgs.lib.nixosSystem {
sparky = nixpkgs.lib.nixosSystem { inherit specialArgs;
inherit specialArgs; modules = [
modules = [ ./hosts/nebula
./hosts/sparky home-manager.nixosModules.home-manager
home-manager.nixosModules.home-manager {
{ home-manager.extraSpecialArgs = specialArgs;
home-manager.extraSpecialArgs = specialArgs; }
} ];
]; };
}; citadel = nixpkgs.lib.nixosSystem {
semita = nixpkgs.lib.nixosSystem { inherit specialArgs;
inherit specialArgs; modules = [
modules = [ ./hosts/citadel
./hosts/semita home-manager.nixosModules.home-manager
home-manager.nixosModules.home-manager {
{ home-manager.extraSpecialArgs = specialArgs;
home-manager.extraSpecialArgs = specialArgs; }
} ];
];
};
merlin = nixpkgs.lib.nixosSystem {
inherit specialArgs;
modules = [
./hosts/nebula
home-manager.nixosModules.home-manager
{
home-manager.extraSpecialArgs = specialArgs;
}
];
};
citadel = nixpkgs.lib.nixosSystem {
inherit specialArgs;
modules = [
./hosts/citadel
home-manager.nixosModules.home-manager
{
home-manager.extraSpecialArgs = specialArgs;
}
];
};
}; };
}; };
};
} }

View File

@ -1,3 +1,7 @@
{ osConfig , ... }:
let
hostname = osConfig.networking.hostName;
in
{ {
programs.nixvim.plugins = { programs.nixvim.plugins = {
lsp = { lsp = {
@ -10,8 +14,9 @@
settings = { settings = {
nixpkgs.expr = "import <nixpkgs> { }"; nixpkgs.expr = "import <nixpkgs> { }";
options = { options = {
nixos.expr = "(builtins.getFlake ('git+file://' + toString ./.)).nixosConfigurations.k-on.options"; nixos.expr = "(builtins.getFlake \"/etc/nixos\").nixosConfigurations.${hostname}.options";
home_manager.expr = "(builtins.getFlake ('git+file://' + toString ./.)).homeConfigurations.'ruixi@k-on'.options"; # TODO get home-manager options working when hm imported as submodule
# home_manager.expr = "(builtins.getFlake \"github:nix-community/home-manager\").homeConfigurations.${hostname}.options";
}; };
}; };
}; };

View File

@ -32,6 +32,7 @@
./scripts/dmenu-wifi.nix ./scripts/dmenu-wifi.nix
./scripts/battery-status.nix ./scripts/battery-status.nix
./scripts/dmenu-set-wm-class.nix ./scripts/dmenu-set-wm-class.nix
./scripts/key-remaps.nix
]; ];
home.packages = [ home.packages = [

View File

@ -0,0 +1,11 @@
{pkgs, ...}: {
home.packages = with pkgs; [
(writeShellScriptBin "key-remaps" ''
${xorg.xmodmap}/bin/xmodmap -e "keycode 64 = Mode_switch"
${xorg.xmodmap}/bin/xmodmap -e "keycode 43 = h H Left H"
${xorg.xmodmap}/bin/xmodmap -e "keycode 44 = j J Down J"
${xorg.xmodmap}/bin/xmodmap -e "keycode 45 = k K Up K"
${xorg.xmodmap}/bin/xmodmap -e "keycode 46 = l L Right L"
'')
];
}

View File

@ -1,4 +1,4 @@
{pkgs, ...}: { {...}: {
# TODO: configure x11 to look in .config/x11 # TODO: configure x11 to look in .config/x11
home.file.".xinitrc" = { home.file.".xinitrc" = {
recursive = true; recursive = true;
@ -7,7 +7,7 @@
picom -b --config ~/.config/picom/picom.conf picom -b --config ~/.config/picom/picom.conf
xrdb -merge ~/.Xresources xrdb -merge ~/.Xresources
autostart="clipboard-save dwmblocks feh-wallpaper-changer sxhkd" autostart="clipboard-save dwmblocks feh-wallpaper-changer sxhkd key-remaps"
for program in $autostart; do for program in $autostart; do
pidof -sx "$program" || "$program" & pidof -sx "$program" || "$program" &

View File

@ -77,13 +77,14 @@ in {
xkb.options = "caps:swapescape"; xkb.options = "caps:swapescape";
dpi = 196; dpi = 196;
upscaleDefaultCursor = true; upscaleDefaultCursor = true;
displayManager.sessionCommands = pkgs.writeShellScriptBin "key-remaps" '' # FIXME this doesnt work for some reason
${pkgs.xorg.xmodmap}/bin/xmodmap -e "keycode 64 = Mode_switch" # displayManager.sessionCommands = pkgs.writeShellScriptBin "key-remaps" ''
${pkgs.xorg.xmodmap}/bin/xmodmap -e "keycode 43 = h H Left H" # ${pkgs.xorg.xmodmap}/bin/xmodmap -e "keycode 64 = Mode_switch"
${pkgs.xorg.xmodmap}/bin/xmodmap -e "keycode 44 = j J Down J" # ${pkgs.xorg.xmodmap}/bin/xmodmap -e "keycode 43 = h H Left H"
${pkgs.xorg.xmodmap}/bin/xmodmap -e "keycode 45 = k K Up K" # ${pkgs.xorg.xmodmap}/bin/xmodmap -e "keycode 44 = j J Down J"
${pkgs.xorg.xmodmap}/bin/xmodmap -e "keycode 46 = l L Right L" # ${pkgs.xorg.xmodmap}/bin/xmodmap -e "keycode 45 = k K Up K"
''; # ${pkgs.xorg.xmodmap}/bin/xmodmap -e "keycode 46 = l L Right L"
# '';
}; };
}; };