···1617* [NixOS Manual](https://nixos.org/nixos/manual) - how to install, configure, and maintain a purely-functional Linux distribution
18* [Nixpkgs Manual](https://nixos.org/nixpkgs/manual/) - contributing to Nixpkgs and using programming-language-specific Nix expressions
19-* [Nix Package Manager Manual](https://nixos.org/nix/manual) - how to write Nix expresssions (programs), and how to use Nix command line tools
2021# Community
22···2728# Other Project Repositories
2930-The sources of all offical Nix-related projects are in the [NixOS
31organization on GitHub](https://github.com/NixOS/). Here are some of
32the main ones:
33
···1617* [NixOS Manual](https://nixos.org/nixos/manual) - how to install, configure, and maintain a purely-functional Linux distribution
18* [Nixpkgs Manual](https://nixos.org/nixpkgs/manual/) - contributing to Nixpkgs and using programming-language-specific Nix expressions
19+* [Nix Package Manager Manual](https://nixos.org/nix/manual) - how to write Nix expressions (programs), and how to use Nix command line tools
2021# Community
22···2728# Other Project Repositories
2930+The sources of all official Nix-related projects are in the [NixOS
31organization on GitHub](https://github.com/NixOS/). Here are some of
32the main ones:
33
···1+{ config, lib, pkgs, ... }:
2+3+with lib;
4+5+let cfg = config.programs.bandwhich;
6+in {
7+ meta.maintainers = with maintainers; [ filalex77 ];
8+9+ options = {
10+ programs.bandwhich = {
11+ enable = mkOption {
12+ type = types.bool;
13+ default = false;
14+ description = ''
15+ Whether to add bandwhich to the global environment and configure a
16+ setcap wrapper for it.
17+ '';
18+ };
19+ };
20+ };
21+22+ config = mkIf cfg.enable {
23+ environment.systemPackages = with pkgs; [ bandwhich ];
24+ security.wrappers.bandwhich = {
25+ source = "${pkgs.bandwhich}/bin/bandwhich";
26+ capabilities = "cap_net_raw,cap_net_admin+ep";
27+ };
28+ };
29+}
+1-1
nixos/modules/services/torrent/transmission.nix
···118 # 1) Only the "transmission" user and group have access to torrents.
119 # 2) Optionally update/force specific fields into the configuration file.
120 serviceConfig.ExecStartPre = preStart;
121- serviceConfig.ExecStart = "${pkgs.transmission}/bin/transmission-daemon -f --port ${toString config.services.transmission.port}";
122 serviceConfig.ExecReload = "${pkgs.coreutils}/bin/kill -HUP $MAINPID";
123 serviceConfig.User = cfg.user;
124 serviceConfig.Group = cfg.group;
···118 # 1) Only the "transmission" user and group have access to torrents.
119 # 2) Optionally update/force specific fields into the configuration file.
120 serviceConfig.ExecStartPre = preStart;
121+ serviceConfig.ExecStart = "${pkgs.transmission}/bin/transmission-daemon -f --port ${toString config.services.transmission.port} --config-dir ${settingsDir}";
122 serviceConfig.ExecReload = "${pkgs.coreutils}/bin/kill -HUP $MAINPID";
123 serviceConfig.User = cfg.user;
124 serviceConfig.Group = cfg.group;
+1-1
nixos/modules/services/web-apps/nextcloud.nix
···62 https = mkOption {
63 type = types.bool;
64 default = false;
65- description = "Enable if there is a TLS terminating proxy in front of nextcloud.";
66 };
6768 maxUploadSize = mkOption {
···225 fi
226 ${concatStringsSep "\n" (mapAttrsToList renderExtraVeth cfg.extraVeths)}
227 fi
228-229- # Get the leader PID so that we can signal it in
230- # preStop. We can't use machinectl there because D-Bus
231- # might be shutting down. FIXME: in systemd 219 we can
232- # just signal systemd-nspawn to do a clean shutdown.
233- machinectl show "$INSTANCE" | sed 's/Leader=\(.*\)/\1/;t;d' > "/run/containers/$INSTANCE.pid"
234 ''
235 );
236···715716 postStart = postStartScript dummyConfig;
717718- preStop =
719- ''
720- pid="$(cat /run/containers/$INSTANCE.pid)"
721- if [ -n "$pid" ]; then
722- kill -RTMIN+4 "$pid"
723- fi
724- rm -f "/run/containers/$INSTANCE.pid"
725- '';
726727 restartIfChanged = false;
728
···40# They must be propagated to the environment of any executable linking with the library
41, libraryFrameworkDepends ? [], executableFrameworkDepends ? []
42, homepage ? "https://hackage.haskell.org/package/${pname}"
43-, platforms ? with stdenv.lib.platforms; unix ++ windows # GHC can cross-compile
44, hydraPlatforms ? null
45, hyperlinkSource ? true
46, isExecutable ? false, isLibrary ? !isExecutable
···131 '';
132133 crossCabalFlags = [
134- "--with-ghc=${ghc.targetPrefix}ghc"
135 "--with-ghc-pkg=${ghc.targetPrefix}ghc-pkg"
136- "--with-gcc=${stdenv.cc.targetPrefix}cc"
0000137 "--with-ld=${stdenv.cc.bintools.targetPrefix}ld"
138 "--with-ar=${stdenv.cc.bintools.targetPrefix}ar"
139 # use the one that comes with the cross compiler.
···156 "--libsubdir=\\$abi/\\$libname"
157 (optionalString enableSeparateDataOutput "--datadir=$data/share/${ghc.name}")
158 (optionalString enableSeparateDocOutput "--docdir=${docdir "$doc"}")
0159 "--with-gcc=$CC" # Clang won't work without that extra information.
0160 "--package-db=$packageConfDir"
161 (optionalString (enableSharedExecutables && stdenv.isLinux) "--ghc-option=-optl=-Wl,-rpath=$out/lib/${ghc.name}/${pname}-${version}")
162 (optionalString (enableSharedExecutables && stdenv.isDarwin) "--ghc-option=-optl=-Wl,-headerpad_max_install_names")
···40# They must be propagated to the environment of any executable linking with the library
41, libraryFrameworkDepends ? [], executableFrameworkDepends ? []
42, homepage ? "https://hackage.haskell.org/package/${pname}"
43+, platforms ? with stdenv.lib.platforms; all # GHC can cross-compile
44, hydraPlatforms ? null
45, hyperlinkSource ? true
46, isExecutable ? false, isLibrary ? !isExecutable
···131 '';
132133 crossCabalFlags = [
134+ "--with-ghc=${ghcCommand}"
135 "--with-ghc-pkg=${ghc.targetPrefix}ghc-pkg"
136+ # Pass the "wrong" C compiler rather than none at all so packages that just
137+ # use the C preproccessor still work, see
138+ # https://github.com/haskell/cabal/issues/6466 for details.
139+ "--with-gcc=${(if stdenv.hasCC then stdenv else buildPackages.stdenv).cc.targetPrefix}cc"
140+ ] ++ optionals stdenv.hasCC [
141 "--with-ld=${stdenv.cc.bintools.targetPrefix}ld"
142 "--with-ar=${stdenv.cc.bintools.targetPrefix}ar"
143 # use the one that comes with the cross compiler.
···160 "--libsubdir=\\$abi/\\$libname"
161 (optionalString enableSeparateDataOutput "--datadir=$data/share/${ghc.name}")
162 (optionalString enableSeparateDocOutput "--docdir=${docdir "$doc"}")
163+ ] ++ optionals stdenv.hasCC [
164 "--with-gcc=$CC" # Clang won't work without that extra information.
165+ ] ++ [
166 "--package-db=$packageConfDir"
167 (optionalString (enableSharedExecutables && stdenv.isLinux) "--ghc-option=-optl=-Wl,-rpath=$out/lib/${ghc.name}/${pname}-${version}")
168 (optionalString (enableSharedExecutables && stdenv.isDarwin) "--ghc-option=-optl=-Wl,-headerpad_max_install_names")
+3-2
pkgs/development/haskell-modules/hoogle.nix
···23# This will build mmorph and monadControl, and have the hoogle installation
24# refer to their documentation via symlink so they are not garbage collected.
2526-{ lib, stdenv, hoogle, writeText, ghc
027, packages
28}:
29···53 (map (lib.getOutput "doc") packages);
5455in
56-stdenv.mkDerivation {
57 name = "hoogle-local-0.1";
58 buildInputs = [ghc hoogle];
59
···23# This will build mmorph and monadControl, and have the hoogle installation
24# refer to their documentation via symlink so they are not garbage collected.
2526+{ lib, stdenv, buildPackages
27+, hoogle, writeText, ghc
28, packages
29}:
30···54 (map (lib.getOutput "doc") packages);
5556in
57+buildPackages.stdenv.mkDerivation {
58 name = "hoogle-local-0.1";
59 buildInputs = [ghc hoogle];
60
···121 postStage = buildPackages: {
122 __raw = true;
123 stdenv.cc =
124+ if buildPackages.stdenv.hasCC
125+ then
126+ if buildPackages.stdenv.cc.isClang or false
127+ then buildPackages.clang
128+ else buildPackages.gcc
129+ else
130+ # This will blow up if anything uses it, but that's OK. The `if
131+ # buildPackages.stdenv.cc.isClang then ... else ...` would blow up
132+ # everything, so we make sure to avoid that.
133+ buildPackages.stdenv.cc;
134 };
135136in dfold folder postStage (_: {}) withAllowCustomOverrides
+7-1
pkgs/stdenv/cross/default.nix
···51 extraBuildInputs = [ ]; # Old ones run on wrong platform
52 allowedRequisites = null;
530054 cc = if crossSystem.useiOSPrebuilt or false
55 then buildPackages.darwin.iosSdkPkgs.clang
56 else if crossSystem.useAndroidPrebuilt or false
57 then buildPackages."androidndkPkgs_${crossSystem.ndkVer}".clang
58 else if targetPlatform.isGhcjs
59- then null
000060 else if crossSystem.useLLVM or false
61 then buildPackages.llvmPackages_8.lldClang
62 else buildPackages.gcc;
···51 extraBuildInputs = [ ]; # Old ones run on wrong platform
52 allowedRequisites = null;
5354+ hasCC = !targetPlatform.isGhcjs;
55+56 cc = if crossSystem.useiOSPrebuilt or false
57 then buildPackages.darwin.iosSdkPkgs.clang
58 else if crossSystem.useAndroidPrebuilt or false
59 then buildPackages."androidndkPkgs_${crossSystem.ndkVer}".clang
60 else if targetPlatform.isGhcjs
61+ # Need to use `throw` so tryEval for splicing works, ugh. Using
62+ # `null` or skipping the attribute would cause an eval failure
63+ # `tryEval` wouldn't catch, wrecking accessing previous stages
64+ # when there is a C compiler and everything should be fine.
65+ then throw "no C compiler provided for this platform"
66 else if crossSystem.useLLVM or false
67 then buildPackages.llvmPackages_8.lldClang
68 else buildPackages.gcc;
+13-3
pkgs/stdenv/generic/default.nix
···1let lib = import ../../../lib; in lib.makeOverridable (
23-{ name ? "stdenv", preHook ? "", initialPath, cc, shell
0000000004, allowedRequisites ? null, extraAttrs ? {}, overrides ? (self: super: {}), config
56, # The `fetchurl' to use for downloading curl and its dependencies
···57 ../../build-support/setup-hooks/move-sbin.sh
58 ../../build-support/setup-hooks/move-lib64.sh
59 ../../build-support/setup-hooks/set-source-date-epoch-to-latest.sh
60- cc
061 ];
6263 defaultBuildInputs = extraBuildInputs;
···145146 inherit overrides;
147148- inherit cc;
149 }
150151 # Propagate any extra attributes. For instance, we use this to
···1let lib = import ../../../lib; in lib.makeOverridable (
23+{ name ? "stdenv", preHook ? "", initialPath
4+5+, # If we don't have a C compiler, we might either have `cc = null` or `cc =
6+ # throw ...`, but if we do have a C compiler we should definiely have `cc !=
7+ # null`.
8+ #
9+ # TODO(@Ericson2314): Add assert without creating infinite recursion
10+ hasCC ? cc != null, cc
11+12+, shell
13, allowedRequisites ? null, extraAttrs ? {}, overrides ? (self: super: {}), config
1415, # The `fetchurl' to use for downloading curl and its dependencies
···66 ../../build-support/setup-hooks/move-sbin.sh
67 ../../build-support/setup-hooks/move-lib64.sh
68 ../../build-support/setup-hooks/set-source-date-epoch-to-latest.sh
69+ # TODO use lib.optional instead
70+ (if hasCC then cc else null)
71 ];
7273 defaultBuildInputs = extraBuildInputs;
···155156 inherit overrides;
157158+ inherit cc hasCC;
159 }
160161 # Propagate any extra attributes. For instance, we use this to
+32
pkgs/tools/networking/bandwhich/default.nix
···00000000000000000000000000000000
···1+{ stdenv, fetchFromGitHub, rustPlatform, Security }:
2+3+rustPlatform.buildRustPackage rec {
4+ pname = "bandwhich";
5+ version = "0.6.0";
6+7+ src = fetchFromGitHub {
8+ owner = "imsnif";
9+ repo = pname;
10+ rev = version;
11+ sha256 = "0jjqc8sysvw63mwy68z9p16vc1pygrm1wxyll6piwvbbnirpys1y";
12+ };
13+14+ cargoSha256 = "1rixpljqddwhryddzni5l6m4sjyn1krrj0ig0rzc701am7srhg3a";
15+16+ buildInputs = stdenv.lib.optional stdenv.isDarwin Security;
17+18+ meta = with stdenv.lib; {
19+ description = "A CLI utility for displaying current network utilization";
20+ longDescription = ''
21+ bandwhich sniffs a given network interface and records IP packet size, cross
22+ referencing it with the /proc filesystem on linux or lsof on MacOS. It is
23+ responsive to the terminal window size, displaying less info if there is
24+ no room for it. It will also attempt to resolve ips to their host name in
25+ the background using reverse DNS on a best effort basis.
26+ '';
27+ homepage = "https://github.com/imsnif/bandwhich";
28+ license = licenses.mit;
29+ maintainers = with maintainers; [ filalex77 ];
30+ platforms = platforms.unix;
31+ };
32+}