aboutsummaryrefslogtreecommitdiff
path: root/gnu/services/virtualization.scm
blob: 36e9feb05cad2f3ebbb2e0dee04f372b352a3878 (about) (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
;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2017 Ryan Moe <ryan.moe@gmail.com>
;;; Copyright © 2018, 2020 Ludovic Courtès <ludo@gnu.org>
;;; Copyright © 2020,2021 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
;;;
;;; This file is part of GNU Guix.
;;;
;;; GNU Guix is free software; you can redistribute it and/or modify it
;;; under the terms of the GNU General Public License as published by
;;; the Free Software Foundation; either version 3 of the License, or (at
;;; your option) any later version.
;;;
;;; GNU Guix is distributed in the hope that it will be useful, but
;;; WITHOUT ANY WARRANTY; without even the implied warranty of
;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;;; GNU General Public License for more details.
;;;
;;; You should have received a copy of the GNU General Public License
;;; along with GNU Guix.  If not, see <http://www.gnu.org/licenses/>.

(define-module (gnu services virtualization)
  #:use-module (gnu bootloader)
  #:use-module (gnu bootloader grub)
  #:use-module (gnu image)
  #:use-module (gnu packages admin)
  #:use-module (gnu packages gdb)
  #:use-module (gnu packages package-management)
  #:use-module (gnu packages ssh)
  #:use-module (gnu packages virtualization)
  #:use-module (gnu services base)
  #:use-module (gnu services configuration)
  #:use-module (gnu services dbus)
  #:use-module (gnu services shepherd)
  #:use-module (gnu services ssh)
  #:use-module (gnu services)
  #:use-module (gnu system file-systems)
  #:use-module (gnu system hurd)
  #:use-module (gnu system image)
  #:use-module (gnu system shadow)
  #:use-module (gnu system)
  #:use-module (guix derivations)
  #:use-module (guix gexp)
  #:use-module (guix modules)
  #:use-module (guix monads)
  #:use-module (guix packages)
  #:use-module (guix records)
  #:use-module (guix store)
  #:use-module (guix utils)

  #:use-module (srfi srfi-9)
  #:use-module (srfi srfi-26)
  #:use-module (rnrs bytevectors)
  #:use-module (ice-9 match)

  #:export (%hurd-vm-operating-system
            hurd-vm-configuration
            hurd-vm-configuration?
            hurd-vm-configuration-os
            hurd-vm-configuration-qemu
            hurd-vm-configuration-image
            hurd-vm-configuration-disk-size
            hurd-vm-configuration-memory-size
            hurd-vm-configuration-options
            hurd-vm-configuration-id
            hurd-vm-configuration-net-options
            hurd-vm-configuration-secrets

            hurd-vm-disk-image
            hurd-vm-port
            hurd-vm-net-options
            hurd-vm-service-type

            libvirt-configuration
            libvirt-service-type
            virtlog-configuration
            virtlog-service-type

            %qemu-platforms
            lookup-qemu-platforms
            qemu-platform?
            qemu-platform-name

            qemu-binfmt-configuration
            qemu-binfmt-configuration?
            qemu-binfmt-service-type))

(define (uglify-field-name field-name)
  (let ((str (symbol->string field-name)))
    (string-join
     (string-split (string-delete #\? str) #\-)
     "_")))

(define (quote-val val)
  (string-append "\"" val "\""))

(define (serialize-field field-name val)
  (format #t "~a = ~a\n" (uglify-field-name field-name) val))

(define (serialize-string field-name val)
  (serialize-field field-name (quote-val val)))

(define (serialize-boolean field-name val)
  (serialize-field field-name (if val 1 0)))

(define (serialize-integer field-name val)
  (serialize-field field-name val))

(define (build-opt-list val)
  (string-append
   "["
   (string-join (map quote-val val) ",")
   "]"))

(define optional-list? list?)
(define optional-string? string?)

(define (serialize-list field-name val)
  (serialize-field field-name (build-opt-list val)))

(define (serialize-optional-list field-name val)
  (if (null? val)
      (format #t "# ~a = []\n" (uglify-field-name field-name))
      (serialize-list field-name val)))

(define (serialize-optional-string field-name val)
  (if (string-null? val)
      (format #t "# ~a = \"\"\n" (uglify-field-name field-name))
      (serialize-string field-name val)))

(define-configuration libvirt-configuration
  (libvirt
   (package libvirt)
   "Libvirt package.")
  (listen-tls?
   (boolean #t)
   "Flag listening for secure TLS connections on the public TCP/IP port.
must set @code{listen} for this to have any effect.

It is necessary to setup a CA and issue server certificates before
using this capability.")
  (listen-tcp?
   (boolean #f)
   "Listen for unencrypted TCP connections on the public TCP/IP port.
must set @code{listen} for this to have any effect.

Using the TCP socket requires SASL authentication by default. Only
SASL mechanisms which support data encryption are allowed. This is
DIGEST_MD5 and GSSAPI (Kerberos5)")
  (tls-port
   (string "16514")
   "Port for accepting secure TLS connections This can be a port number,
or service name")
  (tcp-port
   (string "16509")
   "Port for accepting insecure TCP connections This can be a port number,
or service name")
  (listen-addr
   (string "0.0.0.0")
   "IP address or hostname used for client connections.")
  (mdns-adv?
   (boolean #f)
   "Flag toggling mDNS advertisement of the libvirt service.

Alternatively can disable for all services on a host by
stopping the Avahi daemon.")
  (mdns-name
   (string (string-append "Virtualization Host " (gethostname)))
   "Default mDNS advertisement name. This must be unique on the
immediate broadcast network.")
  (unix-sock-group
   (string "root")
   "UNIX domain socket group ownership. This can be used to
allow a 'trusted' set of users access to management capabilities
without becoming root.")
  (unix-sock-ro-perms
   (string "0777")
   "UNIX socket permissions for the R/O socket. This is used
for monitoring VM status only.")
  (unix-sock-rw-perms
   (string "0770")
   "UNIX socket permissions for the R/W socket. Default allows
only root. If PolicyKit is enabled on the socket, the default
will change to allow everyone (eg, 0777)")
  (unix-sock-admin-perms
   (string "0777")
   "UNIX socket permissions for the admin socket. Default allows
only owner (root), do not change it unless you are sure to whom
you are exposing the access to.")
  (unix-sock-dir
   (string "/var/run/libvirt")
   "The directory in which sockets will be found/created.")
  (auth-unix-ro
   (string "polkit")
   "Authentication scheme for UNIX read-only sockets. By default
socket permissions allow anyone to connect")
  (auth-unix-rw
   (string "polkit")
   "Authentication scheme for UNIX read-write sockets. By default
socket permissions only allow root. If PolicyKit support was compiled
into libvirt, the default will be to use 'polkit' auth.")
  (auth-tcp
   (string "sasl")
   "Authentication scheme for TCP sockets. If you don't enable SASL,
then all TCP traffic is cleartext. Don't do this outside of a dev/test
scenario.")
  (auth-tls
   (string "none")
   "Authentication scheme for TLS sockets. TLS sockets already have
encryption provided by the TLS layer, and limited authentication is
done by certificates.

It is possible to make use of any SASL authentication mechanism as
well, by using 'sasl' for this option")
  (access-drivers
   (optional-list '())
   "API access control scheme.

By default an authenticated user is allowed access to all APIs. Access
drivers can place restrictions on this.")
  (key-file
   (string "")
   "Server key file path. If set to an empty string, then no private key
is loaded.")
  (cert-file
   (string "")
   "Server key file path. If set to an empty string, then no certificate
is loaded.")
  (ca-file
   (string "")
   "Server key file path. If set to an empty string, then no CA certificate
is loaded.")
  (crl-file
   (string "")
   "Certificate revocation list path. If set to an empty string, then no
CRL is loaded.")
  (tls-no-sanity-cert
   (boolean #f)
   "Disable verification of our own server certificates.

When libvirtd starts it performs some sanity checks against its own
certificates.")
  (tls-no-verify-cert
   (boolean #f)
   "Disable verification of client certificates.

Client certificate verification is the primary authentication mechanism.
Any client which does not present a certificate signed by the CA
will be rejected.")
  (tls-allowed-dn-list
   (optional-list '())
   "Whitelist of allowed x509 Distinguished Name.")
  (sasl-allowed-usernames
   (optional-list '())
   "Whitelist of allowed SASL usernames. The format for username
depends on the SASL authentication mechanism.")
  (tls-priority
   (string "NORMAL")
   "Override the compile time default TLS priority string. The
default is usually \"NORMAL\" unless overridden at build time.
Only set this is it is desired for libvirt to deviate from
the global default settings.")
  (max-clients
   (integer 5000)
   "Maximum number of concurrent client connections to allow
over all sockets combined.")
  (max-queued-clients
   (integer 1000)
   "Maximum length of queue of connections waiting to be
accepted by the daemon. Note, that some protocols supporting
retransmission may obey this so that a later reattempt at
connection succeeds.")
  (max-anonymous-clients
   (integer 20)
   "Maximum length of queue of accepted but not yet authenticated
clients. Set this to zero to turn this feature off")
  (min-workers
   (integer 5)
   "Number of workers to start up initially.")
  (max-workers
   (integer 20)
   "Maximum number of worker threads.

If the number of active clients exceeds @code{min-workers},
then more threads are spawned, up to max_workers limit.
Typically you'd want max_workers to equal maximum number
of clients allowed.")
  (prio-workers
   (integer 5)
   "Number of priority workers. If all workers from above
pool are stuck, some calls marked as high priority
(notably domainDestroy) can be executed in this pool.")
  (max-requests
    (integer 20)
    "Total global limit on concurrent RPC calls.")
  (max-client-requests
    (integer 5)
    "Limit on concurrent requests from a single client
connection. To avoid one client monopolizing the server
this should be a small fraction of the global max_requests
and max_workers parameter.")
  (admin-min-workers
    (integer 1)
    "Same as @code{min-workers} but for the admin interface.")
  (admin-max-workers
     (integer 5)
    "Same as @code{max-workers} but for the admin interface.")
  (admin-max-clients
    (integer 5)
    "Same as @code{max-clients} but for the admin interface.")
  (admin-max-queued-clients
    (integer 5)
    "Same as @code{max-queued-clients} but for the admin interface.")
  (admin-max-client-requests
    (integer 5)
    "Same as @code{max-client-requests} but for the admin interface.")
  (log-level
    (integer 3)
    "Logging level. 4 errors, 3 warnings, 2 information, 1 debug.")
  (log-filters
    (string "3:remote 4:event")
    "Logging filters.

A filter allows selecting a different logging level for a given category
of logs
The format for a filter is one of:
@itemize
@item x:name

@item x:+name
@end itemize

where @code{name} is a string which is matched against the category
given in the @code{VIR_LOG_INIT()} at the top of each libvirt source
file, e.g., \"remote\", \"qemu\", or \"util.json\" (the name in the
filter can be a substring of the full category name, in order
to match multiple similar categories), the optional \"+\" prefix
tells libvirt to log stack trace for each message matching
name, and @code{x} is the minimal level where matching messages should
be logged:

@itemize
@item 1: DEBUG
@item 2: INFO
@item 3: WARNING
@item 4: ERROR
@end itemize

Multiple filters can be defined in a single filters statement, they just
need to be separated by spaces.")
  (log-outputs
    (string "3:syslog:libvirtd")
    "Logging outputs.

An output is one of the places to save logging information
The format for an output can be:

@table @code
@item x:stderr
output goes to stderr

@item x:syslog:name
use syslog for the output and use the given name as the ident

@item x:file:file_path
output to a file, with the given filepath

@item x:journald
output to journald logging system
@end table

In all case the x prefix is the minimal level, acting as a filter

@itemize
@item 1: DEBUG
@item 2: INFO
@item 3: WARNING
@item 4: ERROR
@end itemize

Multiple outputs can be defined, they just need to be separated by spaces.")
  (audit-level
    (integer 1)
    "Allows usage of the auditing subsystem to be altered

@itemize
@item 0: disable all auditing
@item 1: enable auditing, only if enabled on host
@item 2: enable auditing, and exit if disabled on host.
@end itemize
")
  (audit-logging
    (boolean #f)
    "Send audit messages via libvirt logging infrastructure.")
  (host-uuid
    (optional-string "")
    "Host UUID. UUID must not have all digits be the same.")
  (host-uuid-source
    (string "smbios")
    "Source to read host UUID.

@itemize

@item @code{smbios}: fetch the UUID from @code{dmidecode -s system-uuid}

@item @code{machine-id}: fetch the UUID from @code{/etc/machine-id}

@end itemize

If @code{dmidecode} does not provide a valid UUID a temporary UUID
will be generated.")
  (keepalive-interval
    (integer 5)
    "A keepalive message is sent to a client after
@code{keepalive_interval} seconds of inactivity to check if
the client is still responding. If set to -1, libvirtd will
never send keepalive requests; however clients can still send
them and the daemon will send responses.")
  (keepalive-count
    (integer 5)
    "Maximum number of keepalive messages that are allowed to be sent
to the client without getting any response before the connection is
considered broken.

In other words, the connection is automatically
closed approximately after
@code{keepalive_interval * (keepalive_count + 1)} seconds since the last
message received from the client. When @code{keepalive-count} is
set to 0, connections will be automatically closed after
@code{keepalive-interval} seconds of inactivity without sending any
keepalive messages.")
  (admin-keepalive-interval
    (integer 5)
    "Same as above but for admin interface.")
  (admin-keepalive-count
    (integer 5)
    "Same as above but for admin interface.")
  (ovs-timeout
    (integer 5)
    "Timeout for Open vSwitch calls.

The @code{ovs-vsctl} utility is used for the configuration and
its timeout option is set by default to 5 seconds to avoid
potential infinite waits blocking libvirt."))

(define* (libvirt-conf-file config)
  "Return a libvirtd config file."
  (plain-file "libvirtd.conf"
              (with-output-to-string
                (lambda ()
                  (serialize-configuration config libvirt-configuration-fields)))))

(define %libvirt-accounts
  (list (user-group (name "libvirt") (system? #t))))

(define (%libvirt-activation config)
  (let ((sock-dir (libvirt-configuration-unix-sock-dir config)))
    #~(begin
        (use-modules (guix build utils))
        (mkdir-p #$sock-dir))))


(define (libvirt-shepherd-service config)
  (let* ((config-file (libvirt-conf-file config))
         (libvirt (libvirt-configuration-libvirt config)))
    (list (shepherd-service
           (documentation "Run the libvirt daemon.")
           (provision '(libvirtd))
           (start #~(make-forkexec-constructor
                     (list (string-append #$libvirt "/sbin/libvirtd")
                           "-f" #$config-file)
                     ;; For finding qemu and ip binaries.
                     #:environment-variables
                     (list (string-append
                            "PATH=/run/current-system/profile/bin:"
                            "/run/current-system/profile/sbin"))))
           (stop #~(make-kill-destructor))))))

(define libvirt-service-type
  (service-type (name 'libvirt)
		(extensions
                 (list
                  (service-extension polkit-service-type
                                     (compose list libvirt-configuration-libvirt))
                  (service-extension profile-service-type
                                     (lambda (config)
                                       (list
                                        (libvirt-configuration-libvirt config)
                                        qemu)))
                  (service-extension activation-service-type
                                     %libvirt-activation)
                  (service-extension shepherd-root-service-type
                                     libvirt-shepherd-service)
                  (service-extension account-service-type
                                     (const %libvirt-accounts))))
                (default-value (libvirt-configuration))))


(define-record-type* <virtlog-configuration>
  virtlog-configuration make-virtlog-configuration
  virtlog-configuration?
  (libvirt      virtlog-configuration-libvirt
                (default libvirt))
  (log-level    virtlog-configuration-log-level
                (default 3))
  (log-filters  virtlog-configuration-log-filters
                (default "3:remote 4:event"))
  (log-outputs  virtlog-configuration-log-outputs
                (default "3:syslog:virtlogd"))
  (max-clients  virtlog-configuration-max-clients
                (default 1024))
  (max-size     virtlog-configuration-max-size
                (default 2097152)) ;; 2MB
  (max-backups  virtlog-configuration-max-backups
                (default 3)))

(define* (virtlogd-conf-file config)
  "Return a virtlogd config file."
  (plain-file "virtlogd.conf"
              (string-append
               "log_level = " (number->string (virtlog-configuration-log-level config)) "\n"
               "log_filters = \"" (virtlog-configuration-log-filters config) "\"\n"
               "log_outputs = \"" (virtlog-configuration-log-outputs config) "\"\n"
               "max_clients = " (number->string (virtlog-configuration-max-clients config)) "\n"
               "max_size = " (number->string (virtlog-configuration-max-size config)) "\n"
               "max_backups = " (number->string (virtlog-configuration-max-backups config)) "\n")))

(define (virtlogd-shepherd-service config)
  (let* ((config-file (virtlogd-conf-file config))
         (libvirt (virtlog-configuration-libvirt config)))
    (list (shepherd-service
           (documentation "Run the virtlog daemon.")
           (provision '(virtlogd))
           (start #~(make-forkexec-constructor
                     (list (string-append #$libvirt "/sbin/virtlogd")
                           "-f" #$config-file)))
           (stop #~(make-kill-destructor))))))

(define virtlog-service-type
  (service-type (name 'virtlogd)
		(extensions
                 (list
                  (service-extension shepherd-root-service-type
                                     virtlogd-shepherd-service)))
                (default-value (virtlog-configuration))))

(define (generate-libvirt-documentation)
  (generate-documentation
   `((libvirt-configuration ,libvirt-configuration-fields))
   'libvirt-configuration))


;;;
;;; Transparent QEMU emulation via binfmt_misc.
;;;

;; Platforms that QEMU can emulate.
(define-record-type* <qemu-platform>
  qemu-platform make-qemu-platform
  qemu-platform?
  (name     qemu-platform-name)                   ;string
  (family   qemu-platform-family)                 ;string
  (magic    qemu-platform-magic)                  ;bytevector
  (mask     qemu-platform-mask)                   ;bytevector
  (flags    qemu-platform-flags (default "F")))   ;string

(define-syntax bv
  (lambda (s)
    "Expand the given string into a bytevector."
    (syntax-case s ()
      ((_ str)
       (string? (syntax->datum #'str))
       (let ((bv (u8-list->bytevector
                  (map char->integer
                       (string->list (syntax->datum #'str))))))
         bv)))))

;;; The platform descriptions below are taken from
;;; 'scripts/qemu-binfmt-conf.sh' in QEMU.

(define %i386
  (qemu-platform
   (name "i386")
   (family "i386")
   (magic (bv "\x7fELF\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x03\x00"))
   (mask (bv "\xff\xff\xff\xff\xff\xfe\xfe\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff"))))

(define %i486
  (qemu-platform
   (name "i486")
   (family "i386")
   (magic (bv "\x7fELF\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x06\x00"))
   (mask (bv "\xff\xff\xff\xff\xff\xfe\xfe\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff"))))

(define %alpha
  (qemu-platform
   (name "alpha")
   (family "alpha")
   (magic (bv "\x7fELF\x02\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x26\x90"))
   (mask (bv "\xff\xff\xff\xff\xff\xfe\xfe\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff"))))

(define %arm
  (qemu-platform
   (name "arm")
   (family "arm")
   (magic (bv "\x7fELF\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x28\x00"))
   (mask (bv "\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff"))))

(define %armeb
  (qemu-platform
   (name "armeb")
   (family "arm")
   (magic (bv "\x7fELF\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x28"))
   (mask (bv "\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff"))))

(define %sparc
  (qemu-platform
   (name "sparc")
   (family "sparc")
   (magic (bv "\x7fELF\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x02"))
   (mask (bv "\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff"))))

(define %sparc32plus
  (qemu-platform
   (name "sparc32plus")
   (family "sparc")
   (magic (bv "\x7fELF\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x12"))
   (mask (bv "\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff"))))

(define %ppc
  (qemu-platform
   (name "ppc")
   (family "ppc")
   (magic (bv "\x7fELF\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x14"))
   (mask (bv "\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff"))))

(define %ppc64
  (qemu-platform
   (name "ppc64")
   (family "ppc")
   (magic (bv "\x7fELF\x02\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x15"))
   (mask (bv "\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff"))))

(define %ppc64le
  (qemu-platform
   (name "ppc64le")
   (family "ppcle")
   (magic (bv "\x7fELF\x02\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x15\x00"))
   (mask (bv "\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\x00"))))

(define %m68k
  (qemu-platform
   (name "m68k")
   (family "m68k")
   (magic (bv "\x7fELF\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x04"))
   (mask (bv "\xff\xff\xff\xff\xff\xff\xfe\xfe\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff"))))

;; XXX: We could use the other endianness on a MIPS host.
(define %mips
  (qemu-platform
   (name "mips")
   (family "mips")
   (magic (bv "\x7fELF\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x08"))
   (mask (bv "\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff"))))

(define %mipsel
  (qemu-platform
   (name "mipsel")
   (family "mips")
   (magic (bv "\x7fELF\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x08\x00"))
   (mask (bv "\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff"))))

(define %mipsn32
  (qemu-platform
   (name "mipsn32")
   (family "mips")
   (magic (bv "\x7fELF\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x08"))
   (mask (bv "\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff"))))

(define %mipsn32el
  (qemu-platform
   (name "mipsn32el")
   (family "mips")
   (magic (bv "\x7fELF\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x08\x00"))
   (mask (bv "\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff"))))

(define %mips64
  (qemu-platform
   (name "mips64")
   (family "mips")
   (magic (bv "\x7fELF\x02\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x08"))
   (mask (bv "\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff"))))

(define %mips64el
  (qemu-platform
   (name "mips64el")
   (family "mips")
   (magic (bv "\x7fELF\x02\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x08\x00"))
   (mask (bv "\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff"))))

(define %riscv32
  (qemu-platform
   (name "riscv32")
   (family "riscv")
   (magic (bv "\x7fELF\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\xf3\x00"))
   (mask (bv "\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff"))))

(define %riscv64
  (qemu-platform
   (name "riscv64")
   (family "riscv")
   (magic (bv "\x7fELF\x02\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\xf3\x00"))
   (mask (bv "\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff"))))

(define %sh4
  (qemu-platform
   (name "sh4")
   (family "sh4")
   (magic (bv "\x7fELF\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x2a\x00"))
   (mask (bv "\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff"))))

(define %sh4eb
  (qemu-platform
   (name "sh4eb")
   (family "sh4")
   (magic (bv "\x7fELF\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x2a"))
   (mask (bv "\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff"))))

(define %s390x
  (qemu-platform
   (name "s390x")
   (family "s390x")
   (magic (bv "\x7fELF\x02\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x16"))
   (mask (bv "\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff"))))

(define %aarch64
  (qemu-platform
   (name "aarch64")
   (family "arm")
   (magic (bv "\x7fELF\x02\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\xb7\x00"))
   (mask (bv "\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff"))))

(define %hppa
  (qemu-platform
   (name "hppa")
   (family "hppa")
   (magic (bv "\x7f\x45\x4c\x46\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x0f"))
   (mask (bv "\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff"))))

(define %qemu-platforms
  (list %i386 %i486 %alpha %arm %sparc32plus %ppc %ppc64 %ppc64le %m68k
        %mips %mipsel %mipsn32 %mipsn32el %mips64 %mips64el
        %riscv32 %riscv64 %sh4 %sh4eb %s390x %aarch64 %hppa))

(define (lookup-qemu-platforms . names)
  "Return the list of QEMU platforms that match NAMES--a list of names such as
\"arm\", \"hppa\", etc."
  (filter (lambda (platform)
            (member (qemu-platform-name platform) names))
          %qemu-platforms))

(define-record-type* <qemu-binfmt-configuration>
  qemu-binfmt-configuration make-qemu-binfmt-configuration
  qemu-binfmt-configuration?
  (qemu        qemu-binfmt-configuration-qemu
               (default qemu))
  (platforms   qemu-binfmt-configuration-platforms
               (default '())))          ;safest default

(define (qemu-platform->binfmt qemu platform)
  "Return a gexp that evaluates to a binfmt string for PLATFORM, using the
given QEMU package."
  (define (bytevector->binfmt-string bv)
    ;; Return a binfmt-friendly string representing BV.  Hex-encode every
    ;; character, in particular because the doc notes "that you must escape
    ;; any NUL bytes; parsing halts at the first one".
    (string-concatenate
     (map (lambda (n)
            (string-append "\\x"
                           (string-pad (number->string n 16) 2 #\0)))
          (bytevector->u8-list bv))))

  (match platform
    (($ <qemu-platform> name family magic mask flags)
     ;; See 'Documentation/binfmt_misc.txt' in the kernel.
     #~(string-append ":qemu-" #$name ":M::"
                      #$(bytevector->binfmt-string magic)
                      ":" #$(bytevector->binfmt-string mask)
                      ":" #$qemu:static "/bin/qemu-" #$name
                      ":" #$flags))))

(define %binfmt-mount-point
  (file-system-mount-point %binary-format-file-system))

(define %binfmt-register-file
  (string-append %binfmt-mount-point "/register"))

(define qemu-binfmt-shepherd-services
  (match-lambda
    (($ <qemu-binfmt-configuration> qemu platforms)
     (list (shepherd-service
            (provision '(qemu-binfmt))
            (documentation "Install binfmt_misc handlers for QEMU.")
            (requirement '(file-system-/proc/sys/fs/binfmt_misc))
            (start #~(lambda ()
                       ;; Register the handlers for all of PLATFORMS.
                       (for-each (lambda (str)
                                   (call-with-output-file
                                       #$%binfmt-register-file
                                     (lambda (port)
                                       (display str port))))
                                 (list
                                  #$@(map (cut qemu-platform->binfmt qemu
                                               <>)
                                          platforms)))
                       #t))
            (stop #~(lambda (_)
                      ;; Unregister the handlers.
                      (for-each (lambda (name)
                                  (let ((file (string-append
                                               #$%binfmt-mount-point
                                               "/qemu-" name)))
                                    (call-with-output-file file
                                      (lambda (port)
                                        (display "-1" port)))))
                                '#$(map qemu-platform-name platforms))
                      #f)))))))

(define qemu-binfmt-service-type
  ;; TODO: Make a separate binfmt_misc service out of this?
  (service-type (name 'qemu-binfmt)
                (extensions
                 (list (service-extension file-system-service-type
                                          (const
                                           (list %binary-format-file-system)))
                       (service-extension shepherd-root-service-type
                                          qemu-binfmt-shepherd-services)))
                (default-value (qemu-binfmt-configuration))
                (description
                 "This service supports transparent emulation of binaries
compiled for other architectures using QEMU and the @code{binfmt_misc}
functionality of the kernel Linux.")))


;;;
;;; Secrets for guest VMs.
;;;

(define (secret-service-activation port)
  "Return an activation snippet that fetches sensitive material at local PORT,
over TCP.  Reboot upon failure."
  (with-imported-modules '((gnu build secret-service)
                           (guix build utils))
    #~(begin
        (use-modules (gnu build secret-service))
        (let ((sent (secret-service-receive-secrets #$port)))
          (unless sent
            (sleep 3)
            (reboot))))))

(define secret-service-type
  (service-type
   (name 'secret-service)
   (extensions (list (service-extension activation-service-type
                                        secret-service-activation)))
   (description
    "This service fetches secret key and other sensitive material over TCP at
boot time.  This service is meant to be used by virtual machines (VMs) that
can only be accessed by their host.")))

(define (secret-service-operating-system os)
  "Return an operating system based on OS that includes the secret-service,
that will be listening to receive secret keys on port 1004, TCP."
  (operating-system
    (inherit os)
    ;; Arrange so that the secret service activation snippet shows up before
    ;; the OpenSSH and Guix activation snippets.  That way, we receive OpenSSH
    ;; and Guix keys before the activation snippets try to generate fresh keys
    ;; for nothing.
    (services (append (operating-system-user-services os)
                      (list (service secret-service-type 1004))))))


;;;
;;; The Hurd in VM service: a Childhurd.
;;;

(define %hurd-vm-operating-system
  (operating-system
    (inherit %hurd-default-operating-system)
    (host-name "childhurd")
    (timezone "Europe/Amsterdam")
    (bootloader (bootloader-configuration
                 (bootloader grub-minimal-bootloader)
                 (target "/dev/vda")
                 (timeout 0)))
    (packages (cons* gdb-minimal
                     (operating-system-packages
                      %hurd-default-operating-system)))
    (services (cons*
               (service openssh-service-type
                        (openssh-configuration
                         (openssh openssh-sans-x)
                         (use-pam? #f)
                         (port-number 2222)
                         (permit-root-login #t)
                         (allow-empty-passwords? #t)
                         (password-authentication? #t)))

               ;; By default, the secret service introduces a pre-initialized
               ;; /etc/guix/acl file in the childhurd.  Thus, clear
               ;; 'authorize-key?' so that it's not overridden at activation
               ;; time.
               (modify-services %base-services/hurd
                 (guix-service-type config =>
                                    (guix-configuration
                                     (inherit config)
                                     (authorize-key? #f))))))))

(define-record-type* <hurd-vm-configuration>
  hurd-vm-configuration make-hurd-vm-configuration
  hurd-vm-configuration?
  (os          hurd-vm-configuration-os                 ;<operating-system>
               (default %hurd-vm-operating-system))
  (qemu        hurd-vm-configuration-qemu               ;<package>
               (default qemu-minimal))
  (image       hurd-vm-configuration-image              ;string
               (thunked)
               (default (hurd-vm-disk-image this-record)))
  (disk-size   hurd-vm-configuration-disk-size          ;number or 'guess
               (default 'guess))
  (memory-size hurd-vm-configuration-memory-size        ;number
               (default 512))
  (options     hurd-vm-configuration-options            ;list of string
               (default `("--snapshot")))
  (id          hurd-vm-configuration-id                 ;#f or integer [1..]
               (default #f))
  (net-options hurd-vm-configuration-net-options        ;list of string
               (thunked)
               (default (hurd-vm-net-options this-record)))
  (secret-root hurd-vm-configuration-secret-root        ;string
               (default "/etc/childhurd")))

(define (hurd-vm-disk-image config)
  "Return a disk-image for the Hurd according to CONFIG.  The secret-service
is added to the OS specified in CONFIG."
  (let* ((os        (secret-service-operating-system
                     (hurd-vm-configuration-os config)))
         (disk-size (hurd-vm-configuration-disk-size config))
         (type      (lookup-image-type-by-name 'hurd-qcow2))
         (os->image (image-type-constructor type)))
    (system-image
     (image (inherit (os->image os))
            (size disk-size)))))

(define (hurd-vm-port config base)
  "Return the forwarded vm port for this childhurd config."
  (let ((id (or (hurd-vm-configuration-id config) 0)))
    (+ base (* 1000 id))))
(define %hurd-vm-secrets-port 11004)
(define %hurd-vm-ssh-port 10022)
(define %hurd-vm-vnc-port 15900)

(define (hurd-vm-net-options config)
  `("--device" "rtl8139,netdev=net0"
    "--netdev"
    ,(string-append "user,id=net0"
                    ",hostfwd=tcp:127.0.0.1:"
                    (number->string (hurd-vm-port config %hurd-vm-secrets-port))
                    "-:1004"
                    ",hostfwd=tcp:127.0.0.1:"
                    (number->string (hurd-vm-port config %hurd-vm-ssh-port))
                    "-:2222"
                    ",hostfwd=tcp:127.0.0.1:"
                    (number->string (hurd-vm-port config %hurd-vm-vnc-port))
                    "-:5900")))

(define (hurd-vm-shepherd-service config)
  "Return a <shepherd-service> for a Hurd in a Virtual Machine with CONFIG."

  (let ((image       (hurd-vm-configuration-image config))
        (qemu        (hurd-vm-configuration-qemu config))
        (memory-size (hurd-vm-configuration-memory-size config))
        (options     (hurd-vm-configuration-options config))
        (id          (hurd-vm-configuration-id config))
        (net-options (hurd-vm-configuration-net-options config))
        (provisions  '(hurd-vm childhurd)))

    (define vm-command
      #~(append (list #$(file-append qemu "/bin/qemu-system-i386")
                      "-m" (number->string #$memory-size)
                      #$@net-options
                      #$@options
                      "--hda" #+image

                      ;; Cause the service to be respawned if the guest
                      ;; reboots (it can reboot for instance if it did not
                      ;; receive valid secrets, or if it crashed.)
                      "--no-reboot")
                (if (file-exists? "/dev/kvm")
                    '("--enable-kvm")
                    '())))

    (list
     (shepherd-service
      (documentation "Run the Hurd in a Virtual Machine: a Childhurd.")
      (provision (if id
                     (map
                      (cute symbol-append <>
                            (string->symbol (number->string id)))
                      provisions)
                     provisions))
      (requirement '(loopback networking user-processes))
      (start
       (with-imported-modules
           (source-module-closure '((gnu build secret-service)
                                    (guix build utils)))
         #~(lambda ()
             (let ((pid  (fork+exec-command #$vm-command
                                            #:user "childhurd"
                                            ;; XXX TODO: use "childhurd" after
                                            ;; updating Shepherd
                                            #:group "kvm"
                                            #:environment-variables
                                            ;; QEMU tries to write to /var/tmp
                                            ;; by default.
                                            '("TMPDIR=/tmp")))
                   (port #$(hurd-vm-port config %hurd-vm-secrets-port))
                   (root #$(hurd-vm-configuration-secret-root config)))
               (catch #t
                 (lambda _
                   ;; XXX: 'secret-service-send-secrets' won't complete until
                   ;; the guest has booted and its secret service server is
                   ;; running, which could take 20+ seconds during which PID 1
                   ;; is stuck waiting.
                   (if (secret-service-send-secrets port root)
                       pid
                       (begin
                         (kill (- pid) SIGTERM)
                         #f)))
                 (lambda (key . args)
                   (kill (- pid) SIGTERM)
                   (apply throw key args)))))))
      (modules `((gnu build secret-service)
                 (guix build utils)
                 ,@%default-modules))
      (stop  #~(make-kill-destructor))))))

(define %hurd-vm-accounts
  (list (user-group (name "childhurd") (system? #t))
        (user-account
         (name "childhurd")
         (group "childhurd")
         (supplementary-groups '("kvm"))
         (comment "Privilege separation user for the childhurd")
         (home-directory "/var/empty")
         (shell (file-append shadow "/sbin/nologin"))
         (system? #t))))

(define (initialize-hurd-vm-substitutes)
  "Initialize the Hurd VM's key pair and ACL and store it on the host."
  (define run
    (with-imported-modules '((guix build utils))
      #~(begin
          (use-modules (guix build utils)
                       (ice-9 match))

          (define host-key
            "/etc/guix/signing-key.pub")

          (define host-acl
            "/etc/guix/acl")

          (match (command-line)
            ((_ guest-config-directory)
             (setenv "GUIX_CONFIGURATION_DIRECTORY"
                     guest-config-directory)
             (invoke #+(file-append guix "/bin/guix") "archive"
                     "--generate-key")

             (when (file-exists? host-acl)
               ;; Copy the host ACL.
               (copy-file host-acl
                          (string-append guest-config-directory
                                         "/acl")))

             (when (file-exists? host-key)
               ;; Add the host key to the childhurd's ACL.
               (let ((key (open-fdes host-key O_RDONLY)))
                 (close-fdes 0)
                 (dup2 key 0)
                 (execl #+(file-append guix "/bin/guix")
                        "guix" "archive" "--authorize"))))))))

  (program-file "initialize-hurd-vm-substitutes" run))

(define (hurd-vm-activation config)
  "Return a gexp to activate the Hurd VM according to CONFIG."
  (with-imported-modules '((guix build utils))
    #~(begin
        (use-modules (guix build utils))

        (define secret-directory
          #$(hurd-vm-configuration-secret-root config))

        (define ssh-directory
          (string-append secret-directory "/etc/ssh"))

        (define guix-directory
          (string-append secret-directory "/etc/guix"))

        (unless (file-exists? ssh-directory)
          ;; Generate SSH host keys under SSH-DIRECTORY.
          (mkdir-p ssh-directory)
          (invoke #$(file-append openssh "/bin/ssh-keygen")
                  "-A" "-f" secret-directory))

        (unless (file-exists? guix-directory)
          (invoke #$(initialize-hurd-vm-substitutes)
                  guix-directory)))))

(define hurd-vm-service-type
  (service-type
   (name 'hurd-vm)
   (extensions (list (service-extension shepherd-root-service-type
                                        hurd-vm-shepherd-service)
                     (service-extension account-service-type
                                        (const %hurd-vm-accounts))
                     (service-extension activation-service-type
                                        hurd-vm-activation)))
   (default-value (hurd-vm-configuration))
   (description
    "Provide a virtual machine (VM) running GNU/Hurd, also known as a
@dfn{childhurd}.")))
ary-cache.pl and nix-channel commit dcaea042fc895667bf6f529471ff9f449629774c Author: Eelco Dolstra <eelco.dolstra@logicblox.com> Date: Wed Feb 26 13:40:08 2014 +0100 Only start download-via-ssh if it's enabled commit df5de9dfd72f9dc3d57157d0496443732a517491 Author: Shea Levy <shea@shealevy.com> Date: Wed Feb 19 07:05:15 2014 -0500 Add use-ssh-substituter setting. It defaults to false and can be overridden by RemoteStore. Untested currently, just quickly put this together commit 36b90e72d7e09b983acfa08f9016e8b3ece5199d Author: Eelco Dolstra <eelco.dolstra@logicblox.com> Date: Wed Feb 19 17:08:01 2014 +0100 nix-shell: Add --packages flag This allows you to easily set up a build environment containing the specified packages from Nixpkgs. For example: $ nix-shell -p sqlite xorg.libX11 hello will start a shell in which the given packages are present. commit a897b583733aaf3ee7aa0efe495f9ea046567555 Author: Eelco Dolstra <eelco.dolstra@logicblox.com> Date: Wed Feb 19 16:46:33 2014 +0100 nix-instantiate: Allow --dry-run as a synonym for --readonly-mode --dry-run is more consistent with nix-env and nix-store. commit e1cf40fa9537162efe0dc19dcea9ae7d043fde66 Author: Eelco Dolstra <eelco.dolstra@logicblox.com> Date: Wed Feb 19 16:34:24 2014 +0100 nix-instantiate: Rename --eval-only to --eval, --parse-only to --parse commit c31836008e45460513188a3fbeda4416f9153a05 Author: Eelco Dolstra <eelco.dolstra@logicblox.com> Date: Wed Feb 19 16:30:19 2014 +0100 nix-instantiate: Add a flag --expr / -E to read expressions from the command line This is basically a shortcut for ‘echo 'expr...' | nix-instantiate -’. Also supported by nix-build and nix-shell. commit e707a8a526698de2237e6ac89e2f1ce6dbc63269 Author: Eelco Dolstra <eelco.dolstra@logicblox.com> Date: Wed Feb 19 15:32:19 2014 +0100 Move manpages around commit 73f74ebba09f8bceed46a11f7348b4c398bde6f3 Author: Eelco Dolstra <eelco.dolstra@logicblox.com> Date: Wed Feb 19 15:01:04 2014 +0100 nix-shell: Don't leave a temporary directory in /tmp behind commit a7e70518b8d0cb9a72cb3733b563b49caf922966 Author: Shea Levy <shea@shealevy.com> Date: Sat Feb 15 11:02:47 2014 -0500 lexer-tab.o and parser-tab.o require each other's headers commit 70a558e20250f7c865fd36c1c678192fe29d088f Author: Shea Levy <shea@shealevy.com> Date: Sat Feb 15 10:56:11 2014 -0500 Update ignores commit 7bef965d6f191efb9c671f49fd187f4214db6120 Author: Eelco Dolstra <eelco.dolstra@logicblox.com> Date: Tue Feb 18 13:35:35 2014 +0100 Make it work on GNU Make > 3.81 again commit 79f699edca26c035a8bcd68c7d5a13b4fbcbf3be Author: Eelco Dolstra <eelco.dolstra@logicblox.com> Date: Tue Feb 18 12:57:32 2014 +0100 More GNU Make 3.81 compatibility commit 8129cf33d959db44344fbffc34a981cc27b29bfb Author: Eelco Dolstra <eelco.dolstra@logicblox.com> Date: Tue Feb 18 10:46:30 2014 +0100 Slight simplification commit 1aa19b24b27c6bbf4d46cdd7f6d06b534dd67c19 Author: Eelco Dolstra <eelco.dolstra@logicblox.com> Date: Tue Feb 18 01:01:14 2014 +0100 Add a flag ‘--check’ to verify build determinism The flag ‘--check’ to ‘nix-store -r’ or ‘nix-build’ will cause Nix to redo the build of a derivation whose output paths are already valid. If the new output differs from the original output, an error is printed. This makes it easier to test if a build is deterministic. (Obviously this cannot catch all sources of non-determinism, but it catches the most common one, namely the current time.) For example: $ nix-build '<nixpkgs>' -A patchelf ... $ nix-build '<nixpkgs>' -A patchelf --check error: derivation `/nix/store/1ipvxsdnbhl1rw6siz6x92s7sc8nwkkb-patchelf-0.6' may not be deterministic: hash mismatch in output `/nix/store/4pc1dmw5xkwmc6q3gdc9i5nbjl4dkjpp-patchelf-0.6.drv' The --check build fails if not all outputs are valid. Thus the first call to nix-build is necessary to ensure that all outputs are valid. The current outputs are left untouched: the new outputs are either put in a chroot or diverted to a different location in the store using hash rewriting. commit 4ec626a286afd4a9596357fc6d36aaf8bc07442a Author: Eelco Dolstra <eelco.dolstra@logicblox.com> Date: Mon Feb 17 23:24:12 2014 +0100 Test nix-store --verify-path and --repair-path commit 99f14c25842a897a1a352a3b3be7c0362cb0313f Author: Eelco Dolstra <eelco.dolstra@logicblox.com> Date: Mon Feb 17 23:10:40 2014 +0100 Don't build on Debian 6.0 Its linker is too old to understand --no-copy-dt-needed-entries. http://hydra.nixos.org/build/9113883 commit b6def5b542d35eaed5e8cbc6eaa9bbf644262686 Author: Eelco Dolstra <eelco.dolstra@logicblox.com> Date: Mon Feb 17 23:09:48 2014 +0100 Make --repair work on Darwin Mac OS X doesn't allow renaming a read-only directory. http://hydra.nixos.org/build/9113895 commit dfbcb7c403363c21c1eab8082ffaade29bba9036 Author: Eelco Dolstra <eelco.dolstra@logicblox.com> Date: Mon Feb 17 23:04:52 2014 +0100 Refactoring commit 71adb090f05532b2116e952b617048abd0a6081d Author: Eelco Dolstra <eelco.dolstra@logicblox.com> Date: Mon Feb 17 22:58:21 2014 +0100 When using a build hook, only copy missing paths commit 69fe6c58faa91c3b8f844e1aafca26354ea14425 Author: Eelco Dolstra <eelco.dolstra@logicblox.com> Date: Mon Feb 17 22:25:15 2014 +0100 Move some code around In particular, do replacing of valid paths during repair later. This prevents us from replacing a valid path after the build fails. commit 1da6ae4f9904f7e09166085a2cfed8887e0e86d4 Author: Eelco Dolstra <eelco.dolstra@logicblox.com> Date: Mon Feb 17 14:48:50 2014 +0100 nix-store --gc --max-freed: Support a unit specifier E.g. "--max-freed 10G" means "free ten gigabytes". commit 00d30496ca32145f55891364ddcf3d4af87f05d5 Author: Eelco Dolstra <eelco.dolstra@logicblox.com> Date: Mon Feb 17 14:15:56 2014 +0100 Heuristically detect if a build may have failed due to a full disk This will allow Hydra to detect that a build should not be marked as "permanently failed", allowing it to be retried later. commit e81d38c02b267eea93a91de3e8a00b185355d681 Author: Eelco Dolstra <eelco.dolstra@logicblox.com> Date: Mon Feb 17 13:34:24 2014 +0100 nix-shell: Execute shellHook if it exists Since normal builds don't execute shellHook, this allows nix-shell specific customisation. Suggested by Domen. commit 832377bbd6ccd43895ac346131cafe4901f7996b Author: Eelco Dolstra <eelco.dolstra@logicblox.com> Date: Mon Feb 17 12:22:50 2014 +0100 Add a test for repairing paths commit 581a160c11dd3de66d9cd1a6e01c0641909546ef Author: Eelco Dolstra <eelco.dolstra@logicblox.com> Date: Fri Feb 14 20:12:04 2014 +0100 Add a function for looking up programs in $PATH commit a9d99ab55fdaa1c9dde87eaa8d289ecdb8cf9068 Author: Eelco Dolstra <eelco.dolstra@logicblox.com> Date: Fri Feb 14 12:31:10 2014 +0100 download-via-ssh: Use readStorePath commit 4db572062ccf318a6524abb8da046592a570eb94 Author: Eelco Dolstra <eelco.dolstra@logicblox.com> Date: Fri Feb 14 12:20:12 2014 +0100 download-via-ssh: Show where we're downloading from commit dba33d4018c07699b59f024ca61442c896579c64 Author: Eelco Dolstra <eelco.dolstra@logicblox.com> Date: Fri Feb 14 11:48:42 2014 +0100 Minor style fixes commit 61fd494d760d667649fa48665f9aa75ba88a1eb6 Merge: f9fc6ac f67f527 Author: Eelco Dolstra <eelco.dolstra@logicblox.com> Date: Fri Feb 14 11:42:47 2014 +0100 Merge remote-tracking branch 'shlevy/ssh-substituter' commit f67f52751f21b2fe70b5a7352053f130eb6f0f59 Author: Shea Levy <shea@shealevy.com> Date: Wed Feb 12 07:33:07 2014 -0500 Indendation fix Signed-off-by: Shea Levy <shea@shealevy.com> commit 62eb9eb76ddacc1aa97400bef9f25b6ca4c50c8c Author: Shea Levy <shea@shealevy.com> Date: Wed Feb 12 07:27:45 2014 -0500 Remove relic of old code Signed-off-by: Shea Levy <shea@shealevy.com> commit 7438f0bc2bc4b92bddf7159744ab2923e34b7457 Author: Shea Levy <shea@shealevy.com> Date: Wed Feb 12 07:26:35 2014 -0500 error messages start in lowercase Signed-off-by: Shea Levy <shea@shealevy.com> commit 2246aa77d291e07141f6a508e46730e2c28e1d84 Author: Shea Levy <shea@shealevy.com> Date: Wed Feb 12 07:22:36 2014 -0500 Remove using declarations from download-via-ssh Signed-off-by: Shea Levy <shea@shealevy.com> commit f9fc6acbf4eadd2d9018d3da14394fdfbddde5f6 Author: Eelco Dolstra <eelco.dolstra@logicblox.com> Date: Wed Feb 12 10:53:22 2014 +0100 Document current meaning of preferLocalBuild Closes #208. commit a35c6eb4a2209716fe1d40cebad2b3adb5d05e0f Author: Eelco Dolstra <eelco.dolstra@logicblox.com> Date: Tue Feb 11 14:15:57 2014 +0100 Support setting CFLAGS and CXXFLAGS for libraries/programs commit 1f841c9d50a100a3d40fec6260d36ec9ee309af3 Author: Eelco Dolstra <eelco.dolstra@logicblox.com> Date: Mon Feb 10 17:42:36 2014 +0100 Force use of Bash "echo -n" doesn't work with /bin/sh on Darwin. commit 57386c9baee78e50eb0c4a901ca9e1c147dc9777 Author: Eelco Dolstra <eelco.dolstra@logicblox.com> Date: Mon Feb 10 16:35:59 2014 +0100 Binary tarball: Automatically create /nix The tarball can now be unpacked anywhere. The installation script uses "sudo" to create /nix if it doesn't exist. It also fetches the nixpkgs-unstable channel. commit c89d6b9b63b629ff936a56855be5689523910c58 Author: Shea Levy <shea@shealevy.com> Date: Mon Feb 10 07:43:13 2014 -0500 nix-store --serve: Use a versioned protocol Signed-off-by: Shea Levy <shea@shealevy.com> commit 38c3beac1a8ac9ddf4fdbbcafd400dabcf195076 Author: Shea Levy <shea@shealevy.com> Date: Mon Feb 10 06:52:48 2014 -0500 Move StoreApi::serve into opServe Signed-off-by: Shea Levy <shea@shealevy.com> commit 16146031659eae475cd5933b8553b13d725ca436 Author: Shea Levy <shea@shealevy.com> Date: Mon Feb 10 06:49:37 2014 -0500 Pass in params by const ref Signed-off-by: Shea Levy <shea@shealevy.com> commit 78d979567fa304fa4445fe7403932d9d97183ebd Author: Shea Levy <shea@shealevy.com> Date: Mon Feb 10 06:43:29 2014 -0500 Clarify comment Signed-off-by: Shea Levy <shea@shealevy.com> commit c5839752b9d5099d4b5e7bcfc853581673e779f6 Author: Eelco Dolstra <eelco.dolstra@logicblox.com> Date: Mon Feb 10 10:50:29 2014 +0100 Binary tarball: Automatically fetch the Nixpkgs channel commit b632153ebd1bf8d773872eb36f9ad335d2c89fab Author: Eelco Dolstra <eelco.dolstra@logicblox.com> Date: Mon Feb 10 10:25:13 2014 +0100 nix-shell: Use shell.nix as the default expression if it exists commit 64e23d0a38f316a07cef0960d0ed74a450214283 Author: Shea Levy <shea@shealevy.com> Date: Sat Feb 8 00:05:46 2014 -0500 Add download-via-ssh substituter This substituter connects to a remote host, runs nix-store --serve there, and then forwards substituter commands on to the remote host and sends their results to the calling program. The ssh-substituter-hosts option can be specified as a list of hosts to try. This is an initial implementation and, while it works, it has some limitations: * Only the first host is used * There is no caching of query results (all queries are sent to the remote machine) * There is no informative output (such as progress bars) * Some failure modes may cause unhelpful error messages * There is no concept of trusted-ssh-substituter-hosts Signed-off-by: Shea Levy <shea@shealevy.com> commit 5671188eb2822b7392a6affa5ebe2f1eb8f521a0 Author: Shea Levy <shea@shealevy.com> Date: Fri Feb 7 16:56:00 2014 -0500 nix-store --serve: Flush out after every loop Signed-off-by: Shea Levy <shea@shealevy.com> commit 73874629ef59dc3b237a2c316179e722f971bb5e Author: Shea Levy <shea@shealevy.com> Date: Fri Feb 7 16:17:52 2014 -0500 nix-store --serve: Use dump instead of export Also remove signing support Signed-off-by: Shea Levy <shea@shealevy.com> commit 188f96500bc16891b22c684ad96122635667a8ff Author: Shea Levy <shea@shealevy.com> Date: Fri Feb 7 15:29:32 2014 -0500 nix-store --serve: Don't fail if asked for info about non-valid path Signed-off-by: Shea Levy <shea@shealevy.com> commit 94884475947ca8c44dda51d83f3c1fbfeff5ccc0 Author: Shea Levy <shea@shealevy.com> Date: Fri Feb 7 14:07:31 2014 -0500 nix-store --serve: Don't loop forever nix-store --export takes a tmproot, which can only release by exiting. Substituters don't currently work in a way that could take advantage of the looping, anyway. Signed-off-by: Shea Levy <shea@shealevy.com> commit 3a38d0f3565a02c034c29b264aceb0eb78dac005 Author: Shea Levy <shea@shealevy.com> Date: Thu Feb 6 11:52:03 2014 -0500 Add the nix-store --serve command This is essentially the substituter API operating on the local store, which will be used by the ssh substituter. It runs in a loop rather than just taking one command so that in the future nix will be able to keep one connection open for multiple instances of the substituter. Signed-off-by: Shea Levy <shea@shealevy.com> commit 84a8b5e9af2df4ed7f7860a6768daf83f72724ca Author: Shea Levy <shea@shealevy.com> Date: Tue Feb 4 10:37:10 2014 -0500 nix-instantiate --eval-only --read-write-mode: Don't depend on ordering Signed-off-by: Shea Levy <shea@shealevy.com> commit e4058fab64d82ddb7723142c7c595e80eeba0f3e Author: Shea Levy <shea@shealevy.com> Date: Tue Feb 4 10:35:30 2014 -0500 Rename --no-readonly-mode --read-write-mode Signed-off-by: Shea Levy <shea@shealevy.com> commit 0c3e8a616e8e243ee45c78491fe86f50230d82b9 Author: Shea Levy <shea@shealevy.com> Date: Tue Feb 4 09:17:59 2014 -0500 nix-instantiate: Add a --no-readonly-mode flag This allows running nix-instantiate --eval-only without performing the evaluation in readonly mode, letting features like import from derivation and automatic substitution of builtins.storePath paths work. Signed-off-by: Shea Levy <shea@shealevy.com> commit 0432bc52ea21bb7b60477965054362f7414c569f Author: Eelco Dolstra <eelco.dolstra@logicblox.com> Date: Fri Feb 7 17:34:39 2014 +0100 Fix the RPM build commit 7fab23e237b36a7ca2df6f34eb5febe4c851db42 Author: Eelco Dolstra <eelco.dolstra@logicblox.com> Date: Fri Feb 7 17:15:00 2014 +0100 Install header files commit 764d90597a2ef9f5f5a5041993b728e020fb08b0 Merge: 2a469ad a210c99 Author: Eelco Dolstra <eelco.dolstra@logicblox.com> Date: Fri Feb 7 16:27:34 2014 +0100 Merge commit 'a210c995cdd9279ed4137ec5d2e4cc928cb36097' commit a210c995cdd9279ed4137ec5d2e4cc928cb36097 Author: Eelco Dolstra <eelco.dolstra@logicblox.com> Date: Fri Feb 7 15:06:21 2014 +0100 Support DESTDIR commit 97f8e9bc76b08ac6d63c6419490f8fcc9670a58b Author: Eelco Dolstra <eelco.dolstra@logicblox.com> Date: Thu Feb 6 19:06:08 2014 +0100 Remove dead code commit 2a469ad31da7cac5c4ecab6838c364956319821f Author: Eelco Dolstra <eelco.dolstra@logicblox.com> Date: Thu Feb 6 14:21:14 2014 +0100 Set a maintainer address Issue #202. commit 1f94ec3924f132ae6d92b29631a59f9818ba4e31 Author: Eelco Dolstra <eelco.dolstra@logicblox.com> Date: Thu Feb 6 13:54:44 2014 +0100 Clean up a test warning commit 20d059892819d2f06f4da8c1150c91e16df1f8cd Author: Eelco Dolstra <eelco.dolstra@logicblox.com> Date: Thu Feb 6 13:51:57 2014 +0100 Drop dependency on ‘expr’ http://hydra.nixos.org/build/8715639 Not sure why this causes a failure now. commit 4161fce472a8875427e73776d0e8665ca49c1835 Author: Eelco Dolstra <eelco.dolstra@logicblox.com> Date: Thu Feb 6 10:59:58 2014 +0100 Create the target directory of libraries and programs commit 80b691316c4b15e69c63c285b8ed6cc72fb95e93 Author: Eelco Dolstra <eelco.dolstra@logicblox.com> Date: Tue Feb 4 11:08:41 2014 +0100 Fix version in nix.spec http://hydra.nixos.org/build/8715502 commit 4ee6001f95908578a1693c0fbf7b7fdc309b86c5 Author: Eelco Dolstra <eelco.dolstra@logicblox.com> Date: Tue Feb 4 11:02:49 2014 +0100 GNU Make 3.81 compatibility 3.81 doesn't understand the ‘define foo =’ syntax, which was added in 3.82. So use ‘define foo’ instead. commit 0da82efa5d67ab1eb8b8cc066704d7f863451d5b Author: Eelco Dolstra <eelco.dolstra@logicblox.com> Date: Tue Feb 4 11:02:49 2014 +0100 GNU Make 3.81 compatibility 3.81 doesn't understand the ‘define foo =’ syntax, which was added in 3.82. So use ‘define foo’ instead. commit 143224f7cd6f6667047a1683c1ede4e1f7816843 Author: Eelco Dolstra <eelco.dolstra@logicblox.com> Date: Tue Feb 4 10:09:45 2014 +0100 Add nix.spec to the distribution commit d210cdc4355bb48786b474e41a8ed7f1a152626f Author: Eelco Dolstra <eelco.dolstra@logicblox.com> Date: Mon Feb 3 22:36:07 2014 +0100 Fix assertion failure in ‘nix-store --load-db’ Namely: nix-store: derivations.cc:242: nix::Hash nix::hashDerivationModulo(nix::StoreAPI&, nix::Derivation): Assertion `store.isValidPath(i->first)' failed. This happened because of the derivation output correctness check being applied before the references of a derivation are valid. commit 73a775f3b757d105a9987c5e469d6a3e8f32024f Merge: d6582c0 8468806 Author: Eelco Dolstra <eelco.dolstra@logicblox.com> Date: Mon Feb 3 19:57:02 2014 +0100 Merge commit '8468806552d6730abec6431c42b5b0e897c0222c' commit 8468806552d6730abec6431c42b5b0e897c0222c Author: Eelco Dolstra <eelco.dolstra@logicblox.com> Date: Mon Feb 3 17:05:55 2014 +0100 Add a basic README commit d6582c04c169d7ac32820d855de92ca4e4969de3 Author: Eelco Dolstra <eelco.dolstra@logicblox.com> Date: Sat Feb 1 16:57:38 2014 +0100 Give a friendly error message if the DB directory is not writable Previously we would say "error: setting synchronous mode: unable to open database file" which isn't very helpful. commit 2f9bb5c7e744ddca3fbe5576e520a3e80c106c55 Merge: c5ba081 6dca720 Author: Eelco Dolstra <eelco.dolstra@logicblox.com> Date: Sat Feb 1 16:41:52 2014 +0100 Merge branch 'make' commit 6dca72006aa9b1cf2f226bb5b538e744fcab976f Author: Eelco Dolstra <eelco.dolstra@logicblox.com> Date: Sat Feb 1 16:30:24 2014 +0100 Only run "git ls-files" when doing "make check" commit 2a97f7b039be4cd290076707e1b02d04d3b257b6 Author: Eelco Dolstra <eelco.dolstra@logicblox.com> Date: Sat Feb 1 16:08:59 2014 +0100 Fix logging test commit 965218a62a195632fe754307e09d4d4abd286c82 Author: Eelco Dolstra <eelco.dolstra@logicblox.com> Date: Sat Feb 1 16:08:51 2014 +0100 Remove obsolete file commit b6465ae5d3efb057b82f31e10112cc359b9afdfd Merge: 762ef46 28dc488 Author: Eelco Dolstra <eelco.dolstra@logicblox.com> Date: Sat Feb 1 15:37:59 2014 +0100 Merge commit '28dc4883356a50f2805a3e3c819a541c44a4ff0a' into make commit 762ef464f843a0fe50e25ba07d11296b1540080e Author: Eelco Dolstra <eelco.dolstra@logicblox.com> Date: Sat Feb 1 15:37:50 2014 +0100 Fix the nix-profile test commit 28dc4883356a50f2805a3e3c819a541c44a4ff0a Author: Eelco Dolstra <eelco.dolstra@logicblox.com> Date: Sat Feb 1 15:33:27 2014 +0100 installcheck: Don't depend on install This is a hack to prevent "installcheck" from clobbering files fixed up by Nixpkgs' fixupPhase. commit 844d83352c23db4a3131ac2b11b9ed2af03cdfd6 Author: Eelco Dolstra <eelco.dolstra@logicblox.com> Date: Sat Feb 1 15:18:48 2014 +0100 More "make dist" fixes commit 74ca70da3a6d2f110a9dccf15c46422b1b078e3f Merge: 6ef32bd 1eff3ad Author: Eelco Dolstra <eelco.dolstra@logicblox.com> Date: Sat Feb 1 14:38:28 2014 +0100 Add 'mk/' from commit '1eff3ad37fdb9dcf9f8528fdacea0ebf0e79d545' git-subtree-dir: mk git-subtree-mainline: 6ef32bddc1f10034322966b3a5b85af7b9cdc4d8 git-subtree-split: 1eff3ad37fdb9dcf9f8528fdacea0ebf0e79d545 commit 6ef32bddc1f10034322966b3a5b85af7b9cdc4d8 Author: Eelco Dolstra <eelco.dolstra@logicblox.com> Date: Sat Feb 1 14:28:31 2014 +0100 Fix "make dist" commit 1eff3ad37fdb9dcf9f8528fdacea0ebf0e79d545 Author: Eelco Dolstra <eelco.dolstra@logicblox.com> Date: Sat Feb 1 14:36:44 2014 +0100 Add missing file commit 6f8aa145d43d0453d74e70d1d33cfa6e21fddf89 Author: Eelco Dolstra <eelco.dolstra@logicblox.com> Date: Sat Feb 1 14:22:08 2014 +0100 Improve "make dist" commit 0c6d62cf27b3b22fa60bddad16ea8e8d062e4a99 Author: Eelco Dolstra <eelco.dolstra@logicblox.com> Date: Sat Feb 1 12:26:38 2014 +0100 Remove Automakefiles commit 16e7d692092449263880ee795ec419cecbe22d24 Author: Eelco Dolstra <eelco.dolstra@logicblox.com> Date: Sat Feb 1 12:23:14 2014 +0100 Update Makefile variable names commit ec1738589a3aa1dd59e476de09ae2721d51b3e6e Author: Eelco Dolstra <eelco.dolstra@logicblox.com> Date: Sat Feb 1 12:20:06 2014 +0100 Make variable names more regular commit 35107038f7c726f5ef8d7ab014ad45c73970e65d Author: Eelco Dolstra <eelco.dolstra@logicblox.com> Date: Sat Feb 1 11:47:34 2014 +0100 Support adding "make help" text commit f324b49ea19e606f84b89ecb499f0e961646cd50 Author: Eelco Dolstra <eelco.dolstra@logicblox.com> Date: Sat Feb 1 11:31:25 2014 +0100 Change dependency file names from foo.dep to .foo.o.dep commit ac8c2ef1aa30c50b568883d2051335a66437694f Author: Eelco Dolstra <eelco.dolstra@logicblox.com> Date: Sat Feb 1 11:30:21 2014 +0100 Build/install manual commit 4271927c5be2c5b87ca83682d1f2bd71d5ce4a66 Author: Eelco Dolstra <eelco.dolstra@logicblox.com> Date: Fri Jan 31 15:33:12 2014 +0100 Add support for installing man-pages commit e0234dfddc8343a6bca80ba6e6e93d083ce51a85 Author: Eelco Dolstra <eelco.dolstra@logicblox.com> Date: Thu Jan 30 12:11:06 2014 +0100 Rename Makefile -> local.mk commit 4a2ec9c6598aafb98e5495c2cf3a24e166668790 Author: Eelco Dolstra <eelco.dolstra@logicblox.com> Date: Thu Jan 30 12:08:26 2014 +0100 Install nix-worker symlink commit c5ba08133370f98de722c978bda3b446721985de Author: Eelco Dolstra <eelco.dolstra@logicblox.com> Date: Thu Jan 23 13:33:00 2014 +0100 nix-shell: Add --impure flag This is currently the default, but I might change that to --pure in the future. commit 79dee4283de798da8728dd8504cdc4ab5c9b9fe0 Author: Eelco Dolstra <eelco.dolstra@logicblox.com> Date: Thu Jan 23 13:31:29 2014 +0100 nix-shell: Preserve the TZ variable of the user commit 7fdee6e13695a1e85b0b3f476a33a9e934af3f0b Author: Eelco Dolstra <eelco.dolstra@logicblox.com> Date: Thu Jan 23 13:27:22 2014 +0100 nix-build: Refactor commit 5311b2b25084e53ff132df96d66ab06efead0853 Author: Eelco Dolstra <eelco.dolstra@logicblox.com> Date: Thu Jan 23 10:49:53 2014 +0100 Clang doesn't know the "-z defs" flag commit 94f9c14d526abfe9b18045fc638e8f5a3a670210 Author: Eelco Dolstra <eelco.dolstra@logicblox.com> Date: Tue Jan 21 18:29:55 2014 +0100 Fix some clang warnings commit a26307b28192e61bc06b5f5ef42f0fb51858d822 Author: Eelco Dolstra <eelco.dolstra@logicblox.com> Date: Tue Jan 21 17:39:19 2014 +0100 Fix build commit 625ffd441d8c98331ee357f4900fa50dd9be05bc Author: Eelco Dolstra <eelco.dolstra@logicblox.com> Date: Tue Jan 21 16:38:03 2014 +0100 Ugly hack to fix building with clang commit 68cde53c47e5447d2c91f5fe4521b5209af7b73e Author: Eelco Dolstra <eelco.dolstra@logicblox.com> Date: Tue Jan 21 15:34:04 2014 +0100 Fix building against Bison 3.0.2 commit 81628a6ccc6ce496735b22492bee15c9ad46f072 Merge: b1db599 5ef8508 Author: Eelco Dolstra <eelco.dolstra@logicblox.com> Date: Tue Jan 21 15:30:01 2014 +0100 Merge branch 'master' into make Conflicts: src/libexpr/eval.cc commit 5ef8508a92997dbd7f8aa501b64fd283fb1c7bb8 Author: Eelco Dolstra <eelco.dolstra@logicblox.com> Date: Tue Jan 21 15:11:57 2014 +0100 Remove unused type commit c8fff6a77fb63dc8043a7a468feea37b41bfec06 Author: Eelco Dolstra <eelco.dolstra@logicblox.com> Date: Tue Jan 21 15:09:59 2014 +0100 Fix evaluation commit 0e2ca268187e0a1c17f2ba58ce53f59682df2fc4 Author: Eelco Dolstra <eelco.dolstra@logicblox.com> Date: Mon Jan 20 14:23:07 2014 +0100 nix.spec: Remove "make check" since it's a no-op commit 0f2f44bb0ff8aafc160d8b236201ce510ca0b876 Author: Eelco Dolstra <eelco.dolstra@logicblox.com> Date: Mon Jan 20 14:22:59 2014 +0100 Build Fedora 20 RPMs commit bf0ad8aabca67b4faabe3a1ac3c57884ae9924f4 Author: Eelco Dolstra <eelco.dolstra@logicblox.com> Date: Wed Jan 15 14:34:49 2014 +0100 nix-profile.sh: Add the Nixpkgs channel to $NIX_PATH commit f5e5793cd2f32bc0f0d072b38cda742830f40f25 Author: Shea Levy <shea@shealevy.com> Date: Mon Jan 6 13:53:57 2014 -0500 Bare dynamic attrs: Match interpolation semantics Signed-off-by: Shea Levy <shea@shealevy.com> commit f9913f4422d1317af3c6b5aff37ad18b78083eb5 Author: Shea Levy <shea@shealevy.com> Date: Mon Jan 6 10:27:26 2014 -0500 Allow "bare" dynamic attrs Now, in addition to a."${b}".c, you can write a.${b}.c (applicable wherever dynamic attributes are valid). Signed-off-by: Shea Levy <shea@shealevy.com> commit e640d671443e291b3ca5cc0575919d6fcf14a157 Author: Eelco Dolstra <eelco.dolstra@logicblox.com> Date: Mon Jan 13 13:50:12 2014 +0100 Document nulls commit f1357059a441a588b9a2b78d3500d7068238b478 Author: Eelco Dolstra <eelco.dolstra@logicblox.com> Date: Mon Jan 13 13:46:44 2014 +0100 nix-shell: Don't set NIX_INDENT_MAKE It generally is not useful in interactive environments (and messes up some non-ANSI-compliant terminals). commit ea59f39326c8e9dc42dfed4bcbf597fbce58797c Author: Eelco Dolstra <eelco.dolstra@logicblox.com> Date: Mon Jan 13 13:42:29 2014 +0100 nix-shell: Set $IN_NIX_SHELL before evaluating commit ca73c0102fc68ece171d7cc062e464b4d418d07c Author: Eelco Dolstra <eelco.dolstra@logicblox.com> Date: Fri Jan 10 22:31:38 2014 +0100 Nicer Make output E.g. CXX src/nix-log2xml/log2xml.o CC src/bsdiff-4.3/bsdiff.o GEN scripts/nix-channel LD src/libmain/libnixmain.so commit e991ab942b6ed1bc50a63afafe55ffe5cae8cbad Author: Eelco Dolstra <eelco.dolstra@logicblox.com> Date: Thu Jan 9 22:14:34 2014 +0100 Add support for building shared libraries on Mac OS X commit b1db599dd05e86f65e73dc40584913e6e78c2bac Author: Eelco Dolstra <eelco.dolstra@logicblox.com> Date: Thu Jan 9 22:10:35 2014 +0100 Generate schema.sql.hh commit cf918b889b2ff30d1532a62d00c21007d0cb25cd Author: Eelco Dolstra <eelco.dolstra@logicblox.com> Date: Thu Jan 9 17:33:55 2014 +0100 Handle systems where "echo -n" doesn't work commit 70d8e8fdded9e21995fecc3ecc68e14cf4f53be7 Author: Eelco Dolstra <eelco.dolstra@logicblox.com> Date: Thu Jan 9 16:57:38 2014 +0100 Declare template_files as a simply expanded variable commit 814a73227f9571d8fbd831fedced5e87cd9c926b Author: Eelco Dolstra <eelco.dolstra@logicblox.com> Date: Thu Jan 9 16:54:01 2014 +0100 Remove duplicate elements from *_SOURCES This is useful when you do: foo_SOURCES := $(wildcard *.cc) foo.cc where foo.cc is a generated file. In this case, if foo.cc already exists, you get foo.cc twice in foo_SOURCES, leading to a link error. commit b4c684e0f9c6890e13f9a5cc90b5e379b3d1f75d Author: Eelco Dolstra <eelco.dolstra@logicblox.com> Date: Thu Jan 9 16:53:47 2014 +0100 Update Makefiles commit 568b1b0a8a65cb255d6a7a33dfe2c15df3212103 Author: Eelco Dolstra <eelco.dolstra@logicblox.com> Date: Thu Jan 9 16:15:16 2014 +0100 Remove mk subdirectory in preparation for "git subtree" commit 55c9a40613fefda6622aa9acd22cce4006fd1077 Author: Eelco Dolstra <eelco.dolstra@logicblox.com> Date: Thu Jan 9 16:12:02 2014 +0100 Move stuff to top-level This makes it easier to use with "git subtree". commit f4013b6189af731af42f99684ed7721076a54a0d Author: Eelco Dolstra <eelco.dolstra@logicblox.com> Date: Wed Jan 8 17:56:58 2014 +0100 Fix signed-binary-caches test commit ea38e39a203a96451b1d0469103b737de5a85105 Author: Eelco Dolstra <eelco.dolstra@logicblox.com> Date: Wed Jan 8 17:56:30 2014 +0100 Test whether Nix correctly checks the hash of downloaded NARs commit 11cb4bfb257f18c906ef1d6f14ed450be8fa49fe Author: Eelco Dolstra <eelco.dolstra@logicblox.com> Date: Wed Jan 8 17:32:40 2014 +0100 Fix checking of NAR hashes *headdesk* *headdesk* *headdesk* So since commit 22144afa8d9f8968da351618a1347072a93bd8aa, Nix hasn't actually checked whether the content of a downloaded NAR matches the hash specified in the manifest / NAR info file. Urghhh... commit 0fdf4da0e979f992db75cc17376e455ddc5a96d8 Author: Eelco Dolstra <eelco.dolstra@logicblox.com> Date: Wed Jan 8 15:23:41 2014 +0100 Support cryptographically signed binary caches NAR info files in binary caches can now have a cryptographic signature that Nix will verify before using the corresponding NAR file. To create a private/public key pair for signing and verifying a binary cache, do: $ openssl genrsa -out ./cache-key.sec 2048 $ openssl rsa -in ./cache-key.sec -pubout > ./cache-key.pub You should also come up with a symbolic name for the key, such as "cache.example.org-1". This will be used by clients to look up the public key. (It's a good idea to number keys, in case you ever need to revoke/replace one.) To create a binary cache signed with the private key: $ nix-push --dest /path/to/binary-cache --key ./cache-key.sec --key-name cache.example.org-1 The public key (cache-key.pub) should be distributed to the clients. They should have a nix.conf should contain something like: signed-binary-caches = * binary-cache-public-key-cache.example.org-1 = /path/to/cache-key.pub If all works well, then if Nix fetches something from the signed binary cache, you will see a message like: *** Downloading ‘http://cache.example.org/nar/7dppcj5sc1nda7l54rjc0g5l1hamj09j-subversion-1.7.11’ (signed by ‘cache.example.org-1’) to ‘/nix/store/7dppcj5sc1nda7l54rjc0g5l1hamj09j-subversion-1.7.11’... On the other hand, if the signature is wrong, you get a message like NAR info file `http://cache.example.org/7dppcj5sc1nda7l54rjc0g5l1hamj09j.narinfo' has an invalid signature; ignoring Signatures are implemented as a single line appended to the NAR info file, which looks like this: Signature: 1;cache.example.org-1;HQ9Xzyanq9iV...muQ== Thus the signature has 3 fields: a version (currently "1"), the ID of key, and the base64-encoded signature of the SHA-256 hash of the contents of the NAR info file up to but not including the Signature line. Issue #75. commit 405434e084fa994cc957249db7787731e9311fa8 Author: Eelco Dolstra <eelco.dolstra@logicblox.com> Date: Mon Jan 6 17:38:04 2014 +0100 Revert "nix-shell: Set $IN_NIX_SHELL before evaluation" This reverts commit 0c1198cf08576f16633b2344dc6513cefb567cfc. commit 7a61c88dbb517453f73c5b4ede4a4468e38cae32 Merge: 485f474 cd49fe4 Author: Eelco Dolstra <eelco.dolstra@logicblox.com> Date: Mon Jan 6 15:46:18 2014 +0100 Merge branch 'dynamic-attrs-no-sugar' of github.com:shlevy/nix commit 485f4740ee3ba4228ba3345873eb530466a8f42d Author: Domen Kožar <domen@dev.si> Date: Wed Jan 1 18:10:48 2014 +0100 wording commit fe23e28f12f5eedf387c974c73813f6de8320b21 Author: Eelco Dolstra <eelco.dolstra@logicblox.com> Date: Mon Jan 6 11:34:05 2014 +0100 Disable FreeBSD tests for now The FreeBSD machines in the build farm are currently unreachable. commit 4252b5a645138e84fa8916dfc3f8d6af8e74fc28 Author: Eelco Dolstra <eelco.dolstra@logicblox.com> Date: Mon Jan 6 11:32:22 2014 +0100 Disable the tail call test On i686-linux, GCC stubbornly refuses to do tail-call optimisation. Don't know why. http://hydra.nixos.org/build/7300170 commit cd49fe4f9b338242e1e404fd4dbb0a3ebc1c3a12 Author: Shea Levy <shea@shealevy.com> Date: Tue Dec 31 23:56:26 2013 +0000 Don't use any syntactic sugar for dynamic attrs This doesn't change any functionality but moves some behavior out of the parser and into the evaluator in order to simplify the code. Signed-off-by: Shea Levy <shea@shealevy.com> commit 6f3a51809a2603574a16573bd46b95e4ff5233bd Author: Shea Levy <shea@shealevy.com> Date: Tue Dec 31 17:57:10 2013 -0500 Fold dynamic binds handling into addAttr Since addAttr has to iterate through the AttrPath we pass it, it makes more sense to just iterate through the AttrNames in addAttr instead. As an added bonus, this allows attrsets where two dynamic attribute paths have the same static leading part (see added test case for an example that failed previously). Signed-off-by: Shea Levy <shea@shealevy.com> commit 18fefacf7df570444b332a8a0c2dc4f9d98d4344 Author: Shea Levy <shea@shealevy.com> Date: Fri Sep 20 23:25:30 2013 -0400 Dynamic attrs This adds new syntax for attribute names: * attrs."${name}" => getAttr name attrs * attrs ? "${name}" => isAttrs attrs && hasAttr attrs name * attrs."${name}" or def => if attrs ? "${name}" then attrs."${name}" else def * { "${name}" = value; } => listToAttrs [{ inherit name value; }] Of course, it's a bit more complicated than that. The attribute chains can be arbitrarily long and contain combinations of static and dynamic parts (e.g. attrs."${foo}".bar."${baz}" or qux), which is relatively straightforward for the getAttrs/hasAttrs cases but is more complex for the listToAttrs case due to rules about duplicate attribute definitions. For attribute sets with dynamic attribute names, duplicate static attributes are detected at parse time while duplicate dynamic attributes are detected when the attribute set is forced. So, for example, { a = null; a.b = null; "${"c"}" = true; } will be a parse-time error, while { a = {}; "${"a"}".b = null; c = true; } will be an eval-time error (technically that case could theoretically be detected at parse time, but the general case would require full evaluation). Moreover, duplicate dynamic attributes are not allowed even in cases where they would be with static attributes ({ a.b.d = true; a.b.c = false; } is legal, but { a."${"b"}".d = true; a."${"b"}".c = false; } is not). This restriction might be relaxed in the future in cases where the static variant would not be an error, but it is not obvious that that is desirable. Finally, recursive attribute sets with dynamic attributes have the static attributes in scope but not the dynamic ones. So rec { a = true; "${"b"}" = a; } is equivalent to { a = true; b = true; } but rec { "${"a"}" = true; b = a; } would be an error or use a from the surrounding scope if it exists. Note that the getAttr, getAttr or default, and hasAttr are all implemented purely in the parser as syntactic sugar, while attribute sets with dynamic attribute names required changes to the AST to be implemented cleanly. This is an alternative solution to and closes #167 Signed-off-by: Shea Levy <shea@shealevy.com> commit 136f2f7046dfed18fde0b5f9933ddfafc1518ef5 Author: Shea Levy <shea@shealevy.com> Date: Fri Sep 13 16:55:33 2013 -0400 Add the ExprBuiltin Expr type to the AST Certain desugaring schemes may require the parser to use some builtin function to do some of the work (e.g. currently `throw` is used to lazily cause an error if a `<>`-style path is not in the search path) Unfortunately, these names are not reserved keywords, so an expression that uses such a syntactic sugar will not see the expected behavior (see tests/lang/eval-okay-redefine-builtin.nix for an example). This adds the ExprBuiltin AST type, which when evaluated uses the value from the rootmost variable scope (which of course is initialized internally and can't shadow any of the builtins). Signed-off-by: Shea Levy <shea@shealevy.com> commit 5ba5993470a6ad532fc8e842084a574a88876b0a Author: Shea Levy <shea@shealevy.com> Date: Mon Dec 30 07:58:14 2013 -0500 nix-shell --pure: Don't clear IN_NIX_SHELL Signed-off-by: Shea Levy <shea@shealevy.com> commit b352fe2775d09993add893ebff8c0c4c8369182a Author: Eelco Dolstra <eelco.dolstra@logicblox.com> Date: Fri Dec 20 14:18:24 2013 +0100 Revert "Scan /proc/<pid>/cmdline for GC roots" This reverts commit 194e3374b89b8b2dec6296923877304bdb5c6ae2. Checking the command line for GC roots means that $ nix-store --delete $path will fail because $path is now a root because it's mentioned on the command line. commit 8931bf7168cbbc6a078bed6486b8081652663836 Author: Eelco Dolstra <eelco.dolstra@logicblox.com> Date: Fri Dec 20 13:09:12 2013 +0000 Doh commit f1e5dedb611d39ecc600fccb4eba4b0de730c5fc Author: Petr Rockai <me@mornfall.net> Date: Sun Nov 24 21:22:23 2013 +0100 perl: Call loadConfFile() in doInit to avoid screwing sqlite journal mode. If the database is opened through perl bindings (and even though nix.conf has use-sqlite-wal set to false), the database is automatically converted into WAL mode. This makes the next nix process to access the database convert it back to "truncate". If the database is still open at the time in wal mode by the perl program, this fails and crashes the nix doing the wal -> truncate conversion. commit 7d203faff6d74d839324cd082236381d20444d8e Author: Eelco Dolstra <eelco.dolstra@logicblox.com> Date: Fri Dec 20 13:56:42 2013 +0100 nix-env --set-flag: Barf if a selector doesn't match any installed package Fixes #184. commit 194e3374b89b8b2dec6296923877304bdb5c6ae2 Author: Eelco Dolstra <eelco.dolstra@logicblox.com> Date: Fri Dec 20 13:31:31 2013 +0100 Scan /proc/<pid>/cmdline for GC roots commit 769f66216504cd882ac7b6bdfa0dd1ff26f3efe5 Author: Eelco Dolstra <eelco.dolstra@logicblox.com> Date: Fri Dec 20 12:19:10 2013 +0000 nix-shell: Don't warn about the lack of a GC root commit 0c1198cf08576f16633b2344dc6513cefb567cfc Author: Eelco Dolstra <eelco.dolstra@logicblox.com> Date: Fri Dec 20 13:11:41 2013 +0100 nix-shell: Set $IN_NIX_SHELL before evaluation This has some hacky applications. commit 65a64522403f353880a501b02aca10fb96ea1c26 Author: Eelco Dolstra <eelco.dolstra@logicblox.com> Date: Fri Dec 20 13:10:14 2013 +0100 nix-shell: Handle --option correctly Fixes #181. commit 259086de841d155f7951c2cc50f799a4631aa512 Author: Eelco Dolstra <eelco.dolstra@logicblox.com> Date: Wed Dec 18 16:40:48 2013 +0100 Add support for building JARs from Java sources commit 99ed25accfd968003d3b0d294720828a1348ce47 Author: Eelco Dolstra <eelco.dolstra@logicblox.com> Date: Wed Dec 18 15:01:14 2013 +0100 Add a function for doing recursive wildcard searches Source: http://blog.jgc.org/2011/07/gnu-make-recursive-wildcard-function.html commit 7b0d8fb23d9c71f1efb119c1f267124349c82742 Author: Eelco Dolstra <eelco.dolstra@logicblox.com> Date: Tue Dec 17 18:16:04 2013 +0100 nix-shell --pure: Keep $TERM commit 088552b319d8f5896e6cfd6a8e449b4239696ea2 Author: Eelco Dolstra <eelco.dolstra@logicblox.com> Date: Tue Dec 17 12:13:48 2013 +0100 Set default installation paths commit e81b82a2cf0c7e460d02c554c597a6cf9a144e8e Author: Eelco Dolstra <eelco.dolstra@logicblox.com> Date: Mon Dec 16 16:51:05 2013 +0100 make dryclean: Sort names commit a630635d7f0e63a865ddd3b0a3cf2d44c603c0e5 Author: Eelco Dolstra <eelco.dolstra@logicblox.com> Date: Mon Dec 16 16:49:41 2013 +0100 No longer interpret $(..._SOURCES) relative to $(..._DIR) commit 4da804651378b612313c8fb71688f71a4717a26e Author: Eelco Dolstra <eelco.dolstra@logicblox.com> Date: Thu Dec 12 11:39:58 2013 +0100 Don't include all *.dep files commit 034bbcafafdbec0b2c4d29b1d5018bec20120e77 Author: Eelco Dolstra <eelco.dolstra@logicblox.com> Date: Thu Dec 12 11:27:47 2013 +0100 Add 'make help' commit 45131da736f21975e5b6d03f508b49f10621a30e Author: Eelco Dolstra <eelco.dolstra@logicblox.com> Date: Thu Dec 12 11:24:03 2013 +0100 Get rid of whitespace in $(d) commit c34f3c5ba4f353d67ec4a88a32c3aa688347aa4d Author: Eelco Dolstra <eelco.dolstra@logicblox.com> Date: Thu Dec 12 11:22:57 2013 +0100 Handle *.cpp extension commit dfcc64f556295481bfea0b68cab11604ec131189 Author: Eelco Dolstra <eelco.dolstra@logicblox.com> Date: Thu Dec 12 11:22:25 2013 +0100 Only provide 'make dist' if PACKAGE_NAME is set commit 3560f52cc427a4eb368815ae7dd9badffba84f3f Author: Eelco Dolstra <eelco.dolstra@logicblox.com> Date: Thu Dec 12 11:22:08 2013 +0100 dryclean: Show what actual files would be deleted commit 49a385096e08b42277b7105d5d8d1e0e62b6b7a4 Author: Eelco Dolstra <eelco.dolstra@logicblox.com> Date: Tue Dec 10 15:54:34 2013 +0100 Initial commit (imported from the Nix repo) commit e36229d27f9ab508e0abf1892f3e8c263d2f8c58 Author: Shea Levy <shea@shealevy.com> Date: Thu Dec 5 12:07:05 2013 -0500 Bump language version for new storePath feature This will allow e.g. channel expressions to use builtins.storePath IFF it is safe to do so without knowing if the path is valid yet. Signed-off-by: Shea Levy <shea@shealevy.com> commit 22d665019a3770148929b7504c73bcdbe025ec12 Author: Shea Levy <shea@shealevy.com> Date: Thu Dec 5 11:51:54 2013 -0500 builtins.storePath: Try to substitute the path if it is not yet valid Signed-off-by: Shea Levy <shea@shealevy.com> commit a6add93d734279db8503951ac6466c275b3c8e4e Author: Eelco Dolstra <eelco.dolstra@logicblox.com> Date: Tue Dec 10 13:13:59 2013 +0100 Garbage collector: Release locks on temporary root files This allows processes waiting for such locks to proceed during the trash deletion phase of the garbage collector. commit c5b8fe315162440c1d808bc0a684a412d78bfa76 Author: Eelco Dolstra <eelco.dolstra@logicblox.com> Date: Thu Dec 5 14:31:57 2013 -0500 Print a trace message if a build fails due to the platform being unknown commit bf8b66adcfdc04f2f0f0a482c66dd419a355cad6 Author: Eelco Dolstra <eelco.dolstra@logicblox.com> Date: Wed Dec 4 13:41:32 2013 -0500 Add missing file commit f3cf0436b520918e061bf91efef3bb19b99bf726 Author: Eelco Dolstra <eelco.dolstra@logicblox.com> Date: Mon Dec 2 20:21:31 2013 +0000 Install bsdiff and bspatch in $(libexecdir)/nix commit 0202ce6b94f287f70a6723473c73a4c7f135dae4 Author: Eelco Dolstra <eelco.dolstra@logicblox.com> Date: Mon Nov 25 18:47:03 2013 +0100 Add support for ‘make installcheck’ commit 9285f0aa2b44427afef7c50f0efae8f74307a7a5 Author: Eelco Dolstra <eelco.dolstra@logicblox.com