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 defaultPackages = map (pkg: setPrio ((pkg.meta.priority or 5) + 3) pkg)
45 [ pkgs.nano
46 pkgs.perl
47 pkgs.rsync
48 pkgs.strace
49 ];
50
51in
52
53{
54 options = {
55
56 environment = {
57
58 systemPackages = mkOption {
59 type = types.listOf types.package;
60 default = [];
61 example = literalExpression "[ pkgs.firefox pkgs.thunderbird ]";
62 description = ''
63 The set of packages that appear in
64 /run/current-system/sw. These packages are
65 automatically available to all users, and are
66 automatically updated every time you rebuild the system
67 configuration. (The latter is the main difference with
68 installing them in the default profile,
69 <filename>/nix/var/nix/profiles/default</filename>.
70 '';
71 };
72
73 defaultPackages = mkOption {
74 type = types.listOf types.package;
75 default = defaultPackages;
76 example = [];
77 description = ''
78 Set of default packages that aren't strictly necessary
79 for a running system, entries can be removed for a more
80 minimal NixOS installation.
81
82 Note: If <package>pkgs.nano</package> is removed from this list,
83 make sure another editor is installed and the
84 <literal>EDITOR</literal> environment variable is set to it.
85 Environment variables can be set using
86 <option>environment.variables</option>.
87
88 Like with systemPackages, packages are installed to
89 <filename>/run/current-system/sw</filename>. They are
90 automatically available to all users, and are
91 automatically updated every time you rebuild the system
92 configuration.
93 '';
94 };
95
96 pathsToLink = mkOption {
97 type = types.listOf types.str;
98 # Note: We need `/lib' to be among `pathsToLink' for NSS modules
99 # to work.
100 default = [];
101 example = ["/"];
102 description = "List of directories to be symlinked in <filename>/run/current-system/sw</filename>.";
103 };
104
105 extraOutputsToInstall = mkOption {
106 type = types.listOf types.str;
107 default = [ ];
108 example = [ "doc" "info" "devdoc" ];
109 description = "List of additional package outputs to be symlinked into <filename>/run/current-system/sw</filename>.";
110 };
111
112 extraSetup = mkOption {
113 type = types.lines;
114 default = "";
115 description = "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.";
116 };
117
118 };
119
120 system = {
121
122 path = mkOption {
123 internal = true;
124 description = ''
125 The packages you want in the boot environment.
126 '';
127 };
128
129 };
130
131 };
132
133 config = {
134
135 environment.systemPackages = requiredPackages ++ config.environment.defaultPackages;
136
137 environment.pathsToLink =
138 [ "/bin"
139 "/etc/xdg"
140 "/etc/gtk-2.0"
141 "/etc/gtk-3.0"
142 "/lib" # FIXME: remove and update debug-info.nix
143 "/sbin"
144 "/share/emacs"
145 "/share/hunspell"
146 "/share/nano"
147 "/share/org"
148 "/share/themes"
149 "/share/vim-plugins"
150 "/share/vulkan"
151 "/share/kservices5"
152 "/share/kservicetypes5"
153 "/share/kxmlgui5"
154 "/share/systemd"
155 "/share/thumbnailers"
156 ];
157
158 system.path = pkgs.buildEnv {
159 name = "system-path";
160 paths = config.environment.systemPackages;
161 inherit (config.environment) pathsToLink extraOutputsToInstall;
162 ignoreCollisions = true;
163 # !!! Hacky, should modularise.
164 # outputs TODO: note that the tools will often not be linked by default
165 postBuild =
166 ''
167 # Remove wrapped binaries, they shouldn't be accessible via PATH.
168 find $out/bin -maxdepth 1 -name ".*-wrapped" -type l -delete
169
170 if [ -x $out/bin/glib-compile-schemas -a -w $out/share/glib-2.0/schemas ]; then
171 $out/bin/glib-compile-schemas $out/share/glib-2.0/schemas
172 fi
173
174 ${config.environment.extraSetup}
175 '';
176 };
177
178 };
179}