refactor: inherit name from mkPackages

This commit is contained in:
Leon Schwarzäugl 2024-12-29 00:36:04 +01:00
parent d397be861b
commit d538762c7e
Signed by: swarsel
GPG key ID: 26A54C31F2A4FD84
23 changed files with 81 additions and 147 deletions

View file

@ -2085,6 +2085,10 @@ As such, I also define three additional overlays:
3) =nixpkgs-stable= 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. 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 *** Packages
:PROPERTIES: :PROPERTIES:
:CUSTOM_ID: h:64a5cc16-6b16-4802-b421-c67ccef853e1 :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 #+end_src
#+begin_src nix :tangle pkgs/pass-fuzzel/default.nix #+begin_src nix :tangle pkgs/pass-fuzzel/default.nix
{ self, writeShellApplication, libnotify, pass, fuzzel, wtype }: { self, name, writeShellApplication, libnotify, pass, fuzzel, wtype }:
let
name = "pass-fuzzel";
in
writeShellApplication { writeShellApplication {
inherit name; inherit name;
runtimeInputs = [ libnotify (pass.withExtensions (exts: [ exts.pass-otp ])) fuzzel wtype ]; 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 #+begin_src nix :tangle pkgs/hm-specialisation/default.nix
{ writeShellApplication, fzf, findutils, home-manager, ... }: { name, writeShellApplication, fzf, findutils, home-manager, ... }:
writeShellApplication { writeShellApplication {
name = "hm-specialisation"; inherit name;
runtimeInputs = [ fzf findutils home-manager ]; runtimeInputs = [ fzf findutils home-manager ];
text = '' text = ''
genpath=$(home-manager generations | head -1 | awk '{print $7}') genpath=$(home-manager generations | head -1 | awk '{print $7}')
dirs=$(find "$genpath/specialisation" -type l 2>/dev/null; [ -d "$genpath" ] && echo "$genpath") dirs=$(find "$genpath/specialisation" -type l 2>/dev/null; [ -d "$genpath" ] && echo "$genpath")
"$(echo "$dirs" | fzf --prompt="Choose home-manager specialisation to activate")"/activate "$(echo "$dirs" | fzf --prompt="Choose home-manager specialisation to activate")"/activate
''; '';
} }
#+end_src #+end_src
@ -2276,10 +2277,10 @@ This script allows for quick git worktree switching.
#+begin_src nix :tangle pkgs/cdw/default.nix #+begin_src nix :tangle pkgs/cdw/default.nix
{ writeShellApplication, fzf, ... }: { name, writeShellApplication, fzf, ... }:
writeShellApplication { writeShellApplication {
name = "cdw"; inherit name;
runtimeInputs = [ fzf ]; runtimeInputs = [ fzf ];
text = '' text = ''
cd "$(git worktree list | fzf | awk '{print $1}')" 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. This script allows for quick git branch switching.
#+begin_src nix :tangle pkgs/cdb/default.nix #+begin_src nix :tangle pkgs/cdb/default.nix
{ writeShellApplication, fzf, ... }: { name, writeShellApplication, fzf, ... }:
writeShellApplication { writeShellApplication {
name = "cdb"; inherit name;
runtimeInputs = [ fzf ]; runtimeInputs = [ fzf ];
text = '' text = ''
git checkout "$(git branch --list | grep -v "^\*" | fzf | awk '{print $1}')" 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 #+begin_src nix :tangle pkgs/bak/default.nix
{ writeShellApplication, ... }: { name, writeShellApplication, ... }:
writeShellApplication { writeShellApplication {
name = "bak"; inherit name;
text = '' text = ''
cp -r "$1"{,.bak} 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 #+begin_src nix :tangle pkgs/timer/default.nix
{ writeShellApplication, speechd, ... }: { name, writeShellApplication, speechd, ... }:
writeShellApplication { writeShellApplication {
name = "timer"; inherit name;
runtimeInputs = [ speechd ]; runtimeInputs = [ speechd ];
text = '' text = ''
sleep "$1"; while true; do spd-say "$2"; sleep 0.5; done; 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 #+end_src
#+begin_src nix :tangle pkgs/e/default.nix #+begin_src nix :tangle pkgs/e/default.nix
{ self, writeShellApplication, emacs30-pgtk, sway, jq }: { self, name, writeShellApplication, emacs30-pgtk, sway, jq }:
let
name = "e";
in
writeShellApplication { writeShellApplication {
inherit name; inherit name;
runtimeInputs = [ emacs30-pgtk sway jq ]; 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 #+end_src
#+begin_src nix :tangle pkgs/swarselcheck/default.nix #+begin_src nix :tangle pkgs/swarselcheck/default.nix
{ self, writeShellApplication, kitty, element-desktop-wayland, vesktop, spotify-player, jq }: { self, name, writeShellApplication, kitty, element-desktop-wayland, vesktop, spotify-player, jq }:
let
name = "swarselcheck";
in
writeShellApplication { writeShellApplication {
inherit name; inherit name;
runtimeInputs = [ kitty element-desktop-wayland vesktop spotify-player jq ]; 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 #+end_src
#+begin_src nix :tangle pkgs/waybarupdate/default.nix #+begin_src nix :tangle pkgs/waybarupdate/default.nix
{ self, writeShellApplication, git }: { self, name, writeShellApplication, git }:
let
name = "waybarupdate";
in
writeShellApplication { writeShellApplication {
inherit name; inherit name;
runtimeInputs = [ git ]; runtimeInputs = [ git ];
@ -2589,10 +2581,7 @@ This app quickly toggles between 5% and 0% transparency.
#+end_src #+end_src
#+begin_src nix :tangle pkgs/opacitytoggle/default.nix #+begin_src nix :tangle pkgs/opacitytoggle/default.nix
{ self, writeShellApplication, sway }: { self, name, writeShellApplication, sway }:
let
name = "opacitytoggle";
in
writeShellApplication { writeShellApplication {
inherit name; inherit name;
runtimeInputs = [ sway ]; runtimeInputs = [ sway ];
@ -2631,10 +2620,7 @@ This utility is used to compare the current state of the root directory with the
#+end_src #+end_src
#+begin_src nix :tangle pkgs/fs-diff/default.nix #+begin_src nix :tangle pkgs/fs-diff/default.nix
{ self, writeShellApplication }: { self, name, writeShellApplication }:
let
name = "fs-diff";
in
writeShellApplication { writeShellApplication {
inherit name; inherit name;
text = builtins.readFile "${self}/scripts/${name}.sh"; 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 #+end_src
#+begin_src nix :tangle pkgs/update-checker/default.nix #+begin_src nix :tangle pkgs/update-checker/default.nix
{ self, writeShellApplication, nvd }: { self, name, writeShellApplication, nvd }:
let
name = "update-checker";
in
writeShellApplication { writeShellApplication {
inherit name; inherit name;
runtimeInputs = [ nvd ]; 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 #+begin_src nix :tangle pkgs/github-notifications/default.nix
{ writeShellApplication, jq, ... }: { name, writeShellApplication, jq, ... }:
writeShellApplication { writeShellApplication {
name = "github-notifications"; inherit name;
runtimeInputs = [ jq ]; runtimeInputs = [ jq ];
text = '' text = ''
count=$(curl -u Swarsel:"$(cat /run/user/1000/secrets/github_notif)" https://api.github.com/notifications | jq '. | length') 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 #+begin_src nix :tangle pkgs/screenshare/default.nix
{ self, writeShellApplication, sway }: { self, name, writeShellApplication, sway }:
let
name = "screenshare";
in
writeShellApplication { writeShellApplication {
inherit name; inherit name;
runtimeInputs = [ sway ]; 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 #+begin_src nix :tangle pkgs/swarsel-bootstrap/default.nix
{ self, writeShellApplication, openssh }: { self, name, writeShellApplication, openssh }:
let
name = "swarsel-bootstrap";
in
writeShellApplication { writeShellApplication {
inherit name; inherit name;
runtimeInputs = [ openssh ]; runtimeInputs = [ openssh ];
@ -3199,10 +3176,7 @@ This program builds a configuration locally.
#+begin_src nix :tangle pkgs/swarsel-rebuild/default.nix #+begin_src nix :tangle pkgs/swarsel-rebuild/default.nix
{ self, writeShellApplication, git }: { self, name, writeShellApplication, git }:
let
name = "swarsel-rebuild";
in
writeShellApplication { writeShellApplication {
inherit name; inherit name;
runtimeInputs = [ git ]; runtimeInputs = [ git ];
@ -3383,10 +3357,7 @@ This program sets up a new NixOS host locally.
#+begin_src nix :tangle pkgs/swarsel-install/default.nix #+begin_src nix :tangle pkgs/swarsel-install/default.nix
{ self, writeShellApplication, git }: { self, name, writeShellApplication, git }:
let
name = "swarsel-install";
in
writeShellApplication { writeShellApplication {
inherit name; inherit name;
runtimeInputs = [ git ]; runtimeInputs = [ git ];
@ -3479,10 +3450,7 @@ This program sets up a new NixOS host locally.
#+begin_src nix :tangle pkgs/swarsel-postinstall/default.nix #+begin_src nix :tangle pkgs/swarsel-postinstall/default.nix
{ self, writeShellApplication, git }: { self, name, writeShellApplication, git }:
let
name = "swarsel-postinstall";
in
writeShellApplication { writeShellApplication {
inherit name; inherit name;
runtimeInputs = [ git ]; runtimeInputs = [ git ];
@ -3498,15 +3466,15 @@ This program sets up a new NixOS host locally.
This script allows for quick git branch switching. This script allows for quick git branch switching.
#+begin_src nix :tangle pkgs/t2ts/default.nix #+begin_src nix :tangle pkgs/t2ts/default.nix
{ writeShellApplication, ... }: { name, writeShellApplication, ... }:
writeShellApplication { writeShellApplication {
name = "t2ts"; inherit name;
runtimeInputs = [ ]; runtimeInputs = [ ];
text = '' text = ''
date -d"$1" +%s date -d"$1" +%s
''; '';
} }
#+end_src #+end_src
@ -3518,10 +3486,10 @@ This script allows for quick git branch switching.
This script allows for quick git branch switching. This script allows for quick git branch switching.
#+begin_src nix :tangle pkgs/ts2t/default.nix #+begin_src nix :tangle pkgs/ts2t/default.nix
{ writeShellApplication, ... }: { name, writeShellApplication, ... }:
writeShellApplication { writeShellApplication {
name = "ts2t"; inherit name;
runtimeInputs = [ ]; runtimeInputs = [ ];
text = '' text = ''
date -d @"$1" 2>/dev/null || date -r "$1" 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. This script allows for quick git branch switching.
#+begin_src nix :tangle pkgs/vershell/default.nix #+begin_src nix :tangle pkgs/vershell/default.nix
{ writeShellApplication, ... }: { name, writeShellApplication, ... }:
writeShellApplication { writeShellApplication {
name = "vershell"; inherit name;
runtimeInputs = [ ]; runtimeInputs = [ ];
text = '' text = ''
nix shell github:nixos/nixpkgs/"$1"#"$2"; nix shell github:nixos/nixpkgs/"$1"#"$2";

View file

@ -1,5 +1,6 @@
{ self, lib, systems, inputs, outputs, ... }: { self, lib, systems, inputs, outputs, ... }:
{ {
mkIfElseList = p: yes: no: lib.mkMerge [ mkIfElseList = p: yes: no: lib.mkMerge [
(lib.mkIf p yes) (lib.mkIf p yes)
(lib.mkIf (!p) no) (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); 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); 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}"); readHosts = type: lib.attrNames (builtins.readDir "${self}/hosts/${type}");
@ -65,7 +67,7 @@
mkPackages = names: pkgs: builtins.listToAttrs (map mkPackages = names: pkgs: builtins.listToAttrs (map
(name: { (name: {
inherit name; inherit name;
value = pkgs.callPackage "${self}/pkgs/${name}" { inherit self; }; value = pkgs.callPackage "${self}/pkgs/${name}" { inherit self name; };
}) })
names); names);

View file

@ -1,7 +1,7 @@
{ writeShellApplication, ... }: { name, writeShellApplication, ... }:
writeShellApplication { writeShellApplication {
name = "bak"; inherit name;
text = '' text = ''
cp -r "$1"{,.bak} cp -r "$1"{,.bak}
''; '';

View file

@ -1,7 +1,7 @@
{ writeShellApplication, fzf, ... }: { name, writeShellApplication, fzf, ... }:
writeShellApplication { writeShellApplication {
name = "cdb"; inherit name;
runtimeInputs = [ fzf ]; runtimeInputs = [ fzf ];
text = '' text = ''
git checkout "$(git branch --list | grep -v "^\*" | fzf | awk '{print $1}')" git checkout "$(git branch --list | grep -v "^\*" | fzf | awk '{print $1}')"

View file

@ -1,7 +1,7 @@
{ writeShellApplication, fzf, ... }: { name, writeShellApplication, fzf, ... }:
writeShellApplication { writeShellApplication {
name = "cdw"; inherit name;
runtimeInputs = [ fzf ]; runtimeInputs = [ fzf ];
text = '' text = ''
cd "$(git worktree list | fzf | awk '{print $1}')" cd "$(git worktree list | fzf | awk '{print $1}')"

View file

@ -1,7 +1,4 @@
{ self, writeShellApplication, emacs30-pgtk, sway, jq }: { self, name, writeShellApplication, emacs30-pgtk, sway, jq }:
let
name = "e";
in
writeShellApplication { writeShellApplication {
inherit name; inherit name;
runtimeInputs = [ emacs30-pgtk sway jq ]; runtimeInputs = [ emacs30-pgtk sway jq ];

View file

@ -1,7 +1,4 @@
{ self, writeShellApplication }: { self, name, writeShellApplication }:
let
name = "fs-diff";
in
writeShellApplication { writeShellApplication {
inherit name; inherit name;
text = builtins.readFile "${self}/scripts/${name}.sh"; text = builtins.readFile "${self}/scripts/${name}.sh";

View file

@ -1,7 +1,7 @@
{ writeShellApplication, jq, ... }: { name, writeShellApplication, jq, ... }:
writeShellApplication { writeShellApplication {
name = "github-notifications"; inherit name;
runtimeInputs = [ jq ]; runtimeInputs = [ jq ];
text = '' text = ''
count=$(curl -u Swarsel:"$(cat /run/user/1000/secrets/github_notif)" https://api.github.com/notifications | jq '. | length') count=$(curl -u Swarsel:"$(cat /run/user/1000/secrets/github_notif)" https://api.github.com/notifications | jq '. | length')

View file

@ -1,7 +1,7 @@
{ writeShellApplication, fzf, findutils, home-manager, ... }: { name, writeShellApplication, fzf, findutils, home-manager, ... }:
writeShellApplication { writeShellApplication {
name = "hm-specialisation"; inherit name;
runtimeInputs = [ fzf findutils home-manager ]; runtimeInputs = [ fzf findutils home-manager ];
text = '' text = ''
genpath=$(home-manager generations | head -1 | awk '{print $7}') genpath=$(home-manager generations | head -1 | awk '{print $7}')

View file

@ -1,7 +1,4 @@
{ self, writeShellApplication, sway }: { self, name, writeShellApplication, sway }:
let
name = "opacitytoggle";
in
writeShellApplication { writeShellApplication {
inherit name; inherit name;
runtimeInputs = [ sway ]; runtimeInputs = [ sway ];

View file

@ -1,7 +1,4 @@
{ self, writeShellApplication, libnotify, pass, fuzzel, wtype }: { self, name, writeShellApplication, libnotify, pass, fuzzel, wtype }:
let
name = "pass-fuzzel";
in
writeShellApplication { writeShellApplication {
inherit name; inherit name;
runtimeInputs = [ libnotify (pass.withExtensions (exts: [ exts.pass-otp ])) fuzzel wtype ]; runtimeInputs = [ libnotify (pass.withExtensions (exts: [ exts.pass-otp ])) fuzzel wtype ];

View file

@ -1,7 +1,4 @@
{ self, writeShellApplication, sway }: { self, name, writeShellApplication, sway }:
let
name = "screenshare";
in
writeShellApplication { writeShellApplication {
inherit name; inherit name;
runtimeInputs = [ sway ]; runtimeInputs = [ sway ];

View file

@ -1,7 +1,4 @@
{ self, writeShellApplication, openssh }: { self, name, writeShellApplication, openssh }:
let
name = "swarsel-bootstrap";
in
writeShellApplication { writeShellApplication {
inherit name; inherit name;
runtimeInputs = [ openssh ]; runtimeInputs = [ openssh ];

View file

@ -1,7 +1,4 @@
{ self, writeShellApplication, git }: { self, name, writeShellApplication, git }:
let
name = "swarsel-install";
in
writeShellApplication { writeShellApplication {
inherit name; inherit name;
runtimeInputs = [ git ]; runtimeInputs = [ git ];

View file

@ -1,7 +1,4 @@
{ self, writeShellApplication, git }: { self, name, writeShellApplication, git }:
let
name = "swarsel-postinstall";
in
writeShellApplication { writeShellApplication {
inherit name; inherit name;
runtimeInputs = [ git ]; runtimeInputs = [ git ];

View file

@ -1,7 +1,4 @@
{ self, writeShellApplication, git }: { self, name, writeShellApplication, git }:
let
name = "swarsel-rebuild";
in
writeShellApplication { writeShellApplication {
inherit name; inherit name;
runtimeInputs = [ git ]; runtimeInputs = [ git ];

View file

@ -1,7 +1,4 @@
{ self, writeShellApplication, kitty, element-desktop-wayland, vesktop, spotify-player, jq }: { self, name, writeShellApplication, kitty, element-desktop-wayland, vesktop, spotify-player, jq }:
let
name = "swarselcheck";
in
writeShellApplication { writeShellApplication {
inherit name; inherit name;
runtimeInputs = [ kitty element-desktop-wayland vesktop spotify-player jq ]; runtimeInputs = [ kitty element-desktop-wayland vesktop spotify-player jq ];

View file

@ -1,7 +1,7 @@
{ writeShellApplication, ... }: { name, writeShellApplication, ... }:
writeShellApplication { writeShellApplication {
name = "t2ts"; inherit name;
runtimeInputs = [ ]; runtimeInputs = [ ];
text = '' text = ''
date -d"$1" +%s date -d"$1" +%s

View file

@ -1,7 +1,7 @@
{ writeShellApplication, speechd, ... }: { name, writeShellApplication, speechd, ... }:
writeShellApplication { writeShellApplication {
name = "timer"; inherit name;
runtimeInputs = [ speechd ]; runtimeInputs = [ speechd ];
text = '' text = ''
sleep "$1"; while true; do spd-say "$2"; sleep 0.5; done; sleep "$1"; while true; do spd-say "$2"; sleep 0.5; done;

View file

@ -1,7 +1,7 @@
{ writeShellApplication, ... }: { name, writeShellApplication, ... }:
writeShellApplication { writeShellApplication {
name = "ts2t"; inherit name;
runtimeInputs = [ ]; runtimeInputs = [ ];
text = '' text = ''
date -d @"$1" 2>/dev/null || date -r "$1" date -d @"$1" 2>/dev/null || date -r "$1"

View file

@ -1,7 +1,4 @@
{ self, writeShellApplication, nvd }: { self, name, writeShellApplication, nvd }:
let
name = "update-checker";
in
writeShellApplication { writeShellApplication {
inherit name; inherit name;
runtimeInputs = [ nvd ]; runtimeInputs = [ nvd ];

View file

@ -1,7 +1,7 @@
{ writeShellApplication, ... }: { name, writeShellApplication, ... }:
writeShellApplication { writeShellApplication {
name = "vershell"; inherit name;
runtimeInputs = [ ]; runtimeInputs = [ ];
text = '' text = ''
nix shell github:nixos/nixpkgs/"$1"#"$2"; nix shell github:nixos/nixpkgs/"$1"#"$2";

View file

@ -1,7 +1,4 @@
{ self, writeShellApplication, git }: { self, name, writeShellApplication, git }:
let
name = "waybarupdate";
in
writeShellApplication { writeShellApplication {
inherit name; inherit name;
runtimeInputs = [ git ]; runtimeInputs = [ git ];