1# This module defines the packages that appear in
2# /run/current-system/sw.
3
4{ config, lib, pkgs, ... }:
5
6with lib;
7
8let
9
10 requiredPackages = map (pkg: setPrio ((pkg.meta.priority or 5) + 3) pkg)
11 [ pkgs.acl
12 pkgs.attr
13 pkgs.bashInteractive # bash with ncurses support
14 pkgs.bzip2
15 pkgs.coreutils-full
16 pkgs.cpio
17 pkgs.curl
18 pkgs.diffutils
19 pkgs.findutils
20 pkgs.gawk
21 pkgs.stdenv.cc.libc
22 pkgs.getent
23 pkgs.getconf
24 pkgs.gnugrep
25 pkgs.gnupatch
26 pkgs.gnused
27 pkgs.gnutar
28 pkgs.gzip
29 pkgs.xz
30 pkgs.less
31 pkgs.libcap
32 pkgs.ncurses
33 pkgs.netcat
34 config.programs.ssh.package
35 pkgs.mkpasswd
36 pkgs.procps
37 pkgs.su
38 pkgs.time
39 pkgs.util-linux
40 pkgs.which
41 pkgs.zstd
42 ];
43
44 defaultPackageNames =
45 [ "nano"
46 "perl"
47 "rsync"
48 "strace"
49 ];
50 defaultPackages =
51 map
52 (n: let pkg = pkgs.${n}; in setPrio ((pkg.meta.priority or 5) + 3) pkg)
53 defaultPackageNames;
54 defaultPackagesText = "[ ${concatMapStringsSep " " (n: "pkgs.${n}") defaultPackageNames } ]";
55
56in
57
58{
59 options = {
60
61 environment = {
62
63 systemPackages = mkOption {
64 type = types.listOf types.package;
65 default = [];
66 example = literalExpression "[ pkgs.firefox pkgs.thunderbird ]";
67 description = lib.mdDoc ''
68 The set of packages that appear in
69 /run/current-system/sw. These packages are
70 automatically available to all users, and are
71 automatically updated every time you rebuild the system
72 configuration. (The latter is the main difference with
73 installing them in the default profile,
74 {file}`/nix/var/nix/profiles/default`.
75 '';
76 };
77
78 defaultPackages = mkOption {
79 type = types.listOf types.package;
80 default = defaultPackages;
81 defaultText = literalMD ''
82 these packages, with their `meta.priority` numerically increased
83 (thus lowering their installation priority):
84
85 ${defaultPackagesText}
86 '';
87 example = [];
88 description = lib.mdDoc ''
89 Set of default packages that aren't strictly necessary
90 for a running system, entries can be removed for a more
91 minimal NixOS installation.
92
93 Note: If `pkgs.nano` is removed from this list,
94 make sure another editor is installed and the
95 `EDITOR` environment variable is set to it.
96 Environment variables can be set using
97 {option}`environment.variables`.
98
99 Like with systemPackages, packages are installed to
100 {file}`/run/current-system/sw`. They are
101 automatically available to all users, and are
102 automatically updated every time you rebuild the system
103 configuration.
104 '';
105 };
106
107 pathsToLink = mkOption {
108 type = types.listOf types.str;
109 # Note: We need `/lib' to be among `pathsToLink' for NSS modules
110 # to work.
111 default = [];
112 example = ["/"];
113 description = lib.mdDoc "List of directories to be symlinked in {file}`/run/current-system/sw`.";
114 };
115
116 extraOutputsToInstall = mkOption {
117 type = types.listOf types.str;
118 default = [ ];
119 example = [ "doc" "info" "devdoc" ];
120 description = lib.mdDoc "List of additional package outputs to be symlinked into {file}`/run/current-system/sw`.";
121 };
122
123 extraSetup = mkOption {
124 type = types.lines;
125 default = "";
126 description = lib.mdDoc "Shell fragments to be run after the system environment has been created. This should only be used for things that need to modify the internals of the environment, e.g. generating MIME caches. The environment being built can be accessed at $out.";
127 };
128
129 };
130
131 system = {
132
133 path = mkOption {
134 internal = true;
135 description = lib.mdDoc ''
136 The packages you want in the boot environment.
137 '';
138 };
139
140 };
141
142 };
143
144 config = {
145
146 environment.systemPackages = requiredPackages ++ config.environment.defaultPackages;
147
148 environment.pathsToLink =
149 [ "/bin"
150 "/etc/xdg"
151 "/etc/gtk-2.0"
152 "/etc/gtk-3.0"
153 "/lib" # FIXME: remove and update debug-info.nix
154 "/sbin"
155 "/share/emacs"
156 "/share/hunspell"
157 "/share/nano"
158 "/share/org"
159 "/share/themes"
160 "/share/vim-plugins"
161 "/share/vulkan"
162 "/share/kservices5"
163 "/share/kservicetypes5"
164 "/share/kxmlgui5"
165 "/share/systemd"
166 "/share/thumbnailers"
167 ];
168
169 system.path = pkgs.buildEnv {
170 name = "system-path";
171 paths = config.environment.systemPackages;
172 inherit (config.environment) pathsToLink extraOutputsToInstall;
173 ignoreCollisions = true;
174 # !!! Hacky, should modularise.
175 # outputs TODO: note that the tools will often not be linked by default
176 postBuild =
177 ''
178 # Remove wrapped binaries, they shouldn't be accessible via PATH.
179 find $out/bin -maxdepth 1 -name ".*-wrapped" -type l -delete
180
181 if [ -x $out/bin/glib-compile-schemas -a -w $out/share/glib-2.0/schemas ]; then
182 $out/bin/glib-compile-schemas $out/share/glib-2.0/schemas
183 fi
184
185 ${config.environment.extraSetup}
186 '';
187 };
188
189 };
190}