aboutsummaryrefslogtreecommitdiff
blob: 4c31e3389d9cdf9ed6aad9cbf6ccef4cee6491dc (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
;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2012, 2013, 2015 Ludovic Courtès <ludo@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 (test-snix)
  #:use-module (guix import snix)
  #:use-module (srfi srfi-1)
  #:use-module (srfi srfi-64)
  #:use-module (ice-9 match))

(define %nixpkgs-directory
  (getenv "NIXPKGS"))

(define factorize-uri
  (@@ (guix import snix) factorize-uri))

(define-syntax-rule (every? proc lists ...)
  (not (not (every proc lists ...))))

(test-begin "snix")

(test-assert "factorize-uri"
  (every? (match-lambda
           ((uri version '-> expected)
            (equal? (factorize-uri uri version)
                    expected)))
          '(("http://example.com/foo.tgz" "1.0"
             -> "http://example.com/foo.tgz")
            ("http://example.com/foo-2.8.tgz" "2.8"
             -> ("http://example.com/foo-" version ".tgz"))
            ("http://example.com/2.8/foo-2.8.tgz" "2.8"
             -> ("http://example.com/" version "/foo-" version ".tgz")))))

(test-skip (if (and %nixpkgs-directory
                    (file-exists? (string-append %nixpkgs-directory
                                                 "/default.nix")))
               0
               1))

(test-assert "nixpkgs->guix-package"
  (match (nixpkgs->guix-package %nixpkgs-directory "guile")
    (('package
       ('name "guile")
       ('version (? string?))
       ('source ('origin _ ...))
       ('build-system _)
       ('inputs ('quasiquote (inputs ...)))
       ('propagated-inputs ('quasiquote (pinputs ...)))
       ('home-page (? string?))
       ('synopsis (? string?))
       ('description (? string?))
       ('license (? symbol?)))
     (and (member '("libffi" ,libffi) inputs)
          (member '("gmp" ,gmp) pinputs)
          #t))
    (x
     (pk 'fail x #f))))

(test-end "snix")
var_run_t (lnk_file (read))) (allow guix_daemon_t var_run_t (dir (search))) ;; Spawning processes, execute helpers (allow guix_daemon_t self (process (fork execmem setrlimit setpgid setsched))) (allow guix_daemon_t guix_daemon_exec_t (file (execute execute_no_trans read write open entrypoint map getattr link unlink))) ;; Remounting /gnu/store read-write. (allow guix_daemon_t fs_t (filesystem (remount))) ;; TODO: unknown (allow guix_daemon_t root_t (dir (mounton))) (allow guix_daemon_t fs_t (filesystem (getattr))) (allow guix_daemon_conf_t fs_t (filesystem (associate))) ;; Build isolation (allow guix_daemon_t guix_store_content_t (file (ioctl mounton))) (allow guix_store_content_t fs_t (filesystem (associate))) (allow guix_daemon_t guix_store_content_t (dir (read mounton))) (allow guix_daemon_t guix_daemon_t (capability (net_admin fsetid fowner chown setuid setgid dac_override dac_read_search sys_chroot sys_admin))) (allow guix_daemon_t fs_t (filesystem (unmount))) (allow guix_daemon_t devpts_t (dir (search))) (allow guix_daemon_t devpts_t (filesystem (mount))) (allow guix_daemon_t devpts_t (chr_file (ioctl open read write setattr getattr))) (allow guix_daemon_t tmpfs_t (filesystem (getattr mount))) (allow guix_daemon_t tmpfs_t (file (create open read unlink write))) (allow guix_daemon_t ;same as above, but with tmp_t tmp_t (file (create open read unlink write))) (allow guix_daemon_t tmpfs_t (dir (getattr add_name remove_name write))) (allow guix_daemon_t proc_t (file (getattr open read))) (allow guix_daemon_t proc_t (dir (read))) (allow guix_daemon_t proc_t (filesystem (associate mount))) (allow guix_daemon_t null_device_t (chr_file (getattr open read write))) (allow guix_daemon_t kvm_device_t (chr_file (getattr))) (allow guix_daemon_t zero_device_t (chr_file (getattr))) (allow guix_daemon_t urandom_device_t (chr_file (getattr))) (allow guix_daemon_t random_device_t (chr_file (getattr))) (allow guix_daemon_t devtty_t (chr_file (getattr))) ;; Access to store items (allow guix_daemon_t guix_store_content_t (dir (reparent create getattr setattr search rename add_name remove_name open write rmdir relabelfrom))) (allow guix_daemon_t guix_store_content_t (file (create lock setattr getattr execute execute_no_trans link unlink map rename append open read write relabelfrom))) (allow guix_daemon_t guix_store_content_t (lnk_file (create getattr setattr link unlink read rename))) (allow guix_daemon_t guix_store_content_t (fifo_file (create getattr open read unlink write))) (allow guix_daemon_t guix_store_content_t (sock_file (create getattr setattr unlink write))) ;; Access to run state directories (allow guix_daemon_t system_dbusd_var_run_t (dir (search))) (allow guix_daemon_t init_var_run_t (dir (search))) ;; Access to configuration files and directories (allow guix_daemon_t guix_daemon_conf_t (dir (search create setattr getattr add_name remove_name open read write))) (allow guix_daemon_t guix_daemon_conf_t (file (create rename lock map getattr setattr unlink open read write))) (allow guix_daemon_t guix_daemon_conf_t (lnk_file (create getattr rename unlink read))) (allow guix_daemon_t net_conf_t (file (getattr open read))) (allow guix_daemon_t net_conf_t (lnk_file (read))) (allow guix_daemon_t NetworkManager_var_run_t (dir (search))) ;; Access to profiles (allow guix_daemon_t guix_profiles_t (dir (search getattr setattr read write open create add_name))) (allow guix_daemon_t guix_profiles_t (lnk_file (read getattr))) ;; Access to profile links in the home directory ;; TODO: allow access to profile links *anywhere* on the filesystem (allow guix_daemon_t user_home_t (lnk_file (read getattr))) (allow guix_daemon_t user_home_t (dir (search))) (allow guix_daemon_t cache_home_t (dir (search))) (allow guix_daemon_t cache_home_t (lnk_file (getattr read))) ;; self upgrades (allow guix_daemon_t self (dir (add_name write))) (allow guix_daemon_t self (netlink_route_socket (bind create getattr nlmsg_read read write getopt))) ;; Socket operations (allow guix_daemon_t guix_daemon_socket_t (sock_file (unlink write))) (allow guix_daemon_t init_t (fd (use))) (allow guix_daemon_t init_t (unix_stream_socket (write))) (allow guix_daemon_t guix_daemon_conf_t (unix_stream_socket (listen))) (allow guix_daemon_t guix_daemon_conf_t (sock_file (create unlink write))) (allow guix_daemon_t self (unix_stream_socket (create read write connect bind accept getopt setopt))) (allow guix_daemon_t self (tcp_socket (accept listen bind connect create setopt getopt getattr ioctl read write shutdown))) (allow guix_daemon_t unreserved_port_t (tcp_socket (name_bind name_connect accept listen))) (allow guix_daemon_t self (udp_socket (connect getattr bind getopt setopt read write))) (allow guix_daemon_t self (fifo_file (write read))) (allow guix_daemon_t self (udp_socket (ioctl create))) (allow guix_daemon_t self (unix_stream_socket (connectto))) (allow guix_daemon_t self (unix_dgram_socket (create bind connect sendto read write))) ;; For some esoteric build jobs (i.e. running PostgreSQL, etc). (allow guix_daemon_t self (capability (kill))) (allow guix_daemon_t node_t (tcp_socket (node_bind))) (allow guix_daemon_t node_t (udp_socket (node_bind))) (allow guix_daemon_t port_t (tcp_socket (name_connect))) (allow guix_daemon_t tmpfs_t (file (map read write link getattr))) (allow guix_daemon_t usermodehelper_t (file (read))) (allow guix_daemon_t hugetlbfs_t (file (map read write))) (allow guix_daemon_t proc_net_t (file (read))) (allow guix_daemon_t postgresql_port_t (tcp_socket (name_connect name_bind))) (allow guix_daemon_t rtp_media_port_t (udp_socket (name_bind))) (allow guix_daemon_t vnc_port_t (tcp_socket (name_bind))) ;; I guess sometimes it needs random numbers (allow guix_daemon_t random_device_t (chr_file (read))) ;; guix system vm (allow guix_daemon_t kvm_device_t (chr_file (ioctl open read write))) (allow guix_daemon_t kernel_t (system (ipc_info))) ;; Label file system (filecon "@guix_sysconfdir@/guix(/.*)?" any (system_u object_r guix_daemon_conf_t (low low))) (filecon "@guix_localstatedir@/guix(/.*)?" any (system_u object_r guix_daemon_conf_t (low low))) (filecon "@guix_localstatedir@/guix/profiles(/.*)?" any (system_u object_r guix_profiles_t (low low))) (filecon "/gnu" dir (unconfined_u object_r guix_store_content_t (low low))) (filecon "@storedir@(/.+)?" any (unconfined_u object_r guix_store_content_t (low low))) (filecon "@storedir@/[^/]+/.+" any (unconfined_u object_r guix_store_content_t (low low))) (filecon "@prefix@/bin/guix-daemon" file (system_u object_r guix_daemon_exec_t (low low))) (filecon "@guix_localstatedir@/guix/profiles/per-user/[^/]+/current-guix/bin/guix-daemon" file (system_u object_r guix_daemon_exec_t (low low))) (filecon "@storedir@/.+-(guix-.+|profile)/bin/guix-daemon" file (system_u object_r guix_daemon_exec_t (low low))) (filecon "@storedir@/[a-z0-9]+-guix-daemon" file (system_u object_r guix_daemon_exec_t (low low))) (filecon "@guix_localstatedir@/guix/daemon-socket/socket" any (system_u object_r guix_daemon_socket_t (low low))))