summaryrefslogtreecommitdiff
path: root/accounts
diff options
context:
space:
mode:
authorGregor Kleen <gkleen@yggdrasil.li>2025-05-02 16:15:52 +0200
committerGregor Kleen <gkleen@yggdrasil.li>2025-05-02 16:15:52 +0200
commitb37371a61aa9f6ec3f4e4e4b118a9d06f3689b5e (patch)
tree09c76f10f6767c8867bc2bd092b5f4844e197a6a /accounts
parentc22c3cf38fc94429480082c4225702b28d48c134 (diff)
downloadnixos-b37371a61aa9f6ec3f4e4e4b118a9d06f3689b5e.tar
nixos-b37371a61aa9f6ec3f4e4e4b118a9d06f3689b5e.tar.gz
nixos-b37371a61aa9f6ec3f4e4e4b118a9d06f3689b5e.tar.bz2
nixos-b37371a61aa9f6ec3f4e4e4b118a9d06f3689b5e.tar.xz
nixos-b37371a61aa9f6ec3f4e4e4b118a9d06f3689b5e.zip
...
Diffstat (limited to 'accounts')
-rw-r--r--accounts/gkleen@sif/default.nix85
-rw-r--r--accounts/gkleen@sif/zshrc62
2 files changed, 101 insertions, 46 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
237nix-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
247swap() { 223swap() {
248 f1=${1} 224 f1=${1}
249 f2=${2} 225 f2=${2}