aboutsummaryrefslogtreecommitdiffhomepage
path: root/org/config_nix.org
blob: 86c61eecca3f2846d3817ab24d82da9bf3fcfd06 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
-*- mode: org -*-
#+TITLE:       configuration nix
#+DESCRIPTION: makefile for spine
#+FILETAGS:    :spine:build:tools:
#+AUTHOR:      Ralph Amissah
#+EMAIL:       [[mailto:ralph.amissah@gmail.com][ralph.amissah@gmail.com]]
#+COPYRIGHT:   Copyright (C) 2015 - 2022 Ralph Amissah
#+LANGUAGE:    en
#+STARTUP:     content hideblocks hidestars noindent entitiespretty
#+PROPERTY:    header-args  :exports code
#+PROPERTY:    header-args+ :noweb yes
#+PROPERTY:    header-args+ :results no
#+PROPERTY:    header-args+ :cache no
#+PROPERTY:    header-args+ :padline no
#+PROPERTY:    header-args+ :mkdirp yes
#+OPTIONS:     H:3 num:nil toc:t \n:t ::t |:t ^:nil -:t f:t *:t

* nix :nix:

#+NAME: nixpkgs_local
#+BEGIN_SRC sh
/nixpkgs-ra/nixpkgs
#+END_SRC

** NOTES
*** nix-shell

- default.nix

#+BEGIN_SRC sh
nix-shell
nix-build
#+END_SRC

- project.nix

#+BEGIN_SRC sh
nix-shell
nix-build project.nix
#+END_SRC

*** nix-shell --pure

- default.nix

#+HEADER: :noweb yes
#+BEGIN_SRC sh
nix-shell --pure
nix-build -I nixpkgs=<<nixpkgs_local>>
nix-build -I .envrc
#+END_SRC

#+BEGIN_SRC sh
nix build -f default.nix --print-build-logs
nix build -f derivation.nix --print-build-logs
nix shell -f default.nix --print-build-logs
# nix build -f project.nix
# nix build -f spine.nix
nix develop --build -f derivation.nix -I .envrc --print-build-logs
#+END_SRC

*** derivation .drv

#+BEGIN_SRC sh
nix show-derivation /nix/store/q7n14bm8j5vzm62qaraczdb4bpyf59vv-spine-0.11.1.drv
#+END_SRC

** spine

- default.nix
- shell.nix

*** envrc :envrc:
**** .envrc

- https://github.com/nix-community/nix-direnv
  - source_url "https://raw.githubusercontent.com/nix-community/nix-direnv/${NixDirEnvVersion}/direnvrc" "sha256-0000000000000000000000000000000000000000000="

#+HEADER: :tangle ../.envrc
#+BEGIN_SRC sh
use flake .
NIX_ENFORCE_PURITY=1
NixDirEnvVersion="2.1.2"
if ! has nix_direnv_version || ! nix_direnv_version ${NixDirEnvVersion}; then
# - https://github.com/nix-community/nix-direnv
# source_url "https://raw.githubusercontent.com/nix-community/nix-direnv/${NixDirEnvVersion}/direnvrc" "sha256-0000000000000000000000000000000000000000000="
  source_url "https://raw.githubusercontent.com/nix-community/nix-direnv/${NixDirEnvVersion}/direnvrc" "sha256-ytpQmMcUBR2czh8kGOqn/dmD6u55m3lDbeu/G8HGD7A="
fi
if [ -f .envrc-local ]; then
  source_env_if_exists .envrc-local || source .envrc-local
fi
#+END_SRC

- lorri?

#+HEADER: :NO-tangle ../.envrc
#+BEGIN_SRC sh
if type lorri &>/dev/null; then
  echo "direnv: using lorri from PATH ($(type -p lorri))"
  # eval "$(lorri direnv)"
else # fallback prevent bootstrapping problems by using direnv's builtin nix support
  use nix
  NIX_ENFORCE_PURITY=0
fi
if [ -f .envrc-local ]; then
  source_env_if_exists .envrc-local || source .envrc-local
fi
#+END_SRC

- enable flakes

#+HEADER: :NO-tangle ../.envrc
#+BEGIN_SRC sh
if [ -f flake.lock ] && [ -f flake.nix ]; then
    # reload when these files change
    watch_file flake.nix
    watch_file flake.lock
    # load the flake devShell
    if [ ! -d $(direnv_layout_dir) ]; then
        mkdir $(direnv_layout_dir)
    fi
    eval "$(nix --experimental-features 'nix-command flakes' print-dev-env --profile "$(direnv_layout_dir)/flake-profile")"
else
    # fall back to using direnv's builtin nix support
    # to prevent bootstrapping problems.
  #  use nix
  if type lorri &>/dev/null; then
      echo "direnv: using lorri from PATH ($(type -p lorri))"
      eval "$(lorri direnv)"
  else
      # fall back to using direnv's builtin nix support
      # to prevent bootstrapping problems.
      use nix
      NIX_ENFORCE_PURITY=0
  fi
  if [ -f .envrc-local ]; then
    source_env_if_exists .envrc-local || source .envrc-local
  fi
fi
#+END_SRC

**** .envrc-local CHECK MODIFY

- bespoke modify appropriately and generate if needed

#+HEADER: :tangle ../.envrc-local_
#+HEADER: :noweb yes
#+BEGIN_SRC nix
echo ".envrc called .envrc-local"
PATH_add result/bin
export NIX_PATH=/nix/var/nix/profiles/per-user/root/channels/nixos
#export NIX_PATH=nixpkgs=/nixpkgs/nixpkgs
#export NIX_PATH=/nixpkgs/nixpkgs
export DFLAGS="-O2 -inline -boundscheck=on -color=on"
# reload when these files change
# watch_file flake.nix
# watch_file flake.lock
## load the flake devShell
# eval "$(nix print-dev-env)"
# echo $NIX_BUILD_TOP
export Date=`date "+%Y%m%d"`
export SpineVER=$(git describe --long --tags | sed 's/^[ a-z_-]\+\([0-9.]\+\)/\1/;s/\([^-]*-g\)/r\1/;s/-/./g')
export SpinePROJ=~/grotto/repo/git.repo/projects/project-spine/doc-reform
export SpineSRC=$SpinePROJ/src
export SpineBIN=$SpinePROJ/result/bin
export SpineDOC=~/grotto/repo/git.repo/projects/project-spine/doc-reform-markup/spine-markup-samples
export SpinePOD=$SpineDOC/markup/pod
export SpineOUTversioned=/srv/www/spine/$SpineVER
export SpineOUT=/srv/www/spine
export SpineDBpath=/var/www/sqlite
#export SpineDBpath=/srv/www/spine/sqlite
export SpineSearchActionLocal='http://localhost/spine_search'
export SpineSearchActionRemote='https://sisudoc.org/spine_search'
export SpineCGIform='spine_search'
export SpineSQLdb='spine.search.db'
export PROG_VER_GIT="`git describe --long --tags | sed -e 's/^[ a-z_-]\+\([0-9.]\+\)/\1/;s/\([^-]*-g\)/r\1/;s/-/./g'`"
export PROG_VER_DECLARED="`cat ./views/version.txt | grep --color=never "enum" | sed 's/.\+(\([0-9]\+\),[ \t]\+\([0-9]\+\),[ \t]\+\([0-9]\+\)[ \t]*).\+/\1.\2.\3/g'`"
#direnv allow
#+END_SRC

**** .env/echo-nixNote CHECK MODIFY

#+HEADER: :tangle ../.env/echo-nixNote
#+BEGIN_SRC sh
echo '-*- mode: org -*-

,* nixpkgs path?

  # eval "$(nix print-dev-env)"
' > nixNote_.org

echo "  <nixpkgs> == `nix-instantiate --find-file nixpkgs`" >> nixNote_.org

echo '
,* nix build and show derivation

,#+BEGIN_SRC sh
nix-shell --pure

nix-build
nix build -f default.nix --print-build-logs
nix shell -f default.nix --print-build-logs
nix develop --build -f derivation.nix -I .envrc --print-build-logs

nix-instantiate | nix-build

nix-instantiate -I .envrc | nix-build -I .envrc
nix build `nix-instantiate`
nix build `nix-instantiate -I .envrc`

nix develop

nix-instantiate | nix show-derivation | jq
nix-instantiate -I .envrc | nix show-derivation -f derivation.nix -I .envrc | jq

nix-instantiate | nix show-derivation --recursive | jq
nix-instantiate -I .envrc | nix show-derivation -f derivation.nix --recursive -I .envrc | jq

nix search --json 2>/dev/null |jq
,#+END_SRC

,* version and build info

,#+BEGIN_SRC sh' >> nixNote_.org

echo 'spine version (git) == $SpineVER' >> nixNote_.org
echo "spine version (git) == $SpineVER" >> nixNote_.org
echo 'nix-instantiate == `nix-instantiate`' >> nixNote_.org
echo "nix-instantiate == `nix-instantiate`" >> nixNote_.org

echo "#+END_SRC

,* initialised shell variables

,#+BEGIN_SRC sh
SpineSRC=$SpineSRC
SpineDOC=$SpineDOC
SpinePOD=$SpinePOD
SpineOUTversioned=$SpineOUTversioned
SpineOUT=$SpineOUT
,#+END_SRC
" >> nixNote_.org

echo '* spine run instruction examples
,** parallelized tasks
,*** doc source

,#+BEGIN_SRC sh
$SpineBIN/spine --very-verbose --pod --source --output="$SpineOUTversioned" $SpinePOD/*
,#+END_SRC

,*** html & epub output

,#+BEGIN_SRC sh
$SpineBIN/spine --very-verbose --html --epub --output="$SpineOUTversioned" $SpinePOD/*
,#+END_SRC

,*** sqlite db for each document - populate each db

,#+BEGIN_SRC sh
$SpineBIN/spine --very-verbose --sqlite-discrete --output="$SpineOUTversioned" $SpinePOD/*
,#+END_SRC

,*** doc source; html, epub; sqlite outputs

,#+BEGIN_SRC sh
$SpineBIN/spine --verbose --pod --html --epub --sqlite-discrete --output="$SpineOUTversioned" $SpinePOD/*
,#+END_SRC

,*** curate (authors topics)

,#+BEGIN_SRC sh
$SpineBIN/spine --very-verbose --curate --output="$SpineOUTversioned" $SpinePOD/*
,#+END_SRC

,*** html, curate

,#+BEGIN_SRC sh
$SpineBIN/spine --verbose --dark --html --html-link-curate --curate --output="$SpineOUTversioned" $SpinePOD/*
$SpineBIN/spine --very-verbose --html --html-link-curate --curate --output="$SpineOUTversioned" $SpinePOD/*
,#+END_SRC

,*** composite command: source pod, html, epub, curate, sqlite

,#+BEGIN_SRC sh
$SpineBIN/spine --verbose --dark --pod --epub --html --html-link-curate --curate --sqlite-discrete --output="$SpineOUTversioned" $SpinePOD/*
,#+END_SRC

,** sequential tasks
,*** sqlite db (shared) - create db

,#+BEGIN_SRC sh
$SpineBIN/spine --very-verbose --sqlite-db-create --output="$SpineOUTversioned"
,#+END_SRC

,*** sqlite db (shared) - populate db

,#+BEGIN_SRC sh
$SpineBIN/spine --very-verbose --sqlite-update --output="$SpineOUTversioned" $SpineDOC/spine-markup-samples/markup/pod/*
,#+END_SRC

,*** sqlite db (shared) - drop db

,#+BEGIN_SRC sh
$SpineBIN/spine --very-verbose --sqlite-db-drop --output="$SpineOUTversioned"
,#+END_SRC

,*** sqlite db (shared) - create & populate db (single step)

,#+BEGIN_SRC sh
$SpineBIN/spine --very-verbose --sqlite-db-create --sqlite-update --output="$SpineOUTversioned" $SpinePOD/*
,#+END_SRC

,*** composite command: source pod, html, epub, curate, sqlite

,#+BEGIN_SRC sh
$SpineBIN/spine --verbose --no-parallel --dark --pod --epub --html --html-link-curate --curate --sqlite-discrete --output="$SpineOUTversioned" $SpinePOD/*
,#+END_SRC

,** config [./pod/].dr/config_local_site

,#+BEGIN_SRC sh
cat $SpinePOD/.dr/config_local_site
$SpineBIN/spine --show-config $SpinePOD
$SpineBIN/spine --show-config --output="$SpineOUTversioned" $SpinePOD
,#+END_SRC

,** cgi operations (output to $SpineOUT /var/www)

,#+BEGIN_SRC sh
$SpineBIN/spine --very-verbose --sqlite-db-create --output="$SpineOUT" $SpinePOD/*

$SpineBIN/spine -v --cgi-search-form-codegen --output=$SpineOUT $SpinePOD/*

$SpineBIN/spine -v --show-config --config=$SpinePOD/.dr

$SpineBIN/spine --html $SpinePOD/*


$SpineBIN/spine -v --cgi-search-form-codegen --config=$SpinePOD/.dr/config_local_site
,#+END_SRC

,*** generate html linked to search form

,#+BEGIN_SRC sh
$SpineBIN/spine -v --html --html-link-search --html-link-curate --curate  --output=$SpineOUT $SpinePOD/*
,#+END_SRC

,*** create or re-create sql db (--sqlite-db-create or --sqlite-db-recreate)

,#+BEGIN_SRC sh
$SpineBIN/spine -v --sqlite-db-create --sqlite-db-filename="<<spine_search_db>>" --sqlite-db-path="$SpineDBpath"
$SpineBIN/spine -v --sqlite-db-recreate --sqlite-db-filename="<<spine_search_db>>" --sqlite-db-path="$SpineDBpath"
,#+END_SRC

,*** populate sqlite db

,#+BEGIN_SRC sh
$SpineBIN/spine -v --sqlite-update --sqlite-db-filename="<<spine_search_db>>" --output=$SpineOUT $SpinePOD/*
,#+END_SRC

,*** generate html (linked to search form), sql output, curate COMPOSITE

,#+BEGIN_SRC sh
$SpineBIN/spine -v --html --html-link-search --html-link-curate --curate --sqlite-update --sqlite-db-filename="<<spine_search_db>>" --cgi-sqlite-search-filename="<<spine_search_cgi>>" --sqlite-db-path="$SpineDBpath" --output="$SpineOUT" $SpinePOD/*
$SpineBIN/spine --epub --html --html-link-search --html-link-curate --curate --sqlite-update --sqlite-db-filename="spine.search.db" --cgi-sqlite-search-filename="spine_search" --cgi-url-action="https://sisudoc.org/spine_search" --ouput="$SpineOUT" $SpinePOD/*
,#+END_SRC

,*** generate html (linked to search form), sql output, curate COMPOSITE with resource configuration

if names and paths are configured in resource configuration file, e.g. $SpinePOD/.rc/config_local_site

,#+BEGIN_SRC sh
$SpineBIN/spine -v --html --html-link-search --html-link-curate --curate --sqlite-update $SpinePOD/*
,#+END_SRC

,#+BEGIN_SRC yaml
# sample resource configuration file ( $SpinePOD/.rc/config_local_site )
output:
  path:                        "/srv/www/spine"
default:
  language:                    "en"
  papersize:                   "a4"
  text_wrap:                   "80"
  digest:                      "sha256"
webserv:
  http:                        "http"
  domain:                      "localhost"
  data_http:                   "http"
  data_domain:                 "localhost"
  data_root_url:               "https://sisudoc.org"
  data_root_path:              "/srv/www/spine"
  images_root_part:            "image"
  cgi_search_form_title:       "≅ SiSU Spine search"
  cgi_http:                    "https"
  cgi_domain:                  "sisudoc.org"
  cgi_bin_url:                 "http://sisudoc.org/cgi-bin"
  cgi_bin_part:                "cgi-bin"
  cgi_bin_path:                "/var/www/cgi/cgi-bin"
  cgi_search_script:           "<<spine_search_cgi>>"
  cgi_action:                  "https://sisudoc.org/spine_search"
  db_sqlite_filename:          "<<spine_search_db>>"
  db_sqlite_path:              "/var/www/sqlite"
,#+END_SRC

,*** make search form

,#+BEGIN_SRC sh
$SpineBIN/spine -v --cgi-search-form-codegen --config=$SpinePOD/.dr/config_local_site
,#+END_SRC

,*** latex

,#+BEGIN_SRC sh
$SpineBIN/spine --latex --serial --output="$SpineOUT" $SpinePOD/*
ls $SpineOutstatic/latex/*.tex
,#+END_SRC
' >> nixNote_.org

#cat nixNote_.org

#echo "emacs nixNote_.org"
#echo "cat nixNote_.org"
#+END_SRC

*** makefile

#+HEADER: :tangle ../makefile_
#+BEGIN_SRC make
buildPhase:
	HOME=$${PWD}; \
	for DC_ in dmd ldmd2 gdmd; do \
	  echo "- check for D compiler $${DC_}"; \
	  DC=$$(type -P $${DC_} || echo ""); \
	  if [ ! "$${DC}" == "" ]; then \
	    break; \
	  fi; \
	done; \
  echo "D compiler = $${DC}"; \
	if [ "$${DC}" == "" ]; then \
    echo "Error: could not find D compiler"; \
	  exit 1; \
	fi; \
	echo "$${DC_} used as D compiler to build $${pname}"; \
	export DFLAGS="-O2 -inline"; \
	dub build --compiler=$${DC} --build=release --combined --skip-registry=all;
checkPhase:
	runHook preCheck; \
	HOME=$${PWD}; \
	dub test --combined --skip-registry=all; \
	runHook postCheck
installPhase:
	runHook preInstall; \
	mkdir -p $${out}/bin; \
	install -m755 ./bin/spine $${out}/bin/spine; \
	runHook postInstall
	#cp -r bin/spine $out/bin/.
postInstall:
	echo "$${out}/share/cgi-bin"; \
	echo `ls -la $${out}/bin/spine`
#+END_SRC

*** flake :flake:

- flake.nix
    /nixpkgs-ra/nixpkgs
    ./shell.nix
  - shell.nix
      ./pkgs/shell-pkgs.nix
    - pkgs/shell-pkgs.nix
  - default.nix
     ./nix/dub.selections.nix #
    - dub.selections.nix

- nix develop

- nix flake update

- nix shell -f default.nix --print-build-logs
- nix shell -c default.nix

- nix build `nix-instantiate`
- nix build -f default.nix --print-build-logs
- nix shell -f default.nix --print-build-logs
- nix develop --build -f derivation.nix -I .envrc --print-build-logs

- nix search --json 2>/dev/null |jq
- nix flake show
- nix show-derivation

# nix-instantiate | nix-build

#+HEADER: :tangle ../flake.nix
#+HEADER: :noweb yes
#+BEGIN_SRC nix
{
  description = "a sisu like parser and document generator";
  inputs.flake-utils.url = "github:numtide/flake-utils";
  inputs.nixpkgs.url = "github:nixos/nixpkgs";
  #inputs.nixpkgs.url = "/nixpkgs-ra/nixpkgs";
  outputs = { self, nixpkgs, flake-utils }: {
    packages.x86_64-linux.spine =
      let
        pkgs = import nixpkgs {
          system = "x86_64-linux";
        };
        #targetOf = package: "${package.targetPath or "."}/${package.targetName or package.name}";
      in pkgs.stdenv.mkDerivation {
        pname       = "spine";
        version     = "<<spine_version_set>>";
        description = "a sisu like parser and document generator";
        inherit self;
        src = self;
        shell = ./shell.nix;
        buildPhase = ''
          runHook preBuild
          HOME="$PWD"
          DFLAGS="-O2 -inline"
          for DC_ in dmd ldmd2 gdmd; do
            echo "- check for D compiler $DC_"
            DC=$(type -P $DC_ || echo "")
            if [ ! "$DC" == "" ]; then break; fi
          done
          if [ "$DC" == "" ]; then
            exit "Error: could not find D compiler"
          fi
          echo "$DC_ used as D compiler to build $pname"
          dub build --compiler=$DC --build=release --combined --skip-registry=all
          runHook postBuild
        '';
        checkPhase = ''
          runHook preCheck
          HOME="$PWD"
          dub test --combined --skip-registry=all
          runHook postCheck
        '';
        installPhase = ''
          runHook preInstall
          mkdir -p $out/bin
          install -m755 ./bin/spine $out/bin/spine
          #cp -r bin/spine $out/bin/.
          runHook postInstall
        '';
        postInstall = ''
          echo `ls -la $out/bin/spine`
          echo ""
          echo "nix build or nix develop? (suggestions):"
          echo '- nix build'
          echo '  nix build .#spine --print-build-logs'
          echo '    nix build --print-build-logs'
          echo '- nix run'
          echo '  nix run .#spine --print-build-logs'
          echo '  nix run default.nix --print-build-logs'
          echo '- nix shell'
          echo '  nix shell --print-build-logs --command spine -v'
          echo '- nix develop'
          echo '  nix develop --build -f derivation.nix -I .envrc --print-build-logs'
          echo '    nix develop ; eval "$buildPhase"'
          echo 'spine -v'
          echo 'nix-instantiate | nix show-derivation | jq'
          echo `ls -la $out/bin/spine`
          echo "built:"
          $out/bin/spine -v
        '';
        nativeBuildInputs = with pkgs; [ ldc dub ];
        buildInputs = with pkgs; [ sqlite ];
     };
     packages.x86_64-linux.default = self.packages.x86_64-linux.spine;
  };
}

#nix flake update
#nix flake check
#nix flake show
#nix develop
#nix build .#default --print-build-logs
#+END_SRC

#+BEGIN_SRC nix
src = fetchTarball {
  url       = "file:///[path]/$(pname)-$(version).tar.gz";
  sha256    = "sha256:0000000000000000000000000000000000000000000000000000";
};
#+END_SRC
#+HEADER: :noweb yes
#+BEGIN_SRC nix
{
  description = "a sisu like parser & document generator";
  inputs = {
    flake-utils.url = "github:numtide/flake-utils";
    nixpkgs.url = "<<nixpkgs_url>>";
  };
  outputs = { self, nixpkgs, flake-utils }:
  let
    pkgs = nixpkgs.legacyPackages.x86_64-linux;
  in {
    packages.x86_64-linux.spine = pkgs.stdenv.mkDerivation {
      name = "spine";
      inherit self;
      src = self;
      shell = ./shell.nix;
      installPhase = ''
         install -m755 spine $out/bin/spine
      '';
    };
    defaultPackage.x86_64-linux = self.packages.x86_64-linux.spine;
  };
}
#+END_SRC

#+HEADER: :noweb yes
#+BEGIN_SRC nix
{
  description = "a sisu like document parser";
  inputs = {
    flake-utils.url = "github:numtide/flake-utils";
    nixpkgs.url = "<<nixpkgs_url>>";
    d2sqlite3 = {
      url    = "github:dlang-community/d2sqlite3";
      flake  = false;
    };
    tinyendian = {
      url    = "github:kiith-sa/tinyendian";
      flake  = false;
    };
    dyaml = {
      url    = "github:dlang-community/D-YAML";
      flake  = false;
    };
    imageformats = {
      url    = "github:lgvz/imageformats";
      flake  = false;
    };
  };
  outputs = { self, d2sqlite3, tinyendian, dyaml, imageformats, nixpkgs, flake-utils }:
  let
    pkgs = nixpkgs.legacyPackages.x86_64-linux;
  in {
    packages.x86_64-linux.spine = pkgs.stdenv.mkDerivation {
      name = "spine";
      inherit self;
      src = self;
      shell = ./shell.nix;
      installPhase = ''
         install -m755 spine $out/bin/spine
      '';
    };
    defaultPackage.x86_64-linux = self.packages.x86_64-linux.spine;
  };
}
#+END_SRC

*** shell.nix :shell:
**** tangle

#+HEADER: :tangle ../shell.nix
#+HEADER: :tangle-mode (identity #o755)
#+HEADER: :shebang "#!/usr/bin/env -S nix-shell --pure\n#!nix-shell -i bash"
#+HEADER: :noweb yes
#+BEGIN_SRC nix
{ pkgs ? import <nixpkgs> {} }:
with pkgs;
mkShell {
  buildInputs = [
    direnv
    nixVersions.unstable #nixFlakes
    nix-prefetch-git
    validatePkgConfig
    nix-tree jq nix-output-monitor
    git
    ps
    ### d_build_related
    dub
    ## compiler
    ldc
    rund
    ## linker
    #lld
    #mold
    ## builder
    #ninja
    #meson
    ### sqlite search related
    sqlite
    # ### pdf_latex_related
    # source-sans-pro
    # source-serif-pro
    # source-code-pro
    # texlive.combined.scheme-full
    # ### xml_and_epub_related
    # libxml2
    # html-tidy
    # xmlstarlet
    # epubcheck
    # ebook_tools
    # epr
    # sigil
    # calibre #(suite includes: ebook-viewer)
    # foliate
    # ### i18n translation related
    # perl534Packages.Po4a
    ### candy
    starship
  ];
  shellHook = ''
    #if [[ -f ".envrc" ]]; then
    #  source .envrc
    #fi
    nix flake update
    echo ""
    echo "nix flake metadata:"
    nix flake metadata
    echo ""
    echo "nix flake check:"
    nix flake check
    echo ""
    echo "nix flake show:"
    nix flake show
    echo "
      nix flake update
      nix flake metadata
      nix flake check
      nix flake show

      nix build or nix develop? (suggestions):

      - nix build
        nix build .#default --print-build-logs
        nix build --print-build-logs
        nix build .#default --print-build-logs |& nom

      - nix run
        nix run .#spine --print-build-logs
        nix run default.nix --print-build-logs

      - nix shell
        nix shell --print-build-logs --command spine -v

      - nix develop
        nix develop --build  .#default --print-build-logs
        nix develop --build -f derivation.nix -I .envrc --print-build-logs
        nix develop ; eval \$buildPhase

        nix-build |& nom

      spine -v

      nix-instantiate | nix show-derivation | jq
      nix-build . --no-out-link | xargs -o nix-tree
      nix-tree --derivation .#spine

    "
    #echo "ldc `${pkgs.ldc}/bin/ldc2 -v`"
  '';
}
#+END_SRC

**** Notes

#+BEGIN_SRC text
#% Notes

# - shell.nix -I .envrc
# - shell.nix -I .envrc --pure

# [ nix-shell ]

  # - nix-shell -I nixpkgs=/nixpkgs-ra/nixpkgs --pure
  # - nix-shell -p "with import /nixpkgs-ra/nixpkgs {}; ldc" --pure
  # - nix-shell -p "with import /nixpkgs-ra/nixpkgs {}; [dub ldc]" --pure

  # - nix-shell -p nixVersions.unstable #nixFlakes
  # - nix-shell -p nixFlakes --pure
  # - nix-shell -p nixFlakes --pure -p "with import /nixpkgs-ra/nixpkgs {}; [nix dub ldc git ps]"
  # - nix-shell shell.nix direnv: export +IN_NIX_SHELL
  # - nix-shell shell.nix

# [ nix-build ]

  # - nix-build -I nixpkgs=/nixpkgs-ra/nixpkgs # --pure
  # - nix-build -I .envrc --pure
  # - nix-build default.nix -I .envrc && result/bin/spine -v

# [ nix-instantiate ]

  # - nix-instantiate | nix show-derivation | jq
  # - nix-instantiate -I .envrc | nix show-derivation -f derivation.nix -I .envrc | jq
  # - nix-instantiate | nix show-derivation --recursive | jq
  # - nix-instantiate -I .envrc | nix show-derivation -f derivation.nix --recursive -I .envrc | jq
  # - nix-instantiate | nix-build
  # - nix-instantiate -I .envrc | nix-build -I .envrc

# [ nix shell ]

  # - nix shell -c default.nix
  # - nix shell -f default.nix --print-build-logs

# [ nix build ]

  # - nix build -I .envrc --print-build-logs
  # - nix build -f default.nix --print-build-logs
  # - nix build -f derivation.nix --print-build-logs

  # - nix build `nix-instantiate`
  # - nix build `nix-instantiate -I .envrc`

  # - nix build -f default.nix && ./result/bin/spine -v && noti -t "spine build" -m "see ./result/bin/spine"
  # - nix build .#spine

# [ nix run ]

  # - nix run default.nix --print-build-logs
  # - nix run -I .envrc default.nix --print-build-logs
  # - nix run .#spine

# - nix-shell -I .envrc --pure
# - nix develop --build -f derivation.nix -I .envrc --print-build-logs

# - nix-shell -p nixFlakes --pure -p "with import /nixpkgs-ra/nixpkgs {}; [nix dub ldc git ps]"
# - nix-build
# - nix build `nix-instantiate -I .envrc`

# - nix develop --build -f default.nix -I .envrc

# - nix-shell -I .envrc --pure
# - nix-build default.nix -I .envrc && result/bin/spine -v

# - nix shell -f default.nix --print-build-logs
# - nix-instantiate -I .envrc | nix-build -I .envrc
#+END_SRC

#+BEGIN_SRC text
#% Notes
- nix-shell

- shell.nix --pure
- shell.nix --pure -I .envrc

- nix-shell --pure -I nixpkgs=<<nixpkgs_local>>
- nix-shell --pure -p "with import <<nixpkgs_local>> {}; ldc"
- nix-shell --pure -p "with import /nixpkgs-ra/nixpkgs {}; [dub ldc]"

- shell.nix direnv: export +IN_NIX_SHELL

- nix-shell -p nixFlakes
- nix-shell -p nixFlakes --pure
- nix-shell -p nixFlakes --pure -p "with import /nixpkgs-ra/nixpkgs {}; [dub ldc]"

- shell.nix -I .envrc
- nix-shell -I nixpkgs=<provide local nix path>
- nix-shell -I nixpkgs=<provide local nix path> --pure
- shell.nix
- nix-shell shell.nix --pure

- nix shell -c default.nix

- nix run default.nix --print-build-logs
- nix run -I .envrc default.nix --print-build-logs

- nix develop

- nix-build -I nixpkgs=<provide local nix path>
- nix-build -I .envrc

- nix build -f default.nix --print-build-logs
- nix build -f derivation.nix --print-build-logs
- nix build -I .envrc --print-build-logs
- nix shell -f default.nix --print-build-logs
- nix develop --build -f derivation.nix -I .envrc --print-build-logs

- buildPhase

- nix build -f default.nix && noti
- nix build -f default.nix && ./result/bin/spine -v && noti -t "spine build" -m "see ./result/bin/spine"
- nix develop --build -f derivation.nix -I .envrc --print-build-logs

  ./result/bin/spine
#+END_SRC

**** parts
***** packages nix related

#+NAME: shell_packages_nix_related
#+BEGIN_SRC nix
### nix_related
direnv
nixVersions.unstable #nixFlakes
nix-prefetch-git
validatePkgConfig
jq
git
ps
#+END_SRC

***** packages d build related

#+NAME: shell_packages_d_build_related
#+BEGIN_SRC nix
### d_build_related
## package manager
dub
## compiler
ldc
rund
## linker
#lld
#mold
## builder
#ninja
#meson
#+END_SRC

***** packages tools

#+NAME: shell_packages_tool_download
#+BEGIN_SRC nix
### tools
#curl
#wget
aria
#+END_SRC

***** packages candy

#+NAME: shell_packages_candy
#+BEGIN_SRC nix
### candy
starship
#+END_SRC

***** packages search sqlite related

#+NAME: shell_packages_search_related_sqlite
#+BEGIN_SRC nix
### sqlite search related
sqlite
#+END_SRC

***** packages pdf latex related

#+NAME: shell_packages_pdf_latex_related
#+BEGIN_SRC nix
### pdf_latex_related
source-sans-pro
source-serif-pro
source-code-pro
texlive.combined.scheme-full
#+END_SRC

***** packages xml epub related

#+NAME: shell_packages_xml_and_epub_related
#+BEGIN_SRC nix
### xml_and_epub_related
libxml2
html-tidy
xmlstarlet
epubcheck
ebook_tools
epr
sigil
calibre #(suite includes: ebook-viewer)
foliate
#+END_SRC

***** packages i18n_translation related

#+NAME: shell_packages_i18n_translation
#+BEGIN_SRC nix
### i18n translation related
perl534Packages.Po4a
#+END_SRC

**** misc

#+HEADER: :NO-tangle ../shell.nix
#+HEADER: :tangle-mode (identity #o755)
#+HEADER: :shebang "#!/usr/bin/env -S nix-shell"
#+BEGIN_SRC nix
{ pkgs ? import <nixpkgs> {} }:
pkgs.mkShell {
  buildInputs = with pkgs; [
    (import ./nix/pkglst/shell-pkgs.nix { inherit pkgs; })
  ];
  buildPhase = "nix build -f default.nix";
  shellHook = ''
    echo "built spine @ ./result/bin/spine"
    if [[ -f ".envrc" ]]; then
      source .envrc
    fi
    nix-instantiate | nix show-derivation | jq
  '';
}
#+END_SRC

*** default.nix :default:

- default.nix -I nixpkgs=<provide local nix path>
  e.g. default.nix -I nixpkgs=/nixpkgs-ra/nixpkgs

- nix-build -I nixpkgs=<provide local nix path>
  e.g. nix-build -I nixpkgs=<<nixpkgs_local>>

#+HEADER: :noweb yes
#+BEGIN_SRC sh
nix-build -I nixpkgs=<<nixpkgs_local>>
nix-build -I .envrc-local
nix-build -I .envrc
default.nix -I .envrc
default.nix

nix build -f default.nix --print-build-logs
nix build -f derivation.nix --print-build-logs
nix shell -f default.nix --print-build-logs
nix develop --build -f derivation.nix -I .envrc --print-build-logs

# nix build -f project.nix
# nix build -f spine.nix
#+END_SRC

#+HEADER: :tangle ../default.nix
#+HEADER: :tangle-mode (identity #o755)
#+HEADER: :shebang "#!/usr/bin/env -S nix-build"
#+BEGIN_SRC nix
{ pkgs ? import <nixpkgs> {} }:
pkgs.callPackage ./derivation.nix {}
#+END_SRC

*** derivation.nix :default:

#+HEADER: :tangle ../derivation.nix
#+HEADER: :tangle-mode (identity #o644)
#+HEADER: :noweb yes
#+BEGIN_SRC nix
{ pkgs ? import <nixpkgs> {},
  stdenv ? pkgs.stdenv,
  lib ? pkgs.lib,
  ldc ? null,
  dcompiler ? pkgs.ldc,
  dub ? pkgs.dub
}:
assert dcompiler != null;
with (
  with lib;
  let
    filterDub = name: type: let baseName = baseNameOf (toString name); in ! ( # filter function to remove the .dub package folder from src
      type == "directory" && baseName == ".dub"
    );
    targetOf = package: "${package.targetPath or "."}/${package.targetName or package.name}";
    # remove reference to build tools and library sources
    disallowedReferences = deps: [ dcompiler dub ];
    removeExpr = refs: ''remove-references-to ${lib.concatMapStrings (ref: " -t ${ref}") refs}'';
  in {
    mkDubDerivation = lib.makeOverridable ({
      src,
      nativeBuildInputs ? [],
      dubJSON ? src + "/dub.json",
      passthru ? {},
      package ? lib.importJSON dubJSON,
      ...
    } @ attrs: stdenv.mkDerivation (attrs // {
      pname = package.name;
      nativeBuildInputs = [ dcompiler dub pkgs.removeReferencesTo ] ++ nativeBuildInputs;
      disallowedReferences = disallowedReferences deps;
      passthru = passthru // {
        inherit dub dcompiler pkgs;
      };
      src = lib.cleanSourceWith {
        filter = filterDub;
        src = lib.cleanSource src;
      };
      preFixup = ''
        find $out/bin -type f -exec ${removeExpr (disallowedReferences deps)} '{}' + || true
      '';
      buildPhase = ''
        runHook preBuild
        HOME="$PWD"
        DFLAGS="-O2 -inline"
        for DC_ in dmd ldmd2 gdmd; do
          echo "- check for D compiler $DC_"
          DC=$(type -P $DC_ || echo "")
          if [ ! "$DC" == "" ]; then
            break
          fi
        done
        if [ "$DC" == "" ]; then
          exit "Error: could not find D compiler"
        fi
        echo "$DC_ used as D compiler to build $pname"
        dub build --compiler=$DC --build=release --combined --skip-registry=all
        runHook postBuild
      '';
      checkPhase = ''
        runHook preCheck
        HOME="$PWD"
        dub test --combined --skip-registry=all
        runHook postCheck
      '';
      installPhase = ''
        runHook preInstall
        mkdir -p $out/bin
        cp -r "${targetOf package}" $out/bin
        runHook postInstall
      '';
      meta = lib.optionalAttrs (package ? description) {
        description = package.description;
      } // attrs.meta or {};
    } // lib.optionalAttrs (!(attrs ? version)) {
      name = package.name; # use name from dub.json, unless pname and version are specified
    }));
  }
);
mkDubDerivation rec {
  pname         = "spine";
  version       = "<<spine_version_set>>";
  src           = ./.;
  nativeBuildInputs = with pkgs; [ dub ldc ];
  buildInputs = with pkgs; [ nixVersions.unstable sqlite ];
  meta = with pkgs.lib; {
    description = "A sisu like parser and document generator";
    longDescription = ''
      A sisu like parser and document generator
    '';
    homepage    = "https://sisudoc.org";
    license     = licenses.agpl3Plus;
    platforms   = platforms.linux;
    maintainers = [ "RalphAmissah" ];
  };
}
#+END_SRC

- unused
  - installPhase

#+BEGIN_SRC txt
installPhase = ''
  mkdir -p $out/bin
  cp spine $out/bin
  chmod +x $out/bin/spine
'';
#+END_SRC

*** project meta

#+NAME: nix_project_meta
#+HEADER: :noweb yes
#+BEGIN_SRC nix
meta = with pkgs.lib; {
  pname       = "spine";
  version     = "<<spine_version_set>>";
  description = "a sisu like document parser";
  longDescription = ''
    A sisu like parser and document generator
  '';
  homepage    = "https://sisudoc.org";
  license     = licenses.agpl3Plus;
  platforms   = platforms.linux;
  maintainers = [ "RalphAmissah" ];
};
#+END_SRC

*** dub.selections.json

#+HEADER: :NO-tangle ../dub.selections.json
#+BEGIN_SRC nix
{
	"fileVersion": 1,
	"versions": {
		"d2sqlite3": "0.19.1",
		"dyaml": "0.8.3",
		"imageformats": "7.0.2",
		"tinyendian": "0.2.0"
	}
}
#+END_SRC

*** dub.selections.nix

#+HEADER: :NO-tangle ../nix/dub.selections.nix
#+BEGIN_SRC nix
# This file was generated by https://github.com/lionello/dub2nix v0.2.3
[ {
  fetch = {
    type = "git";
    url = "https://github.com/dlang-community/d2sqlite3.git";
    rev = "v0.19.1";
    sha256 = "0rnsgla6xyr8r34knf7v6dwhacra96q1b5rhxcz9246inwhvrk5k";
    fetchSubmodules = false;
    date = "2020-07-21T12:32:51+02:00";
    deepClone = false;
    leaveDotGit = false;
    path = "/nix/store/hsi8xvl15w6fwlqvs042m1z5i88yc72i-d2sqlite3";
  };
} {
  fetch = {
    type = "git";
    url = "https://github.com/kiith-sa/tinyendian.git";
    rev = "v0.2.0";
    sha256 = "086gf5aga52wr5rj2paq54daj8lafn980x77b706vvvqaz2mlis8";
    fetchSubmodules = false;
    date = "2018-06-10T11:04:28+02:00";
    deepClone = false;
    leaveDotGit = false;
    path = "/nix/store/9c7fsmi5am84j6dq2mp3va306x3ay291-tinyendian";
  };
} {
  fetch = {
    type = "git";
    url = "https://github.com/kiith-sa/D-YAML.git";
    rev = "v0.8.3";
    sha256 = "13wy304xjbwkpgg7ilql1lkxkm83s87jm59ffnrg26slp7cx149q";
    fetchSubmodules = false;
    date = "2020-09-19T23:46:57+02:00";
    deepClone = false;
    leaveDotGit = false;
    path = "/nix/store/3i8i56lkmw2xq3lxr5h66v909waq2mqg-D-YAML";
  };
} {
  fetch = {
    type = "git";
    url = "https://github.com/lgvz/imageformats.git";
    rev = "v7.0.2";
    sha256 = "1mfbsmi4fs1xny4zqs6jyr04d5f4h03r9f6jadvkdqj5kd1k0ws7";
    fetchSubmodules = false;
    date = "2019-10-10T07:54:45+03:00";
    deepClone = false;
    leaveDotGit = false;
    path = "/nix/store/wn554pn21nzmpvw2hs7hvv9v9y0sgarg-imageformats";
  };
} ]
#+END_SRC

*** dub2nix & shared pkgs SHARED
**** dub2nix with pkgs shared

#+NAME: nix_with_pkgs
#+HEADER: :noweb yes
#+BEGIN_SRC nix
with pkgs; [
  <<nix_shell_with_pkgs_list>>
]
#+END_SRC

**** with pkgs list

#+NAME: nix_shell_with_pkgs_list
#+BEGIN_SRC nix
nixVersions.unstable #nixFlakes
rund
dub
ldc
sqlite
nix-prefetch-git
validatePkgConfig
jq
git
#+END_SRC

** variables
*** spine version SET VERSION :version:set:project:

#+NAME: spine_version_set
#+BEGIN_SRC sh
0.12.0
#+END_SRC

*** set names SET

#+NAME: spine_search_db
#+BEGIN_SRC sh
spine.search.db
#+END_SRC

#+NAME: spine_search_cgi
#+BEGIN_SRC sh
spine_search
#+END_SRC

*** nixpkgs_path SETUP
**** nixpkgs select path SELECT

#+NAME: nixpkgs_path
#+HEADER: :noweb yes
#+BEGIN_SRC nix
<<nixpkgs_path_local>>
#+END_SRC

**** nixpkgs path options

- <nixpkgs>

#+NAME: nixpkgs_path_default
#+HEADER: :noweb yes
#+BEGIN_SRC nix
<nixpkgs>
#+END_SRC

#+NAME: nix_path_directory
#+HEADER: :noweb yes
#+BEGIN_SRC nix
nixpkgs=<<nixpkgs_path_local>>
#+END_SRC

#+NAME: project_path_local_project
#+HEADER: :noweb yes
#+BEGIN_SRC nix
~/grotto/repo/git.repo/projects/project-spine/doc-reform
#+END_SRC

#+NAME: project_path_local_src
#+HEADER: :noweb yes
#+BEGIN_SRC nix
<<project_path_local_project>>/src
#+END_SRC

#+NAME: project_path_local_bin
#+HEADER: :noweb yes
#+BEGIN_SRC nix
<<project_path_local_project>>/result/bin
#+END_SRC

#+NAME: project_path_cgi_bin
#+BEGIN_SRC nix
/var/www/cgi/cgi-bin
#+END_SRC

#+NAME: project_path_local_doc
#+BEGIN_SRC nix
~/grotto/repo/git.repo/projects/project-spine/doc-reform-markup/spine-markup-samples
#+END_SRC

#+NAME: project_path_local_out
#+BEGIN_SRC nix
/srv/www/spine/$SpineVER
#+END_SRC

#+NAME: project_path_local_out_
#+HEADER: :noweb yes
#+BEGIN_SRC nix
/tmp/spine/$SpineVER/www
#+END_SRC

#+NAME: project_path_local_out_static
#+HEADER: :noweb yes
#+BEGIN_SRC nix
/srv/www/spine
#+END_SRC

#+NAME: project_path_local_out_static_
#+BEGIN_SRC nix
/var/www
#+END_SRC

#+NAME: project_path_sqlite
#+BEGIN_SRC nix
/var/www/sqlite
#+END_SRC

#+NAME: nixpkgs_url
#+BEGIN_SRC nix
github:nixos/nixpkgs
#+END_SRC

#+HEADER: :noweb yes
#+BEGIN_SRC nix
<<nixpkgs_path_local>>
#+END_SRC

- local path SET WARN

#+NAME: nixpkgs_path_local
#+BEGIN_SRC nix
/nixpkgs-ra/nixpkgs
#+END_SRC

**** project path options

- local path SET WARN

#+NAME: nix_path_channel
#+BEGIN_SRC nix
/nix/var/nix/profiles/per-user/root/channels/nixos
#+END_SRC

** texlive xetex xelatex shell.nix
*** shell.nix :shell:

#+BEGIN_SRC nix
#!/usr/bin/env -S nix-shell --pure
{ pkgs ? import <nixpkgs> {} }:
pkgs.mkShell {
  buildInputs = with pkgs; [
    nixVersions.unstable #nixFlakes
    nix-prefetch-git
    validatePkgConfig
    jq
    git
    fontconfig
    source-sans-pro
    source-serif-pro
    source-code-pro
    #(texlive.combine {
    #  inherit (texlive) scheme-tetex xetex fontspec footmisc multirow titlesec listings anysize float graphics helvetic times courier;
    #})
    texlive.combined.scheme-full
    dejavu_fonts dejavu_fontsEnv
    liberation_ttf
    evince
    zathura
    apvlv
  ];
    #FONTCONFIG_FILE = makeFontsConf { fontDirectories = [
    #  liberation_ttf
    #];
  shellHook = ''
    if [[ -f ".envrc" ]]; then
      source .envrc
    fi
    #for texfile in *.tex; do xelatex -interaction=nonstopmode $texfile; done
    #for texfile in *.tex; do xelatex -interaction=batchmode $texfile; done
  '';
}
#+END_SRC

*** notes

#+BEGIN_SRC sh
nix-shell --run 'which xetex'
echo 'for texfile in *.tex; do echo "* --> " ~ $texfile && xelatex -interaction=batchmode $texfile; rm *.aux *.log *.toc *.out; done'

$SpineBIN/spine --latex --serial --output="$SpineOUT" $SpinePOD/* && for texfile in $SpineOUT/latex/*.tex; do xelatex -interaction=nonstopmode $texfile; done 2>&1 | tee _err.xelatex_.org; ls $SpineOUT/latex/*.{tex,pdf}

/run/current-system/sw/share/X11/fonts/

kpsewhich pdftexconfig.tex
/nix/store/2r4qa8rbll085nmpx56jg1rbmbir1zkp-texlive-combined-2021/share/texmf/tex/generic/tex-ini-files/pdftexconfig.tex
/nix/store/2r4qa8rbll085nmpx56jg1rbmbir1zkp-texlive-combined-2021/share/texmf/fonts/opentype/public/

find: texclive-fonts.conf
fc-cache && mkfontscale && mkfontdir

fc-match LiberationSans

cd /nix/var/nix/profiles/system/sw/share/X11/fonts
fc-query LiberationSans-Regular.ttf | grep '^\s\+family:' | cut -d'"' -f2
Liberation Sans
fc-query LiberationMono-Regular.ttf | grep '^\s\+family:' | cut -d'"' -f2
Liberation Mono

fc-query DejaVuSans.ttf | grep '^\s\+family:' | cut -d'"' -f2

$XDG_DATA_HOME/fonts
~/.local/share/fonts
#+END_SRC