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

View File

@ -57,13 +57,12 @@
}; };
}; };
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"
@ -76,38 +75,16 @@
inputs inputs
outputs outputs
configVars configVars
; }; ;
in };
{ in {
packages = forAllSystems (system: import ./pkgs nixpkgs.legacyPackages.${system}); packages = forAllSystems (system: import ./pkgs nixpkgs.legacyPackages.${system});
#formatter = forAllSystems (system: nixpkgs.legacyPackages.${system}.alejandra);
overlays = import ./overlays {inherit inputs;}; overlays = import ./overlays {inherit inputs;};
nixosModules = import ./modules/nixos; nixosModules = import ./modules/nixos;
homeManagerModules = import ./modules/home-manager; homeManagerModules = import ./modules/home-manager;
# System level configs # System level configs
nixosConfigurations = { nixosConfigurations = {
nixdev = nixpkgs.lib.nixosSystem {
inherit specialArgs;
modules = [
./hosts/nixdev
home-manager.nixosModules.home-manager
{
home-manager.extraSpecialArgs = specialArgs;
}
];
};
fileserver = nixpkgs.lib.nixosSystem {
inherit specialArgs;
modules = [
./hosts/fileserver
home-manager.nixosModules.home-manager
{
home-manager.extraSpecialArgs = specialArgs;
}
];
};
bootstrap = nixpkgs.lib.nixosSystem { bootstrap = nixpkgs.lib.nixosSystem {
inherit specialArgs; inherit specialArgs;
modules = [ modules = [

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"
# '';
}; };
}; };