From 2839b1a2a889adc8db4b0c1deb3df6f50c369214 Mon Sep 17 00:00:00 2001 From: emily Date: Wed, 3 Apr 2024 15:35:54 +0200 Subject: [PATCH] fixes --- builders | 2 +- config/hosts/lain/configuration.nix | 2 +- config/profiles/graphical/default.nix | 25 +++--- .../graphical/files/scripts/colorpicker.sh | 17 ---- .../graphical/files/scripts/screenshot.sh | 78 ----------------- config/profiles/graphical/scripts.nix | 87 +++++++++++++++++++ config/profiles/headless.nix | 1 + config/profiles/rpi.nix | 4 - flake.lock | 53 +++-------- flake.nix | 12 ++- 10 files changed, 121 insertions(+), 160 deletions(-) delete mode 100755 config/profiles/graphical/files/scripts/colorpicker.sh delete mode 100755 config/profiles/graphical/files/scripts/screenshot.sh create mode 100644 config/profiles/graphical/scripts.nix diff --git a/builders b/builders index 5246b7d..6e1fdd7 100644 --- a/builders +++ b/builders @@ -1 +1 @@ -ssh://nixremote@seras.kyouma.net x86_64-linux,aarch64-linux - 40 2 nixos-test,benchmark,big-parallel,kvm +ssh://nixremote@seras.kyouma.net x86_64-linux,aarch64-linux - 40 5 nixos-test,benchmark,big-parallel,kvm diff --git a/config/hosts/lain/configuration.nix b/config/hosts/lain/configuration.nix index f5d6c7d..8ac3419 100644 --- a/config/hosts/lain/configuration.nix +++ b/config/hosts/lain/configuration.nix @@ -1,7 +1,7 @@ { config, inputs, lib, pkgs, ... }: { imports = [ ../../common - ../../profiles/remote-builder.nix + ../../profiles/remote-build.nix ../../profiles/rpi.nix ../../profiles/headless.nix ]; diff --git a/config/profiles/graphical/default.nix b/config/profiles/graphical/default.nix index 7b0e405..0acb8b9 100644 --- a/config/profiles/graphical/default.nix +++ b/config/profiles/graphical/default.nix @@ -3,6 +3,7 @@ inputs.home-manager.nixosModules.home-manager inputs.stylix.nixosModules.stylix ./nixvim.nix + ./scripts.nix ]; kyouma.machine-type.graphical = true; @@ -114,6 +115,12 @@ enable = true; source = config.stylix.image; }; + home.file.".local/bin/hypr" = { + enable = true; + executable = true; + recursive = true; + source = ./files/scripts; + }; wayland.windowManager.hyprland = { enable = true; settings = let @@ -275,10 +282,6 @@ "CTRL_ALT, L, exec, ${swaylock} -f -i $XDG_PICTURES_DIR/wallpapers/lockscreen.png" # Function keys - ", XF86MonBrightnessUp, exec, ${brightnessctl} s +10%" - ", XF86MonBrightnessDown, exec, ${brightnessctl} s 10%-" - ", XF86AudioRaiseVolume, exec, ${pactl} set-sink-volume @DEFAULT_SINK@ +2dB" - ", XF86AudioLowerVolume, exec, ${pactl} set-sink-volume @DEFAULT_SINK@ -2dB" ", XF86AudioMute, exec, ${pactl} set-sink-mute @DEFAULT_SINK@ toggle" ", XF86AudioMicMute, exec, ${pactl} set-source-mute @DEFAULT_SOURCE@ toggle" ", XF86AudioNext, exec, ${playerctl} next" @@ -294,7 +297,6 @@ ", Print, exec, ${screenshot} --now" "ALT, Print, exec, ${screenshot} --in5" "SHIFT, Print, exec, ${screenshot} --in10" - "CTRL, Print, exec, ${screenshot} --win" "$mod, Print, exec, ${screenshot} --area" # Hyprland @@ -374,6 +376,11 @@ "$mod SHIFT, O, toggleopaque" ]; binde = [ + # Function keys repeat + ", XF86MonBrightnessUp, exec, ${brightnessctl} s +10%" + ", XF86MonBrightnessDown, exec, ${brightnessctl} s 10%-" + ", XF86AudioRaiseVolume, exec, ${pactl} set-sink-volume @DEFAULT_SINK@ +5%" + ", XF86AudioLowerVolume, exec, ${pactl} set-sink-volume @DEFAULT_SINK@ -5%" # Resize Active "$mod CTRL, left, resizeactive, -20 0" "$mod CTRL, H, resizeactive, -20 0" @@ -466,7 +473,7 @@ spacing = 8; }; clock = { - tooltip-format = "{:%A %d %B | %H:%M}"; + #tooltip-format = "{:%A %d %B | %H:%M}"; format = " {:%Y-%m-%d  %H:%M:%OS}"; format-alt = " {:%Y %b %d %a  %H:%M:%OS}"; interval = 1; @@ -668,12 +675,6 @@ BindsTo = "waybar.service"; After = "waybar.service"; }; - home.file.".local/bin/hypr" = { - enable = true; - executable = true; - recursive = true; - source = ./files/scripts; - }; xdg.configFile."mako-icons" = { enable = true; recursive = true; diff --git a/config/profiles/graphical/files/scripts/colorpicker.sh b/config/profiles/graphical/files/scripts/colorpicker.sh deleted file mode 100755 index cbbd257..0000000 --- a/config/profiles/graphical/files/scripts/colorpicker.sh +++ /dev/null @@ -1,17 +0,0 @@ -#!/usr/bin/env bash - -color=$(grim -g "`slurp -b 20262C00 -p`" -t ppm - | convert - -format '%[pixel:p{0,0}]' txt:- | tail -n1 | cut -d' ' -f4) -image=/tmp/${color}.png - -main() { - if [[ "$color" ]]; then - # copy color code to clipboard - echo $color | tr -d "\n" | wl-copy - # generate preview - convert -size 48x48 xc:"$color" ${image} - # notify about it - notify-send -h string:x-canonical-private-synchronous:sys-notify-picker -u low -i ${image} "$color, copied to clipboard." - fi -} - -main diff --git a/config/profiles/graphical/files/scripts/screenshot.sh b/config/profiles/graphical/files/scripts/screenshot.sh deleted file mode 100755 index 23f6012..0000000 --- a/config/profiles/graphical/files/scripts/screenshot.sh +++ /dev/null @@ -1,78 +0,0 @@ -#!/usr/bin/env bash - -iDIR="$HOME/.config/mako-icons" - -time=`date +%Y-%m-%d-%H-%M-%S` -dir="$HOME/Pictures/screenshots" -file="${time}.png" - -# notify and view screenshot -notify_cmd_shot="notify-send -h string:x-canonical-private-synchronous:sys-notify-shot -u low -i ${iDIR}/picture.png" -notify_view () { - ${notify_cmd_shot} "Copied to clipboard." - paplay /usr/share/sounds/freedesktop/stereo/screen-capture.oga &>/dev/null & - image-roll "${dir}/$file" - if [[ -e "$dir/$file" ]]; then - ${notify_cmd_shot} "Screenshot Saved." - else - ${notify_cmd_shot} "Screenshot Deleted." - fi -} - -# countdown -countdown () { - for sec in `seq $1 -1 1`; do - notify-send -h string:x-canonical-private-synchronous:sys-notify-count -t 1000 -i "$iDIR"/timer.png "Taking shot in : $sec" - sleep 1 - done -} - -# take shots -shotnow () { - cd ${dir} && sleep 0.5 && grim - | tee "$file" | wl-copy - notify_view -} - -shot5 () { - countdown '5' - sleep 1 && cd ${dir} && grim - | tee "$file" | wl-copy - notify_view -} - -shot10 () { - countdown '10' - sleep 1 && cd ${dir} && grim - | tee "$file" | wl-copy - notify_view -} - -shotwin () { - w_pos=`hyprctl activewindow | grep 'at:' | cut -d':' -f2 | tr -d ' ' | tail -n1` - w_size=`hyprctl activewindow | grep 'size:' | cut -d':' -f2 | tr -d ' ' | tail -n1 | sed s/,/x/g` - cd ${dir} && grim -g "$w_pos $w_size" - | tee "$file" | wl-copy - notify_view -} - -shotarea () { - cd ${dir} && grim -g "$(slurp -b 20262CCC -c B4A1DBff -s B4A1DB0D -w 2 && sleep 0.3)" - | tee "$file" | wl-copy - notify_view -} - -if [[ ! -d "$dir" ]]; then - mkdir -p "$dir" -fi - -if [[ "$1" == "--now" ]]; then - shotnow -elif [[ "$1" == "--in5" ]]; then - shot5 -elif [[ "$1" == "--in10" ]]; then - shot10 -elif [[ "$1" == "--win" ]]; then - shotwin -elif [[ "$1" == "--area" ]]; then - shotarea -else - echo -e "Available Options : --now --in5 --in10 --win --area" -fi - -exit 0 diff --git a/config/profiles/graphical/scripts.nix b/config/profiles/graphical/scripts.nix new file mode 100644 index 0000000..35244df --- /dev/null +++ b/config/profiles/graphical/scripts.nix @@ -0,0 +1,87 @@ +{ pkgs, inputs, ... }: { + imports = [ + inputs.home-manager.nixosModules.home-manager + ]; + home-manager.users.emily.home.file.".local/bin/hypr/colorpicker.sh" = { + enable = true; + executable = true; + text = '' + #!/${pkgs.bash}/bin/bash + color=$(${pkgs.grim}/bin/grim -g "`${pkgs.slurp}/bin/slurp -b 20262C00 -p`" -t ppm - | \ + ${pkgs.imagemagick_light}/bin/convert - -format '%[pixel:p{0,0}]' txt:- | \ + ${pkgs.coreutils}/bin/tail -n1 | ${pkgs.coreutils}/bin/cut -d' ' -f4) + image=/tmp/''${color}.png + main() { + if [[ "$color" ]]; then + ${pkgs.coreutils}/bin/echo $color | ${pkgs.coreutils}/bin/tr -d "\n" | ${pkgs.wl-clipboard}/bin/wl-copy + ${pkgs.imagemagick_light}/bin/convert -size 48x48 xc:"$color" ''${image} + ${pkgs.libnotify}/bin/notify-send -h string:x-canonical-private-synchronous:sys-notify-picker -u low -i ''${image} "$color, copied to clipboard." + fi + } + main + ''; + }; + home-manager.users.emily.home.file.".local/bin/hypr/screenshot.sh" = let + cu = "${pkgs.coreutils}/bin"; + grim = "${pkgs.grim}/bin/grim"; + notify-send = "${pkgs.libnotify}/bin/notify-send"; + paplay = "${pkgs.pulseaudio}/bin/paplay"; + slurp = "${pkgs.slurp}/bin/slurp"; + image-roll = "${pkgs.image-roll}/bin/image-roll"; + wl-copy = "${pkgs.wl-clipboard}/bin/wl-copy"; + in { + enable = true; + executable = true; + text = '' + #!/${pkgs.bash}/bin/bash + iDIR="$HOME/.config/mako-icons" + time=`${cu}/date +%Y-%m-%d-%H-%M-%S` + dir="$HOME/Pictures/screenshots" + file="''${time}.png" + + notify_cmd_shot="${notify-send} -h string:x-canonical-private-synchronous:sys-notify-shot -u low -i ''${iDIR}/picture.png" + notify_view () { + ''${notify_cmd_shot} "Copied to clipboard." + ${paplay} /usr/share/sounds/freedesktop/stereo/screen-capture.oga &>/dev/null & + ${image-roll} "''${dir}/$file" + if [[ -e "$dir/$file" ]]; then + ''${notify_cmd_shot} "Screenshot Saved." + else + ''${notify_cmd_shot} "Screenshot Deleted." + fi + } + countdown () { + for sec in `${cu}/seq $1 -1 1`; do + ${notify-send} -h string:x-canonical-private-synchronous:sys-notify-count -t 1000 -i "$iDIR"/timer.png "Taking shot in : $sec" + ${cu}/sleep 1 + done + } + shotnow () { + cd ''${dir} && ${cu}/sleep 0.5 && ${grim} - | ${cu}/tee "$file" | ${wl-copy} + notify_view + } + shotarea () { + cd ''${dir} && ${grim} -g "$(${slurp} -b 20262CCC -c B4A1DBff -s B4A1DB0D -w 2 && ${cu}/sleep 0.3)" - | ${cu}/tee "$file" | ${wl-copy} + notify_view + } + if [[ ! -d "$dir" ]]; then + ${cu}/mkdir -p "$dir" + fi + + if [[ "$1" == "--now" ]]; then + shotnow + elif [[ "$1" == "--in5" ]]; then + countdown '5' + shotnow + elif [[ "$1" == "--in10" ]]; then + countdown '10' + shotnow + elif [[ "$1" == "--area" ]]; then + shotarea + else + echo -e "Available Options : --now --in5 --in10 --area" + fi + exit 0 + ''; + }; +} diff --git a/config/profiles/headless.nix b/config/profiles/headless.nix index 4d7e61d..dd64f1c 100644 --- a/config/profiles/headless.nix +++ b/config/profiles/headless.nix @@ -1,5 +1,6 @@ { config, lib, ... }: with lib; { kyouma.machine-type.headless = true; + documentation.man.generateCaches = false; services.openssh.enable = mkDefault true; services.vnstat.enable = mkDefault true; } diff --git a/config/profiles/rpi.nix b/config/profiles/rpi.nix index 71cb6c5..4c332cc 100644 --- a/config/profiles/rpi.nix +++ b/config/profiles/rpi.nix @@ -16,8 +16,6 @@ }; console.enable = false; - documentation.man.generateCaches = false; - environment.systemPackages = with pkgs; [ bluez bluez-tools @@ -43,10 +41,8 @@ dtsText = '' /dts-v1/; /plugin/; - / { compatible = "brcm,bcm2711"; - fragment@0 { target = <&uart0_pins>; __overlay__ { diff --git a/flake.lock b/flake.lock index caf72b5..5a89166 100644 --- a/flake.lock +++ b/flake.lock @@ -458,27 +458,6 @@ } }, "home-manager_2": { - "inputs": { - "nixpkgs": [ - "nixvim", - "nixpkgs" - ] - }, - "locked": { - "lastModified": 1711133180, - "narHash": "sha256-WJOahf+6115+GMl3wUfURu8fszuNeJLv9qAWFQl3Vmo=", - "owner": "nix-community", - "repo": "home-manager", - "rev": "1c2c5e4cabba4c43504ef0f8cc3f3dfa284e2dbb", - "type": "github" - }, - "original": { - "owner": "nix-community", - "repo": "home-manager", - "type": "github" - } - }, - "home-manager_3": { "inputs": { "nixpkgs": [ "stylix", @@ -502,7 +481,9 @@ "kyouma-www": { "inputs": { "flake-utils": "flake-utils_3", - "nixpkgs": "nixpkgs_2" + "nixpkgs": [ + "nixpkgs" + ] }, "locked": { "lastModified": 1711306151, @@ -571,22 +552,6 @@ } }, "nixpkgs_2": { - "locked": { - "lastModified": 1705133751, - "narHash": "sha256-rCIsyE80jgiOU78gCWN3A0wE0tR2GI5nH6MlS+HaaSQ=", - "owner": "nixos", - "repo": "nixpkgs", - "rev": "9b19f5e77dd906cb52dade0b7bd280339d2a1f3d", - "type": "github" - }, - "original": { - "owner": "nixos", - "ref": "nixos-unstable", - "repo": "nixpkgs", - "type": "github" - } - }, - "nixpkgs_3": { "locked": { "lastModified": 1711163522, "narHash": "sha256-YN/Ciidm+A0fmJPWlHBGvVkcarYWSC+s3NTPk/P+q3c=", @@ -602,7 +567,7 @@ "type": "github" } }, - "nixpkgs_4": { + "nixpkgs_3": { "locked": { "lastModified": 1700856099, "narHash": "sha256-RnEA7iJ36Ay9jI0WwP+/y4zjEhmeN6Cjs9VOFBH7eVQ=", @@ -623,7 +588,9 @@ "devshell": "devshell", "flake-compat": "flake-compat", "flake-parts": "flake-parts", - "home-manager": "home-manager_2", + "home-manager": [ + "home-manager" + ], "nix-darwin": "nix-darwin", "nixpkgs": [ "nixpkgs" @@ -680,7 +647,7 @@ "home-manager": "home-manager", "kyouma-www": "kyouma-www", "nixos-hardware": "nixos-hardware", - "nixpkgs": "nixpkgs_3", + "nixpkgs": "nixpkgs_2", "nixvim": "nixvim", "stylix": "stylix" } @@ -698,8 +665,8 @@ "base16-vim": "base16-vim", "flake-compat": "flake-compat_3", "gnome-shell": "gnome-shell", - "home-manager": "home-manager_3", - "nixpkgs": "nixpkgs_4" + "home-manager": "home-manager_2", + "nixpkgs": "nixpkgs_3" }, "locked": { "lastModified": 1711224130, diff --git a/flake.nix b/flake.nix index dfba0a6..f0d43a5 100644 --- a/flake.nix +++ b/flake.nix @@ -5,7 +5,6 @@ nixos-hardware.url = "github:nixos/nixos-hardware"; fernglas.url = "github:wobcom/fernglas"; flake-utils.url = "github:numtide/flake-utils"; - kyouma-www.url = "git+https://git.bsd.gay/snaki/kyouma-net.git"; stylix.url = "github:danth/stylix"; disko = { url = "github:nix-community/disko"; @@ -15,20 +14,25 @@ url = "github:nix-community/home-manager"; inputs.nixpkgs.follows = "nixpkgs"; }; + kyouma-www = { + url = "git+https://git.bsd.gay/snaki/kyouma-net.git"; + inputs.nixpkgs.follows = "nixpkgs"; + }; nixvim = { url = "github:nix-community/nixvim"; inputs.nixpkgs.follows = "nixpkgs"; + inputs.home-manager.follows = "home-manager"; }; }; nixConfig = { builders-use-substitutes = true; - builders = "ssh://nixremote@seras.kyouma.net x86_64-linux,aarch64-linux - 40 2 nixos-test,benchmark,big-parallel,kvm"; + builders = "ssh://nixremote@seras.kyouma.net x86_64-linux,aarch64-linux - 40 5 nixos-test,benchmark,big-parallel,kvm"; }; outputs = { self, nixpkgs, flake-utils, ... }@inputs: { colmena = let - hosts = [ "web-dus" "crime" "ryuuko" "lain" "seras" ]; + hosts = builtins.attrNames (nixpkgs.lib.filterAttrs (name: type: type == "directory") (builtins.readDir ./config/hosts)); hostCfg = hostname: { imports = [ (./config/hosts/${hostname}/configuration.nix) ]; }; @@ -42,7 +46,7 @@ }; specialArgs = { inherit inputs; }; }; - } // (builtins.listToAttrs (builtins.map (hosts: nixpkgs.lib.attrsets.nameValuePair hosts (hostCfg hosts)) hosts)); + } // nixpkgs.lib.attrsets.genAttrs hosts (hostCfg); nixosConfigurations = { ryuuko = nixpkgs.lib.nixosSystem {