diff options
Diffstat (limited to 'modules')
-rw-r--r-- | modules/ryan-packages/package-management.scm | 233 | ||||
-rw-r--r-- | modules/ryan-services/nix.scm | 182 |
2 files changed, 415 insertions, 0 deletions
diff --git a/modules/ryan-packages/package-management.scm b/modules/ryan-packages/package-management.scm new file mode 100644 index 0000000..9629168 --- /dev/null +++ b/modules/ryan-packages/package-management.scm | |||
@@ -0,0 +1,233 @@ | |||
1 | (define-module (ryan-packages package-management) | ||
2 | #:use-module ((guix licenses) #:prefix license:) | ||
3 | #:use-module (guix build-system meson) | ||
4 | #:use-module (guix build-system cmake) | ||
5 | #:use-module (guix packages) | ||
6 | #:use-module (guix git-download) | ||
7 | #:use-module (guix gexp) | ||
8 | #:use-module (gnu packages) | ||
9 | #:use-module (gnu packages autotools) | ||
10 | #:use-module (gnu packages backup) | ||
11 | #:use-module (gnu packages bdw-gc) | ||
12 | #:use-module (gnu packages bison) | ||
13 | #:use-module (gnu packages boost) | ||
14 | #:use-module (gnu packages compression) | ||
15 | #:use-module (gnu packages check) | ||
16 | #:use-module (gnu packages cmake) | ||
17 | #:use-module (gnu packages cpp) | ||
18 | #:use-module (gnu packages crypto) | ||
19 | #:use-module (gnu packages curl) | ||
20 | #:use-module (gnu packages databases) | ||
21 | #:use-module (gnu packages flex) | ||
22 | #:use-module (gnu packages gcc) | ||
23 | #:use-module (gnu packages libedit) | ||
24 | #:use-module (gnu packages linux) | ||
25 | #:use-module (gnu packages llvm) | ||
26 | #:use-module (gnu packages markup) | ||
27 | #:use-module (gnu packages package-management) | ||
28 | #:use-module (gnu packages perl) | ||
29 | #:use-module (gnu packages pkg-config) | ||
30 | #:use-module (gnu packages sqlite) | ||
31 | #:use-module (gnu packages tls) | ||
32 | #:use-module (gnu packages version-control) | ||
33 | #:use-module (gnu packages web) | ||
34 | #:use-module (guix utils)) | ||
35 | |||
36 | (define-public nix-ryan | ||
37 | (package | ||
38 | (name "nix") | ||
39 | (version "2.26.3") | ||
40 | (source | ||
41 | (origin | ||
42 | (method git-fetch) | ||
43 | (uri (git-reference | ||
44 | (url "https://github.com/NixOS/nix") | ||
45 | (commit version))) | ||
46 | (file-name (git-file-name "nix" version)) | ||
47 | (sha256 | ||
48 | (base32 "1rh9k0cdixahqzziylgg7p8j9p58h55m08h3l1kg369wlmi7r5g5")))) | ||
49 | (build-system meson-build-system) | ||
50 | (arguments | ||
51 | (list | ||
52 | #:configure-flags #~(list "--sysconfdir=/etc") | ||
53 | #:tests? #f)) | ||
54 | (native-inputs | ||
55 | (list autoconf | ||
56 | autoconf-archive | ||
57 | automake | ||
58 | bison | ||
59 | gcc-14 | ||
60 | cmake | ||
61 | flex | ||
62 | perl | ||
63 | perl-dbi | ||
64 | perl-dbd-sqlite | ||
65 | googletest | ||
66 | jq | ||
67 | libtool | ||
68 | pkg-config | ||
69 | rapidcheck)) | ||
70 | (inputs | ||
71 | (list boost-ryan | ||
72 | brotli | ||
73 | bzip2 | ||
74 | curl | ||
75 | editline | ||
76 | libarchive | ||
77 | libgc-ryan | ||
78 | libseccomp-ryan | ||
79 | libsodium | ||
80 | libbl3 | ||
81 | libgit2-1.9 | ||
82 | lowdown | ||
83 | nlohmann-json | ||
84 | openssl | ||
85 | sqlite | ||
86 | toml11 | ||
87 | xz | ||
88 | zlib)) | ||
89 | (home-page "https://nixos.org/") | ||
90 | (synopsis "The Nix package manager") | ||
91 | (description "todo") | ||
92 | (license license:lgpl2.1+))) | ||
93 | |||
94 | (define libbl3 | ||
95 | (package | ||
96 | (name "blake3") | ||
97 | (version "1.7.0") | ||
98 | (source | ||
99 | (origin | ||
100 | (method git-fetch) | ||
101 | (uri (git-reference | ||
102 | (url "https://github.com/BLAKE3-team/BLAKE3") | ||
103 | (commit version))) | ||
104 | (file-name (git-file-name name version)) | ||
105 | (sha256 | ||
106 | (base32 "1dsx5jmr8csgzdvfxf4byc1086rg6vclqgqkz54la8rpfn3gkh6k")))) | ||
107 | (build-system cmake-build-system) | ||
108 | (arguments | ||
109 | (list | ||
110 | #:configure-flags #~(list "-DCMAKE_POSITION_INDEPENDENT_CODE=on") | ||
111 | #:phases | ||
112 | #~(modify-phases %standard-phases | ||
113 | (add-after 'unpack 'enter-build-directory | ||
114 | (lambda _ (chdir "c") #t)) | ||
115 | (add-before 'build 'set-env | ||
116 | (lambda _ | ||
117 | (setenv "CFLAGS" "-fPIC") | ||
118 | (setenv "CXXFLAGS" "-fPIC") | ||
119 | #t))))) | ||
120 | (home-page "https://github.com/BLAKE3-team/BLAKE3") | ||
121 | (synopsis "Official C implementation of BLAKE3") | ||
122 | (description "todo") | ||
123 | (license license:expat))) | ||
124 | |||
125 | (define toml11 | ||
126 | (package | ||
127 | (name "toml11") | ||
128 | (version "v4.4.0") | ||
129 | (source | ||
130 | (origin | ||
131 | (method git-fetch) | ||
132 | (uri (git-reference | ||
133 | (url "https://github.com/ToruNiina/toml11") | ||
134 | (commit version))) | ||
135 | (sha256 | ||
136 | (base32 "0d15b50cf9jgvh3w99xh6crh03bn2dmv9bdyvzq6knsk2diql1dj")))) | ||
137 | (build-system cmake-build-system) | ||
138 | (home-page "https://github.com/ToruNiina/toml11") | ||
139 | (synopsis "TODO") | ||
140 | (description "TODO") | ||
141 | (license license:expat))) | ||
142 | |||
143 | (define libgit2-1.9 | ||
144 | (package | ||
145 | (inherit libgit2-1.8) | ||
146 | (version "1.9.0") | ||
147 | (source (origin | ||
148 | (inherit (package-source libgit2-1.8)) | ||
149 | (uri (git-reference | ||
150 | (url "https://github.com/libgit2/libgit2") | ||
151 | (commit (string-append "v" version)))) | ||
152 | (file-name (git-file-name "libgit2" version)) | ||
153 | (sha256 | ||
154 | (base32 | ||
155 | "06ajn5i5l1209z7x7jxcpw68ph0a6g3q67bmx0jm381rr8cb4zdz")) | ||
156 | (snippet | ||
157 | #~(begin | ||
158 | (for-each delete-file-recursively | ||
159 | '("deps/llhttp" | ||
160 | "deps/ntlmclient" | ||
161 | "deps/pcre" | ||
162 | "deps/winhttp" | ||
163 | "deps/zlib")))))))) | ||
164 | |||
165 | (define libgc-ryan | ||
166 | (package | ||
167 | (inherit libgc) | ||
168 | (version "8.2.8") | ||
169 | (source (origin | ||
170 | (method git-fetch) | ||
171 | (uri (git-reference | ||
172 | (url "https://github.com/ivmai/bdwgc") | ||
173 | (commit (string-append "v" version)))) | ||
174 | (file-name (git-file-name "libgc" version)) | ||
175 | (sha256 | ||
176 | (base32 "1xzvr5wb36flkbjqjyk5ilhda1a3yk61rgprxfjzdf1rzlmqn12i")))) | ||
177 | (native-inputs (modify-inputs (package-native-inputs libgc) (prepend autoconf autoconf-archive automake libtool))))) | ||
178 | |||
179 | (define boost-ryan | ||
180 | (package | ||
181 | (inherit boost) | ||
182 | (version "1.87.0") | ||
183 | (source (origin | ||
184 | (method git-fetch) | ||
185 | (uri (git-reference | ||
186 | (url "https://github.com/boostorg/boost") | ||
187 | (commit (string-append "boost-" version)) | ||
188 | (recursive? #t))) | ||
189 | (file-name (git-file-name "boost" version)) | ||
190 | (sha256 | ||
191 | (base32 "1xirczrh2rgk2x70crw33w6566d2by9q675wlyv0zj69f49z8prn")))) | ||
192 | (native-inputs (modify-inputs (package-native-inputs boost) (prepend clang-18))) | ||
193 | (arguments | ||
194 | (append | ||
195 | (substitute-keyword-arguments (package-arguments boost)) | ||
196 | (list | ||
197 | #:tests? #f | ||
198 | #:configure-flags | ||
199 | #~(let ((icu (dirname (dirname (search-input-file | ||
200 | %build-inputs "bin/uconv"))))) | ||
201 | (list | ||
202 | ;; Auto-detection looks for ICU only in traditional | ||
203 | ;; install locations. | ||
204 | (string-append "--with-icu=" icu) | ||
205 | ;; Ditto for Python. | ||
206 | #$@(if (%current-target-system) | ||
207 | #~() | ||
208 | #~((let ((python (dirname (dirname (search-input-file | ||
209 | %build-inputs | ||
210 | "bin/python"))))) | ||
211 | (string-append "--with-python-root=" python) | ||
212 | (string-append "--with-python=" python | ||
213 | "/bin/python") | ||
214 | (string-append "--with-python-version=" | ||
215 | (python-version python))))) | ||
216 | "--with-toolset=clang"))))))) | ||
217 | |||
218 | (define libseccomp-ryan | ||
219 | (package | ||
220 | (inherit libseccomp) | ||
221 | (version "2.6.0") | ||
222 | (source (origin | ||
223 | (method git-fetch) | ||
224 | (uri (git-reference | ||
225 | (url "https://github.com/seccomp/libseccomp") | ||
226 | (commit (string-append "v" version)))) | ||
227 | (file-name (git-file-name "libseccomp" version)) | ||
228 | (sha256 | ||
229 | (base32 "189yh66aj3z3jvns739qbj504f3mcl3w44pxxizw877pbj3kal11")))) | ||
230 | (native-inputs (modify-inputs (package-native-inputs libseccomp) (prepend autoconf autoconf-archive automake libtool))))) | ||
231 | |||
232 | |||
233 | nix-ryan | ||
diff --git a/modules/ryan-services/nix.scm b/modules/ryan-services/nix.scm new file mode 100644 index 0000000..75c9082 --- /dev/null +++ b/modules/ryan-services/nix.scm | |||
@@ -0,0 +1,182 @@ | |||
1 | ;;; GNU Guix --- Functional package management for GNU | ||
2 | ;;; Copyright © 2019, 2020, 2021, 2024 Oleg Pykhalov <go.wigust@gmail.com> | ||
3 | ;;; Copyright © 2020 Peng Mei Yu <i@pengmeiyu.com> | ||
4 | ;;; | ||
5 | ;;; This file is part of GNU Guix. | ||
6 | ;;; | ||
7 | ;;; GNU Guix is free software; you can redistribute it and/or modify it | ||
8 | ;;; under the terms of the GNU General Public License as published by | ||
9 | ;;; the Free Software Foundation; either version 3 of the License, or (at | ||
10 | ;;; your option) any later version. | ||
11 | ;;; | ||
12 | ;;; GNU Guix is distributed in the hope that it will be useful, but | ||
13 | ;;; WITHOUT ANY WARRANTY; without even the implied warranty of | ||
14 | ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
15 | ;;; GNU General Public License for more details. | ||
16 | ;;; | ||
17 | ;;; You should have received a copy of the GNU General Public License | ||
18 | ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>. | ||
19 | |||
20 | (define-module (ryan-services nix) | ||
21 | #:use-module (gnu packages admin) | ||
22 | #:use-module (gnu packages bash) | ||
23 | #:use-module (gnu packages package-management) | ||
24 | #:use-module (gnu services base) | ||
25 | #:use-module (gnu services configuration) | ||
26 | #:use-module (gnu services shepherd) | ||
27 | #:use-module (gnu services web) | ||
28 | #:use-module (gnu services) | ||
29 | #:use-module (gnu system file-systems) | ||
30 | #:use-module (gnu system shadow) | ||
31 | #:use-module (guix gexp) | ||
32 | #:use-module (guix packages) | ||
33 | #:use-module (guix records) | ||
34 | #:use-module (guix store) | ||
35 | #:use-module (srfi srfi-1) | ||
36 | #:use-module (srfi srfi-26) | ||
37 | #:use-module (ice-9 match) | ||
38 | #:use-module (ice-9 format) | ||
39 | #:use-module (guix modules) | ||
40 | #:export (nix-service-type | ||
41 | |||
42 | nix-configuration | ||
43 | nix-configuration?)) | ||
44 | |||
45 | ;;; Commentary: | ||
46 | ;;; | ||
47 | ;;; This module provides a service definition for the Nix daemon. | ||
48 | ;;; | ||
49 | ;;; Code: | ||
50 | |||
51 | (define-record-type* <nix-configuration> | ||
52 | nix-configuration make-nix-configuration | ||
53 | nix-configuration? | ||
54 | (package nix-configuration-package ;file-like | ||
55 | (default nix)) | ||
56 | (sandbox nix-configuration-sandbox ;boolean | ||
57 | (default #t)) | ||
58 | (build-directory nix-configuration-build-directory ;string | ||
59 | (default "/tmp")) | ||
60 | (build-sandbox-items nix-configuration-build-sandbox-items ;list of strings | ||
61 | (default '())) | ||
62 | (extra-config nix-configuration-extra-config ;list of strings | ||
63 | (default '())) | ||
64 | (extra-options nix-configuration-extra-options ;list of strings | ||
65 | (default '()))) | ||
66 | |||
67 | ;; Copied from gnu/services/base.scm | ||
68 | (define* (nix-build-accounts count #:key | ||
69 | (group "nixbld") | ||
70 | (shadow shadow)) | ||
71 | "Return a list of COUNT user accounts for Nix build users with the given | ||
72 | GID." | ||
73 | (unfold (cut > <> count) | ||
74 | (lambda (n) | ||
75 | (user-account | ||
76 | (name (format #f "nixbld~2,'0d" n)) | ||
77 | (system? #t) | ||
78 | (group group) | ||
79 | (supplementary-groups (list group "kvm")) | ||
80 | (comment (format #f "Nix Build User ~2d" n)) | ||
81 | (home-directory "/var/empty") | ||
82 | (shell (file-append shadow "/sbin/nologin")))) | ||
83 | 1+ | ||
84 | 1)) | ||
85 | (define (nix-accounts _) | ||
86 | "Return the user accounts and user groups." | ||
87 | (cons (user-group | ||
88 | (name "nixbld") | ||
89 | (system? #t) | ||
90 | |||
91 | ;; Use a fixed GID so that we can create the store with the right | ||
92 | ;; owner. | ||
93 | (id 40000)) | ||
94 | (nix-build-accounts 10 #:group "nixbld"))) | ||
95 | |||
96 | (define (nix-activation _) | ||
97 | ;; Return the activation gexp. | ||
98 | #~(begin | ||
99 | (use-modules (guix build utils) | ||
100 | (srfi srfi-26)) | ||
101 | (for-each (cut mkdir-p <>) '("/nix/var/log" | ||
102 | "/nix/var/nix/gcroots/per-user" | ||
103 | "/nix/var/nix/profiles/per-user")) | ||
104 | (unless (file-exists? #$%nix-store-directory) | ||
105 | (mkdir-p #$%nix-store-directory) | ||
106 | (chown #$%nix-store-directory | ||
107 | (passwd:uid (getpw "root")) (group:gid (getpw "nixbld01"))) | ||
108 | (chmod #$%nix-store-directory #o775)) | ||
109 | (for-each (cut chmod <> #o777) '("/nix/var/nix/profiles" | ||
110 | "/nix/var/nix/profiles/per-user")))) | ||
111 | |||
112 | (define nix-service-etc | ||
113 | (match-lambda | ||
114 | (($ <nix-configuration> package sandbox build-directory build-sandbox-items extra-config) | ||
115 | (let ((ref-file (references-file package))) | ||
116 | `(("nix/nix.conf" | ||
117 | ,(computed-file | ||
118 | "nix.conf" | ||
119 | #~(begin | ||
120 | (use-modules (srfi srfi-26) | ||
121 | (ice-9 format)) | ||
122 | (with-output-to-file #$output | ||
123 | (lambda _ | ||
124 | (define internal-sandbox-paths | ||
125 | (call-with-input-file #$ref-file read)) | ||
126 | |||
127 | (format #t "sandbox = ~a~%" (if #$sandbox "true" "false")) | ||
128 | ;; config.nix captures store file names. | ||
129 | (format #t "sandbox-paths = ~{~a ~}~%" | ||
130 | (append (list (string-append "/bin/sh=" #$bash-minimal "/bin/bash")) | ||
131 | internal-sandbox-paths | ||
132 | '#$build-sandbox-items)) | ||
133 | (for-each (cut display <>) '#$extra-config))))))))))) | ||
134 | |||
135 | (define %nix-store-directory | ||
136 | "/nix/store") | ||
137 | |||
138 | (define %immutable-nix-store | ||
139 | ;; Read-only store to avoid users or daemons accidentally modifying it. | ||
140 | ;; 'nix-daemon' has provisions to remount it read-write in its own name | ||
141 | ;; space. | ||
142 | (list (file-system | ||
143 | (device %nix-store-directory) | ||
144 | (mount-point %nix-store-directory) | ||
145 | (type "none") | ||
146 | (check? #f) | ||
147 | (flags '(read-only bind-mount))))) | ||
148 | |||
149 | (define nix-shepherd-service | ||
150 | ;; Return a <shepherd-service> for Nix. | ||
151 | (match-lambda | ||
152 | (($ <nix-configuration> package _ build-directory _ _ extra-options) | ||
153 | (list | ||
154 | (shepherd-service | ||
155 | (provision '(nix-daemon)) | ||
156 | (documentation "Run nix-daemon.") | ||
157 | (requirement '(user-processes file-system-/nix/store)) | ||
158 | (start #~(make-forkexec-constructor | ||
159 | (list (string-append #$package "/bin/nix-daemon") | ||
160 | #$@extra-options) | ||
161 | #:environment-variables | ||
162 | (list (string-append "TMPDIR=" #$build-directory) | ||
163 | "PATH=/run/current-system/profile/bin"))) | ||
164 | (respawn? #f) | ||
165 | (stop #~(make-kill-destructor))))))) | ||
166 | |||
167 | (define nix-service-type | ||
168 | (service-type | ||
169 | (name 'nix) | ||
170 | (extensions | ||
171 | (list (service-extension shepherd-root-service-type nix-shepherd-service) | ||
172 | (service-extension account-service-type nix-accounts) | ||
173 | (service-extension activation-service-type nix-activation) | ||
174 | (service-extension etc-service-type nix-service-etc) | ||
175 | (service-extension profile-service-type | ||
176 | (compose list nix-configuration-package)) | ||
177 | (service-extension file-system-service-type | ||
178 | (const %immutable-nix-store)))) | ||
179 | (description "Run the Nix daemon.") | ||
180 | (default-value (nix-configuration)))) | ||
181 | |||
182 | ;;; nix.scm ends here | ||