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