diff --git a/SwarselSystems.org b/SwarselSystems.org index f6f8dc3..397a9eb 100644 --- a/SwarselSystems.org +++ b/SwarselSystems.org @@ -2085,6 +2085,10 @@ As such, I also define three additional overlays: 3) =nixpkgs-stable= This is simply a mirror of the most recent stable branch of nixpkgs. Useful for packages that are broken on nixpkgs, but do not need to be on bleeding edge anyways. +Also, this is where I define all of my own modules. These are mostly used for setting some host-specifics directly than opposed to through multiple options. + +Lastly, I add some of my own library functions to be used alongside the functions provided by =nixpkgs= and =home-manager=. + *** Packages :PROPERTIES: :CUSTOM_ID: h:64a5cc16-6b16-4802-b421-c67ccef853e1 @@ -2190,10 +2194,7 @@ This app allows me, in conjunction with my Yubikey, to quickly enter passwords w #+end_src #+begin_src nix :tangle pkgs/pass-fuzzel/default.nix - { self, writeShellApplication, libnotify, pass, fuzzel, wtype }: - let - name = "pass-fuzzel"; - in + { self, name, writeShellApplication, libnotify, pass, fuzzel, wtype }: writeShellApplication { inherit name; runtimeInputs = [ libnotify (pass.withExtensions (exts: [ exts.pass-otp ])) fuzzel wtype ]; @@ -2252,17 +2253,17 @@ This script allows for quick git home-manager specialisation switching. #+begin_src nix :tangle pkgs/hm-specialisation/default.nix - { writeShellApplication, fzf, findutils, home-manager, ... }: + { name, writeShellApplication, fzf, findutils, home-manager, ... }: - writeShellApplication { - name = "hm-specialisation"; - runtimeInputs = [ fzf findutils home-manager ]; - text = '' - genpath=$(home-manager generations | head -1 | awk '{print $7}') - dirs=$(find "$genpath/specialisation" -type l 2>/dev/null; [ -d "$genpath" ] && echo "$genpath") - "$(echo "$dirs" | fzf --prompt="Choose home-manager specialisation to activate")"/activate - ''; - } + writeShellApplication { + inherit name; + runtimeInputs = [ fzf findutils home-manager ]; + text = '' + genpath=$(home-manager generations | head -1 | awk '{print $7}') + dirs=$(find "$genpath/specialisation" -type l 2>/dev/null; [ -d "$genpath" ] && echo "$genpath") + "$(echo "$dirs" | fzf --prompt="Choose home-manager specialisation to activate")"/activate + ''; + } #+end_src @@ -2276,10 +2277,10 @@ This script allows for quick git worktree switching. #+begin_src nix :tangle pkgs/cdw/default.nix - { writeShellApplication, fzf, ... }: + { name, writeShellApplication, fzf, ... }: writeShellApplication { - name = "cdw"; + inherit name; runtimeInputs = [ fzf ]; text = '' cd "$(git worktree list | fzf | awk '{print $1}')" @@ -2297,10 +2298,10 @@ This script allows for quick git worktree switching. This script allows for quick git branch switching. #+begin_src nix :tangle pkgs/cdb/default.nix - { writeShellApplication, fzf, ... }: + { name, writeShellApplication, fzf, ... }: writeShellApplication { - name = "cdb"; + inherit name; runtimeInputs = [ fzf ]; text = '' git checkout "$(git branch --list | grep -v "^\*" | fzf | awk '{print $1}')" @@ -2318,10 +2319,10 @@ This script lets me quickly backup files by appending =.bak= to the filename. #+begin_src nix :tangle pkgs/bak/default.nix - { writeShellApplication, ... }: + { name, writeShellApplication, ... }: writeShellApplication { - name = "bak"; + inherit name; text = '' cp -r "$1"{,.bak} ''; @@ -2339,10 +2340,10 @@ This app starts a configuratble timer and uses TTS to say something once the tim #+begin_src nix :tangle pkgs/timer/default.nix - { writeShellApplication, speechd, ... }: + { name, writeShellApplication, speechd, ... }: writeShellApplication { - name = "timer"; + inherit name; runtimeInputs = [ speechd ]; text = '' sleep "$1"; while true; do spd-say "$2"; sleep 0.5; done; @@ -2385,10 +2386,7 @@ This is a shorthand for calling emacsclient mostly. Also, it hides the kittyterm #+end_src #+begin_src nix :tangle pkgs/e/default.nix - { self, writeShellApplication, emacs30-pgtk, sway, jq }: - let - name = "e"; - in + { self, name, writeShellApplication, emacs30-pgtk, sway, jq }: writeShellApplication { inherit name; runtimeInputs = [ emacs30-pgtk sway jq ]; @@ -2514,10 +2512,7 @@ This app checks for different apps that I keep around in the scratchpad for quic #+end_src #+begin_src nix :tangle pkgs/swarselcheck/default.nix - { self, writeShellApplication, kitty, element-desktop-wayland, vesktop, spotify-player, jq }: - let - name = "swarselcheck"; - in + { self, name, writeShellApplication, kitty, element-desktop-wayland, vesktop, spotify-player, jq }: writeShellApplication { inherit name; runtimeInputs = [ kitty element-desktop-wayland vesktop spotify-player jq ]; @@ -2561,10 +2556,7 @@ This scripts checks if there are uncommited changes in either my dotfile repo, m #+end_src #+begin_src nix :tangle pkgs/waybarupdate/default.nix - { self, writeShellApplication, git }: - let - name = "waybarupdate"; - in + { self, name, writeShellApplication, git }: writeShellApplication { inherit name; runtimeInputs = [ git ]; @@ -2589,10 +2581,7 @@ This app quickly toggles between 5% and 0% transparency. #+end_src #+begin_src nix :tangle pkgs/opacitytoggle/default.nix - { self, writeShellApplication, sway }: - let - name = "opacitytoggle"; - in + { self, name, writeShellApplication, sway }: writeShellApplication { inherit name; runtimeInputs = [ sway ]; @@ -2631,10 +2620,7 @@ This utility is used to compare the current state of the root directory with the #+end_src #+begin_src nix :tangle pkgs/fs-diff/default.nix - { self, writeShellApplication }: - let - name = "fs-diff"; - in + { self, name, writeShellApplication }: writeShellApplication { inherit name; text = builtins.readFile "${self}/scripts/${name}.sh"; @@ -2666,10 +2652,7 @@ This utility checks if there are updated packages in nixpkgs-unstable. It does s #+end_src #+begin_src nix :tangle pkgs/update-checker/default.nix - { self, writeShellApplication, nvd }: - let - name = "update-checker"; - in + { self, name, writeShellApplication, nvd }: writeShellApplication { inherit name; runtimeInputs = [ nvd ]; @@ -2686,10 +2669,10 @@ This utility checks if there are updated packages in nixpkgs-unstable. It does s #+begin_src nix :tangle pkgs/github-notifications/default.nix - { writeShellApplication, jq, ... }: + { name, writeShellApplication, jq, ... }: writeShellApplication { - name = "github-notifications"; + inherit name; runtimeInputs = [ jq ]; text = '' count=$(curl -u Swarsel:"$(cat /run/user/1000/secrets/github_notif)" https://api.github.com/notifications | jq '. | length') @@ -2729,10 +2712,7 @@ This utility checks if there are updated packages in nixpkgs-unstable. It does s #+begin_src nix :tangle pkgs/screenshare/default.nix - { self, writeShellApplication, sway }: - let - name = "screenshare"; - in + { self, name, writeShellApplication, sway }: writeShellApplication { inherit name; runtimeInputs = [ sway ]; @@ -3091,10 +3071,7 @@ This program sets up a new NixOS host remotely. It also takes care of secret man #+begin_src nix :tangle pkgs/swarsel-bootstrap/default.nix - { self, writeShellApplication, openssh }: - let - name = "swarsel-bootstrap"; - in + { self, name, writeShellApplication, openssh }: writeShellApplication { inherit name; runtimeInputs = [ openssh ]; @@ -3199,10 +3176,7 @@ This program builds a configuration locally. #+begin_src nix :tangle pkgs/swarsel-rebuild/default.nix - { self, writeShellApplication, git }: - let - name = "swarsel-rebuild"; - in + { self, name, writeShellApplication, git }: writeShellApplication { inherit name; runtimeInputs = [ git ]; @@ -3383,10 +3357,7 @@ This program sets up a new NixOS host locally. #+begin_src nix :tangle pkgs/swarsel-install/default.nix - { self, writeShellApplication, git }: - let - name = "swarsel-install"; - in + { self, name, writeShellApplication, git }: writeShellApplication { inherit name; runtimeInputs = [ git ]; @@ -3479,10 +3450,7 @@ This program sets up a new NixOS host locally. #+begin_src nix :tangle pkgs/swarsel-postinstall/default.nix - { self, writeShellApplication, git }: - let - name = "swarsel-postinstall"; - in + { self, name, writeShellApplication, git }: writeShellApplication { inherit name; runtimeInputs = [ git ]; @@ -3498,15 +3466,15 @@ This program sets up a new NixOS host locally. This script allows for quick git branch switching. #+begin_src nix :tangle pkgs/t2ts/default.nix - { writeShellApplication, ... }: + { name, writeShellApplication, ... }: - writeShellApplication { - name = "t2ts"; - runtimeInputs = [ ]; - text = '' - date -d"$1" +%s - ''; - } + writeShellApplication { + inherit name; + runtimeInputs = [ ]; + text = '' + date -d"$1" +%s + ''; + } #+end_src @@ -3518,10 +3486,10 @@ This script allows for quick git branch switching. This script allows for quick git branch switching. #+begin_src nix :tangle pkgs/ts2t/default.nix - { writeShellApplication, ... }: + { name, writeShellApplication, ... }: writeShellApplication { - name = "ts2t"; + inherit name; runtimeInputs = [ ]; text = '' date -d @"$1" 2>/dev/null || date -r "$1" @@ -3535,10 +3503,10 @@ This script allows for quick git branch switching. This script allows for quick git branch switching. #+begin_src nix :tangle pkgs/vershell/default.nix - { writeShellApplication, ... }: + { name, writeShellApplication, ... }: writeShellApplication { - name = "vershell"; + inherit name; runtimeInputs = [ ]; text = '' nix shell github:nixos/nixpkgs/"$1"#"$2"; diff --git a/lib/default.nix b/lib/default.nix index f452bc3..59953f7 100644 --- a/lib/default.nix +++ b/lib/default.nix @@ -1,5 +1,6 @@ { self, lib, systems, inputs, outputs, ... }: { + mkIfElseList = p: yes: no: lib.mkMerge [ (lib.mkIf p yes) (lib.mkIf (!p) no) @@ -48,6 +49,7 @@ }; mkFullHostConfigs = hosts: type: lib.foldl (acc: set: acc // set) { } (lib.map (host: lib.swarselsystems.mkFullHost host type) hosts); + mkHalfHostConfigs = hosts: type: pkgs: lib.foldl (acc: set: acc // set) { } (lib.map (host: lib.swarselsystems.mkFullHost host type pkgs) hosts); readHosts = type: lib.attrNames (builtins.readDir "${self}/hosts/${type}"); @@ -65,7 +67,7 @@ mkPackages = names: pkgs: builtins.listToAttrs (map (name: { inherit name; - value = pkgs.callPackage "${self}/pkgs/${name}" { inherit self; }; + value = pkgs.callPackage "${self}/pkgs/${name}" { inherit self name; }; }) names); diff --git a/pkgs/bak/default.nix b/pkgs/bak/default.nix index 50e57b2..91ae8f4 100644 --- a/pkgs/bak/default.nix +++ b/pkgs/bak/default.nix @@ -1,7 +1,7 @@ -{ writeShellApplication, ... }: +{ name, writeShellApplication, ... }: writeShellApplication { - name = "bak"; + inherit name; text = '' cp -r "$1"{,.bak} ''; diff --git a/pkgs/cdb/default.nix b/pkgs/cdb/default.nix index fdf9064..d657a18 100644 --- a/pkgs/cdb/default.nix +++ b/pkgs/cdb/default.nix @@ -1,7 +1,7 @@ -{ writeShellApplication, fzf, ... }: +{ name, writeShellApplication, fzf, ... }: writeShellApplication { - name = "cdb"; + inherit name; runtimeInputs = [ fzf ]; text = '' git checkout "$(git branch --list | grep -v "^\*" | fzf | awk '{print $1}')" diff --git a/pkgs/cdw/default.nix b/pkgs/cdw/default.nix index 190f7d2..b4b5bf7 100644 --- a/pkgs/cdw/default.nix +++ b/pkgs/cdw/default.nix @@ -1,7 +1,7 @@ -{ writeShellApplication, fzf, ... }: +{ name, writeShellApplication, fzf, ... }: writeShellApplication { - name = "cdw"; + inherit name; runtimeInputs = [ fzf ]; text = '' cd "$(git worktree list | fzf | awk '{print $1}')" diff --git a/pkgs/e/default.nix b/pkgs/e/default.nix index f058ecb..94a201d 100644 --- a/pkgs/e/default.nix +++ b/pkgs/e/default.nix @@ -1,7 +1,4 @@ -{ self, writeShellApplication, emacs30-pgtk, sway, jq }: -let - name = "e"; -in +{ self, name, writeShellApplication, emacs30-pgtk, sway, jq }: writeShellApplication { inherit name; runtimeInputs = [ emacs30-pgtk sway jq ]; diff --git a/pkgs/fs-diff/default.nix b/pkgs/fs-diff/default.nix index 2ed8a34..de6a2e6 100644 --- a/pkgs/fs-diff/default.nix +++ b/pkgs/fs-diff/default.nix @@ -1,7 +1,4 @@ -{ self, writeShellApplication }: -let - name = "fs-diff"; -in +{ self, name, writeShellApplication }: writeShellApplication { inherit name; text = builtins.readFile "${self}/scripts/${name}.sh"; diff --git a/pkgs/github-notifications/default.nix b/pkgs/github-notifications/default.nix index 13d6099..4da31d9 100644 --- a/pkgs/github-notifications/default.nix +++ b/pkgs/github-notifications/default.nix @@ -1,7 +1,7 @@ -{ writeShellApplication, jq, ... }: +{ name, writeShellApplication, jq, ... }: writeShellApplication { - name = "github-notifications"; + inherit name; runtimeInputs = [ jq ]; text = '' count=$(curl -u Swarsel:"$(cat /run/user/1000/secrets/github_notif)" https://api.github.com/notifications | jq '. | length') diff --git a/pkgs/hm-specialisation/default.nix b/pkgs/hm-specialisation/default.nix index 285fcb9..bbe3809 100644 --- a/pkgs/hm-specialisation/default.nix +++ b/pkgs/hm-specialisation/default.nix @@ -1,7 +1,7 @@ -{ writeShellApplication, fzf, findutils, home-manager, ... }: +{ name, writeShellApplication, fzf, findutils, home-manager, ... }: writeShellApplication { - name = "hm-specialisation"; + inherit name; runtimeInputs = [ fzf findutils home-manager ]; text = '' genpath=$(home-manager generations | head -1 | awk '{print $7}') diff --git a/pkgs/opacitytoggle/default.nix b/pkgs/opacitytoggle/default.nix index 6223df3..4c65c9f 100644 --- a/pkgs/opacitytoggle/default.nix +++ b/pkgs/opacitytoggle/default.nix @@ -1,7 +1,4 @@ -{ self, writeShellApplication, sway }: -let - name = "opacitytoggle"; -in +{ self, name, writeShellApplication, sway }: writeShellApplication { inherit name; runtimeInputs = [ sway ]; diff --git a/pkgs/pass-fuzzel/default.nix b/pkgs/pass-fuzzel/default.nix index a8cfba1..48afb79 100644 --- a/pkgs/pass-fuzzel/default.nix +++ b/pkgs/pass-fuzzel/default.nix @@ -1,7 +1,4 @@ -{ self, writeShellApplication, libnotify, pass, fuzzel, wtype }: -let - name = "pass-fuzzel"; -in +{ self, name, writeShellApplication, libnotify, pass, fuzzel, wtype }: writeShellApplication { inherit name; runtimeInputs = [ libnotify (pass.withExtensions (exts: [ exts.pass-otp ])) fuzzel wtype ]; diff --git a/pkgs/screenshare/default.nix b/pkgs/screenshare/default.nix index bc3819e..4c65c9f 100644 --- a/pkgs/screenshare/default.nix +++ b/pkgs/screenshare/default.nix @@ -1,7 +1,4 @@ -{ self, writeShellApplication, sway }: -let - name = "screenshare"; -in +{ self, name, writeShellApplication, sway }: writeShellApplication { inherit name; runtimeInputs = [ sway ]; diff --git a/pkgs/swarsel-bootstrap/default.nix b/pkgs/swarsel-bootstrap/default.nix index f8bfb3d..6c3749b 100644 --- a/pkgs/swarsel-bootstrap/default.nix +++ b/pkgs/swarsel-bootstrap/default.nix @@ -1,7 +1,4 @@ -{ self, writeShellApplication, openssh }: -let - name = "swarsel-bootstrap"; -in +{ self, name, writeShellApplication, openssh }: writeShellApplication { inherit name; runtimeInputs = [ openssh ]; diff --git a/pkgs/swarsel-install/default.nix b/pkgs/swarsel-install/default.nix index e61a540..6799593 100644 --- a/pkgs/swarsel-install/default.nix +++ b/pkgs/swarsel-install/default.nix @@ -1,7 +1,4 @@ -{ self, writeShellApplication, git }: -let - name = "swarsel-install"; -in +{ self, name, writeShellApplication, git }: writeShellApplication { inherit name; runtimeInputs = [ git ]; diff --git a/pkgs/swarsel-postinstall/default.nix b/pkgs/swarsel-postinstall/default.nix index 9b278f7..6799593 100644 --- a/pkgs/swarsel-postinstall/default.nix +++ b/pkgs/swarsel-postinstall/default.nix @@ -1,7 +1,4 @@ -{ self, writeShellApplication, git }: -let - name = "swarsel-postinstall"; -in +{ self, name, writeShellApplication, git }: writeShellApplication { inherit name; runtimeInputs = [ git ]; diff --git a/pkgs/swarsel-rebuild/default.nix b/pkgs/swarsel-rebuild/default.nix index 2225126..6799593 100644 --- a/pkgs/swarsel-rebuild/default.nix +++ b/pkgs/swarsel-rebuild/default.nix @@ -1,7 +1,4 @@ -{ self, writeShellApplication, git }: -let - name = "swarsel-rebuild"; -in +{ self, name, writeShellApplication, git }: writeShellApplication { inherit name; runtimeInputs = [ git ]; diff --git a/pkgs/swarselcheck/default.nix b/pkgs/swarselcheck/default.nix index be6a182..12dde09 100644 --- a/pkgs/swarselcheck/default.nix +++ b/pkgs/swarselcheck/default.nix @@ -1,7 +1,4 @@ -{ self, writeShellApplication, kitty, element-desktop-wayland, vesktop, spotify-player, jq }: -let - name = "swarselcheck"; -in +{ self, name, writeShellApplication, kitty, element-desktop-wayland, vesktop, spotify-player, jq }: writeShellApplication { inherit name; runtimeInputs = [ kitty element-desktop-wayland vesktop spotify-player jq ]; diff --git a/pkgs/t2ts/default.nix b/pkgs/t2ts/default.nix index aad3e6a..c77e451 100644 --- a/pkgs/t2ts/default.nix +++ b/pkgs/t2ts/default.nix @@ -1,7 +1,7 @@ -{ writeShellApplication, ... }: +{ name, writeShellApplication, ... }: writeShellApplication { - name = "t2ts"; + inherit name; runtimeInputs = [ ]; text = '' date -d"$1" +%s diff --git a/pkgs/timer/default.nix b/pkgs/timer/default.nix index 92b9558..758fcdd 100644 --- a/pkgs/timer/default.nix +++ b/pkgs/timer/default.nix @@ -1,7 +1,7 @@ -{ writeShellApplication, speechd, ... }: +{ name, writeShellApplication, speechd, ... }: writeShellApplication { - name = "timer"; + inherit name; runtimeInputs = [ speechd ]; text = '' sleep "$1"; while true; do spd-say "$2"; sleep 0.5; done; diff --git a/pkgs/ts2t/default.nix b/pkgs/ts2t/default.nix index e09d193..9ed561c 100644 --- a/pkgs/ts2t/default.nix +++ b/pkgs/ts2t/default.nix @@ -1,7 +1,7 @@ -{ writeShellApplication, ... }: +{ name, writeShellApplication, ... }: writeShellApplication { - name = "ts2t"; + inherit name; runtimeInputs = [ ]; text = '' date -d @"$1" 2>/dev/null || date -r "$1" diff --git a/pkgs/update-checker/default.nix b/pkgs/update-checker/default.nix index 908b9b2..7d15257 100644 --- a/pkgs/update-checker/default.nix +++ b/pkgs/update-checker/default.nix @@ -1,7 +1,4 @@ -{ self, writeShellApplication, nvd }: -let - name = "update-checker"; -in +{ self, name, writeShellApplication, nvd }: writeShellApplication { inherit name; runtimeInputs = [ nvd ]; diff --git a/pkgs/vershell/default.nix b/pkgs/vershell/default.nix index 16dea35..5917b54 100644 --- a/pkgs/vershell/default.nix +++ b/pkgs/vershell/default.nix @@ -1,7 +1,7 @@ -{ writeShellApplication, ... }: +{ name, writeShellApplication, ... }: writeShellApplication { - name = "vershell"; + inherit name; runtimeInputs = [ ]; text = '' nix shell github:nixos/nixpkgs/"$1"#"$2"; diff --git a/pkgs/waybarupdate/default.nix b/pkgs/waybarupdate/default.nix index 9438ba1..6799593 100644 --- a/pkgs/waybarupdate/default.nix +++ b/pkgs/waybarupdate/default.nix @@ -1,7 +1,4 @@ -{ self, writeShellApplication, git }: -let - name = "waybarupdate"; -in +{ self, name, writeShellApplication, git }: writeShellApplication { inherit name; runtimeInputs = [ git ];