From 2ddffc74c93b9acee813e31568c04f5f5ccbc2ef Mon Sep 17 00:00:00 2001 From: Christoph Schmatzler Date: Sun, 3 Aug 2025 20:35:48 +0200 Subject: [PATCH] format --- flake.nix | 97 +++++--- hosts/darwin/default.nix | 36 ++- hosts/nixos/default.nix | 91 +++++--- modules/darwin/casks.nix | 3 +- modules/darwin/files.nix | 9 +- modules/darwin/home-manager.nix | 41 ++-- modules/darwin/packages.nix | 7 +- modules/darwin/secrets.nix | 12 +- modules/nixos/files.nix | 397 ++++++++++++++++---------------- modules/nixos/home-manager.nix | 31 ++- modules/nixos/packages.nix | 7 +- modules/nixos/secrets.nix | 12 +- modules/shared/default.nix | 14 +- modules/shared/files.nix | 3 +- modules/shared/home-manager.nix | 45 ++-- modules/shared/packages.nix | 3 +- result | 1 - 17 files changed, 476 insertions(+), 333 deletions(-) delete mode 120000 result diff --git a/flake.nix b/flake.nix index 50cccf8..e3054a8 100644 --- a/flake.nix +++ b/flake.nix @@ -32,28 +32,55 @@ flake = false; }; }; - outputs = { self, darwin, nix-homebrew, homebrew-bundle, homebrew-core, homebrew-cask, home-manager, nixpkgs, disko, agenix, secrets } @inputs: + outputs = + { + self, + darwin, + nix-homebrew, + homebrew-bundle, + homebrew-core, + homebrew-cask, + home-manager, + nixpkgs, + disko, + agenix, + secrets, + }@inputs: let user = "cschmatzler"; linuxSystems = [ "x86_64-linux" ]; darwinSystems = [ "aarch64-darwin" ]; forAllSystems = f: nixpkgs.lib.genAttrs (linuxSystems ++ darwinSystems) f; - devShell = system: let pkgs = nixpkgs.legacyPackages.${system}; in { - default = with pkgs; mkShell { - nativeBuildInputs = with pkgs; [ bashInteractive git age age-plugin-yubikey ]; - shellHook = with pkgs; '' - export EDITOR=vim - ''; + devShell = + system: + let + pkgs = nixpkgs.legacyPackages.${system}; + in + { + default = + with pkgs; + mkShell { + nativeBuildInputs = with pkgs; [ + bashInteractive + git + age + age-plugin-yubikey + ]; + shellHook = with pkgs; '' + export EDITOR=vim + ''; + }; }; - }; mkApp = scriptName: system: { type = "app"; - program = "${(nixpkgs.legacyPackages.${system}.writeScriptBin scriptName '' - #!/usr/bin/env bash - PATH=${nixpkgs.legacyPackages.${system}.git}/bin:$PATH - echo "Running ${scriptName} for ${system}" - exec ${self}/apps/${system}/${scriptName} - '')}/bin/${scriptName}"; + program = "${ + (nixpkgs.legacyPackages.${system}.writeScriptBin scriptName '' + #!/usr/bin/env bash + PATH=${nixpkgs.legacyPackages.${system}.git}/bin:$PATH + echo "Running ${scriptName} for ${system}" + exec ${self}/apps/${system}/${scriptName} + '') + }/bin/${scriptName}"; }; mkLinuxApps = system: { "apply" = mkApp "apply" system; @@ -76,9 +103,11 @@ in { devShells = forAllSystems devShell; - apps = nixpkgs.lib.genAttrs linuxSystems mkLinuxApps // nixpkgs.lib.genAttrs darwinSystems mkDarwinApps; + apps = + nixpkgs.lib.genAttrs linuxSystems mkLinuxApps // nixpkgs.lib.genAttrs darwinSystems mkDarwinApps; - darwinConfigurations = nixpkgs.lib.genAttrs darwinSystems (system: + darwinConfigurations = nixpkgs.lib.genAttrs darwinSystems ( + system: darwin.lib.darwinSystem { inherit system; specialArgs = inputs; @@ -103,20 +132,24 @@ } ); - nixosConfigurations = nixpkgs.lib.genAttrs linuxSystems (system: nixpkgs.lib.nixosSystem { - inherit system; - specialArgs = inputs; - modules = [ - disko.nixosModules.disko - home-manager.nixosModules.home-manager { - home-manager = { - useGlobalPkgs = true; - useUserPackages = true; - users.${user} = import ./modules/nixos/home-manager.nix; - }; - } - ./hosts/nixos - ]; - }); - }; + nixosConfigurations = nixpkgs.lib.genAttrs linuxSystems ( + system: + nixpkgs.lib.nixosSystem { + inherit system; + specialArgs = inputs; + modules = [ + disko.nixosModules.disko + home-manager.nixosModules.home-manager + { + home-manager = { + useGlobalPkgs = true; + useUserPackages = true; + users.${user} = import ./modules/nixos/home-manager.nix; + }; + } + ./hosts/nixos + ]; + } + ); + }; } diff --git a/hosts/darwin/default.nix b/hosts/darwin/default.nix index 8fd17c0..1d85ebf 100644 --- a/hosts/darwin/default.nix +++ b/hosts/darwin/default.nix @@ -1,6 +1,13 @@ -{ agenix, config, pkgs, ... }: +{ + agenix, + config, + pkgs, + ... +}: -let user = "cschmatzler"; in +let + user = "cschmatzler"; +in { imports = [ @@ -13,13 +20,23 @@ let user = "cschmatzler"; in nix = { package = pkgs.nix; settings = { - trusted-users = [ "@admin" "${user}" ]; - substituters = [ "https://nix-community.cachix.org" "https://cache.nixos.org" ]; + trusted-users = [ + "@admin" + "${user}" + ]; + substituters = [ + "https://nix-community.cachix.org" + "https://cache.nixos.org" + ]; trusted-public-keys = [ "cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY=" ]; }; gc = { automatic = true; - interval = { Weekday = 0; Hour = 2; Minute = 0; }; + interval = { + Weekday = 0; + Hour = 2; + Minute = 0; + }; options = "--delete-older-than 30d"; }; extraOptions = '' @@ -27,9 +44,12 @@ let user = "cschmatzler"; in ''; }; - environment.systemPackages = with pkgs; [ - agenix.packages."${pkgs.system}".default - ] ++ (import ../../modules/shared/packages.nix { inherit pkgs; }); + environment.systemPackages = + with pkgs; + [ + agenix.packages."${pkgs.system}".default + ] + ++ (import ../../modules/shared/packages.nix { inherit pkgs; }); system = { checks.verifyNixPath = false; diff --git a/hosts/nixos/default.nix b/hosts/nixos/default.nix index 1a174b0..8acc153 100644 --- a/hosts/nixos/default.nix +++ b/hosts/nixos/default.nix @@ -1,7 +1,15 @@ -{ config, inputs, pkgs, agenix, ... }: +{ + config, + inputs, + pkgs, + agenix, + ... +}: -let user = "cschmatzler"; - keys = [ "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIOk8iAnIaa1deoc7jw8YACPNVka1ZFJxhnU4G74TmS+p" ]; in +let + user = "cschmatzler"; + keys = [ "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIOk8iAnIaa1deoc7jw8YACPNVka1ZFJxhnU4G74TmS+p" ]; +in { imports = [ ../../modules/nixos/secrets.nix @@ -19,7 +27,14 @@ let user = "cschmatzler"; }; efi.canTouchEfiVariables = true; }; - initrd.availableKernelModules = [ "xhci_pci" "ahci" "nvme" "usbhid" "usb_storage" "sd_mod" ]; + initrd.availableKernelModules = [ + "xhci_pci" + "ahci" + "nvme" + "usbhid" + "usb_storage" + "sd_mod" + ]; # Uncomment for AMD GPU # initrd.kernelModules = [ "amdgpu" ]; kernelPackages = pkgs.linuxPackages_latest; @@ -42,8 +57,14 @@ let user = "cschmatzler"; nixPath = [ "nixos-config=/home/${user}/.local/share/src/nixos-config:/etc/nixos" ]; settings = { allowed-users = [ "${user}" ]; - trusted-users = [ "@admin" "${user}" ]; - substituters = [ "https://nix-community.cachix.org" "https://cache.nixos.org" ]; + trusted-users = [ + "@admin" + "${user}" + ]; + substituters = [ + "https://nix-community.cachix.org" + "https://cache.nixos.org" + ]; trusted-public-keys = [ "cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY=" ]; }; @@ -120,7 +141,7 @@ let user = "cschmatzler"; overrideDevices = true; settings = { - devices = {}; + devices = { }; options.globalAnnounceEnabled = false; # Only sync on LAN }; }; @@ -154,8 +175,8 @@ let user = "cschmatzler"; "class_g = 'i3lock'" ]; round-borders = 3; - round-borders-exclude = []; - round-borders-rule = []; + round-borders-exclude = [ ]; + round-borders-rule = [ ]; shadow = true; shadow-radius = 8; shadow-opacity = 0.4; @@ -206,12 +227,29 @@ let user = "cschmatzler"; log-level = "info"; wintypes = { - normal = { fade = true; shadow = false; }; - tooltip = { fade = true; shadow = false; opacity = 0.75; focus = true; full-shadow = false; }; - dock = { shadow = false; }; - dnd = { shadow = false; }; - popup_menu = { opacity = 1.0; }; - dropdown_menu = { opacity = 1.0; }; + normal = { + fade = true; + shadow = false; + }; + tooltip = { + fade = true; + shadow = false; + opacity = 0.75; + focus = true; + full-shadow = false; + }; + dock = { + shadow = false; + }; + dnd = { + shadow = false; + }; + popup_menu = { + opacity = 1.0; + }; + dropdown_menu = { + opacity = 1.0; + }; }; }; }; @@ -241,8 +279,7 @@ let user = "cschmatzler"; ledger.enable = true; }; - - # Add docker daemon + # Add docker daemon virtualisation.docker.enable = true; virtualisation.docker.logDriver = "json-file"; @@ -266,15 +303,17 @@ let user = "cschmatzler"; # Don't require password for users in `wheel` group for these commands security.sudo = { enable = true; - extraRules = [{ - commands = [ - { - command = "${pkgs.systemd}/bin/reboot"; - options = [ "NOPASSWD" ]; - } - ]; - groups = [ "wheel" ]; - }]; + extraRules = [ + { + commands = [ + { + command = "${pkgs.systemd}/bin/reboot"; + options = [ "NOPASSWD" ]; + } + ]; + groups = [ "wheel" ]; + } + ]; }; fonts.packages = with pkgs; [ diff --git a/modules/darwin/casks.nix b/modules/darwin/casks.nix index dc5398b..cc773b7 100644 --- a/modules/darwin/casks.nix +++ b/modules/darwin/casks.nix @@ -1,2 +1 @@ -_: -[] +_: [ ] diff --git a/modules/darwin/files.nix b/modules/darwin/files.nix index 4bc3505..f8ce358 100644 --- a/modules/darwin/files.nix +++ b/modules/darwin/files.nix @@ -1,2 +1,7 @@ -{ user, config, pkgs, ... }: -{} +{ + user, + config, + pkgs, + ... +}: +{ } diff --git a/modules/darwin/home-manager.nix b/modules/darwin/home-manager.nix index 603dfb1..3010ddb 100644 --- a/modules/darwin/home-manager.nix +++ b/modules/darwin/home-manager.nix @@ -1,4 +1,10 @@ -{ config, pkgs, lib, home-manager, ... }: +{ + config, + pkgs, + lib, + home-manager, + ... +}: let user = "cschmatzler"; @@ -7,7 +13,7 @@ let in { imports = [ - ./dock + ./dock ]; # It me @@ -20,7 +26,7 @@ in homebrew = { enable = true; - casks = pkgs.callPackage ./casks.nix {}; + casks = pkgs.callPackage ./casks.nix { }; masApps = { }; @@ -28,18 +34,25 @@ in home-manager = { useGlobalPkgs = true; - users.${user} = { pkgs, config, lib, ... }:{ - home = { - enableNixpkgsReleaseCheck = false; - packages = pkgs.callPackage ./packages.nix {}; - file = lib.mkMerge [ - sharedFiles - additionalFiles - ]; - stateVersion = "23.11"; + users.${user} = + { + pkgs, + config, + lib, + ... + }: + { + home = { + enableNixpkgsReleaseCheck = false; + packages = pkgs.callPackage ./packages.nix { }; + file = lib.mkMerge [ + sharedFiles + additionalFiles + ]; + stateVersion = "23.11"; + }; + programs = { } // import ../shared/home-manager.nix { inherit config pkgs lib; }; }; - programs = {} // import ../shared/home-manager.nix { inherit config pkgs lib; }; - }; }; # Fully declarative dock using the latest from Nix Store diff --git a/modules/darwin/packages.nix b/modules/darwin/packages.nix index 4ec88e6..59ddb96 100644 --- a/modules/darwin/packages.nix +++ b/modules/darwin/packages.nix @@ -1,8 +1,11 @@ { pkgs }: with pkgs; -let shared-packages = import ../shared/packages.nix { inherit pkgs; }; in -shared-packages ++ [ +let + shared-packages = import ../shared/packages.nix { inherit pkgs; }; +in +shared-packages +++ [ dockutil _1password-gui raycast diff --git a/modules/darwin/secrets.nix b/modules/darwin/secrets.nix index f6b1af4..f535571 100644 --- a/modules/darwin/secrets.nix +++ b/modules/darwin/secrets.nix @@ -1,6 +1,14 @@ -{ config, pkgs, agenix, secrets, ... }: +{ + config, + pkgs, + agenix, + secrets, + ... +}: -let user = "cschmatzler"; in +let + user = "cschmatzler"; +in { age.identityPaths = [ "/Users/${user}/.ssh/id_ed25519" diff --git a/modules/nixos/files.nix b/modules/nixos/files.nix index 0138558..b1251ff 100644 --- a/modules/nixos/files.nix +++ b/modules/nixos/files.nix @@ -1,10 +1,11 @@ { user, ... }: let - home = builtins.getEnv "HOME"; + home = builtins.getEnv "HOME"; xdg_configHome = "${home}/.config"; - xdg_dataHome = "${home}/.local/share"; - xdg_stateHome = "${home}/.local/state"; in + xdg_dataHome = "${home}/.local/share"; + xdg_stateHome = "${home}/.local/state"; +in { "${xdg_configHome}/bspwm/bspwmrc" = { @@ -62,162 +63,162 @@ let "${xdg_configHome}/sxhkd/sxhkdrc" = { text = '' - # Close window - alt + F4 - bspc node --close + # Close window + alt + F4 + bspc node --close - # Make split ratios equal - super + equal - bspc node @/ --equalize + # Make split ratios equal + super + equal + bspc node @/ --equalize - # Make split ratios balanced - super + minus - bspc node @/ --balance + # Make split ratios balanced + super + minus + bspc node @/ --balance - # Toogle tiling of window - super + d - bspc query --nodes -n focused.tiled && state=floating || state=tiled; \ - bspc node --state \~$state + # Toogle tiling of window + super + d + bspc query --nodes -n focused.tiled && state=floating || state=tiled; \ + bspc node --state \~$state - # Toggle fullscreen of window - super + f - bspc node --state \~fullscreen + # Toggle fullscreen of window + super + f + bspc node --state \~fullscreen - # Swap the current node and the biggest window - super + g - bspc node -s biggest.window + # Swap the current node and the biggest window + super + g + bspc node -s biggest.window - # Swap the current node and the smallest window - super + shift + g - bspc node -s biggest.window + # Swap the current node and the smallest window + super + shift + g + bspc node -s biggest.window - # Alternate between the tiled and monocle layout - super + m - bspc desktop -l next + # Alternate between the tiled and monocle layout + super + m + bspc desktop -l next - # Move between windows in monocle layout - super + {_, alt + }m - bspc node -f {next, prev}.local.!hidden.window + # Move between windows in monocle layout + super + {_, alt + }m + bspc node -f {next, prev}.local.!hidden.window - # Focus the node in the given direction - super + {_,shift + }{h,j,k,l} - bspc node -{f,s} {west,south,north,east} + # Focus the node in the given direction + super + {_,shift + }{h,j,k,l} + bspc node -{f,s} {west,south,north,east} - # Focus left/right occupied desktop - super + {Left,Right} - bspc desktop --focus {prev,next}.occupied + # Focus left/right occupied desktop + super + {Left,Right} + bspc desktop --focus {prev,next}.occupied - # Focus left/right occupied desktop - super + {Up,Down} - bspc desktop --focus {prev,next}.occupied + # Focus left/right occupied desktop + super + {Up,Down} + bspc desktop --focus {prev,next}.occupied - # Focus left/right desktop - ctrl + alt + {Left,Right} - bspc desktop --focus {prev,next} + # Focus left/right desktop + ctrl + alt + {Left,Right} + bspc desktop --focus {prev,next} - # Focus left/right desktop - ctrl + alt + {Up, Down} - bspc desktop --focus {prev,next} + # Focus left/right desktop + ctrl + alt + {Up, Down} + bspc desktop --focus {prev,next} - # Focus the older or newer node in the focus history - super + {o,i} - bspc wm -h off; \ - bspc node {older,newer} -f; \ - bspc wm -h on + # Focus the older or newer node in the focus history + super + {o,i} + bspc wm -h off; \ + bspc node {older,newer} -f; \ + bspc wm -h on - # Focus or send to the given desktop - super + {_,shift + }{1-9,0} - bspc {desktop -f,node -d} '^{1-9,10}' + # Focus or send to the given desktop + super + {_,shift + }{1-9,0} + bspc {desktop -f,node -d} '^{1-9,10}' - # Preselect the direction - super + alt + {h,j,k,l} - bspc node -p {west,south,north,east} + # Preselect the direction + super + alt + {h,j,k,l} + bspc node -p {west,south,north,east} - # Cancel the preselect - # For context on syntax: https://github.com/baskerville/bspwm/issues/344 - super + alt + {_,shift + }Escape - bspc query -N -d | xargs -I id -n 1 bspc node id -p cancel + # Cancel the preselect + # For context on syntax: https://github.com/baskerville/bspwm/issues/344 + super + alt + {_,shift + }Escape + bspc query -N -d | xargs -I id -n 1 bspc node id -p cancel - # Preselect the direction - super + ctrl + {h,j,k,l} - bspc node -p {west,south,north,east} + # Preselect the direction + super + ctrl + {h,j,k,l} + bspc node -p {west,south,north,east} - # Cancel the preselect - # For context on syntax: https://github.com/baskerville/bspwm/issues/344 - super + ctrl + {_,shift + }Escape - bspc query -N -d | xargs -I id -n 1 bspc node id -p cancel + # Cancel the preselect + # For context on syntax: https://github.com/baskerville/bspwm/issues/344 + super + ctrl + {_,shift + }Escape + bspc query -N -d | xargs -I id -n 1 bspc node id -p cancel - # Set the node flags - super + ctrl + {m,x,s,p} - bspc node -g {marked,locked,sticky,private} + # Set the node flags + super + ctrl + {m,x,s,p} + bspc node -g {marked,locked,sticky,private} - # Send the newest marked node to the newest preselected node - super + y - bspc node newest.marked.local -n newest.!automatic.local + # Send the newest marked node to the newest preselected node + super + y + bspc node newest.marked.local -n newest.!automatic.local - # Program launcher - super + @space - rofi -config -no-lazy-grab -show drun -modi drun -theme /home/${user}/.config/rofi/launcher.rasi + # Program launcher + super + @space + rofi -config -no-lazy-grab -show drun -modi drun -theme /home/${user}/.config/rofi/launcher.rasi - # Terminal emulator - super + Return - bspc rule -a Alacritty -o state=floating rectangle=1024x768x0x0 center=true && /etc/profiles/per-user/${user}/bin/alacritty + # Terminal emulator + super + Return + bspc rule -a Alacritty -o state=floating rectangle=1024x768x0x0 center=true && /etc/profiles/per-user/${user}/bin/alacritty - # Terminal emulator - super + ctrl + Return - /etc/profiles/per-user/${user}/bin/alacritty + # Terminal emulator + super + ctrl + Return + /etc/profiles/per-user/${user}/bin/alacritty - # Jump to workspaces - super + t - bspc desktop --focus ^2 - super + b - bspc desktop --focus ^1 - super + w - bspc desktop --focus ^4 - super + Tab - bspc {node,desktop} -f last + # Jump to workspaces + super + t + bspc desktop --focus ^2 + super + b + bspc desktop --focus ^1 + super + w + bspc desktop --focus ^4 + super + Tab + bspc {node,desktop} -f last - # Keepass XC - super + shift + x - /etc/profiles/per-user/${user}/bin/keepassxc + # Keepass XC + super + shift + x + /etc/profiles/per-user/${user}/bin/keepassxc - # Emacs - # -c flag is --create-frame - # -a flag is fallback to plain emacs if daemon fails - super + alt + Return - emacsclient -c -a emacs + # Emacs + # -c flag is --create-frame + # -a flag is fallback to plain emacs if daemon fails + super + alt + Return + emacsclient -c -a emacs - super + alt + e - systemctl --user restart emacs.service && \ - emacsclient -c -a emacs + super + alt + e + systemctl --user restart emacs.service && \ + emacsclient -c -a emacs - # Web browser - ctrl + alt + Return - google-chrome-stable + # Web browser + ctrl + alt + Return + google-chrome-stable - # File browser at home dir - super + shift + @space - pcmanfm + # File browser at home dir + super + shift + @space + pcmanfm - # Take a screenshot with PrintSc - Print - flameshot gui -c -p $HOME/.local/share/img/screenshots + # Take a screenshot with PrintSc + Print + flameshot gui -c -p $HOME/.local/share/img/screenshots - # Lock the screen - ctrl + alt + BackSpace - i3lock + # Lock the screen + ctrl + alt + BackSpace + i3lock - # Audio controls for + volume - XF86AudioRaiseVolume - pactl set-sink-volume @DEFAULT_SINK@ +5% + # Audio controls for + volume + XF86AudioRaiseVolume + pactl set-sink-volume @DEFAULT_SINK@ +5% - # Audio controls for - volume - XF86AudioLowerVolume - pactl set-sink-volume @DEFAULT_SINK@ -5% + # Audio controls for - volume + XF86AudioLowerVolume + pactl set-sink-volume @DEFAULT_SINK@ -5% - # Audio controls for mute - XF86AudioMute - pactl set-sink-mute @DEFAULT_SINK@ toggle + # Audio controls for mute + XF86AudioMute + pactl set-sink-mute @DEFAULT_SINK@ toggle ''; }; @@ -285,84 +286,84 @@ let "${xdg_configHome}/rofi/bin/powermenu.sh" = { executable = true; text = '' - #!/bin/sh + #!/bin/sh - configDir="${xdg_configHome}/rofi" - uptime=$(uptime -p | sed -e 's/up //g') - rofi_command="rofi -no-config -theme $configDir/powermenu.rasi" + configDir="${xdg_configHome}/rofi" + uptime=$(uptime -p | sed -e 's/up //g') + rofi_command="rofi -no-config -theme $configDir/powermenu.rasi" - # Options - shutdown=" Shutdown" - reboot=" Restart" - lock=" Lock" - suspend=" Sleep" - logout=" Logout" + # Options + shutdown=" Shutdown" + reboot=" Restart" + lock=" Lock" + suspend=" Sleep" + logout=" Logout" - # Confirmation - confirm_exit() { - rofi -dmenu\ - -no-config\ - -i\ - -no-fixed-num-lines\ - -p "Are You Sure? : "\ - -theme $configDir/confirm.rasi - } + # Confirmation + confirm_exit() { + rofi -dmenu\ + -no-config\ + -i\ + -no-fixed-num-lines\ + -p "Are You Sure? : "\ + -theme $configDir/confirm.rasi + } - # Message - msg() { - rofi -no-config -theme "$configDir/message.rasi" -e "Available Options - yes / y / no / n" - } + # Message + msg() { + rofi -no-config -theme "$configDir/message.rasi" -e "Available Options - yes / y / no / n" + } - # Variable passed to rofi - options="$lock\n$suspend\n$logout\n$reboot\n$shutdown" - chosen="$(echo -e "$options" | $rofi_command -p "Uptime: $uptime" -dmenu -selected-row 0)" - case $chosen in - $shutdown) - ans=$(confirm_exit &) - if [[ $ans == "yes" || $ans == "YES" || $ans == "y" || $ans == "Y" ]]; then - systemctl poweroff - elif [[ $ans == "no" || $ans == "NO" || $ans == "n" || $ans == "N" ]]; then - exit 0 - else - msg - fi - ;; - $reboot) - ans=$(confirm_exit &) - if [[ $ans == "yes" || $ans == "YES" || $ans == "y" || $ans == "Y" ]]; then - systemctl reboot - elif [[ $ans == "no" || $ans == "NO" || $ans == "n" || $ans == "N" ]]; then - exit 0 - else - msg - fi - ;; - $lock) - betterlockscreen -l - ;; - $suspend) - ans=$(confirm_exit &) - if [[ $ans == "yes" || $ans == "YES" || $ans == "y" || $ans == "Y" ]]; then - mpc -q pause - amixer set Master mute - systemctl suspend - elif [[ $ans == "no" || $ans == "NO" || $ans == "n" || $ans == "N" ]]; then - exit 0 - else - msg - fi - ;; - $logout) - ans=$(confirm_exit &) - if [[ $ans == "yes" || $ans == "YES" || $ans == "y" || $ans == "Y" ]]; then - bspc quit - elif [[ $ans == "no" || $ans == "NO" || $ans == "n" || $ans == "N" ]]; then - exit 0 - else - msg - fi - ;; - esac - ''; + # Variable passed to rofi + options="$lock\n$suspend\n$logout\n$reboot\n$shutdown" + chosen="$(echo -e "$options" | $rofi_command -p "Uptime: $uptime" -dmenu -selected-row 0)" + case $chosen in + $shutdown) + ans=$(confirm_exit &) + if [[ $ans == "yes" || $ans == "YES" || $ans == "y" || $ans == "Y" ]]; then + systemctl poweroff + elif [[ $ans == "no" || $ans == "NO" || $ans == "n" || $ans == "N" ]]; then + exit 0 + else + msg + fi + ;; + $reboot) + ans=$(confirm_exit &) + if [[ $ans == "yes" || $ans == "YES" || $ans == "y" || $ans == "Y" ]]; then + systemctl reboot + elif [[ $ans == "no" || $ans == "NO" || $ans == "n" || $ans == "N" ]]; then + exit 0 + else + msg + fi + ;; + $lock) + betterlockscreen -l + ;; + $suspend) + ans=$(confirm_exit &) + if [[ $ans == "yes" || $ans == "YES" || $ans == "y" || $ans == "Y" ]]; then + mpc -q pause + amixer set Master mute + systemctl suspend + elif [[ $ans == "no" || $ans == "NO" || $ans == "n" || $ans == "N" ]]; then + exit 0 + else + msg + fi + ;; + $logout) + ans=$(confirm_exit &) + if [[ $ans == "yes" || $ans == "YES" || $ans == "y" || $ans == "Y" ]]; then + bspc quit + elif [[ $ans == "no" || $ans == "NO" || $ans == "n" || $ans == "N" ]]; then + exit 0 + else + msg + fi + ;; + esac + ''; }; } diff --git a/modules/nixos/home-manager.nix b/modules/nixos/home-manager.nix index 5916c48..f94bc45 100644 --- a/modules/nixos/home-manager.nix +++ b/modules/nixos/home-manager.nix @@ -1,18 +1,25 @@ -{ config, pkgs, lib, ... }: +{ + config, + pkgs, + lib, + ... +}: let user = "cschmatzler"; - xdg_configHome = "/home/${user}/.config"; + xdg_configHome = "/home/${user}/.config"; shared-programs = import ../shared/home-manager.nix { inherit config pkgs lib; }; shared-files = import ../shared/files.nix { inherit config pkgs; }; - polybar-user_modules = builtins.readFile (pkgs.replaceVars ./config/polybar/user_modules.ini { - packages = "${xdg_configHome}/polybar/bin/check-nixos-updates.sh"; - searchpkgs = "${xdg_configHome}/polybar/bin/search-nixos-updates.sh"; - launcher = "${xdg_configHome}/polybar/bin/launcher.sh"; - powermenu = "${xdg_configHome}/rofi/bin/powermenu.sh"; - calendar = "${xdg_configHome}/polybar/bin/popup-calendar.sh"; - }); + polybar-user_modules = builtins.readFile ( + pkgs.replaceVars ./config/polybar/user_modules.ini { + packages = "${xdg_configHome}/polybar/bin/check-nixos-updates.sh"; + searchpkgs = "${xdg_configHome}/polybar/bin/search-nixos-updates.sh"; + launcher = "${xdg_configHome}/polybar/bin/launcher.sh"; + powermenu = "${xdg_configHome}/rofi/bin/powermenu.sh"; + calendar = "${xdg_configHome}/polybar/bin/popup-calendar.sh"; + } + ); polybar-config = pkgs.replaceVars ./config/polybar/config.ini { font0 = "DejaVu Sans:size=12;3"; @@ -29,7 +36,7 @@ in enableNixpkgsReleaseCheck = false; username = "${user}"; homeDirectory = "/home/${user}"; - packages = pkgs.callPackage ./packages.nix {}; + packages = pkgs.callPackage ./packages.nix { }; file = shared-files // import ./files.nix { inherit user; }; stateVersion = "21.05"; }; @@ -112,6 +119,8 @@ in }; }; - programs = shared-programs // { gpg.enable = true; }; + programs = shared-programs // { + gpg.enable = true; + }; } diff --git a/modules/nixos/packages.nix b/modules/nixos/packages.nix index d67dc55..9afe9fd 100644 --- a/modules/nixos/packages.nix +++ b/modules/nixos/packages.nix @@ -1,8 +1,11 @@ { pkgs }: with pkgs; -let shared-packages = import ../shared/packages.nix { inherit pkgs; }; in -shared-packages ++ [ +let + shared-packages = import ../shared/packages.nix { inherit pkgs; }; +in +shared-packages +++ [ # Security and authentication yubikey-agent diff --git a/modules/nixos/secrets.nix b/modules/nixos/secrets.nix index 4f14770..8e9bd5e 100644 --- a/modules/nixos/secrets.nix +++ b/modules/nixos/secrets.nix @@ -1,6 +1,14 @@ -{ config, pkgs, agenix, secrets, ... }: +{ + config, + pkgs, + agenix, + secrets, + ... +}: -let user = "cschmatzler"; in +let + user = "cschmatzler"; +in { age.identityPaths = [ "/home/${user}/.ssh/id_ed25519" diff --git a/modules/shared/default.nix b/modules/shared/default.nix index d3f6d6f..c16f426 100644 --- a/modules/shared/default.nix +++ b/modules/shared/default.nix @@ -9,10 +9,14 @@ }; overlays = - let path = ../../overlays; in with builtins; - map (n: import (path + ("/" + n))) - (filter (n: match ".*\\.nix" n != null || - pathExists (path + ("/" + n + "/default.nix"))) - (attrNames (readDir path))); + let + path = ../../overlays; + in + with builtins; + map (n: import (path + ("/" + n))) ( + filter (n: match ".*\\.nix" n != null || pathExists (path + ("/" + n + "/default.nix"))) ( + attrNames (readDir path) + ) + ); }; } diff --git a/modules/shared/files.nix b/modules/shared/files.nix index b3b22a6..508f56f 100644 --- a/modules/shared/files.nix +++ b/modules/shared/files.nix @@ -1,2 +1 @@ -{ pkgs, config, ... }: -{} +{ pkgs, config, ... }: { } diff --git a/modules/shared/home-manager.nix b/modules/shared/home-manager.nix index 383b2c8..4d475e9 100644 --- a/modules/shared/home-manager.nix +++ b/modules/shared/home-manager.nix @@ -1,8 +1,15 @@ -{ config, pkgs, lib, ... }: +{ + config, + pkgs, + lib, + ... +}: -let name = "Christoph Schmatzler"; - user = "cschmatzler"; - email = "christoph@schmatzler.com"; in +let + name = "Christoph Schmatzler"; + user = "cschmatzler"; + email = "christoph@schmatzler.com"; +in { zsh = { enable = true; @@ -10,14 +17,14 @@ let name = "Christoph Schmatzler"; cdpath = [ "~/Projects" ]; plugins = [ { - name = "powerlevel10k"; - src = pkgs.zsh-powerlevel10k; - file = "share/zsh-powerlevel10k/powerlevel10k.zsh-theme"; + name = "powerlevel10k"; + src = pkgs.zsh-powerlevel10k; + file = "share/zsh-powerlevel10k/powerlevel10k.zsh-theme"; } { - name = "powerlevel10k-config"; - src = lib.cleanSource ./config; - file = "p10k.zsh"; + name = "powerlevel10k-config"; + src = lib.cleanSource ./config; + file = "p10k.zsh"; } ]; initContent = lib.mkBefore '' @@ -74,7 +81,7 @@ let name = "Christoph Schmatzler"; extraConfig = { init.defaultBranch = "main"; core = { - editor = "vim"; + editor = "vim"; autocrlf = "input"; }; commit.gpgsign = true; @@ -86,23 +93,15 @@ let name = "Christoph Schmatzler"; ssh = { enable = true; includes = [ - (lib.mkIf pkgs.stdenv.hostPlatform.isLinux - "/home/${user}/.ssh/config_external" - ) - (lib.mkIf pkgs.stdenv.hostPlatform.isDarwin - "/Users/${user}/.ssh/config_external" - ) + (lib.mkIf pkgs.stdenv.hostPlatform.isLinux "/home/${user}/.ssh/config_external") + (lib.mkIf pkgs.stdenv.hostPlatform.isDarwin "/Users/${user}/.ssh/config_external") ]; matchBlocks = { "github.com" = { identitiesOnly = true; identityFile = [ - (lib.mkIf pkgs.stdenv.hostPlatform.isLinux - "/home/${user}/.ssh/id_github" - ) - (lib.mkIf pkgs.stdenv.hostPlatform.isDarwin - "/Users/${user}/.ssh/id_github" - ) + (lib.mkIf pkgs.stdenv.hostPlatform.isLinux "/home/${user}/.ssh/id_github") + (lib.mkIf pkgs.stdenv.hostPlatform.isDarwin "/Users/${user}/.ssh/id_github") ]; }; }; diff --git a/modules/shared/packages.nix b/modules/shared/packages.nix index 2da63a4..3673f80 100644 --- a/modules/shared/packages.nix +++ b/modules/shared/packages.nix @@ -1,6 +1,7 @@ { pkgs }: -with pkgs; [ +with pkgs; +[ age age-plugin-yubikey bat diff --git a/result b/result deleted file mode 120000 index 95b8eda..0000000 --- a/result +++ /dev/null @@ -1 +0,0 @@ -/nix/store/n2fqwnq3a9v4l273ka2hbn1b3c72v6x2-darwin-system-25.11.e04a388 \ No newline at end of file