···224224225225- Dashes in the package name _should_ be preserved in new variable names, rather than converted to underscores or camel cased — e.g., `http-parser` instead of `http_parser` or `httpParser`. The hyphenated style is preferred in all three package names.
226226227227-- If there are multiple versions of a package, this _should_ be reflected in the variable names in `all-packages.nix`, e.g. `json-c-0-9` and `json-c-0-11`. If there is an obvious “default” version, make an attribute like `json-c = json-c-0-9;`. See also [](#sec-versioning)
227227+- If there are multiple versions of a package, this _should_ be reflected in the variable names in `all-packages.nix`, e.g. `json-c_0_9` and `json-c_0_11`. If there is an obvious “default” version, make an attribute like `json-c = json-c_0_9;`. See also [](#sec-versioning)
228228229229## File naming and organisation {#sec-organisation}
230230
-4
doc/stdenv/meta.chapter.md
···192192193193If set to `true`, the package is marked as "broken", meaning that it won’t show up in `nix-env -qa`, and cannot be built or installed. Such packages should be removed from Nixpkgs eventually unless they are fixed.
194194195195-### `updateWalker` {#var-meta-updateWalker}
196196-197197-If set to `true`, the package is tested to be updated correctly by the `update-walker.sh` script without additional settings. Such packages have `meta.version` set and their homepage (or the page specified by `meta.downloadPage`) contains a direct link to the package tarball.
198198-199195## Licenses {#sec-meta-license}
200196201197The `meta.license` attribute should preferably contain a value from `lib.licenses` defined in [`nixpkgs/lib/licenses.nix`](https://github.com/NixOS/nixpkgs/blob/master/lib/licenses.nix), or in-place license description of the same format if the license is unlikely to be useful in another expression.
+1-5
flake.nix
···4848 system.nixos.versionSuffix =
4949 ".${final.substring 0 8 (self.lastModifiedDate or self.lastModified or "19700101")}.${self.shortRev or "dirty"}";
5050 system.nixos.revision = final.mkIf (self ? rev) self.rev;
5151-5252- # NOTE: This assumes that `nixpkgs.config` is _not_ used when
5353- # nixpkgs.pkgs is set OR _module.args.pkgs is set.
5454- nixpkgs.config.path = self.outPath;
5551 }
5652 ];
5753 });
···6662 }).nixos.manual.x86_64-linux;
6763 };
68646969- legacyPackages = forAllSystems (system: import ./. { inherit system; config.path = self.outPath; });
6565+ legacyPackages = forAllSystems (system: import ./. { inherit system; });
70667167 nixosModules = {
7268 notDetected = import ./nixos/modules/installer/scan/not-detected.nix;
···442442 </listitem>
443443 <listitem>
444444 <para>
445445- The interface that allows activation scripts to restart units
446446- has been reworked. Restarting and reloading is now done by a
447447- single file
448448- <literal>/run/nixos/activation-restart-list</literal> that
449449- honors <literal>restartIfChanged</literal> and
450450- <literal>reloadIfChanged</literal> of the units.
445445+ <literal>switch-to-configuration</literal> (the script that is
446446+ run when running <literal>nixos-rebuild switch</literal> for
447447+ example) has been reworked
451448 </para>
449449+ <itemizedlist spacing="compact">
450450+ <listitem>
451451+ <para>
452452+ The interface that allows activation scripts to restart
453453+ units has been streamlined. Restarting and reloading is
454454+ now done by a single file
455455+ <literal>/run/nixos/activation-restart-list</literal> that
456456+ honors <literal>restartIfChanged</literal> and
457457+ <literal>reloadIfChanged</literal> of the units.
458458+ </para>
459459+ </listitem>
460460+ <listitem>
461461+ <para>
462462+ The script now uses a proper ini-file parser to parse
463463+ systemd units. Some values are now only searched in one
464464+ section instead of in the entire unit. This is only
465465+ relevant for units that don’t use the NixOS systemd moule.
466466+ </para>
467467+ <itemizedlist spacing="compact">
468468+ <listitem>
469469+ <para>
470470+ <literal>RefuseManualStop</literal>,
471471+ <literal>X-OnlyManualStart</literal>,
472472+ <literal>X-StopOnRemoval</literal>,
473473+ <literal>X-StopOnReconfiguration</literal> are only
474474+ searched in the <literal>[Unit]</literal> section
475475+ </para>
476476+ </listitem>
477477+ <listitem>
478478+ <para>
479479+ <literal>X-ReloadIfChanged</literal>,
480480+ <literal>X-RestartIfChanged</literal>,
481481+ <literal>X-StopIfChanged</literal> are only searched
482482+ in the <literal>[Service]</literal> section
483483+ </para>
484484+ </listitem>
485485+ </itemizedlist>
486486+ </listitem>
487487+ </itemizedlist>
452488 </listitem>
453489 <listitem>
454490 <para>
···533569 </listitem>
534570 <listitem>
535571 <para>
572572+ The configuration portion of the <literal>nix-daemon</literal>
573573+ module has been reworked and exposed as
574574+ <link xlink:href="options.html#opt-nix-settings">nix.settings</link>:
575575+ </para>
576576+ <itemizedlist spacing="compact">
577577+ <listitem>
578578+ <para>
579579+ Legacy options have been mapped to the corresponding
580580+ options under under
581581+ <link xlink:href="options.html#opt-nix.settings">nix.settings</link>
582582+ but may be deprecated in the future.
583583+ </para>
584584+ </listitem>
585585+ <listitem>
586586+ <para>
587587+ <link xlink:href="options.html#opt-nix.buildMachines.publicHostKey">nix.buildMachines.publicHostKey</link>
588588+ has been added.
589589+ </para>
590590+ </listitem>
591591+ </itemizedlist>
592592+ </listitem>
593593+ <listitem>
594594+ <para>
536595 The
537596 <literal>writers.writePyPy2</literal>/<literal>writers.writePyPy3</literal>
538597 and corresponding
539598 <literal>writers.writePyPy2Bin</literal>/<literal>writers.writePyPy3Bin</literal>
540599 convenience functions to create executable Python 2/3 scripts
541600 using the PyPy interpreter were added.
601601+ </para>
602602+ </listitem>
603603+ <listitem>
604604+ <para>
605605+ If you are using Wayland you can choose to use the Ozone
606606+ Wayland support in Chrome and several Electron apps by setting
607607+ the environment variable <literal>NIXOS_OZONE_WL=1</literal>
608608+ (for example via
609609+ <literal>environment.sessionVariables.NIXOS_OZONE_WL = "1"</literal>).
610610+ This is not enabled by default because Ozone Wayland is still
611611+ under heavy development and behavior is not always flawless.
612612+ Furthermore, not all Electron apps use the latest Electron
613613+ versions.
542614 </para>
543615 </listitem>
544616 <listitem>
+1-1
nixos/doc/manual/man-nixos-rebuild.xml
···453453 Allow ad-hoc remote builders for building the new system. This requires
454454 the user executing <command>nixos-rebuild</command> (usually root) to be
455455 configured as a trusted user in the Nix daemon. This can be achieved by
456456- using the <literal>nix.trustedUsers</literal> NixOS option. Examples
456456+ using the <literal>nix.settings.trusted-users</literal> NixOS option. Examples
457457 values for that option are described in the <literal>Remote builds
458458 chapter</literal> in the Nix manual, (i.e. <command>--builders
459459 "ssh://bigbrother x86_64-linux"</command>). By specifying an empty string
+22-5
nixos/doc/manual/release-notes/rl-2205.section.md
···6060## Backward Incompatibilities {#sec-release-22.05-incompatibilities}
61616262- `pkgs.ghc` now refers to `pkgs.targetPackages.haskellPackages.ghc`.
6363- This *only* makes a difference if you are cross-compiling and will
6363+ This _only_ makes a difference if you are cross-compiling and will
6464 ensure that `pkgs.ghc` always runs on the host platform and compiles
6565 for the target platform (similar to `pkgs.gcc` for example).
6666 `haskellPackages.ghc` still behaves as before, running on the build
···141141 `pkgs.noto-fonts-cjk` is currently an alias of `pkgs.noto-fonts-cjk-sans` and
142142 doesn't include serif fonts.
143143144144-- The interface that allows activation scripts to restart units has been reworked. Restarting and reloading is now done by a single file `/run/nixos/activation-restart-list` that honors `restartIfChanged` and `reloadIfChanged` of the units.
144144+- `switch-to-configuration` (the script that is run when running `nixos-rebuild switch` for example) has been reworked
145145+ * The interface that allows activation scripts to restart units has been streamlined. Restarting and reloading is now done by a single file `/run/nixos/activation-restart-list` that honors `restartIfChanged` and `reloadIfChanged` of the units.
146146+ * The script now uses a proper ini-file parser to parse systemd units. Some values are now only searched in one section instead of in the entire unit. This is only relevant for units that don't use the NixOS systemd moule.
147147+ * `RefuseManualStop`, `X-OnlyManualStart`, `X-StopOnRemoval`, `X-StopOnReconfiguration` are only searched in the `[Unit]` section
148148+ * `X-ReloadIfChanged`, `X-RestartIfChanged`, `X-StopIfChanged` are only searched in the `[Service]` section
145149146150- The `services.bookstack.cacheDir` option has been removed, since the
147151 cache directory is now handled by systemd.
···177181 to allow users to make changes to the `nixos-rebuild build-vm` configuration
178182 that do not apply to their normal system.
179183180180- The `config.system.build.vm` attribute now always exists and defaults to the
184184+ The `config.system.build.vm` attribute now always exists and defaults to the
181185 value from `vmVariant`. Configurations that import the `virtualisation/qemu-vm.nix`
182186 module themselves will override this value, such that `vmVariant` is not used.
183187184188 Similarly [virtualisation.vmVariantWithBootloader](#opt-virtualisation.vmVariantWithBootLoader) was added.
189189+190190+- The configuration portion of the `nix-daemon` module has been reworked and exposed as [nix.settings](options.html#opt-nix-settings):
191191+ * Legacy options have been mapped to the corresponding options under under [nix.settings](options.html#opt-nix.settings) but may be deprecated in the future.
192192+ * [nix.buildMachines.publicHostKey](options.html#opt-nix.buildMachines.publicHostKey) has been added.
185193186194- The `writers.writePyPy2`/`writers.writePyPy3` and corresponding `writers.writePyPy2Bin`/`writers.writePyPy3Bin` convenience functions to create executable Python 2/3 scripts using the PyPy interpreter were added.
187195196196+- If you are using Wayland you can choose to use the Ozone Wayland support
197197+ in Chrome and several Electron apps by setting the environment variable
198198+ `NIXOS_OZONE_WL=1` (for example via
199199+ `environment.sessionVariables.NIXOS_OZONE_WL = "1"`).
200200+ This is not enabled by default because Ozone Wayland is
201201+ still under heavy development and behavior is not always flawless.
202202+ Furthermore, not all Electron apps use the latest Electron versions.
203203+188204- The `influxdb2` package was split into `influxdb2-server` and
189205 `influxdb2-cli`, matching the split that took place upstream. A
190206 combined `influxdb2` package is still provided in this release for
···236252 Plugins are automatically repackaged using autoPatchelf.
237253238254- The `zrepl` package has been updated from 0.4.0 to 0.5:
239239- * The RPC protocol version was bumped; all zrepl daemons in a setup must be updated and restarted before replication can resume.
240240- * A bug involving encrypt-on-receive has been fixed. Read the [zrepl documentation](https://zrepl.github.io/configuration/sendrecvoptions.html#job-recv-options-placeholder) and check the output of `zfs get -r encryption,zrepl:placeholder PATH_TO_ROOTFS` on the receiver.
255255+256256+ - The RPC protocol version was bumped; all zrepl daemons in a setup must be updated and restarted before replication can resume.
257257+ - A bug involving encrypt-on-receive has been fixed. Read the [zrepl documentation](https://zrepl.github.io/configuration/sendrecvoptions.html#job-recv-options-placeholder) and check the output of `zfs get -r encryption,zrepl:placeholder PATH_TO_ROOTFS` on the receiver.
241258242259- Renamed option `services.openssh.challengeResponseAuthentication` to `services.openssh.kbdInteractiveAuthentication`.
243260 Reason is that the old name has been deprecated upstream.
+1-1
nixos/lib/systemd-unit-options.nix
···98989999 description = mkOption {
100100 default = "";
101101- type = types.str;
101101+ type = types.singleLineStr;
102102 description = "Description of this unit used in systemd messages and progress indicators.";
103103 };
104104
···25252626 installer.cloneConfigExtra = ''
2727 # Let demo build as a trusted user.
2828- # nix.trustedUsers = [ "demo" ];
2828+ # nix.settings.trusted-users = [ "demo" ];
29293030 # Mount a VirtualBox shared folder.
3131 # This is configurable in the VirtualBox menu at
+4-72
nixos/modules/misc/documentation.nix
···6161 in scrubbedEval.options;
6262 baseOptionsJSON =
6363 let
6464- filterIntoStore =
6464+ filter =
6565 builtins.filterSource
6666 (n: t:
6767 (t == "directory" -> baseNameOf n != "tests")
6868 && (t == "file" -> hasSuffix ".nix" n)
6969 );
7070-7171- # Figure out if Nix runs in pure evaluation mode. May return true in
7272- # impure mode, but this is highly unlikely.
7373- # We need to know because of https://github.com/NixOS/nix/issues/1888
7474- # and https://github.com/NixOS/nix/issues/5868
7575- isPureEval = builtins.getEnv "PATH" == "" && builtins.getEnv "_" == "";
7676-7777- # Return a nixpkgs subpath with minimal copying.
7878- #
7979- # The sources for the base options json derivation can come in one of
8080- # two forms:
8181- # - single source: a store path with all of nixpkgs, postfix with
8282- # subpaths to access various directories. This has the benefit of
8383- # not creating copies of these subtrees in the Nix store, but
8484- # can cause unnecessary rebuilds if you update the Nixpkgs `pkgs`
8585- # tree often.
8686- # - split sources: multiple store paths with subdirectories of
8787- # nixpkgs that exclude the bulk of the pkgs directory.
8888- # This requires more copying and hashing during evaluation but
8989- # requires fewer files to be copied. This method produces fewer
9090- # unnecessary rebuilds of the base options json.
9191- #
9292- # Flake
9393- #
9494- # Flakes always put a copy of the full nixpkgs sources in the store,
9595- # so we can use the "single source" method. This method is ideal
9696- # for using nixpkgs as a dependency, as the base options json will be
9797- # substitutable from cache.nixos.org.
9898- #
9999- # This requires that the `self.outPath` is wired into `pkgs` correctly,
100100- # which is done for you if `pkgs` comes from the `lib.nixosSystem` or
101101- # `legacyPackages` flake attributes.
102102- #
103103- # Other Nixpkgs invocation
104104- #
105105- # If you do not use the known-correct flake attributes, but rather
106106- # invoke Nixpkgs yourself, set `config.path` to the correct path value,
107107- # e.g. `import nixpkgs { config.path = nixpkgs; }`.
108108- #
109109- # Choosing between single or split source paths
110110- #
111111- # We make assumptions based on the type and contents of `pkgs.path`.
112112- # By passing a different `config.path` to Nixpkgs, you can influence
113113- # how your documentation cache is evaluated and rebuilt.
114114- #
115115- # Single source
116116- # - If pkgs.path is a string containing a store path, the code has no
117117- # choice but to create this store path, if it hasn't already been.
118118- # We assume that the "single source" method is most efficient.
119119- # - If pkgs.path is a path value containing that is a store path,
120120- # we try to convert it to a string with context without copying.
121121- # This occurs for example when nixpkgs was fetched and using its
122122- # default `config.path`, which is `./.`.
123123- # Nix currently does not allow this conversion when evaluating in
124124- # pure mode. If the conversion is not possible, we use the
125125- # "split source" method.
126126- #
127127- # Split source
128128- # - If pkgs.path is a path value that is not a store path, we assume
129129- # that it's unlikely for all of nixpkgs to end up in the store for
130130- # other reasons and try to keep both the copying and rebuilds low.
131131- pull =
132132- if builtins.typeOf pkgs.path == "string" && isStorePath pkgs.path then
133133- dir: "${pkgs.path}/${dir}"
134134- else if !isPureEval && isStorePath pkgs.path then
135135- dir: "${builtins.storePath pkgs.path}/${dir}"
136136- else
137137- dir: filterIntoStore "${toString pkgs.path}/${dir}";
13870 in
13971 pkgs.runCommand "lazy-options.json" {
140140- libPath = pull "lib";
141141- pkgsLibPath = pull "pkgs/pkgs-lib";
142142- nixosPath = pull "nixos";
7272+ libPath = filter "${toString pkgs.path}/lib";
7373+ pkgsLibPath = filter "${toString pkgs.path}/pkgs/pkgs-lib";
7474+ nixosPath = filter "${toString pkgs.path}/nixos";
14375 modules = map (p: ''"${removePrefix "${modulesPath}/" (toString p)}"'') docModules.lazy;
14476 } ''
14577 export NIX_STORE_DIR=$TMPDIR/store
-2
nixos/modules/misc/nixpkgs.nix
···5959 inherit (cfg) config overlays localSystem crossSystem;
6060 };
61616262- # NOTE: flake.nix assumes that nixpkgs.config is only used with ../../..
6363- # as nixpkgs.config.path should be equivalent to ../../..
6462 finalPkgs = if opt.pkgs.isDefined then cfg.pkgs.appendOverlays cfg.overlays else defaultPkgs;
65636664in
···147147 concurrent = mkOption {
148148 type = types.int;
149149 default = 1;
150150- example = literalExpression "config.nix.maxJobs";
150150+ example = literalExpression "config.nix.settings.max-jobs";
151151 description = ''
152152 Limits how many jobs globally can be run concurrently.
153153 The most upper limit of jobs using all defined runners.
···258258 uid = config.ids.uids.hydra-www;
259259 };
260260261261- nix.trustedUsers = [ "hydra-queue-runner" ];
262262-263261 services.hydra.extraConfig =
264262 ''
265263 using_frontend_proxy = 1
···277275278276 environment.variables = hydraEnv;
279277280280- nix.extraOptions = ''
281281- keep-outputs = true
282282- keep-derivations = true
278278+ nix.settings = mkMerge [
279279+ {
280280+ keep-outputs = true;
281281+ keep-derivations = true;
282282+ trusted-users = [ "hydra-queue-runner" ];
283283+ }
283284284284-285285- '' + optionalString (versionOlder (getVersion config.nix.package.out) "2.4pre") ''
286286- # The default (`true') slows Nix down a lot since the build farm
287287- # has so many GC roots.
288288- gc-check-reachability = false
289289- '';
285285+ (mkIf (versionOlder (getVersion config.nix.package.out) "2.4pre")
286286+ {
287287+ # The default (`true') slows Nix down a lot since the build farm
288288+ # has so many GC roots.
289289+ gc-check-reachability = false;
290290+ }
291291+ )
292292+ ];
290293291294 systemd.services.hydra-init =
292295 { wantedBy = [ "multi-user.target" ];
+1-4
nixos/modules/services/misc/mx-puppet-discord.nix
···79798080 config = mkIf cfg.enable {
8181 systemd.services.mx-puppet-discord = {
8282- description = ''
8383- mx-puppet-discord is a discord puppeting bridge for matrix.
8484- It handles bridging private and group DMs, as well as Guilds (servers).
8585- '';
8282+ description = "Matrix to Discord puppeting bridge";
86838784 wantedBy = [ "multi-user.target" ];
8885 wants = [ "network-online.target" ] ++ cfg.serviceDependencies;
+383-277
nixos/modules/services/misc/nix-daemon.nix
···6677 cfg = config.nix;
8899- nix = cfg.package.out;
1010-1111- nixVersion = getVersion nix;
99+ nixPackage = cfg.package.out;
12101313- isNix23 = versionAtLeast nixVersion "2.3pre";
1111+ isNixAtLeast = versionAtLeast (getVersion nixPackage);
14121513 makeNixBuildUser = nr: {
1616- name = "nixbld${toString nr}";
1414+ name = "nixbld${toString nr}";
1715 value = {
1816 description = "Nix build user ${toString nr}";
19172020- /* For consistency with the setgid(2), setuid(2), and setgroups(2)
2121- calls in `libstore/build.cc', don't add any supplementary group
2222- here except "nixbld". */
1818+ /*
1919+ For consistency with the setgid(2), setuid(2), and setgroups(2)
2020+ calls in `libstore/build.cc', don't add any supplementary group
2121+ here except "nixbld".
2222+ */
2323 uid = builtins.add config.ids.uids.nixbld nr;
2424 isSystemUser = true;
2525 group = "nixbld";
···3030 nixbldUsers = listToAttrs (map makeNixBuildUser (range 1 cfg.nrBuildUsers));
31313232 nixConf =
3333- assert versionAtLeast nixVersion "2.2";
3434- pkgs.runCommand "nix.conf" { preferLocalBuild = true; extraOptions = cfg.extraOptions; } (
3535- ''
3636- cat > $out <<END
3333+ assert isNixAtLeast "2.2";
3434+ let
3535+3636+ mkValueString = v:
3737+ if v == null then ""
3838+ else if isInt v then toString v
3939+ else if isBool v then boolToString v
4040+ else if isFloat v then floatToString v
4141+ else if isList v then toString v
4242+ else if isDerivation v then toString v
4343+ else if builtins.isPath v then toString v
4444+ else if isString v then v
4545+ else if isCoercibleToString v then toString v
4646+ else abort "The nix conf value: ${toPretty {} v} can not be encoded";
4747+4848+ mkKeyValue = k: v: "${escape [ "=" ] k} = ${mkValueString v}";
4949+5050+ mkKeyValuePairs = attrs: concatStringsSep "\n" (mapAttrsToList mkKeyValue attrs);
5151+5252+ in
5353+ pkgs.writeTextFile {
5454+ name = "nix.conf";
5555+ text = ''
3756 # WARNING: this file is generated from the nix.* options in
3857 # your NixOS configuration, typically
3958 # /etc/nixos/configuration.nix. Do not edit it!
4040- build-users-group = nixbld
4141- max-jobs = ${toString (cfg.maxJobs)}
4242- cores = ${toString (cfg.buildCores)}
4343- sandbox = ${if (builtins.isBool cfg.useSandbox) then boolToString cfg.useSandbox else cfg.useSandbox}
4444- extra-sandbox-paths = ${toString cfg.sandboxPaths}
4545- substituters = ${toString cfg.binaryCaches}
4646- trusted-substituters = ${toString cfg.trustedBinaryCaches}
4747- trusted-public-keys = ${toString cfg.binaryCachePublicKeys}
4848- auto-optimise-store = ${boolToString cfg.autoOptimiseStore}
4949- require-sigs = ${boolToString cfg.requireSignedBinaryCaches}
5050- trusted-users = ${toString cfg.trustedUsers}
5151- allowed-users = ${toString cfg.allowedUsers}
5252- ${optionalString (!cfg.distributedBuilds) ''
5353- builders =
5454- ''}
5555- system-features = ${toString cfg.systemFeatures}
5656- ${optionalString isNix23 ''
5757- sandbox-fallback = false
5858- ''}
5959- $extraOptions
6060- END
6161- '' + optionalString cfg.checkConfig (
6262- if pkgs.stdenv.hostPlatform != pkgs.stdenv.buildPlatform then ''
6363- echo "Ignore nix.checkConfig when cross-compiling"
6464- '' else ''
6565- echo "Checking that Nix can read nix.conf..."
6666- ln -s $out ./nix.conf
6767- NIX_CONF_DIR=$PWD ${cfg.package}/bin/nix show-config ${optionalString isNix23 "--no-net --option experimental-features nix-command"} >/dev/null
6868- '')
6969- );
5959+ ${mkKeyValuePairs cfg.settings}
6060+ ${cfg.extraOptions}
6161+ '';
6262+ checkPhase =
6363+ if pkgs.stdenv.hostPlatform != pkgs.stdenv.buildPlatform then ''
6464+ echo "Ignoring validation for cross-compilation"
6565+ ''
6666+ else ''
6767+ echo "Validating generated nix.conf"
6868+ ln -s $out ./nix.conf
6969+ set -e
7070+ set +o pipefail
7171+ NIX_CONF_DIR=$PWD \
7272+ ${cfg.package}/bin/nix show-config ${optionalString (isNixAtLeast "2.3pre") "--no-net --option experimental-features nix-command"} \
7373+ |& sed -e 's/^warning:/error:/' \
7474+ | (! grep '${if cfg.checkConfig then "^error:" else "^error: unknown setting"}')
7575+ set -o pipefail
7676+ '';
7777+ };
7878+7979+ legacyConfMappings = {
8080+ useSandbox = "sandbox";
8181+ buildCores = "cores";
8282+ maxJobs = "max-jobs";
8383+ sandboxPaths = "extra-sandbox-paths";
8484+ binaryCaches = "substituters";
8585+ trustedBinaryCaches = "trusted-substituters";
8686+ binaryCachePublicKeys = "trusted-public-keys";
8787+ autoOptimiseStore = "auto-optimise-store";
8888+ requireSignedBinaryCaches = "require-sigs";
8989+ trustedUsers = "trusted-users";
9090+ allowedUsers = "allowed-users";
9191+ systemFeatures = "system-feature";
9292+ };
9393+9494+ semanticConfType = with types;
9595+ let
9696+ confAtom = nullOr
9797+ (oneOf [
9898+ bool
9999+ int
100100+ float
101101+ str
102102+ path
103103+ package
104104+ ]) // {
105105+ description = "Nix config atom (null, bool, int, float, str, path or package)";
106106+ };
107107+ in
108108+ attrsOf (either confAtom (listOf confAtom));
7010971110in
72111···76115 (mkRenamedOptionModule [ "nix" "chrootDirs" ] [ "nix" "sandboxPaths" ])
77116 (mkRenamedOptionModule [ "nix" "daemonIONiceLevel" ] [ "nix" "daemonIOSchedPriority" ])
78117 (mkRemovedOptionModule [ "nix" "daemonNiceLevel" ] "Consider nix.daemonCPUSchedPolicy instead.")
7979- ];
118118+ ] ++ mapAttrsToList (oldConf: newConf: mkRenamedOptionModule [ "nix" oldConf ] [ "nix" "settings" newConf ]) legacyConfMappings;
8011981120 ###### interface
82121···102141 '';
103142 };
104143105105- maxJobs = mkOption {
106106- type = types.either types.int (types.enum ["auto"]);
107107- default = "auto";
108108- example = 64;
109109- description = ''
110110- This option defines the maximum number of jobs that Nix will try to
111111- build in parallel. The default is auto, which means it will use all
112112- available logical cores. It is recommend to set it to the total
113113- number of logical cores in your system (e.g., 16 for two CPUs with 4
114114- cores each and hyper-threading).
115115- '';
116116- };
117117-118118- autoOptimiseStore = mkOption {
119119- type = types.bool;
120120- default = false;
121121- example = true;
122122- description = ''
123123- If set to true, Nix automatically detects files in the store that have
124124- identical contents, and replaces them with hard links to a single copy.
125125- This saves disk space. If set to false (the default), you can still run
126126- nix-store --optimise to get rid of duplicate files.
127127- '';
128128- };
129129-130130- buildCores = mkOption {
131131- type = types.int;
132132- default = 0;
133133- example = 64;
134134- description = ''
135135- This option defines the maximum number of concurrent tasks during
136136- one build. It affects, e.g., -j option for make.
137137- The special value 0 means that the builder should use all
138138- available CPU cores in the system. Some builds may become
139139- non-deterministic with this option; use with care! Packages will
140140- only be affected if enableParallelBuilding is set for them.
141141- '';
142142- };
143143-144144- useSandbox = mkOption {
145145- type = types.either types.bool (types.enum ["relaxed"]);
146146- default = true;
147147- description = "
148148- If set, Nix will perform builds in a sandboxed environment that it
149149- will set up automatically for each build. This prevents impurities
150150- in builds by disallowing access to dependencies outside of the Nix
151151- store by using network and mount namespaces in a chroot environment.
152152- This is enabled by default even though it has a possible performance
153153- impact due to the initial setup time of a sandbox for each build. It
154154- doesn't affect derivation hashes, so changing this option will not
155155- trigger a rebuild of packages.
156156- ";
157157- };
158158-159159- sandboxPaths = mkOption {
160160- type = types.listOf types.str;
161161- default = [];
162162- example = [ "/dev" "/proc" ];
163163- description =
164164- ''
165165- Directories from the host filesystem to be included
166166- in the sandbox.
167167- '';
168168- };
169169-170170- extraOptions = mkOption {
171171- type = types.lines;
172172- default = "";
173173- example = ''
174174- keep-outputs = true
175175- keep-derivations = true
176176- '';
177177- description = "Additional text appended to <filename>nix.conf</filename>.";
178178- };
179179-180144 distributedBuilds = mkOption {
181145 type = types.bool;
182146 default = false;
···187151 };
188152189153 daemonCPUSchedPolicy = mkOption {
190190- type = types.enum ["other" "batch" "idle"];
154154+ type = types.enum [ "other" "batch" "idle" ];
191155 default = "other";
192156 example = "batch";
193157 description = ''
···218182 };
219183220184 daemonIOSchedClass = mkOption {
221221- type = types.enum ["best-effort" "idle"];
185185+ type = types.enum [ "best-effort" "idle" ];
222186 default = "best-effort";
223187 example = "idle";
224188 description = ''
···250214 scheduling policy: With idle, priorities are not used in scheduling
251215 decisions. best-effort supports values in the range 0 (high) to 7
252216 (low).
253253- '';
217217+ '';
254218 };
255219256220 buildMachines = mkOption {
257257- type = types.listOf (types.submodule ({
221221+ type = types.listOf (types.submodule {
258222 options = {
259223 hostName = mkOption {
260224 type = types.str;
···276240 };
277241 systems = mkOption {
278242 type = types.listOf types.str;
279279- default = [];
243243+ default = [ ];
280244 example = [ "x86_64-linux" "aarch64-linux" ];
281245 description = ''
282246 The system types the build machine can execute derivations on.
···293257 The username to log in as on the remote host. This user must be
294258 able to log in and run nix commands non-interactively. It must
295259 also be privileged to build derivations, so must be included in
296296- <option>nix.trustedUsers</option>.
260260+ <option>nix.settings.trusted-users</option>.
297261 '';
298262 };
299263 sshKey = mkOption {
···331295 };
332296 mandatoryFeatures = mkOption {
333297 type = types.listOf types.str;
334334- default = [];
298298+ default = [ ];
335299 example = [ "big-parallel" ];
336300 description = ''
337301 A list of features mandatory for this builder. The builder will
···342306 };
343307 supportedFeatures = mkOption {
344308 type = types.listOf types.str;
345345- default = [];
309309+ default = [ ];
346310 example = [ "kvm" "big-parallel" ];
347311 description = ''
348312 A list of features supported by this builder. The builder will
···350314 list.
351315 '';
352316 };
317317+ publicHostKey = mkOption {
318318+ type = types.nullOr types.str;
319319+ default = null;
320320+ description = ''
321321+ The (base64-encoded) public host key of this builder. The field
322322+ is calculated via <command>base64 -w0 /etc/ssh/ssh_host_type_key.pub</command>.
323323+ If null, SSH will use its regular known-hosts file when connecting.
324324+ '';
325325+ };
353326 };
354354- }));
355355- default = [];
327327+ });
328328+ default = [ ];
356329 description = ''
357330 This option lists the machines to be used if distributed builds are
358331 enabled (see <option>nix.distributedBuilds</option>).
···366339 envVars = mkOption {
367340 type = types.attrs;
368341 internal = true;
369369- default = {};
342342+ default = { };
370343 description = "Environment variables used by Nix.";
371344 };
372345···391364 '';
392365 };
393366394394- binaryCaches = mkOption {
395395- type = types.listOf types.str;
396396- description = ''
397397- List of binary cache URLs used to obtain pre-built binaries
398398- of Nix packages.
399399-400400- By default https://cache.nixos.org/ is added,
401401- to override it use <literal>lib.mkForce []</literal>.
402402- '';
403403- };
404404-405405- trustedBinaryCaches = mkOption {
406406- type = types.listOf types.str;
407407- default = [ ];
408408- example = [ "https://hydra.nixos.org/" ];
409409- description = ''
410410- List of binary cache URLs that non-root users can use (in
411411- addition to those specified using
412412- <option>nix.binaryCaches</option>) by passing
413413- <literal>--option binary-caches</literal> to Nix commands.
414414- '';
415415- };
416416-417417- requireSignedBinaryCaches = mkOption {
418418- type = types.bool;
419419- default = true;
420420- description = ''
421421- If enabled (the default), Nix will only download binaries from binary caches if
422422- they are cryptographically signed with any of the keys listed in
423423- <option>nix.binaryCachePublicKeys</option>. If disabled, signatures are neither
424424- required nor checked, so it's strongly recommended that you use only
425425- trustworthy caches and https to prevent man-in-the-middle attacks.
426426- '';
427427- };
428428-429429- binaryCachePublicKeys = mkOption {
430430- type = types.listOf types.str;
431431- example = [ "hydra.nixos.org-1:CNHJZBh9K4tP3EKF6FkkgeVYsS3ohTl+oS0Qa8bezVs=" ];
432432- description = ''
433433- List of public keys used to sign binary caches. If
434434- <option>nix.requireSignedBinaryCaches</option> is enabled,
435435- then Nix will use a binary from a binary cache if and only
436436- if it is signed by <emphasis>any</emphasis> of the keys
437437- listed here. By default, only the key for
438438- <uri>cache.nixos.org</uri> is included.
439439- '';
440440- };
441441-442442- trustedUsers = mkOption {
443443- type = types.listOf types.str;
444444- default = [ "root" ];
445445- example = [ "root" "alice" "@wheel" ];
446446- description = ''
447447- A list of names of users that have additional rights when
448448- connecting to the Nix daemon, such as the ability to specify
449449- additional binary caches, or to import unsigned NARs. You
450450- can also specify groups by prefixing them with
451451- <literal>@</literal>; for instance,
452452- <literal>@wheel</literal> means all users in the wheel
453453- group.
454454- '';
455455- };
456456-457457- allowedUsers = mkOption {
458458- type = types.listOf types.str;
459459- default = [ "*" ];
460460- example = [ "@wheel" "@builders" "alice" "bob" ];
461461- description = ''
462462- A list of names of users (separated by whitespace) that are
463463- allowed to connect to the Nix daemon. As with
464464- <option>nix.trustedUsers</option>, you can specify groups by
465465- prefixing them with <literal>@</literal>. Also, you can
466466- allow all users by specifying <literal>*</literal>. The
467467- default is <literal>*</literal>. Note that trusted users are
468468- always allowed to connect.
469469- '';
470470- };
471471-472367 nixPath = mkOption {
473368 type = types.listOf types.str;
474474- default =
475475- [
476476- "nixpkgs=/nix/var/nix/profiles/per-user/root/channels/nixos"
477477- "nixos-config=/etc/nixos/configuration.nix"
478478- "/nix/var/nix/profiles/per-user/root/channels"
479479- ];
369369+ default = [
370370+ "nixpkgs=/nix/var/nix/profiles/per-user/root/channels/nixos"
371371+ "nixos-config=/etc/nixos/configuration.nix"
372372+ "/nix/var/nix/profiles/per-user/root/channels"
373373+ ];
480374 description = ''
481375 The default Nix expression search path, used by the Nix
482376 evaluator to look up paths enclosed in angle brackets
···484378 '';
485379 };
486380487487- systemFeatures = mkOption {
488488- type = types.listOf types.str;
489489- example = [ "kvm" "big-parallel" "gccarch-skylake" ];
490490- description = ''
491491- The supported features of a machine
492492- '';
493493- };
494494-495381 checkConfig = mkOption {
496382 type = types.bool;
497383 default = true;
498384 description = ''
499499- If enabled (the default), checks that Nix can parse the generated nix.conf.
385385+ If enabled (the default), checks for data type mismatches and that Nix
386386+ can parse the generated nix.conf.
500387 '';
501388 };
502389503390 registry = mkOption {
504391 type = types.attrsOf (types.submodule (
505392 let
506506- inputAttrs = types.attrsOf (types.oneOf [types.str types.int types.bool types.package]);
393393+ referenceAttrs = with types; attrsOf (oneOf [
394394+ str
395395+ int
396396+ bool
397397+ package
398398+ ]);
507399 in
508400 { config, name, ... }:
509509- { options = {
401401+ {
402402+ options = {
510403 from = mkOption {
511511- type = inputAttrs;
404404+ type = referenceAttrs;
512405 example = { type = "indirect"; id = "nixpkgs"; };
513406 description = "The flake reference to be rewritten.";
514407 };
515408 to = mkOption {
516516- type = inputAttrs;
409409+ type = referenceAttrs;
517410 example = { type = "github"; owner = "my-org"; repo = "my-nixpkgs"; };
518518- description = "The flake reference to which <option>from></option> is to be rewritten.";
411411+ description = "The flake reference <option>from></option> is rewritten to.";
519412 };
520413 flake = mkOption {
521414 type = types.nullOr types.attrs;
522415 default = null;
523416 example = literalExpression "nixpkgs";
524417 description = ''
525525- The flake input to which <option>from></option> is to be rewritten.
418418+ The flake input <option>from></option> is rewritten to.
526419 '';
527420 };
528421 exact = mkOption {
···537430 };
538431 config = {
539432 from = mkDefault { type = "indirect"; id = name; };
540540- to = mkIf (config.flake != null)
541541- ({ type = "path";
542542- path = config.flake.outPath;
543543- } // lib.filterAttrs
544544- (n: v: n == "lastModified" || n == "rev" || n == "revCount" || n == "narHash")
545545- config.flake);
433433+ to = mkIf (config.flake != null) (mkDefault
434434+ {
435435+ type = "path";
436436+ path = config.flake.outPath;
437437+ } // filterAttrs
438438+ (n: _: n == "lastModified" || n == "rev" || n == "revCount" || n == "narHash")
439439+ config.flake);
546440 };
547441 }
548442 ));
549549- default = {};
443443+ default = { };
550444 description = ''
551445 A system-wide flake registry.
552446 '';
553447 };
554448555555- };
449449+ extraOptions = mkOption {
450450+ type = types.lines;
451451+ default = "";
452452+ example = ''
453453+ keep-outputs = true
454454+ keep-derivations = true
455455+ '';
456456+ description = "Additional text appended to <filename>nix.conf</filename>.";
457457+ };
458458+459459+ settings = mkOption {
460460+ type = types.submodule {
461461+ freeformType = semanticConfType;
462462+463463+ options = {
464464+ max-jobs = mkOption {
465465+ type = types.either types.int (types.enum [ "auto" ]);
466466+ default = "auto";
467467+ example = 64;
468468+ description = ''
469469+ This option defines the maximum number of jobs that Nix will try to
470470+ build in parallel. The default is auto, which means it will use all
471471+ available logical cores. It is recommend to set it to the total
472472+ number of logical cores in your system (e.g., 16 for two CPUs with 4
473473+ cores each and hyper-threading).
474474+ '';
475475+ };
476476+477477+ auto-optimise-store = mkOption {
478478+ type = types.bool;
479479+ default = false;
480480+ example = true;
481481+ description = ''
482482+ If set to true, Nix automatically detects files in the store that have
483483+ identical contents, and replaces them with hard links to a single copy.
484484+ This saves disk space. If set to false (the default), you can still run
485485+ nix-store --optimise to get rid of duplicate files.
486486+ '';
487487+ };
488488+489489+ cores = mkOption {
490490+ type = types.int;
491491+ default = 0;
492492+ example = 64;
493493+ description = ''
494494+ This option defines the maximum number of concurrent tasks during
495495+ one build. It affects, e.g., -j option for make.
496496+ The special value 0 means that the builder should use all
497497+ available CPU cores in the system. Some builds may become
498498+ non-deterministic with this option; use with care! Packages will
499499+ only be affected if enableParallelBuilding is set for them.
500500+ '';
501501+ };
502502+503503+ sandbox = mkOption {
504504+ type = types.either types.bool (types.enum [ "relaxed" ]);
505505+ default = true;
506506+ description = ''
507507+ If set, Nix will perform builds in a sandboxed environment that it
508508+ will set up automatically for each build. This prevents impurities
509509+ in builds by disallowing access to dependencies outside of the Nix
510510+ store by using network and mount namespaces in a chroot environment.
511511+ This is enabled by default even though it has a possible performance
512512+ impact due to the initial setup time of a sandbox for each build. It
513513+ doesn't affect derivation hashes, so changing this option will not
514514+ trigger a rebuild of packages.
515515+ '';
516516+ };
517517+518518+ extra-sandbox-paths = mkOption {
519519+ type = types.listOf types.str;
520520+ default = [ ];
521521+ example = [ "/dev" "/proc" ];
522522+ description = ''
523523+ Directories from the host filesystem to be included
524524+ in the sandbox.
525525+ '';
526526+ };
556527528528+ substituters = mkOption {
529529+ type = types.listOf types.str;
530530+ description = ''
531531+ List of binary cache URLs used to obtain pre-built binaries
532532+ of Nix packages.
533533+534534+ By default https://cache.nixos.org/ is added.
535535+ '';
536536+ };
537537+538538+ trusted-substituters = mkOption {
539539+ type = types.listOf types.str;
540540+ default = [ ];
541541+ example = [ "https://hydra.nixos.org/" ];
542542+ description = ''
543543+ List of binary cache URLs that non-root users can use (in
544544+ addition to those specified using
545545+ <option>nix.settings.substituters</option>) by passing
546546+ <literal>--option binary-caches</literal> to Nix commands.
547547+ '';
548548+ };
549549+550550+ require-sigs = mkOption {
551551+ type = types.bool;
552552+ default = true;
553553+ description = ''
554554+ If enabled (the default), Nix will only download binaries from binary caches if
555555+ they are cryptographically signed with any of the keys listed in
556556+ <option>nix.settings.trusted-public-keys</option>. If disabled, signatures are neither
557557+ required nor checked, so it's strongly recommended that you use only
558558+ trustworthy caches and https to prevent man-in-the-middle attacks.
559559+ '';
560560+ };
561561+562562+ trusted-public-keys = mkOption {
563563+ type = types.listOf types.str;
564564+ example = [ "hydra.nixos.org-1:CNHJZBh9K4tP3EKF6FkkgeVYsS3ohTl+oS0Qa8bezVs=" ];
565565+ description = ''
566566+ List of public keys used to sign binary caches. If
567567+ <option>nix.settings.trusted-public-keys</option> is enabled,
568568+ then Nix will use a binary from a binary cache if and only
569569+ if it is signed by <emphasis>any</emphasis> of the keys
570570+ listed here. By default, only the key for
571571+ <uri>cache.nixos.org</uri> is included.
572572+ '';
573573+ };
574574+575575+ trusted-users = mkOption {
576576+ type = types.listOf types.str;
577577+ default = [ "root" ];
578578+ example = [ "root" "alice" "@wheel" ];
579579+ description = ''
580580+ A list of names of users that have additional rights when
581581+ connecting to the Nix daemon, such as the ability to specify
582582+ additional binary caches, or to import unsigned NARs. You
583583+ can also specify groups by prefixing them with
584584+ <literal>@</literal>; for instance,
585585+ <literal>@wheel</literal> means all users in the wheel
586586+ group.
587587+ '';
588588+ };
589589+590590+ system-features = mkOption {
591591+ type = types.listOf types.str;
592592+ example = [ "kvm" "big-parallel" "gccarch-skylake" ];
593593+ description = ''
594594+ The set of features supported by the machine. Derivations
595595+ can express dependencies on system features through the
596596+ <literal>requiredSystemFeatures</literal> attribute.
597597+598598+ By default, pseudo-features <literal>nixos-test</literal>, <literal>benchmark</literal>,
599599+ and <literal>big-parallel</literal> used in Nixpkgs are set, <literal>kvm</literal>
600600+ is also included in it is avaliable.
601601+ '';
602602+ };
603603+604604+ allowed-users = mkOption {
605605+ type = types.listOf types.str;
606606+ default = [ "*" ];
607607+ example = [ "@wheel" "@builders" "alice" "bob" ];
608608+ description = ''
609609+ A list of names of users (separated by whitespace) that are
610610+ allowed to connect to the Nix daemon. As with
611611+ <option>nix.settings.trusted-users</option>, you can specify groups by
612612+ prefixing them with <literal>@</literal>. Also, you can
613613+ allow all users by specifying <literal>*</literal>. The
614614+ default is <literal>*</literal>. Note that trusted users are
615615+ always allowed to connect.
616616+ '';
617617+ };
618618+ };
619619+ };
620620+ default = { };
621621+ example = literalExpression ''
622622+ {
623623+ use-sandbox = true;
624624+ show-trace = true;
625625+626626+ system-features = [ "big-parallel" "kvm" "recursive-nix" ];
627627+ sandbox-paths = { "/bin/sh" = "''${pkgs.busybox-sandbox-shell.out}/bin/busybox"; };
628628+ }
629629+ '';
630630+ description = ''
631631+ Configuration for Nix, see
632632+ <link xlink:href="https://nixos.org/manual/nix/stable/#sec-conf-file"/> or
633633+ <citerefentry>
634634+ <refentrytitle>nix.conf</refentrytitle>
635635+ <manvolnum>5</manvolnum>
636636+ </citerefentry> for avalaible options.
637637+ The value declared here will be translated directly to the key-value pairs Nix expects.
638638+ </para>
639639+ <para>
640640+ You can use <command>nix-instantiate --eval --strict '<nixpkgs/nixos>' -A config.nix.settings</command>
641641+ to view the current value. By default it is empty.
642642+ </para>
643643+ <para>
644644+ Nix configurations defined under <option>nix.*</option> will be translated and applied to this
645645+ option. In addition, configuration specified in <option>nix.extraOptions</option> which will be appended
646646+ verbatim to the resulting config file.
647647+ '';
648648+ };
649649+ };
557650 };
558651559652560653 ###### implementation
561654562655 config = mkIf cfg.enable {
563563-564564- nix.binaryCachePublicKeys = [ "cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY=" ];
565565- nix.binaryCaches = [ "https://cache.nixos.org/" ];
566566-567656 environment.systemPackages =
568568- [ nix
657657+ [
658658+ nixPackage
569659 pkgs.nix-info
570660 ]
571661 ++ optional (config.programs.bash.enableCompletion) pkgs.nix-bash-completions;
···579669580670 # List of machines for distributed Nix builds in the format
581671 # expected by build-remote.pl.
582582- environment.etc."nix/machines" =
583583- { enable = cfg.buildMachines != [];
584584- text =
585585- concatMapStrings (machine:
586586- "${if machine.sshUser != null then "${machine.sshUser}@" else ""}${machine.hostName} "
587587- + (if machine.system != null then machine.system else concatStringsSep "," machine.systems)
588588- + " ${if machine.sshKey != null then machine.sshKey else "-"} ${toString machine.maxJobs} "
589589- + toString (machine.speedFactor)
590590- + " "
591591- + concatStringsSep "," (machine.mandatoryFeatures ++ machine.supportedFeatures)
592592- + " "
593593- + concatStringsSep "," machine.mandatoryFeatures
672672+ environment.etc."nix/machines" = mkIf (cfg.buildMachines != [ ]) {
673673+ text =
674674+ concatMapStrings
675675+ (machine:
676676+ (concatStringsSep " " ([
677677+ "${optionalString (machine.sshUser != null) "${machine.sshUser}@"}${machine.hostName}"
678678+ (if machine.system != null then machine.system else if machine.systems != [ ] then concatStringsSep "," machine.systems else "-")
679679+ (if machine.sshKey != null then machine.sshKey else "-")
680680+ (toString machine.maxJobs)
681681+ (toString machine.speedFactor)
682682+ (concatStringsSep "," machine.supportedFeatures)
683683+ (concatStringsSep "," machine.mandatoryFeatures)
684684+ ]
685685+ ++ optional (isNixAtLeast "2.4pre") (if machine.publicHostKey != null then machine.publicHostKey else "-")))
594686 + "\n"
595595- ) cfg.buildMachines;
596596- };
687687+ )
688688+ cfg.buildMachines;
689689+ };
690690+597691 assertions =
598598- let badMachine = m: m.system == null && m.systems == [];
599599- in [
692692+ let badMachine = m: m.system == null && m.systems == [ ];
693693+ in
694694+ [
600695 {
601601- assertion = !(builtins.any badMachine cfg.buildMachines);
696696+ assertion = !(any badMachine cfg.buildMachines);
602697 message = ''
603698 At least one system type (via <varname>system</varname> or
604699 <varname>systems</varname>) must be set for every build machine.
605700 Invalid machine specifications:
606701 '' + " " +
607607- (builtins.concatStringsSep "\n "
608608- (builtins.map (m: m.hostName)
609609- (builtins.filter (badMachine) cfg.buildMachines)));
702702+ (concatStringsSep "\n "
703703+ (map (m: m.hostName)
704704+ (filter (badMachine) cfg.buildMachines)));
610705 }
611706 ];
612707613613-614614- systemd.packages = [ nix ];
708708+ systemd.packages = [ nixPackage ];
615709616710 systemd.sockets.nix-daemon.wantedBy = [ "sockets.target" ];
617711618712 systemd.services.nix-daemon =
619619- { path = [ nix pkgs.util-linux config.programs.ssh.package ]
713713+ {
714714+ path = [ nixPackage pkgs.util-linux config.programs.ssh.package ]
620715 ++ optionals cfg.distributedBuilds [ pkgs.gzip ];
621716622717 environment = cfg.envVars
···626721 unitConfig.RequiresMountsFor = "/nix/store";
627722628723 serviceConfig =
629629- { CPUSchedulingPolicy = cfg.daemonCPUSchedPolicy;
724724+ {
725725+ CPUSchedulingPolicy = cfg.daemonCPUSchedPolicy;
630726 IOSchedulingClass = cfg.daemonIOSchedClass;
631727 IOSchedulingPriority = cfg.daemonIOSchedPriority;
632728 LimitNOFILE = 4096;
···636732 };
637733638734 # Set up the environment variables for running Nix.
639639- environment.sessionVariables = cfg.envVars //
640640- { NIX_PATH = cfg.nixPath;
641641- };
735735+ environment.sessionVariables = cfg.envVars // { NIX_PATH = cfg.nixPath; };
642736643737 environment.extraInit =
644738 ''
···647741 fi
648742 '';
649743650650- nix.nrBuildUsers = mkDefault (lib.max 32 (if cfg.maxJobs == "auto" then 0 else cfg.maxJobs));
744744+ nix.nrBuildUsers = mkDefault (max 32 (if cfg.settings.max-jobs == "auto" then 0 else cfg.settings.max-jobs));
651745652746 users.users = nixbldUsers;
653747···663757 fi
664758 '';
665759666666- nix.systemFeatures = mkDefault (
667667- [ "nixos-test" "benchmark" "big-parallel" "kvm" ] ++
668668- optionals (pkgs.hostPlatform ? gcc.arch) (
669669- # a builder can run code for `gcc.arch` and inferior architectures
670670- [ "gccarch-${pkgs.hostPlatform.gcc.arch}" ] ++
671671- map (x: "gccarch-${x}") lib.systems.architectures.inferiors.${pkgs.hostPlatform.gcc.arch}
672672- )
673673- );
760760+ # Legacy configuration conversion.
761761+ nix.settings = mkMerge [
762762+ {
763763+ trusted-public-keys = [ "cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY=" ];
764764+ substituters = [ "https://cache.nixos.org/" ];
765765+766766+ system-features = mkDefault (
767767+ [ "nixos-test" "benchmark" "big-parallel" "kvm" ] ++
768768+ optionals (pkgs.hostPlatform ? gcc.arch) (
769769+ # a builder can run code for `gcc.arch` and inferior architectures
770770+ [ "gccarch-${pkgs.hostPlatform.gcc.arch}" ] ++
771771+ map (x: "gccarch-${x}") systems.architectures.inferiors.${pkgs.hostPlatform.gcc.arch}
772772+ )
773773+ );
774774+ }
775775+776776+ (mkIf (!cfg.distributedBuilds) { builders = null; })
777777+778778+ (mkIf (isNixAtLeast "2.3pre") { sandbox-fallback = false; })
779779+ ];
674780675781 };
676782
+1-1
nixos/modules/services/misc/nix-ssh-serve.nix
···2020 write = mkOption {
2121 type = types.bool;
2222 default = false;
2323- description = "Whether to enable writing to the Nix store as a remote store via SSH. Note: the sshServe user is named nix-ssh and is not a trusted-user. nix-ssh should be added to the nix.trustedUsers option in most use cases, such as allowing remote building of derivations.";
2323+ description = "Whether to enable writing to the Nix store as a remote store via SSH. Note: the sshServe user is named nix-ssh and is not a trusted-user. nix-ssh should be added to the <option>nix.settings.trusted-users</option> option in most use cases, such as allowing remote building of derivations.";
2424 };
25252626 keys = mkOption {
···2233use strict;
44use warnings;
55+use Config::IniFiles;
56use File::Path qw(make_path);
67use File::Basename;
78use File::Slurp;
···113114 return ($fss, $swaps);
114115}
115116117117+# This subroutine takes a single ini file that specified systemd configuration
118118+# like unit configuration and parses it into a hash where the keys are the sections
119119+# of the unit file and the values are hashes themselves. These hashes have the unit file
120120+# keys as their keys (left side of =) and an array of all values that were set as their
121121+# values. If a value is empty (for example `ExecStart=`), then all current definitions are
122122+# removed.
123123+#
124124+# Instead of returning the hash, this subroutine takes a hashref to return the data in. This
125125+# allows calling the subroutine multiple times with the same hash to parse override files.
126126+sub parseSystemdIni {
127127+ my ($unitContents, $path) = @_;
128128+ # Tie the ini file to a hash for easier access
129129+ my %fileContents;
130130+ tie %fileContents, "Config::IniFiles", (-file => $path, -allowempty => 1, -allowcontinue => 1);
131131+132132+ # Copy over all sections
133133+ foreach my $sectionName (keys %fileContents) {
134134+ # Copy over all keys
135135+ foreach my $iniKey (keys %{$fileContents{$sectionName}}) {
136136+ # Ensure the value is an array so it's easier to work with
137137+ my $iniValue = $fileContents{$sectionName}{$iniKey};
138138+ my @iniValues;
139139+ if (ref($iniValue) eq "ARRAY") {
140140+ @iniValues = @{$iniValue};
141141+ } else {
142142+ @iniValues = $iniValue;
143143+ }
144144+ # Go over all values
145145+ for my $iniValue (@iniValues) {
146146+ # If a value is empty, it's an override that tells us to clean the value
147147+ if ($iniValue eq "") {
148148+ delete $unitContents->{$sectionName}->{$iniKey};
149149+ next;
150150+ }
151151+ push(@{$unitContents->{$sectionName}->{$iniKey}}, $iniValue);
152152+ }
153153+ }
154154+ }
155155+ return;
156156+}
157157+158158+# This subroutine takes the path to a systemd configuration file (like a unit configuration),
159159+# parses it, and returns a hash that contains the contents. The contents of this hash are
160160+# explained in the `parseSystemdIni` subroutine. Neither the sections nor the keys inside
161161+# the sections are consistently sorted.
162162+#
163163+# If a directory with the same basename ending in .d exists next to the unit file, it will be
164164+# assumed to contain override files which will be parsed as well and handled properly.
116165sub parseUnit {
117117- my ($filename) = @_;
118118- my $info = {};
119119- parseKeyValues($info, read_file($filename)) if -f $filename;
120120- parseKeyValues($info, read_file("${filename}.d/overrides.conf")) if -f "${filename}.d/overrides.conf";
121121- return $info;
166166+ my ($unitPath) = @_;
167167+168168+ # Parse the main unit and all overrides
169169+ my %unitData;
170170+ parseSystemdIni(\%unitData, $_) for glob("${unitPath}{,.d/*.conf}");
171171+ return %unitData;
122172}
123173124124-sub parseKeyValues {
125125- my $info = shift;
126126- foreach my $line (@_) {
127127- # FIXME: not quite correct.
128128- $line =~ /^([^=]+)=(.*)$/ or next;
129129- $info->{$1} = $2;
174174+# Checks whether a specified boolean in a systemd unit is true
175175+# or false, with a default that is applied when the value is not set.
176176+sub parseSystemdBool {
177177+ my ($unitConfig, $sectionName, $boolName, $default) = @_;
178178+179179+ my @values = @{$unitConfig->{$sectionName}{$boolName} // []};
180180+ # Return default if value is not set
181181+ if (scalar @values lt 1 || not defined $values[-1]) {
182182+ return $default;
130183 }
131131-}
132132-133133-sub boolIsTrue {
134134- my ($s) = @_;
135135- return $s eq "yes" || $s eq "true";
184184+ # If value is defined multiple times, use the last definition
185185+ my $last = $values[-1];
186186+ # These are valid values as of systemd.syntax(7)
187187+ return $last eq "1" || $last eq "yes" || $last eq "true" || $last eq "on";
136188}
137189138190sub recordUnit {
···167219 # Revert of the attempt: https://github.com/NixOS/nixpkgs/pull/147609
168220 # More details: https://github.com/NixOS/nixpkgs/issues/74899#issuecomment-981142430
169221 } else {
170170- my $unitInfo = parseUnit($newUnitFile);
171171- if (boolIsTrue($unitInfo->{'X-ReloadIfChanged'} // "no")) {
222222+ my %unitInfo = parseUnit($newUnitFile);
223223+ if (parseSystemdBool(\%unitInfo, "Service", "X-ReloadIfChanged", 0)) {
172224 $unitsToReload->{$unit} = 1;
173225 recordUnit($reloadListFile, $unit);
174226 }
175175- elsif (!boolIsTrue($unitInfo->{'X-RestartIfChanged'} // "yes") || boolIsTrue($unitInfo->{'RefuseManualStop'} // "no") || boolIsTrue($unitInfo->{'X-OnlyManualStart'} // "no")) {
227227+ elsif (!parseSystemdBool(\%unitInfo, "Service", "X-RestartIfChanged", 1) || parseSystemdBool(\%unitInfo, "Unit", "RefuseManualStop", 0) || parseSystemdBool(\%unitInfo, "Unit", "X-OnlyManualStart", 0)) {
176228 $unitsToSkip->{$unit} = 1;
177229 } else {
178230 # It doesn't make sense to stop and start non-services because
179231 # they can't have ExecStop=
180180- if (!boolIsTrue($unitInfo->{'X-StopIfChanged'} // "yes") || $unit !~ /\.service$/) {
232232+ if (!parseSystemdBool(\%unitInfo, "Service", "X-StopIfChanged", 1) || $unit !~ /\.service$/) {
181233 # This unit should be restarted instead of
182234 # stopped and started.
183235 $unitsToRestart->{$unit} = 1;
···188240 # socket(s) instead of the service.
189241 my $socketActivated = 0;
190242 if ($unit =~ /\.service$/) {
191191- my @sockets = split / /, ($unitInfo->{Sockets} // "");
243243+ my @sockets = split(/ /, join(" ", @{$unitInfo{Service}{Sockets} // []}));
192244 if (scalar @sockets == 0) {
193245 @sockets = ("$baseName.socket");
194246 }
···254306255307 if (-e $prevUnitFile && ($state->{state} eq "active" || $state->{state} eq "activating")) {
256308 if (! -e $newUnitFile || abs_path($newUnitFile) eq "/dev/null") {
257257- my $unitInfo = parseUnit($prevUnitFile);
258258- $unitsToStop{$unit} = 1 if boolIsTrue($unitInfo->{'X-StopOnRemoval'} // "yes");
309309+ my %unitInfo = parseUnit($prevUnitFile);
310310+ $unitsToStop{$unit} = 1 if parseSystemdBool(\%unitInfo, "Unit", "X-StopOnRemoval", 1);
259311 }
260312261313 elsif ($unit =~ /\.target$/) {
262262- my $unitInfo = parseUnit($newUnitFile);
314314+ my %unitInfo = parseUnit($newUnitFile);
263315264316 # Cause all active target units to be restarted below.
265317 # This should start most changed units we stop here as
···268320 # active after the system has resumed, which probably
269321 # should not be the case. Just ignore it.
270322 if ($unit ne "suspend.target" && $unit ne "hibernate.target" && $unit ne "hybrid-sleep.target") {
271271- unless (boolIsTrue($unitInfo->{'RefuseManualStart'} // "no") || boolIsTrue($unitInfo->{'X-OnlyManualStart'} // "no")) {
323323+ unless (parseSystemdBool(\%unitInfo, "Unit", "RefuseManualStart", 0) || parseSystemdBool(\%unitInfo, "Unit", "X-OnlyManualStart", 0)) {
272324 $unitsToStart{$unit} = 1;
273325 recordUnit($startListFile, $unit);
274326 # Don't spam the user with target units that always get started.
···287339 # Stopping a target generally has no effect on other units
288340 # (unless there is a PartOf dependency), so this is just a
289341 # bookkeeping thing to get systemd to do the right thing.
290290- if (boolIsTrue($unitInfo->{'X-StopOnReconfiguration'} // "no")) {
342342+ if (parseSystemdBool(\%unitInfo, "Unit", "X-StopOnReconfiguration", 0)) {
291343 $unitsToStop{$unit} = 1;
292344 }
293345 }
···546598while (my ($unit, $state) = each %{$activeNew}) {
547599 if ($state->{state} eq "failed") {
548600 push @failed, $unit;
601601+ next;
549602 }
550550- elsif ($state->{state} eq "auto-restart") {
551551- # A unit in auto-restart state is a failure *if* it previously failed to start
552552- my $lines = `@systemd@/bin/systemctl show '$unit'`;
553553- my $info = {};
554554- parseKeyValues($info, split("\n", $lines));
555603556556- if ($info->{ExecMainStatus} ne '0') {
604604+ if ($state->{substate} eq "auto-restart") {
605605+ # A unit in auto-restart substate is a failure *if* it previously failed to start
606606+ my $main_status = `@systemd@/bin/systemctl show --value --property=ExecMainStatus '$unit'`;
607607+ chomp($main_status);
608608+609609+ if ($main_status ne "0") {
557610 push @failed, $unit;
611611+ next;
558612 }
559613 }
614614+560615 # Ignore scopes since they are not managed by this script but rather
561616 # created and managed by third-party services via the systemd dbus API.
562562- elsif ($state->{state} ne "failed" && !defined $activePrev->{$unit} && $unit !~ /\.scope$/) {
617617+ # This only lists units that are not failed (including ones that are in auto-restart but have not failed previously)
618618+ if ($state->{state} ne "failed" && !defined $activePrev->{$unit} && $unit !~ /\.scope$/msx) {
563619 push @new, $unit;
564620 }
565621}
566622567567-print STDERR "the following new units were started: ", join(", ", sort(@new)), "\n"
568568- if scalar @new > 0;
623623+if (scalar @new > 0) {
624624+ print STDERR "the following new units were started: ", join(", ", sort(@new)), "\n"
625625+}
569626570627if (scalar @failed > 0) {
571571- print STDERR "warning: the following units failed: ", join(", ", sort(@failed)), "\n";
572572- foreach my $unit (@failed) {
573573- print STDERR "\n";
574574- system("COLUMNS=1000 @systemd@/bin/systemctl status --no-pager '$unit' >&2");
575575- }
628628+ my @failed_sorted = sort @failed;
629629+ print STDERR "warning: the following units failed: ", join(", ", @failed_sorted), "\n\n";
630630+ system "@systemd@/bin/systemctl status --no-pager --full '" . join("' '", @failed_sorted) . "' >&2";
576631 $res = 4;
577632}
578633
+2-2
nixos/modules/system/activation/top-level.nix
···117117 configurationName = config.boot.loader.grub.configurationName;
118118119119 # Needed by switch-to-configuration.
120120- perl = pkgs.perl.withPackages (p: with p; [ FileSlurp NetDBus XMLParser XMLTwig ]);
120120+ perl = pkgs.perl.withPackages (p: with p; [ FileSlurp NetDBus XMLParser XMLTwig ConfigIniFiles ]);
121121 };
122122123123 # Handle assertions and warnings
···156156157157 specialisation = mkOption {
158158 default = {};
159159- example = lib.literalExpression "{ fewJobsManyCores.configuration = { nix.buildCores = 0; nix.maxJobs = 1; }; }";
159159+ example = lib.literalExpression "{ fewJobsManyCores.configuration = { nix.settings = { core = 0; max-jobs = 1; }; }";
160160 description = ''
161161 Additional configurations to build. If
162162 <literal>inheritParentConfig</literal> is true, the system
···10101111 # XXX: Sandbox setup fails while trying to hardlink files from the host's
1212 # store file system into the prepared chroot directory.
1313- nix.useSandbox = false;
1414- nix.binaryCaches = []; # don't try to access cache.nixos.org
1313+ nix.settings.sandbox = false;
1414+ nix.settings.substituters = []; # don't try to access cache.nixos.org
15151616 virtualisation.writableStore = true;
1717 # Make sure we always have all the required dependencies for creating a
···4545 systemd.services.test.restartIfChanged = false;
4646 };
47474848+ simpleServiceFailing.configuration = {
4949+ imports = [ simpleServiceModified.configuration ];
5050+ systemd.services.test.serviceConfig.ExecStart = lib.mkForce "${pkgs.coreutils}/bin/false";
5151+ };
5252+5353+ autorestartService.configuration = {
5454+ # A service that immediately goes into restarting (but without failing)
5555+ systemd.services.autorestart = {
5656+ wantedBy = [ "multi-user.target" ];
5757+ serviceConfig = {
5858+ Type = "simple";
5959+ Restart = "always";
6060+ RestartSec = "20y"; # Should be long enough
6161+ ExecStart = "${pkgs.coreutils}/bin/true";
6262+ };
6363+ };
6464+ };
6565+6666+ autorestartServiceFailing.configuration = {
6767+ imports = [ autorestartService.configuration ];
6868+ systemd.services.autorestart.serviceConfig = {
6969+ ExecStart = lib.mkForce "${pkgs.coreutils}/bin/false";
7070+ };
7171+ };
7272+4873 restart-and-reload-by-activation-script.configuration = {
4974 systemd.services = rec {
5075 simple-service = {
···189214 exec env -i "$@" | tee /dev/stderr
190215 '';
191216 in /* python */ ''
192192- def switch_to_specialisation(system, name, action="test"):
217217+ def switch_to_specialisation(system, name, action="test", fail=False):
193218 if name == "":
194219 stc = f"{system}/bin/switch-to-configuration"
195220 else:
196221 stc = f"{system}/specialisation/{name}/bin/switch-to-configuration"
197197- out = machine.succeed(f"{stc} {action} 2>&1")
222222+ out = machine.fail(f"{stc} {action} 2>&1") if fail \
223223+ else machine.succeed(f"{stc} {action} 2>&1")
198224 assert_lacks(out, "switch-to-configuration line") # Perl warnings
199225 return out
200226···305331 assert_lacks(out, "as well:")
306332 assert_contains(out, "would start the following units: test.service\n")
307333334334+ with subtest("failing units"):
335335+ # Let the simple service fail
336336+ switch_to_specialisation("${machine}", "simpleServiceModified")
337337+ out = switch_to_specialisation("${machine}", "simpleServiceFailing", fail=True)
338338+ assert_contains(out, "stopping the following units: test.service\n")
339339+ assert_lacks(out, "NOT restarting the following changed units:")
340340+ assert_lacks(out, "reloading the following units:")
341341+ assert_lacks(out, "\nrestarting the following units:")
342342+ assert_contains(out, "\nstarting the following units: test.service\n")
343343+ assert_lacks(out, "the following new units were started:")
344344+ assert_contains(out, "warning: the following units failed: test.service\n")
345345+ assert_contains(out, "Main PID:") # output of systemctl
346346+ assert_lacks(out, "as well:")
347347+348348+ # A unit that gets into autorestart without failing is not treated as failed
349349+ out = switch_to_specialisation("${machine}", "autorestartService")
350350+ assert_lacks(out, "stopping the following units:")
351351+ assert_lacks(out, "NOT restarting the following changed units:")
352352+ assert_lacks(out, "reloading the following units:")
353353+ assert_lacks(out, "\nrestarting the following units:")
354354+ assert_lacks(out, "\nstarting the following units:")
355355+ assert_contains(out, "the following new units were started: autorestart.service\n")
356356+ assert_lacks(out, "as well:")
357357+ machine.systemctl('stop autorestart.service') # cancel the 20y timer
358358+359359+ # Switching to the same system should do nothing (especially not treat the unit as failed)
360360+ out = switch_to_specialisation("${machine}", "autorestartService")
361361+ assert_lacks(out, "stopping the following units:")
362362+ assert_lacks(out, "NOT restarting the following changed units:")
363363+ assert_lacks(out, "reloading the following units:")
364364+ assert_lacks(out, "\nrestarting the following units:")
365365+ assert_lacks(out, "\nstarting the following units:")
366366+ assert_contains(out, "the following new units were started: autorestart.service\n")
367367+ assert_lacks(out, "as well:")
368368+ machine.systemctl('stop autorestart.service') # cancel the 20y timer
369369+370370+ # If systemd thinks the unit has failed and is in autorestart, we should show it as failed
371371+ out = switch_to_specialisation("${machine}", "autorestartServiceFailing", fail=True)
372372+ assert_lacks(out, "stopping the following units:")
373373+ assert_lacks(out, "NOT restarting the following changed units:")
374374+ assert_lacks(out, "reloading the following units:")
375375+ assert_lacks(out, "\nrestarting the following units:")
376376+ assert_lacks(out, "\nstarting the following units:")
377377+ assert_lacks(out, "the following new units were started:")
378378+ assert_contains(out, "warning: the following units failed: autorestart.service\n")
379379+ assert_contains(out, "Main PID:") # output of systemctl
380380+ assert_lacks(out, "as well:")
381381+308382 with subtest("restart and reload by activation script"):
383383+ switch_to_specialisation("${machine}", "simpleServiceNorestart")
309384 out = switch_to_specialisation("${machine}", "restart-and-reload-by-activation-script")
310385 assert_contains(out, "stopping the following units: test.service\n")
311386 assert_lacks(out, "NOT restarting the following changed units:")
···108108 gappsWrapperArgs+=(
109109 # Add gio to PATH so that moving files to the trash works when not using a desktop environment
110110 --prefix PATH : ${glib.bin}/bin
111111+ --add-flags "\''${NIXOS_OZONE_WL:+\''${WAYLAND_DISPLAY:+--enable-features=UseOzonePlatform --ozone-platform=wayland}}"
111112 )
112113 '';
113114
···24242525in stdenv.mkDerivation rec {
2626 pname = "signal-desktop";
2727- version = "5.27.1"; # Please backport all updates to the stable channel.
2727+ version = "5.29.1"; # Please backport all updates to the stable channel.
2828 # All releases have a limited lifetime and "expire" 90 days after the release.
2929 # When releases "expire" the application becomes unusable until an update is
3030 # applied. The expiration date for the current release can be extracted with:
···34343535 src = fetchurl {
3636 url = "https://updates.signal.org/desktop/apt/pool/main/s/signal-desktop/signal-desktop_${version}_amd64.deb";
3737- sha256 = "0z0v7q0rpxdx7ic78jv7wp1hq8nrfp51jjdr6d85x0hsfdj0z1mc";
3737+ sha256 = "1a56mnmv0lnizmd4dl8fya3mdsy0jy5qr5bqb72m9cipq0069alc";
3838 };
39394040 nativeBuildInputs = [
···123123 gappsWrapperArgs+=(
124124 --prefix LD_LIBRARY_PATH : "${lib.makeLibraryPath [ stdenv.cc.cc ] }"
125125 ${customLanguageWrapperArgs}
126126+ --add-flags "\''${NIXOS_OZONE_WL:+\''${WAYLAND_DISPLAY:+--enable-features=UseOzonePlatform --ozone-platform=wayland}}"
126127 )
127128128129 # Fix the desktop link
···11-Next to file.nix we get src-for-file.nix
22-src-for-file.nix should evaluate to a flat attribute set with
33-string values.
44-It is supposed to be imported in the main expression.
55-In the ideal world it can export url, hash, version.
66-77-src-for-file.nix generation is directed by
88-src-info-for-file.nix.
99-1010-Attributes:
1111-1212-src-info-for-file.nix:
1313-1414-downloadPage
1515-rev (for repos)
1616-baseName (default = unnamed-package)
1717-sourceRegexp (default = '.*[.]tar[.].*')
1818-choiceCommand (default = 'head -1')
1919-versionExtractorSedScript (default = 's/.*-([0-9.]+)[.].*/\1/')
2020-versionReferenceCreator (default = 's/-([0-9.]+)[.]/-${version}./')
2121-mirrorSedScript (default = none)
2222-2323-src-for-file.nix:
2424-2525-advertisedUrl (its match is the check for update presence)
2626-url
2727-hash
2828-version
2929-name
···11-{
22- a=1;
33- b="text";
44- c=''
55- text
66- '';
77- d=''
88- Multi-line text with special characters -
99- like \ (backslash) and ''${} (dollar +
1010- curly braces) and $ (dollar) and ' (quote)
1111- and " (double quote).
1212- '';
1313-}
···11-update-walker is an imperative semiautomated update helper.
22-33-It runs the X.upstream file to find the freshest version of the package in
44-the specified upstream source and updates the corresponding X.nix file.
55-66-77-88-The simplest available commands:
99-1010-url: set the upstream source list URL equal to $1; the default is
1111-meta.downloadPage with meta.homepage fallback
1212-1313-dl_url_re: set the regular expression used to select download links to $1; the
1414-default is meta.downloadURLRegexp or '[.]tar[.]([^./])+\$' if it is not set
1515-1616-target: specify target expression; default is to replace .upstream extension
1717-with .nix extension
1818-1919-name: specify the derivation name; default is the basename of the dirname
2020-of the .upstream file
2121-2222-attribute_name: specify the attribute name to evaluate for getting the current
2323-version from meta.version; default is to use the derivation name
2424-2525-minimize_overwrite: set config options that mean that only version= and
2626-sha256= have to be replaced; the default is to regenerate a full upstream
2727-description block with url, name, version, hash etc.
2828-2929-3030-3131-A lot of packages can be updated in a pseudo-declarative style using only
3232-the commands from the previous paragraph.
3333-3434-Some packages do not need any non-default settings, in these case just setting
3535-meta.updateWalker to true is enough, you can run update-walker directly on the
3636-.nix file afterwards. In this case minimize_overwrite it implied unless
3737-meta.fullRegenerate is set.
3838-3939-4040-4141-The packages that require more fine-grained control than the described options
4242-allow, you need to take into account the default control flow of the tool.
4343-4444-First, the definitions from update-walker script and additional definitions
4545-from update-walker-service-specific.sh are loaded. Then the config is executed
4646-as a shell script. Some of the commands it can use do remember whether they
4747-have been used. Afterwards the following steps happen:
4848-4949-attribute_name is set to name unless it has been already set
5050-5151-meta.version is read from the NixPkgs package called attribute_name
5252-5353-download URL regexp is set to default unless it has been already set in the
5454-updater script
5555-5656-the download page URL gets set to default value unless it has been set
5757-previously
5858-5959-if the action of getting the download page and choosing the freshest link by
6060-version has not yet been taken, it happens
6161-6262-if the version has not yet been extracted from the URL, it gets extracted
6363-6464-target nix expression to update gets set to the default value unless it has
6565-been set explicitly
6666-6767-if the URL version is fresher than the packaged version, the new file gets
6868-downloaded and its hash is calculated
6969-7070-do_overwrite function is called; the default calculates a big upstream data
7171-block and puts it after the '# Generated upstream information' marker (the
7272-marker can be changed by the command marker)
7373-7474-7575-7676-If the update needs some special logic, it is put into the updater script and
7777-the corresponding steps are skipped because the needed action has already been
7878-performed.
7979-8080-For example:
8181-8282-minimize_overwrite is exactly the same as
8383-8484-do_overwrite() { do_overwrite_just_version; }
8585-8686-redefinition. You can do a more complex do_overwrite redifinition, if needed.
8787-It can probably use ensure_hash to download the source and calculate the hash
8888-and set_var_value.
8989-9090-set_var_value alters the $3-th instance of assigning the $1 name in the
9191-expression to the value $2. $3 defaults to 1. It can modify $4 instead of the
9292-current target, it can put the value without quotes if $5 is 1.
9393-9494-9595-9696-Typical steps include:
9797-9898-ensure_choice: download current URL and find the freshest version link on the
9999-page, it is now the new URL
100100-101101-ensure_hash: download current URL and calculate the source package hash
102102-103103-ensure_version: extract version from the URL
104104-105105-SF_redirect: replace the current URL with a SourceForge.net mirror:// URL
106106-107107-SF_version_dir: assume SourceForge.net layout and choose the freshest
108108-version-named subdirectory in the file catalog; you can optionally specify $1
109109-as a directory name regexp (digits and periods will be required after it)
110110-111111-SF_version_tarball: assume SourceForge.net layout and choose the freshest
112112-tarball download link
113113-114114-version: apply replacement of $1 with $2 (extended regexp format) to extract
115115-the version from URL
116116-117117-version_link: choose the freshest versioned link, $1 is the regexp of
118118-acceptable links
+4-4
pkgs/data/misc/hackage/pin.json
···11{
22- "commit": "6f406277d7106375f7148466c985061d20cb028b",
33- "url": "https://github.com/commercialhaskell/all-cabal-hashes/archive/6f406277d7106375f7148466c985061d20cb028b.tar.gz",
44- "sha256": "0jvxybgv975lmk268x12dlp8xxv12vmpwc00k3nv6qqp0xd9bwla",
55- "msg": "Update from Hackage at 2022-01-18T22:54:05Z"
22+ "commit": "3034b8f1052c41d5b3c571cb2bedb5f62bbede65",
33+ "url": "https://github.com/commercialhaskell/all-cabal-hashes/archive/3034b8f1052c41d5b3c571cb2bedb5f62bbede65.tar.gz",
44+ "sha256": "0kqga1mf7vr292jcaqw8qk4s1bjwc2z1wwjih5xwli3hkk584l20",
55+ "msg": "Update from Hackage at 2022-01-24T10:21:35Z"
66}
···11+diff --git a/pthread_stop_world.c b/pthread_stop_world.c
22+index 4b2c429..1fb4c52 100644
33+--- a/pthread_stop_world.c
44++++ b/pthread_stop_world.c
55+@@ -673,6 +673,8 @@ GC_INNER void GC_push_all_stacks(void)
66+ struct GC_traced_stack_sect_s *traced_stack_sect;
77+ pthread_t self = pthread_self();
88+ word total_size = 0;
99++ size_t stack_limit;
1010++ pthread_attr_t pattr;
1111+1212+ if (!EXPECT(GC_thr_initialized, TRUE))
1313+ GC_thr_init();
1414+@@ -722,6 +724,31 @@ GC_INNER void GC_push_all_stacks(void)
1515+ hi = p->altstack + p->altstack_size;
1616+ /* FIXME: Need to scan the normal stack too, but how ? */
1717+ /* FIXME: Assume stack grows down */
1818++ } else {
1919++ if (pthread_getattr_np(p->id, &pattr)) {
2020++ ABORT("GC_push_all_stacks: pthread_getattr_np failed!");
2121++ }
2222++ if (pthread_attr_getstacksize(&pattr, &stack_limit)) {
2323++ ABORT("GC_push_all_stacks: pthread_attr_getstacksize failed!");
2424++ }
2525++ if (pthread_attr_destroy(&pattr)) {
2626++ ABORT("GC_push_all_stacks: pthread_attr_destroy failed!");
2727++ }
2828++ // When a thread goes into a coroutine, we lose its original sp until
2929++ // control flow returns to the thread.
3030++ // While in the coroutine, the sp points outside the thread stack,
3131++ // so we can detect this and push the entire thread stack instead,
3232++ // as an approximation.
3333++ // We assume that the coroutine has similarly added its entire stack.
3434++ // This could be made accurate by cooperating with the application
3535++ // via new functions and/or callbacks.
3636++ #ifndef STACK_GROWS_UP
3737++ if (lo >= hi || lo < hi - stack_limit) { // sp outside stack
3838++ lo = hi - stack_limit;
3939++ }
4040++ #else
4141++ #error "STACK_GROWS_UP not supported in boost_coroutine2 (as of june 2021), so we don't support it in Nix."
4242++ #endif
4343+ }
4444+ GC_push_all_stack_sections(lo, hi, traced_stack_sect);
4545+ # ifdef STACK_GROWS_UP
···3232 feature = "run <literal>checkPhase</literal> by default";
3333 };
34343535- path = mkOption {
3636- type = types.path;
3737- default = ../..;
3838- defaultText = lib.literalDocBook "a path expression";
3939- internal = true;
4040- description = ''
4141- A reference to Nixpkgs' own sources.
4242-4343- This is overridable in order to avoid copying sources unnecessarily,
4444- as a path expression that references a store path will not short-circuit
4545- to the store path itself, but copy the store path instead.
4646- '';
4747- };
4848-4935 };
50365137in {