···10I also declare configuration as packages/wrappers that you can try with `nix run
11github:Ladas552/Flake-Ocean#app`, replace `app` with:
1213-- [nvf](https://github.com/NotAShelf/nvf) - Nix declared Neovim
14- [nixvim](https://github.com/nix-community/nixvim) - another Nix declared Neovim
15- rofi-powermenu - power menu made of Rofi with a [nice theme](https://github.com/adi1090x/rofi)
16- all the other scripts in [pkgs directory](./pkgs/default.nix)
···10I also declare configuration as packages/wrappers that you can try with `nix run
11github:Ladas552/Flake-Ocean#app`, replace `app` with:
1213+- [nvf](https://github.com/NotAShelf/nvf) - Nix declared Neovim (current daily driver)
14- [nixvim](https://github.com/nix-community/nixvim) - another Nix declared Neovim
15- rofi-powermenu - power menu made of Rofi with a [nice theme](https://github.com/adi1090x/rofi)
16- all the other scripts in [pkgs directory](./pkgs/default.nix)
···94 # Boilerplate
95 systems.url = "github:nix-systems/default-linux";
9697- # Inputs below are either unused, or replaced with nvfetcher inputs
98-99- # Secrets
100- # sops-nix = {
101- # url = "github:Mic92/sops-nix";
102- # inputs.nixpkgs.follows = "nixpkgs";
103- # };
104-105- # impermanence = {
106- # url = "github:nix-community/impermanence";
107- # inputs.nixpkgs.follows = "";
108- # inputs.home-manager.follows = "";
109- # };
110-111- # nixos-wsl = {
112- # url = "github:nix-community/NixOS-WSL";
113- # inputs.nixpkgs.follows = "nixpkgs";
114- # # No useless inputs
115- # inputs.flake-compat.follows = "";
116- # };
117-118- # noctalia = {
119- # url = "github:noctalia-dev/noctalia-shell";
120- # inputs.nixpkgs.follows = "nixpkgs";
121- # };
122-123- # nixos-hardware.url = "github:nixos/nixos-hardware";
124-125- # Overlays
126- # neorg-overlay.url = "github:nvim-neorg/nixpkgs-neorg-overlay";
127- # emacs-overlay.url = "github:nix-community/emacs-overlay";
128- # helix-overlay.url = "github:helix-editor/helix";
129- # neovim-nightly-overlay.url = "github:nix-community/neovim-nightly-overlay";
130-131- # ghostty.url = "github:ghostty-org/ghostty";
132- # ghostty-shaders = {
133- # url = "github:hackr-sh/ghostty-shaders";
134- # flake = false;
135- # };
136- # ghostty-cursor = {
137- # url = "github:KroneCorylus/shader-playground";
138- # flake = false;
139- # };
140-141 };
142 outputs =
143 inputs:
144 let
145 # Function to stop using `import-tree` by Vic.
146 # Just to lighten the config a bit, written by @llakala https://github.com/llakala/synaptic-standard/blob/main/demo/recursivelyImport.nix
147- import-tree = import ./stuff/recursivelyImport.nix { lib = inputs.nixpkgs.lib; };
148149 # a way to fetch nix files via nvfetcher and import them in the config
150 # basically parse the json crated by nvfetcher, and use fetchTarball
···169 specialArgs = { inherit modules; };
170 }
171 {
172- imports = import-tree [ ./modules ];
000173 flake.templates = import ./templates;
000174 };
175}
···94 # Boilerplate
95 systems.url = "github:nix-systems/default-linux";
9697+ # Also check inputs in ./nvfetcher.toml for more modules I use
000000000000000000000000000000000000000000098 };
99 outputs =
100 inputs:
101 let
102 # Function to stop using `import-tree` by Vic.
103 # Just to lighten the config a bit, written by @llakala https://github.com/llakala/synaptic-standard/blob/main/demo/recursivelyImport.nix
104+ import-tree = import ./lib/recursivelyImport.nix { lib = inputs.nixpkgs.lib; };
105106 # a way to fetch nix files via nvfetcher and import them in the config
107 # basically parse the json crated by nvfetcher, and use fetchTarball
···126 specialArgs = { inherit modules; };
127 }
128 {
129+ imports = import-tree [
130+ ./modules
131+ inputs.flake-parts.flakeModules.modules
132+ ];
133 flake.templates = import ./templates;
134+ # aarch64 and x86_64 Linux systems
135+ systems = import inputs.systems;
136+137 };
138}
-9
modules/flake-parts/flake-parts.nix
···1-{ inputs, ... }:
2-{
3- imports = [
4- inputs.flake-parts.flakeModules.modules
5- ../../pkgs
6- ];
7- # aarch64 and x86_64 Linux systems
8- systems = import inputs.systems;
9-}
···000000000
+17
modules/wrappers/scripts/Subtitlenator.nix
···00000000000000000
···1+{
2+ # Adds `ass` subtitle files to mkv files and creates subdirectory for copied mkv files. Subtitles aren't burned into mkv, just added to the pool. Nice if you don't have subtitle fuzzy find in your Media Player
3+4+ perSystem =
5+ { pkgs, lib, ... }:
6+ {
7+ packages.Subtitlenator = pkgs.writeShellScriptBin "Subtitlenator.sh" ''
8+ ${lib.meta.getExe' pkgs.coreutils "mkdir"} Subbed_"$(${lib.meta.getExe' pkgs.coreutils "basename"} "$PWD")"
9+10+ for i in *.mkv
11+ do
12+ file="$(${lib.meta.getExe' pkgs.coreutils "basename"} "$i" .mkv)"
13+ (ffmpeg -i "$file.mkv" -i "$file.ass" -map 0 -map 1 -c copy Subbed_"$(${lib.meta.getExe' pkgs.coreutils "basename"} "$PWD")/$file.mkv")
14+ done
15+ '';
16+ };
17+}
···1+{
2+ # I download songs with yt-dlp, and it embeds the url of the media into `comments` or `purl` tag, so i use ffmpeg to get the data to clipboard and share the media.
3+4+ perSystem =
5+ { pkgs, ... }:
6+ {
7+ packages.musnow =
8+ pkgs.writers.writeFishBin "musnow.sh" { } # fish
9+ ''
10+ #Dependencis
11+ #fish,ffmpeg,mpd,mpc
12+ #get current's song url into 'crtl+v' clipboard
13+ ffprobe -loglevel error -show_entries format_tags=purl -of default=noprint_wrappers=1:nokey=1 ~/Music/(mpc -f %file% current) | wl-copy
14+ '';
15+ };
16+}
+38
modules/wrappers/scripts/restore.nix
···00000000000000000000000000000000000000
···1+{
2+ # I have this nasty bug that corrupts my /boot, I need to fix it
3+ # but here is a script I use to not do it manually everytime
4+ # Do this all in sudo tho
5+6+ perSystem =
7+ { pkgs, ... }:
8+ {
9+ packages.restore =
10+ pkgs.writeShellScriptBin "restore.sh" # bash
11+ ''
12+ mkfs.vfat /dev/nvme0n1p5 -n NIXBOOT
13+ zpool import zroot -f
14+ # Need so that install doesn't run out of memory
15+ zfs create -o mountpoint=legacy zroot/root
16+ mount -t zfs zroot/root /mnt
17+ mount --mkdir /dev/nvme0n1p5 /mnt/boot
18+ mount --mkdir -t zfs zroot/nix /mnt/nix
19+ mount --mkdir -t zfs zroot/tmp /mnt/tmp
20+ mount --mkdir -t zfs zroot/cache /mnt/cache
21+ mount --mkdir -t zfs zroot/persist /mnt/persist
22+ nixos-install --no-root-password --flake "github:Ladas552/Flake-Ocean#NixPort"
23+ # unmount the system, and remount it to correctly link the build
24+ umount /mnt/boot
25+ umount /mnt/nix
26+ umount /mnt/cache
27+ umount /mnt/tmp
28+ umount /mnt/persist
29+ umount /mnt
30+ mount --mkdir /dev/nvme0n1p5 /mnt/boot
31+ mount --mkdir -t zfs zroot/nix /mnt/nix
32+ mount --mkdir -t zfs zroot/tmp /mnt/tmp
33+ mount --mkdir -t zfs zroot/cache /mnt/cache
34+ mount --mkdir -t zfs zroot/persist /mnt/persist
35+ nixos-install --no-root-password --flake "github:Ladas552/Flake-Ocean#NixPort"
36+ '';
37+ };
38+}
···1+{
2+ # It was a test script, never worked tbh. Suppose to replace nm-applet with Rofi
3+4+ perSystem =
5+ { pkgs, lib, ... }:
6+ {
7+ packages.rofi-wifi =
8+ pkgs.writeShellScriptBin "wifiMenu" # bash
9+ ''
10+ ${lib.getExe pkgs.libnotify} "Getting list of available Wi-Fi networks..."
11+ # Get a list of available wifi connections and morph it into a nice-looking list
12+ wifi_list=$(nmcli --fields "SECURITY,SSID" device wifi list | sed 1d | sed 's/ */ /g' | sed -E "s/WPA*.?\S/ /g" | sed "s/^--/ /g" | sed "s/ //g" | sed "/--/d")
13+14+ connected=$(nmcli -fields WIFI g)
15+ if [[ "$connected" =~ "enabled" ]]; then
16+ toggle=" Disable Wi-Fi"
17+ elif [[ "$connected" =~ "disabled" ]]; then
18+ toggle=" Enable Wi-Fi"
19+ fi
20+21+ # Use rofi to select wifi network
22+ chosen_network=$(echo -e "$toggle\n$wifi_list" | uniq -u | rofi -dmenu -i -selected-row 1 -p "Wi-Fi SSID: " )
23+ # Get name of connection
24+ read -r chosen_id <<< "''${chosen_network:3}"
25+26+ if [ "$chosen_network" = "" ]; then
27+ exit
28+ elif [ "$chosen_network" = " Enable Wi-Fi" ]; then
29+ nmcli radio wifi on
30+ elif [ "$chosen_network" = " Disable Wi-Fi" ]; then
31+ nmcli radio wifi off
32+ else
33+ # Message to show when connection is activated successfully
34+ success_message="You are now connected to the Wi-Fi network \"$chosen_id\"."
35+ # Get saved connections
36+ nmcli -g NAME connection
37+ if [[ $(echo "$saved_connections" | grep -w "$chosen_id") = "$chosen_id" ]]; then
38+ nmcli connection up id "$chosen_id" | grep "successfully" && ${lib.getExe pkgs.libnotify} "Connection Established" "$success_message"
39+ else
40+ if [[ "$chosen_network" =~ "" ]]; then
41+ wifi_password=$(rofi -dmenu -p "Password: " )
42+ fi
43+ nmcli device wifi connect "$chosen_id" password "$wifi_password" | grep "successfully" && ${lib.getExe pkgs.libnotify} "Connection Established" "$success_message"
44+ fi
45+ fi
46+ '';
47+ };
48+}
+45
modules/wrappers/scripts/word-lookup.nix
···000000000000000000000000000000000000000000000
···1+{
2+ # This script looks up a word in the dictionary from mouse selected word
3+ # Script is stolen from Reddit
4+5+ perSystem =
6+ { pkgs, lib, ... }:
7+ {
8+ packages.word-lookup =
9+ pkgs.writeShellScriptBin "word-lookup.sh" # bash
10+ ''
11+ usage(){
12+ echo "Usage: $(basename "$0") [-h]
13+ Looks up the definition of currently selected word.
14+ -w: Use the wayland clipboard (instead of X11) "
15+16+ }
17+18+ USEWAYLAND=true
19+20+ while getopts 'hw' c
21+ do
22+ case $c in
23+ h) usage; exit ;;
24+ w) USEWAYLAND=true ;;
25+ *) usage; exit 1 ;;
26+ esac
27+ done
28+29+ shift $((OPTIND-1))
30+31+ if [ $USEWAYLAND = true ]
32+ then
33+ word=$(wl-paste -p)
34+ else
35+ word=$(xclip -o)
36+ fi
37+38+ res=$(curl -s "https://api.dictionaryapi.dev/api/v2/entries/en_US/$word")
39+ regex=$'"definition":"\K(.*?)(?=")'
40+ definitions=$(echo "$res" | grep -Po "$regex")
41+ separatedDefinition=$(sed ':a;N;$!ba;s/\n/\n\n/g' <<< "$definitions")
42+ ${lib.getExe pkgs.libnotify} --urgency=critical -a "word-lookup" "$word" "$separatedDefinition"
43+ '';
44+ };
45+}
+13
modules/wrappers/scripts/wpick.nix
···0000000000000
···1+{
2+ # It is a one liner to replace xpick on Wayland. Compatible with Wlroots. Doesn't need dependencies outside of ImageMagick that already declared in host
3+4+ perSystem =
5+ { pkgs, lib, ... }:
6+ {
7+ packages.wpick =
8+ pkgs.writeShellScriptBin "wpick" # bash
9+ ''
10+ ${lib.meta.getExe' pkgs.grim "grim"} -g "$(${lib.meta.getExe' pkgs.slurp "slurp"} -p)" -t ppm - | ${lib.meta.getExe' pkgs.imagemagick "magick"} - -format '%[pixel:p{0,0}]' txt:-
11+ '';
12+ };
13+}
-11
pkgs/Subtitlenator.nix
···1-{ pkgs, lib }:
2-# Adds `ass` subtitle files to mkv files and creates subdirectory for copied mkv files. Subtitles aren't burned into mkv, just added to the pool. Nice if you don't have subtitle fuzzy find in your Media Player
3-pkgs.writeShellScriptBin "Subtitlenator.sh" ''
4- ${lib.meta.getExe' pkgs.coreutils "mkdir"} Subbed_"$(${lib.meta.getExe' pkgs.coreutils "basename"} "$PWD")"
5-6- for i in *.mkv
7- do
8- file="$(${lib.meta.getExe' pkgs.coreutils "basename"} "$i" .mkv)"
9- (ffmpeg -i "$file.mkv" -i "$file.ass" -map 0 -map 1 -c copy Subbed_"$(${lib.meta.getExe' pkgs.coreutils "basename"} "$PWD")/$file.mkv")
10- done
11-''
···1-{ pkgs }:
2-# I download songs with yt-dlp, and it embeds the url of the media into `comments` or `purl` tag, so i use ffmpeg to get the data to clipboard and share the media.
3-pkgs.writers.writeFishBin "musnow.sh" { } # fish
4- ''
5- #Dependencis
6- #fish,ffmpeg,mpd,mpc
7- #get current's song url into 'crtl+v' clipboard
8- ffprobe -loglevel error -show_entries format_tags=purl -of default=noprint_wrappers=1:nokey=1 ~/Music/(mpc -f %file% current) | wl-copy
9- ''
10-11-# X11 version
12-#ffprobe -loglevel error -show_entries format_tags=purl -of default=noprint_wrappers=1:nokey=1 ~/Music/(mpc -f %file% current) | xclip -selection clipboard
···000000000000
-31
pkgs/restore.nix
···1-{ pkgs, lib }:
2-# I have this nasty bug that corrupts my /boot, I need to fix it
3-# but here is a script I use to not do it manually everytime
4-# Do this all in sudo tho
5-pkgs.writeShellScriptBin "restore.sh" # bash
6- ''
7- mkfs.vfat /dev/nvme0n1p5 -n NIXBOOT
8- zpool import zroot -f
9- # Need so that install doesn't run out of memory
10- zfs create -o mountpoint=legacy zroot/root
11- mount -t zfs zroot/root /mnt
12- mount --mkdir /dev/nvme0n1p5 /mnt/boot
13- mount --mkdir -t zfs zroot/nix /mnt/nix
14- mount --mkdir -t zfs zroot/tmp /mnt/tmp
15- mount --mkdir -t zfs zroot/cache /mnt/cache
16- mount --mkdir -t zfs zroot/persist /mnt/persist
17- nixos-install --no-root-password --flake "github:Ladas552/Flake-Ocean#NixPort"
18- # unmount the system, and remount it to correctly link the build
19- umount /mnt/boot
20- umount /mnt/nix
21- umount /mnt/cache
22- umount /mnt/tmp
23- umount /mnt/persist
24- umount /mnt
25- mount --mkdir /dev/nvme0n1p5 /mnt/boot
26- mount --mkdir -t zfs zroot/nix /mnt/nix
27- mount --mkdir -t zfs zroot/tmp /mnt/tmp
28- mount --mkdir -t zfs zroot/cache /mnt/cache
29- mount --mkdir -t zfs zroot/persist /mnt/persist
30- nixos-install --no-root-password --flake "github:Ladas552/Flake-Ocean#NixPort"
31- ''
···1-{ pkgs, lib }:
2-# It was a test script, never worked tbh. Suppose to replace nm-applet with Rofi
3-pkgs.writeShellScriptBin "wifiMenu" # bash
4- ''
5- ${lib.getExe pkgs.libnotify} "Getting list of available Wi-Fi networks..."
6- # Get a list of available wifi connections and morph it into a nice-looking list
7- wifi_list=$(nmcli --fields "SECURITY,SSID" device wifi list | sed 1d | sed 's/ */ /g' | sed -E "s/WPA*.?\S/ /g" | sed "s/^--/ /g" | sed "s/ //g" | sed "/--/d")
8-9- connected=$(nmcli -fields WIFI g)
10- if [[ "$connected" =~ "enabled" ]]; then
11- toggle=" Disable Wi-Fi"
12- elif [[ "$connected" =~ "disabled" ]]; then
13- toggle=" Enable Wi-Fi"
14- fi
15-16- # Use rofi to select wifi network
17- chosen_network=$(echo -e "$toggle\n$wifi_list" | uniq -u | rofi -dmenu -i -selected-row 1 -p "Wi-Fi SSID: " )
18- # Get name of connection
19- read -r chosen_id <<< "''${chosen_network:3}"
20-21- if [ "$chosen_network" = "" ]; then
22- exit
23- elif [ "$chosen_network" = " Enable Wi-Fi" ]; then
24- nmcli radio wifi on
25- elif [ "$chosen_network" = " Disable Wi-Fi" ]; then
26- nmcli radio wifi off
27- else
28- # Message to show when connection is activated successfully
29- success_message="You are now connected to the Wi-Fi network \"$chosen_id\"."
30- # Get saved connections
31- saved_connections=$(nmcli -g NAME connection)
32- if [[ $(echo "$saved_connections" | grep -w "$chosen_id") = "$chosen_id" ]]; then
33- nmcli connection up id "$chosen_id" | grep "successfully" && ${lib.getExe pkgs.libnotify} "Connection Established" "$success_message"
34- else
35- if [[ "$chosen_network" =~ "" ]]; then
36- wifi_password=$(rofi -dmenu -p "Password: " )
37- fi
38- nmcli device wifi connect "$chosen_id" password "$wifi_password" | grep "successfully" && ${lib.getExe pkgs.libnotify} "Connection Established" "$success_message"
39- fi
40- fi
41- ''
···00000000000000000000000000000000000000000
-38
pkgs/word-lookup.nix
···1-{ pkgs, lib }:
2-# This script looks up a word in the dictionary from mouse selected word
3-# Script is stolen from Reddit
4-pkgs.writeShellScriptBin "word-lookup.sh" # bash
5- ''
6- usage(){
7- echo "Usage: $(basename "$0") [-h]
8- Looks up the definition of currently selected word.
9- -w: Use the wayland clipboard (instead of X11) "
10-11- }
12-13- USEWAYLAND=true
14-15- while getopts 'hw' c
16- do
17- case $c in
18- h) usage; exit ;;
19- w) USEWAYLAND=true ;;
20- *) usage; exit 1 ;;
21- esac
22- done
23-24- shift $((OPTIND-1))
25-26- if [ $USEWAYLAND = true ]
27- then
28- word=$(wl-paste -p)
29- else
30- word=$(xclip -o)
31- fi
32-33- res=$(curl -s "https://api.dictionaryapi.dev/api/v2/entries/en_US/$word")
34- regex=$'"definition":"\K(.*?)(?=")'
35- definitions=$(echo "$res" | grep -Po "$regex")
36- separatedDefinition=$(sed ':a;N;$!ba;s/\n/\n\n/g' <<< "$definitions")
37- ${lib.getExe pkgs.libnotify} --urgency=critical -a "word-lookup" "$word" "$separatedDefinition"
38- ''
···00000000000000000000000000000000000000
-6
pkgs/wpick.nix
···1-{ pkgs, lib }:
2-# It is a one liner to replace xpick on Wayland. Compatible with Wlroots. Doesn't need dependencies outside of ImageMagick that already declared in host
3-pkgs.writeShellScriptBin "wpick" # bash
4- ''
5- ${lib.meta.getExe' pkgs.grim "grim"} -g "$(${lib.meta.getExe' pkgs.slurp "slurp"} -p)" -t ppm - | ${lib.meta.getExe' pkgs.imagemagick "magick"} - -format '%[pixel:p{0,0}]' txt:-
6- ''