diff options
author | Gregor Kleen <gkleen@yggdrasil.li> | 2025-05-02 16:15:52 +0200 |
---|---|---|
committer | Gregor Kleen <gkleen@yggdrasil.li> | 2025-05-02 16:15:52 +0200 |
commit | b37371a61aa9f6ec3f4e4e4b118a9d06f3689b5e (patch) | |
tree | 09c76f10f6767c8867bc2bd092b5f4844e197a6a | |
parent | c22c3cf38fc94429480082c4225702b28d48c134 (diff) | |
download | nixos-b37371a61aa9f6ec3f4e4e4b118a9d06f3689b5e.tar nixos-b37371a61aa9f6ec3f4e4e4b118a9d06f3689b5e.tar.gz nixos-b37371a61aa9f6ec3f4e4e4b118a9d06f3689b5e.tar.bz2 nixos-b37371a61aa9f6ec3f4e4e4b118a9d06f3689b5e.tar.xz nixos-b37371a61aa9f6ec3f4e4e4b118a9d06f3689b5e.zip |
...
-rw-r--r-- | accounts/gkleen@sif/default.nix | 85 | ||||
-rw-r--r-- | accounts/gkleen@sif/zshrc | 62 | ||||
-rw-r--r-- | overlays/lesspipe.nix | 2 | ||||
-rw-r--r-- | user-profiles/utils.nix | 19 |
4 files changed, 106 insertions, 62 deletions
diff --git a/accounts/gkleen@sif/default.nix b/accounts/gkleen@sif/default.nix index 6574af9d..e900370b 100644 --- a/accounts/gkleen@sif/default.nix +++ b/accounts/gkleen@sif/default.nix | |||
@@ -175,13 +175,92 @@ in { | |||
175 | gpu-api = "vulkan"; | 175 | gpu-api = "vulkan"; |
176 | }; | 176 | }; |
177 | 177 | ||
178 | zsh.initExtra = '' | 178 | zsh.initExtra = let |
179 | source ${./zshrc} | 179 | zshrc = pkgs.resholve.mkDerivation { |
180 | pname = "zshrc"; | ||
181 | version = "0.0.0"; | ||
182 | |||
183 | src = ./zshrc; | ||
184 | |||
185 | dontUnpack = true; | ||
186 | dontConfigure = true; | ||
187 | dontBuild = true; | ||
188 | |||
189 | installPhase = '' | ||
190 | mkdir -p $out/share | ||
191 | install "$src" $out/share/zshrc | ||
192 | ''; | ||
193 | |||
194 | solutions = { | ||
195 | default = { | ||
196 | scripts = [ "share/zshrc" ]; | ||
197 | interpreter = "none"; | ||
198 | inputs = with pkgs; [ | ||
199 | coreutils | ||
200 | rpm | ||
201 | binutils | ||
202 | squashfsTools | ||
203 | unzip | ||
204 | cfg.programs.git.package | ||
205 | magickWrapped | ||
206 | curl | ||
207 | file | ||
208 | gnutar | ||
209 | cpio | ||
210 | magic-wormhole | ||
211 | quickserve | ||
212 | cfg.programs.zsh.package | ||
213 | fuse | ||
214 | util-linux | ||
215 | findutils | ||
216 | qrencode | ||
217 | tty-clock | ||
218 | cfg.programs.jq.package | ||
219 | eza | ||
220 | less | ||
221 | config.systemd.package | ||
222 | config.programs.ssh.package | ||
223 | gnused | ||
224 | ]; | ||
225 | execer = with pkgs; [ | ||
226 | "cannot:${lib.getExe' rpm "rpm2cpio"}" | ||
227 | "cannot:${lib.getExe' squashfsTools "unsquashfs"}" | ||
228 | "cannot:${lib.getExe' unzip "unzip"}" | ||
229 | "cannot:${lib.getExe cfg.programs.git.package}" | ||
230 | "cannot:${lib.getExe cpio}" | ||
231 | "cannot:${lib.getExe' magic-wormhole "wormhole"}" | ||
232 | "cannot:${lib.getExe quickserve}" | ||
233 | "cannot:${lib.getExe' fuse "fusermount"}" | ||
234 | "cannot:${lib.getExe less}" | ||
235 | "cannot:${lib.getExe' config.systemd.package "systemctl"}" | ||
236 | "cannot:${lib.getExe config.programs.ssh.package}" | ||
237 | ]; | ||
238 | wrapper = with pkgs; [ | ||
239 | "${lib.getExe' magickWrapped "magick"}:${lib.getExe' imagemagick "magick"}" | ||
240 | ]; | ||
241 | fake = { | ||
242 | builtin = ["print"]; | ||
243 | external = ["sudo" "umount"]; | ||
244 | }; | ||
245 | }; | ||
246 | }; | ||
247 | }; | ||
248 | magickWrapped = pkgs.symlinkJoin { | ||
249 | inherit (pkgs.imagemagick) name; | ||
250 | paths = [ pkgs.imagemagick ]; | ||
251 | |||
252 | buildInputs = with pkgs; [ makeWrapper ]; | ||
253 | postBuild = '' | ||
254 | wrapProgram $out/bin/magick \ | ||
255 | --prefix PATH : ${lib.makeBinPath (with pkgs; [ ghostscript ])} | ||
256 | ''; | ||
257 | }; | ||
258 | in '' | ||
259 | source ${zshrc}/share/zshrc | ||
180 | ''; | 260 | ''; |
181 | zsh.dirHashes = let | 261 | zsh.dirHashes = let |
182 | flakeHashes = mapAttrs' (n: v: nameValuePair (inputNames.${n} or n) (toString v)) flakeInputs; | 262 | flakeHashes = mapAttrs' (n: v: nameValuePair (inputNames.${n} or n) (toString v)) flakeInputs; |
183 | inputNames = { | 263 | inputNames = { |
184 | "nixpkgs" = "nixos"; | ||
185 | }; | 264 | }; |
186 | in flakeHashes // { | 265 | in flakeHashes // { |
187 | u2w = "$HOME/projects/uni2work"; | 266 | u2w = "$HOME/projects/uni2work"; |
diff --git a/accounts/gkleen@sif/zshrc b/accounts/gkleen@sif/zshrc index c628e2e9..06f6f6f2 100644 --- a/accounts/gkleen@sif/zshrc +++ b/accounts/gkleen@sif/zshrc | |||
@@ -2,8 +2,6 @@ dir() { | |||
2 | curlArchive=false | 2 | curlArchive=false |
3 | templateArchive="" | 3 | templateArchive="" |
4 | repoUrl="" | 4 | repoUrl="" |
5 | nixShell="" | ||
6 | findNix=false | ||
7 | dir="" | 5 | dir="" |
8 | forceShell=false | 6 | forceShell=false |
9 | wormhole=false | 7 | wormhole=false |
@@ -12,7 +10,7 @@ dir() { | |||
12 | quickserve=false | 10 | quickserve=false |
13 | modifyPDF="" | 11 | modifyPDF="" |
14 | 12 | ||
15 | while getopts ':t:a:s:Sd:ir:wqg:p:' arg; do | 13 | while getopts ':t:a:d:ir:wqg:p:' arg; do |
16 | case $arg in | 14 | case $arg in |
17 | "t") ;; | 15 | "t") ;; |
18 | "a") | 16 | "a") |
@@ -23,8 +21,6 @@ dir() { | |||
23 | templateArchive=${OPTARG:a} | 21 | templateArchive=${OPTARG:a} |
24 | fi | 22 | fi |
25 | ;; | 23 | ;; |
26 | "s") nixShell=${OPTARG:a} ;; | ||
27 | "S") findNix=true ;; | ||
28 | "d") dir=${OPTARG} ;; | 24 | "d") dir=${OPTARG} ;; |
29 | "i") forceShell=true ;; | 25 | "i") forceShell=true ;; |
30 | "r") repoUrl=${OPTARG} ;; | 26 | "r") repoUrl=${OPTARG} ;; |
@@ -59,7 +55,11 @@ dir() { | |||
59 | cleanup() | 55 | cleanup() |
60 | { | 56 | { |
61 | cd ${modifyPDF:h} | 57 | cd ${modifyPDF:h} |
62 | [[ -n ${modifyPDF} ]] && nix shell 'nixos#imagemagick' -c convert -verbose ${dir}/${modifyPDF:t:r}_*.png(on) ${modifyPDF} | 58 | if [[ -n ${modifyPDF} ]]; then |
59 | typeset -a pages | ||
60 | eval 'pages=(${dir}/${modifyPDF:t:r}_*.png(on))' | ||
61 | magick -verbose "$pages" ${modifyPDF} | ||
62 | fi | ||
63 | } | 63 | } |
64 | 64 | ||
65 | ( | 65 | ( |
@@ -68,8 +68,6 @@ dir() { | |||
68 | cd ${dir} | 68 | cd ${dir} |
69 | export dir; | 69 | export dir; |
70 | 70 | ||
71 | ${findNix} && { nixShell=$(findNix) || return $? } | ||
72 | |||
73 | [[ -n ${repoUrl} ]] && git clone -- ${repoUrl} . | 71 | [[ -n ${repoUrl} ]] && git clone -- ${repoUrl} . |
74 | 72 | ||
75 | [[ -n ${modifyPDF} ]] && templateArchive=${modifyPDF} | 73 | [[ -n ${modifyPDF} ]] && templateArchive=${modifyPDF} |
@@ -82,7 +80,7 @@ dir() { | |||
82 | } | 80 | } |
83 | trap cleanup EXIT | 81 | trap cleanup EXIT |
84 | 82 | ||
85 | if ${curlArchive}; then | 83 | if [[ $curlArchive = "true" ]]; then |
86 | archiveFile=$(mktemp -t "archive.XXXXXXXXXX.${templateArchive:t}") | 84 | archiveFile=$(mktemp -t "archive.XXXXXXXXXX.${templateArchive:t}") |
87 | 85 | ||
88 | curl -L -o ${archiveFile} ${templateArchive} | 86 | curl -L -o ${archiveFile} ${templateArchive} |
@@ -91,14 +89,14 @@ dir() { | |||
91 | fi | 89 | fi |
92 | 90 | ||
93 | unpack=true | 91 | unpack=true |
94 | while ${unpack}; do | 92 | while [[ $unpack = "true" ]]; do |
95 | case $(file --brief --mime-type --dereference ${templateArchive}) in | 93 | case $(file --brief --mime-type --dereference ${templateArchive}) in |
96 | application/zip) | 94 | application/zip) |
97 | unzip ${templateArchive} | 95 | unzip ${templateArchive} |
98 | unpack=false | 96 | unpack=false |
99 | ;; | 97 | ;; |
100 | application/vnd.debian.binary-package) | 98 | application/vnd.debian.binary-package) |
101 | nix shell 'nixos#binutils' --command ar x ${templateArchive} | 99 | ar x ${templateArchive} |
102 | mkdir control data | 100 | mkdir control data |
103 | tar -C control -xvaf control.* | 101 | tar -C control -xvaf control.* |
104 | tar -C data -xvaf data.* | 102 | tar -C data -xvaf data.* |
@@ -106,7 +104,7 @@ dir() { | |||
106 | ;; | 104 | ;; |
107 | application/x-rpm) | 105 | application/x-rpm) |
108 | cpioArchive=$(mktemp -t "archive.XXXXXXXXXX.${templateArchive:t:r}.cpio") | 106 | cpioArchive=$(mktemp -t "archive.XXXXXXXXXX.${templateArchive:t:r}.cpio") |
109 | nix shell 'nixos#busybox' --command rpm2cpio ${templateArchive} > ${cpioArchive} | 107 | rpm2cpio ${templateArchive} > ${cpioArchive} |
110 | templateArchive=${cpioArchive} | 108 | templateArchive=${cpioArchive} |
111 | unpack=true | 109 | unpack=true |
112 | ;; | 110 | ;; |
@@ -115,12 +113,12 @@ dir() { | |||
115 | unpack=false | 113 | unpack=false |
116 | ;; | 114 | ;; |
117 | application/pdf) | 115 | application/pdf) |
118 | nix shell 'nixos#ghostscript' 'nixos#imagemagick' -c convert -verbose -density 400 ${templateArchive} ${modifyPDF:t:r}_%0d.png | 116 | magick -verbose -density 400 ${templateArchive} ${modifyPDF:t:r}_%0d.png |
119 | unpack=false | 117 | unpack=false |
120 | ;; | 118 | ;; |
121 | application/octet-stream) | 119 | application/octet-stream) |
122 | if [[ $(file --brief --dereferenc ${templateArchive}) =~ Squashfs ]]; then | 120 | if [[ $(file --brief --dereference ${templateArchive}) =~ Squashfs ]]; then |
123 | nix shell 'nixos#squashfsTools' -c unsquashfs -d . ${templateArchive} | 121 | unsquashfs -d . ${templateArchive} |
124 | unpack=false | 122 | unpack=false |
125 | fi | 123 | fi |
126 | ;; | 124 | ;; |
@@ -134,21 +132,17 @@ dir() { | |||
134 | fi | 132 | fi |
135 | 133 | ||
136 | 134 | ||
137 | ${wormhole} && wormhole receive --accept-file | 135 | [[ $wormhole = "true" ]] && wormhole receive --accept-file |
138 | 136 | ||
139 | 137 | ||
140 | if ${quickserve}; then | 138 | if [[ $quickserve = "true" ]]; then |
141 | quickserve --root . --upload . --show-hidden --tar gz | 139 | quickserve --root . --upload . --show-hidden --tar gz |
142 | fi | 140 | fi |
143 | 141 | ||
144 | 142 | ||
145 | if [[ ${#@} -eq 0 ]] || ${forceShell}; then | 143 | if [[ ${#@} -eq 0 ]] || [[ $forceShell = "true" ]]; then |
146 | if [[ ${#@} -gt 0 ]]; then | 144 | if [[ ${#@} -gt 0 ]]; then |
147 | if [[ -z ${nixShell} ]]; then | 145 | ${@} |
148 | ${@} | ||
149 | else | ||
150 | nix-shell ${nixShell} --run "${@}" | ||
151 | fi | ||
152 | fi | 146 | fi |
153 | 147 | ||
154 | cd $(pwd) # Needed for mounting to work | 148 | cd $(pwd) # Needed for mounting to work |
@@ -167,17 +161,9 @@ dir() { | |||
167 | while d=$(isSingleDir); do cd ${d}; done | 161 | while d=$(isSingleDir); do cd ${d}; done |
168 | 162 | ||
169 | 163 | ||
170 | if [[ -z ${nixShell} ]]; then | 164 | zsh |
171 | zsh | ||
172 | else | ||
173 | nix-shell ${nixShell} --run zsh | ||
174 | fi | ||
175 | else | 165 | else |
176 | if [[ -z ${nixShell} ]]; then | 166 | ${@} |
177 | ${@} | ||
178 | else | ||
179 | nix-shell ${nixShell} --run "${@}" | ||
180 | fi | ||
181 | fi | 167 | fi |
182 | ) | 168 | ) |
183 | } | 169 | } |
@@ -234,16 +220,6 @@ public-ip() { | |||
234 | curl -s -H 'Accept: application/json' $@ ifconfig.co | jq -r '.ip' | 220 | curl -s -H 'Accept: application/json' $@ ifconfig.co | jq -r '.ip' |
235 | } | 221 | } |
236 | 222 | ||
237 | nix-ghci() { | ||
238 | pkgExpr="" | ||
239 | if [[ ${#@} -gt 0 ]]; then | ||
240 | pkgExpr="${1}" | ||
241 | shift | ||
242 | fi | ||
243 | |||
244 | nix-shell -p "with (import <nixpkgs> {}); pkgs.haskellPackages.ghcWithPackages (p: with p; [${pkgExpr}])" --run "ghci ${@}" | ||
245 | } | ||
246 | |||
247 | swap() { | 223 | swap() { |
248 | f1=${1} | 224 | f1=${1} |
249 | f2=${2} | 225 | f2=${2} |
diff --git a/overlays/lesspipe.nix b/overlays/lesspipe.nix index 3258eb70..b791f6e5 100644 --- a/overlays/lesspipe.nix +++ b/overlays/lesspipe.nix | |||
@@ -17,7 +17,7 @@ | |||
17 | 17 | ||
18 | preFixup = '' | 18 | preFixup = '' |
19 | wrapProgram $out/bin/lesspipe.sh \ | 19 | wrapProgram $out/bin/lesspipe.sh \ |
20 | --prefix PATH : ${final.python3.pkgs.pygments}/bin:${final.file}/bin:${final.ncurses}/bin | 20 | --prefix PATH : ${prev.lib.makeBinPath (with final; [ file ncurses binutils ])} |
21 | ''; | 21 | ''; |
22 | }; | 22 | }; |
23 | } | 23 | } |
diff --git a/user-profiles/utils.nix b/user-profiles/utils.nix index 13eb6033..4b7c4d0f 100644 --- a/user-profiles/utils.nix +++ b/user-profiles/utils.nix | |||
@@ -1,19 +1,6 @@ | |||
1 | { userName, lib, pkgs, config, ... }: | 1 | { userName, lib, pkgs, config, ... }: |
2 | let | 2 | let |
3 | cfg = config.home-manager.users.${userName}; | 3 | cfg = config.home-manager.users.${userName}; |
4 | |||
5 | wrappedLess = pkgs.less.overrideAttrs (oldAttrs: { | ||
6 | pname = "${oldAttrs.pname or "less"}-wrapper"; | ||
7 | |||
8 | nativeBuildInputs = (oldAttrs.nativeBuildInputs or []) ++ (with pkgs; [makeWrapper]); | ||
9 | |||
10 | postInstall = '' | ||
11 | ${oldAttrs.postInstall or ""} | ||
12 | |||
13 | wrapProgram $out/bin/less \ | ||
14 | --prefix PATH : ${lib.makeBinPath (with pkgs; [binutils])} | ||
15 | ''; | ||
16 | }); | ||
17 | in { | 4 | in { |
18 | home-manager.users.${userName} = { | 5 | home-manager.users.${userName} = { |
19 | programs = { | 6 | programs = { |
@@ -55,10 +42,12 @@ in { | |||
55 | }; | 42 | }; |
56 | 43 | ||
57 | jq.enable = true; | 44 | jq.enable = true; |
45 | |||
46 | lesspipe.enable = true; | ||
58 | }; | 47 | }; |
59 | 48 | ||
60 | home.sessionVariables = { | 49 | home.sessionVariables = { |
61 | LESSCOLORIZER = "pygmentize -O style=rrt"; | 50 | LESSCOLORIZER = "${lib.getExe' pkgs.python3Packages.pygments "pygmentize"} -O style=rrt"; |
62 | }; | 51 | }; |
63 | 52 | ||
64 | home.packages = with pkgs; [ | 53 | home.packages = with pkgs; [ |
@@ -67,7 +56,7 @@ in { | |||
67 | psmisc mosh tree vnstat file pv bc zip nmap aspell | 56 | psmisc mosh tree vnstat file pv bc zip nmap aspell |
68 | aspellDicts.de aspellDicts.en borgbackup man-pages rsync socat | 57 | aspellDicts.de aspellDicts.en borgbackup man-pages rsync socat |
69 | inetutils yq cached-nix-shell persistent-nix-shell rage | 58 | inetutils yq cached-nix-shell persistent-nix-shell rage |
70 | smartmontools hdparm nix-output-monitor wrappedLess dscp | 59 | smartmontools hdparm nix-output-monitor less dscp |
71 | iputils | 60 | iputils |
72 | ]; | 61 | ]; |
73 | }; | 62 | }; |