From 10c0cf6e4f20986b90346570846b5d1f723c6b6d Mon Sep 17 00:00:00 2001 From: Joel Date: Thu, 13 Jan 2022 13:14:01 +1000 Subject: [PATCH 01/57] qtile: cleanup --- .../window-managers/qtile/default.nix | 30 +++++++------------ pkgs/top-level/all-packages.nix | 4 +-- 2 files changed, 12 insertions(+), 22 deletions(-) diff --git a/pkgs/applications/window-managers/qtile/default.nix b/pkgs/applications/window-managers/qtile/default.nix index 8c5d65d4978f..2bd92ee6cf66 100644 --- a/pkgs/applications/window-managers/qtile/default.nix +++ b/pkgs/applications/window-managers/qtile/default.nix @@ -1,15 +1,7 @@ -{ lib, fetchFromGitHub, python3, mypy, glib, cairo, pango, pkg-config, libxcb, xcbutilcursor }: +{ lib, fetchFromGitHub, python3, python3Packages, mypy, glib, pango, pkg-config, xcbutilcursor }: let - enabled-xcffib = cairocffi-xcffib: cairocffi-xcffib.override { - withXcffib = true; - }; - - # make it easier to reference python - python = python3; - pythonPackages = python.pkgs; - - unwrapped = pythonPackages.buildPythonPackage rec { + unwrapped = python3Packages.buildPythonPackage rec { pname = "qtile"; version = "0.19.0"; @@ -33,13 +25,13 @@ let nativeBuildInputs = [ pkg-config - ] ++ (with pythonPackages; [ + ] ++ (with python3Packages; [ setuptools-scm ]); - propagatedBuildInputs = with pythonPackages; [ + propagatedBuildInputs = with python3Packages; [ xcffib - (enabled-xcffib cairocffi) + (cairocffi.override { withXcffib = true; }) setuptools python-dateutil dbus-python @@ -68,9 +60,9 @@ let }; }; in - (python.withPackages (ps: [ unwrapped ])).overrideAttrs (_: { - # otherwise will be exported as "env", this restores `nix search` behavior - name = "${unwrapped.pname}-${unwrapped.version}"; - # export underlying qtile package - passthru = { inherit unwrapped; }; - }) +(python3.withPackages (_: [ unwrapped ])).overrideAttrs (_: { + # otherwise will be exported as "env", this restores `nix search` behavior + name = "${unwrapped.pname}-${unwrapped.version}"; + # export underlying qtile package + passthru = { inherit unwrapped; }; +}) diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index bbb34fa55d7b..e3db780e8d25 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -29220,9 +29220,7 @@ with pkgs; qpdfview = libsForQt5.callPackage ../applications/misc/qpdfview {}; - qtile = callPackage ../applications/window-managers/qtile { - inherit (xorg) libxcb; - }; + qtile = callPackage ../applications/window-managers/qtile { }; vimpc = callPackage ../applications/audio/vimpc { }; From 0b27a6c24e051b10b3164deb83b039a162b8bc29 Mon Sep 17 00:00:00 2001 From: Ivar Scholten Date: Tue, 18 Jan 2022 17:51:33 +0100 Subject: [PATCH 02/57] python3Packages.gigalixir: fix build --- pkgs/development/python-modules/gigalixir/default.nix | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pkgs/development/python-modules/gigalixir/default.nix b/pkgs/development/python-modules/gigalixir/default.nix index e7d19091605d..aa5512d99131 100644 --- a/pkgs/development/python-modules/gigalixir/default.nix +++ b/pkgs/development/python-modules/gigalixir/default.nix @@ -24,7 +24,9 @@ buildPythonApplication rec { }; postPatch = '' - substituteInPlace setup.py --replace "'pytest-runner'," "" + substituteInPlace setup.py \ + --replace "'pytest-runner'," "" \ + --replace "cryptography==" "cryptography>=" ''; propagatedBuildInputs = [ From 280ebc81a7ecbfabf1d03a37906f17788ee8c757 Mon Sep 17 00:00:00 2001 From: "R. Ryantm" Date: Wed, 19 Jan 2022 06:33:41 +0000 Subject: [PATCH 03/57] nwg-wrapper: 0.1.0 -> 0.1.2 --- pkgs/applications/misc/nwg-wrapper/default.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/applications/misc/nwg-wrapper/default.nix b/pkgs/applications/misc/nwg-wrapper/default.nix index 770227186ff6..4e7f864f3eaa 100644 --- a/pkgs/applications/misc/nwg-wrapper/default.nix +++ b/pkgs/applications/misc/nwg-wrapper/default.nix @@ -2,13 +2,13 @@ python3Packages.buildPythonPackage rec { pname = "nwg-wrapper"; - version = "0.1.0"; + version = "0.1.2"; src = fetchFromGitHub { owner = "nwg-piotr"; repo = pname; rev = "v${version}"; - sha256 = "0xkxyfbj8zljx7k5wbniz3x9jg0l4jnbbjv8hy5y5p4l10m0vpjs"; + sha256 = "114y55mv2rgnp75a3c7rk46v5v84d1zqb6wkha7x16ab6xa9phzl"; }; nativeBuildInputs = [ gobject-introspection wrapGAppsHook ]; From 38e16d7c76761055096b0dd7e8353e6401f75571 Mon Sep 17 00:00:00 2001 From: "R. Ryantm" Date: Thu, 20 Jan 2022 00:28:02 +0000 Subject: [PATCH 04/57] python310Packages.jdatetime: 3.8.0 -> 3.8.1 --- pkgs/development/python-modules/jdatetime/default.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/development/python-modules/jdatetime/default.nix b/pkgs/development/python-modules/jdatetime/default.nix index 8e8f0e4618a1..7bdecd724764 100644 --- a/pkgs/development/python-modules/jdatetime/default.nix +++ b/pkgs/development/python-modules/jdatetime/default.nix @@ -2,11 +2,11 @@ buildPythonPackage rec { pname = "jdatetime"; - version = "3.8.0"; + version = "3.8.1"; src = fetchPypi { inherit pname version; - sha256 = "389a0723a8011379a5e34386ec466cb3f65b2d5cb5422702c1d3aecb6ac192d0"; + sha256 = "db57ee517356b1bfc1603ef412f5da61eae92241ba0bcaf0851028cae424780c"; }; propagatedBuildInputs = [ six ]; From f57c822f7a1964533f30fd4426ef6a3e3eb7fa0a Mon Sep 17 00:00:00 2001 From: "R. Ryantm" Date: Sat, 22 Jan 2022 08:12:48 +0000 Subject: [PATCH 05/57] swayr: 0.11.2 -> 0.12.0 --- pkgs/tools/wayland/swayr/default.nix | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pkgs/tools/wayland/swayr/default.nix b/pkgs/tools/wayland/swayr/default.nix index 9ccc13532c2a..1e0e963b8e8e 100644 --- a/pkgs/tools/wayland/swayr/default.nix +++ b/pkgs/tools/wayland/swayr/default.nix @@ -2,16 +2,16 @@ rustPlatform.buildRustPackage rec { pname = "swayr"; - version = "0.11.2"; + version = "0.12.0"; src = fetchFromSourcehut { owner = "~tsdh"; repo = "swayr"; rev = "v${version}"; - sha256 = "sha256-IjOoQbKCiwuoCsh2bOmvcSH3/9KMmavmn1Ib1TLBH8w="; + sha256 = "sha256-bmMfrwxdriE/o8fezLbmhorBDvjtC4vaVamwDtrxiMQ="; }; - cargoSha256 = "sha256-EYaISBnWKplKUAKa9SZufWcykeR/qeApvqwIGB9jt3Q="; + cargoSha256 = "sha256-5hTiu2fGyMcbsg05hLngQXsjw3Vql2q8zlW5e6jD9Ok="; patches = [ ./icon-paths.patch From d0700b9e2276bcdf84783c07327fc2b924072014 Mon Sep 17 00:00:00 2001 From: "R. Ryantm" Date: Sat, 22 Jan 2022 22:53:31 +0000 Subject: [PATCH 06/57] python310Packages.aiohwenergy: 0.6.0 -> 0.7.0 --- pkgs/development/python-modules/aiohwenergy/default.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/development/python-modules/aiohwenergy/default.nix b/pkgs/development/python-modules/aiohwenergy/default.nix index 538f628abe66..a3ec8edd6d9f 100644 --- a/pkgs/development/python-modules/aiohwenergy/default.nix +++ b/pkgs/development/python-modules/aiohwenergy/default.nix @@ -8,7 +8,7 @@ buildPythonPackage rec { pname = "aiohwenergy"; - version = "0.6.0"; + version = "0.7.0"; format = "setuptools"; disabled = pythonOlder "3.7"; @@ -17,7 +17,7 @@ buildPythonPackage rec { owner = "DCSBL"; repo = pname; rev = version; - sha256 = "006q2kgc28dn43skk2x76d13fp51sy073nm8f2hrxn4wqwkccsx3"; + sha256 = "0pgk9ky4kfb1kp0mpyxdinwql1q85a3bl5w34pr88wqdqdw467ms"; }; propagatedBuildInputs = [ From 42128ece370b7a133f912136fc7e61cb9c6ea37b Mon Sep 17 00:00:00 2001 From: "R. Ryantm" Date: Sun, 23 Jan 2022 00:32:11 +0000 Subject: [PATCH 07/57] python310Packages.aioesphomeapi: 10.6.0 -> 10.8.0 --- pkgs/development/python-modules/aioesphomeapi/default.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/development/python-modules/aioesphomeapi/default.nix b/pkgs/development/python-modules/aioesphomeapi/default.nix index 5023b0325233..e0f1b1df3c77 100644 --- a/pkgs/development/python-modules/aioesphomeapi/default.nix +++ b/pkgs/development/python-modules/aioesphomeapi/default.nix @@ -12,7 +12,7 @@ buildPythonPackage rec { pname = "aioesphomeapi"; - version = "10.6.0"; + version = "10.8.0"; format = "setuptools"; disabled = pythonOlder "3.7"; @@ -21,7 +21,7 @@ buildPythonPackage rec { owner = "esphome"; repo = pname; rev = "v${version}"; - sha256 = "1z9pybis8yi938i3cgzma4w452ik9vggyyhs3y542zpk4183d7xw"; + sha256 = "1349b2as6r3m9sxlfss8plzafn31kf3rihwa58b4f7cmc4dhb2s8"; }; propagatedBuildInputs = [ From 72a12486732e8e9313fcf5c34d5224cec4d8646e Mon Sep 17 00:00:00 2001 From: Fabian Affolter Date: Sun, 23 Jan 2022 11:43:20 +0100 Subject: [PATCH 08/57] python3Packages.jdatetime: add pythonImportsCheck --- .../python-modules/jdatetime/default.nix | 23 +++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/pkgs/development/python-modules/jdatetime/default.nix b/pkgs/development/python-modules/jdatetime/default.nix index 7bdecd724764..6989c4257c79 100644 --- a/pkgs/development/python-modules/jdatetime/default.nix +++ b/pkgs/development/python-modules/jdatetime/default.nix @@ -1,19 +1,34 @@ -{ lib, buildPythonPackage, fetchPypi, six }: +{ lib +, buildPythonPackage +, fetchPypi +, six +, pythonOlder +}: buildPythonPackage rec { pname = "jdatetime"; version = "3.8.1"; + format = "setuptools"; + + disabled = pythonOlder "3.7"; src = fetchPypi { inherit pname version; sha256 = "db57ee517356b1bfc1603ef412f5da61eae92241ba0bcaf0851028cae424780c"; }; - propagatedBuildInputs = [ six ]; + propagatedBuildInputs = [ + six + ]; + + pythonImportsCheck = [ + "jdatetime" + ]; meta = with lib; { - description = "Jalali datetime binding for python"; - homepage = "https://pypi.python.org/pypi/jdatetime"; + description = "Jalali datetime binding"; + homepage = "https://github.com/slashmili/python-jalali"; license = licenses.psfl; + maintainers = with maintainers; [ ]; }; } From 759416392b476320fa16f2ac863f438b9b3bb19a Mon Sep 17 00:00:00 2001 From: "R. Ryantm" Date: Sun, 23 Jan 2022 11:26:20 +0000 Subject: [PATCH 09/57] vintagestory: 1.16.0 -> 1.16.1 --- pkgs/games/vintagestory/default.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/games/vintagestory/default.nix b/pkgs/games/vintagestory/default.nix index 5a4e8fe852c6..46d847dee690 100644 --- a/pkgs/games/vintagestory/default.nix +++ b/pkgs/games/vintagestory/default.nix @@ -17,11 +17,11 @@ stdenv.mkDerivation rec { pname = "vintagestory"; - version = "1.16.0"; + version = "1.16.1"; src = fetchurl { url = "https://cdn.vintagestory.at/gamefiles/stable/vs_archive_${version}.tar.gz"; - sha256 = "sha256-1lAcE+RwK16xPTGxGCz2Pdq6GhmXFwy60CSZyq3hgnM="; + sha256 = "sha256-o3FMuMvWxj9ECj77H/q5QkpcFbcZ0eNQ1OS51pUal3c="; }; nativeBuildInputs = [ makeWrapper copyDesktopItems ]; From 3ac955acf44e2155d1fef77c49b5c6f068e6e27b Mon Sep 17 00:00:00 2001 From: Robert Hensing Date: Thu, 20 Jan 2022 14:53:35 +0100 Subject: [PATCH 10/57] nixos/system/build: Extract Modules that do not depend on e.g. toplevel should not have to include it just to set things in `system.build`. As a general rule, this keeps tests simple, usage flexible and evaluation fast. While one module is insignificant, consistency and good practices are. --- nixos/modules/system/activation/top-level.nix | 10 +--------- nixos/modules/system/build.nix | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 9 deletions(-) create mode 100644 nixos/modules/system/build.nix diff --git a/nixos/modules/system/activation/top-level.nix b/nixos/modules/system/activation/top-level.nix index 8e53ec1ffab2..e10d668ad2cf 100644 --- a/nixos/modules/system/activation/top-level.nix +++ b/nixos/modules/system/activation/top-level.nix @@ -139,21 +139,13 @@ in { imports = [ + ../build.nix (mkRemovedOptionModule [ "nesting" "clone" ] "Use `specialisation.«name» = { inheritParentConfig = true; configuration = { ... }; }` instead.") (mkRemovedOptionModule [ "nesting" "children" ] "Use `specialisation.«name».configuration = { ... }` instead.") ]; options = { - system.build = mkOption { - internal = true; - default = {}; - type = with types; lazyAttrsOf (uniq unspecified); - description = '' - Attribute set of derivations used to setup the system. - ''; - }; - specialisation = mkOption { default = {}; example = lib.literalExpression "{ fewJobsManyCores.configuration = { nix.buildCores = 0; nix.maxJobs = 1; }; }"; diff --git a/nixos/modules/system/build.nix b/nixos/modules/system/build.nix new file mode 100644 index 000000000000..1539e5b53b0c --- /dev/null +++ b/nixos/modules/system/build.nix @@ -0,0 +1,18 @@ +{ lib, ... }: +let + inherit (lib) mkOption types; +in +{ + options = { + + system.build = mkOption { + internal = true; + default = {}; + type = with types; lazyAttrsOf (uniq unspecified); + description = '' + Attribute set of derivations used to set up the system. + ''; + }; + + }; +} From ccb85a53b6a496984073227fd8c4d4c58889f421 Mon Sep 17 00:00:00 2001 From: Robert Hensing Date: Thu, 20 Jan 2022 15:04:08 +0100 Subject: [PATCH 11/57] nixos: Make system.build a submodule with freeformType This allows the values below it to be specified as options, while remaining compatible with existing code. --- nixos/modules/system/build.nix | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/nixos/modules/system/build.nix b/nixos/modules/system/build.nix index 1539e5b53b0c..58dc3f0d4113 100644 --- a/nixos/modules/system/build.nix +++ b/nixos/modules/system/build.nix @@ -6,12 +6,15 @@ in options = { system.build = mkOption { - internal = true; default = {}; - type = with types; lazyAttrsOf (uniq unspecified); description = '' Attribute set of derivations used to set up the system. ''; + type = types.submoduleWith { + modules = [{ + freeformType = with types; lazyAttrsOf (uniq unspecified); + }]; + }; }; }; From 08595059e836197cb2ea85e8d00c06377b9dfab1 Mon Sep 17 00:00:00 2001 From: ajs124 Date: Wed, 15 Dec 2021 18:58:34 +0000 Subject: [PATCH 12/57] wraith: 1.4.7 -> 1.4.10 --- .../networking/irc/wraith/configure.patch | 4 ++-- pkgs/applications/networking/irc/wraith/default.nix | 4 ++-- pkgs/applications/networking/irc/wraith/dlopen.patch | 12 ++++++------ pkgs/top-level/all-packages.nix | 4 +--- 4 files changed, 11 insertions(+), 13 deletions(-) diff --git a/pkgs/applications/networking/irc/wraith/configure.patch b/pkgs/applications/networking/irc/wraith/configure.patch index e5fa2feb2019..16e65be00a25 100644 --- a/pkgs/applications/networking/irc/wraith/configure.patch +++ b/pkgs/applications/networking/irc/wraith/configure.patch @@ -1,8 +1,8 @@ --- a/configure +++ b/configure -@@ -6029,53 +6029,8 @@ +@@ -6143,53 +6143,8 @@ rm -f confcache + #AC_CHECK_HEADERS(openssl/ssl.h openssl/crypto.h) #AC_CHECK_HEADERS(zlib.h) - #EGG_CHECK_ZLIB -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for path to OpenSSL" >&5 -$as_echo_n "checking for path to OpenSSL... " >&6; } diff --git a/pkgs/applications/networking/irc/wraith/default.nix b/pkgs/applications/networking/irc/wraith/default.nix index 3b1fa79aa266..30aec18c107f 100644 --- a/pkgs/applications/networking/irc/wraith/default.nix +++ b/pkgs/applications/networking/irc/wraith/default.nix @@ -2,10 +2,10 @@ stdenv.mkDerivation rec { pname = "wraith"; - version = "1.4.7"; + version = "1.4.10"; src = fetchurl { url = "mirror://sourceforge/wraithbotpack/wraith-v${version}.tar.gz"; - sha256 = "0h6liac5y7im0jfm2sj18mibvib7d1l727fjs82irsjj1v9kif3j"; + sha256 = "1h8159g6wh1hi69cnhqkgwwwa95fa6z1zrzjl219mynbf6vjjzkw"; }; hardeningDisable = [ "format" ]; buildInputs = [ openssl ]; diff --git a/pkgs/applications/networking/irc/wraith/dlopen.patch b/pkgs/applications/networking/irc/wraith/dlopen.patch index bfc854ef9e9c..5bf11eb72692 100644 --- a/pkgs/applications/networking/irc/wraith/dlopen.patch +++ b/pkgs/applications/networking/irc/wraith/dlopen.patch @@ -1,15 +1,15 @@ diff --git a/src/libcrypto.cc b/src/libcrypto.cc -index 0339258..68746c8 100644 +index 5139f66..517103f 100644 --- a/src/libcrypto.cc +++ b/src/libcrypto.cc -@@ -95,17 +95,9 @@ int load_libcrypto() { +@@ -100,17 +100,9 @@ int load_libcrypto() { } sdprintf("Loading libcrypto"); + dlerror(); // Clear Errors + libcrypto_handle = dlopen("@openssl@/lib/libcrypto.so", RTLD_LAZY|RTLD_GLOBAL); -- bd::Array libs_list(bd::String("libcrypto.so." SHLIB_VERSION_NUMBER " libcrypto.so libcrypto.so.0.9.8 libcrypto.so.7 libcrypto.so.6").split(' ')); +- bd::Array libs_list(bd::String("libcrypto.so." SHLIB_VERSION_NUMBER " libcrypto.so libcrypto.so.1.1 libcrypto.so.1.0.0 libcrypto.so.0.9.8 libcrypto.so.10 libcrypto.so.9 libcrypto.so.8 libcrypto.so.7 libcrypto.so.6").split(' ')); - - for (size_t i = 0; i < libs_list.length(); ++i) { - dlerror(); // Clear Errors @@ -23,17 +23,17 @@ index 0339258..68746c8 100644 fprintf(stderr, STR("Unable to find libcrypto\n")); return(1); diff --git a/src/libssl.cc b/src/libssl.cc -index b432c7b..8940998 100644 +index 6010abc..86e29fc 100644 --- a/src/libssl.cc +++ b/src/libssl.cc -@@ -68,17 +68,9 @@ int load_libssl() { +@@ -78,17 +78,9 @@ int load_libssl() { } sdprintf("Loading libssl"); + dlerror(); // Clear Errors + libssl_handle = dlopen("@openssl@/lib/libssl.so", RTLD_LAZY); -- bd::Array libs_list(bd::String("libssl.so." SHLIB_VERSION_NUMBER " libssl.so libssl.so.0.9.8 libssl.so.7 libssl.so.6").split(' ')); +- bd::Array libs_list(bd::String("libssl.so." SHLIB_VERSION_NUMBER " libssl.so libssl.so.1.1 libssl.so.1.0.0 libssl.so.0.9.8 libssl.so.10 libssl.so.9 libssl.so.8 libssl.so.7 libssl.so.6").split(' ')); - - for (size_t i = 0; i < libs_list.length(); ++i) { - dlerror(); // Clear Errors diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 33b494c083c2..48ce0cf11950 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -33898,9 +33898,7 @@ with pkgs; wprecon = callPackage ../tools/security/wprecon { }; - wraith = callPackage ../applications/networking/irc/wraith { - openssl = openssl_1_0_2; - }; + wraith = callPackage ../applications/networking/irc/wraith { }; wxmupen64plus = callPackage ../misc/emulators/wxmupen64plus { }; From d03a07d5a74ef780b9de78225a7d7d59db8f9169 Mon Sep 17 00:00:00 2001 From: Zhong Jianxin Date: Fri, 27 Aug 2021 16:25:20 +0800 Subject: [PATCH 13/57] fetchgit: Support sparse checkout This allow git checkout small parts of a large repo, and avoid fetching unnecessary blobs from server. --- pkgs/build-support/fetchgit/builder.sh | 1 + pkgs/build-support/fetchgit/default.nix | 3 ++- pkgs/build-support/fetchgit/nix-prefetch-git | 8 +++++++- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/pkgs/build-support/fetchgit/builder.sh b/pkgs/build-support/fetchgit/builder.sh index 0047a335c76c..c7c7d21709a1 100644 --- a/pkgs/build-support/fetchgit/builder.sh +++ b/pkgs/build-support/fetchgit/builder.sh @@ -11,6 +11,7 @@ $SHELL $fetcher --builder --url "$url" --out "$out" --rev "$rev" \ ${fetchLFS:+--fetch-lfs} \ ${deepClone:+--deepClone} \ ${fetchSubmodules:+--fetch-submodules} \ + ${sparseCheckout:+--sparse-checkout "$sparseCheckout"} \ ${branchName:+--branch-name "$branchName"} runHook postFetch diff --git a/pkgs/build-support/fetchgit/default.nix b/pkgs/build-support/fetchgit/default.nix index 3a05008dacb5..1b59668ce4bc 100644 --- a/pkgs/build-support/fetchgit/default.nix +++ b/pkgs/build-support/fetchgit/default.nix @@ -15,6 +15,7 @@ in { url, rev ? "HEAD", md5 ? "", sha256 ? "", hash ? "", leaveDotGit ? deepClone , fetchSubmodules ? true, deepClone ? false , branchName ? null +, sparseCheckout ? "" , name ? urlToName url rev , # Shell code executed after the file has been fetched # successfully. This can do things like check or transform the file. @@ -74,7 +75,7 @@ stdenvNoCC.mkDerivation { else lib.fakeSha256; - inherit url rev leaveDotGit fetchLFS fetchSubmodules deepClone branchName postFetch; + inherit url rev leaveDotGit fetchLFS fetchSubmodules deepClone branchName sparseCheckout postFetch; postHook = if netrcPhase == null then null else '' ${netrcPhase} diff --git a/pkgs/build-support/fetchgit/nix-prefetch-git b/pkgs/build-support/fetchgit/nix-prefetch-git index be5068c7ad31..4e6f25b8dd7d 100755 --- a/pkgs/build-support/fetchgit/nix-prefetch-git +++ b/pkgs/build-support/fetchgit/nix-prefetch-git @@ -48,6 +48,7 @@ Options: --rev ref Any sha1 or references (such as refs/heads/master) --hash h Expected hash. --branch-name Branch name to check out into + --sparse-checkout Only fetch and checkout part of the repository. --deepClone Clone the entire repository. --no-deepClone Make a shallow clone of just the required ref. --leave-dotGit Keep the .git directories. @@ -75,6 +76,7 @@ for arg; do --hash) argfun=set_hashType;; --branch-name) argfun=set_branchName;; --deepClone) deepClone=true;; + --sparse-checkout) argfun=set_sparseCheckout;; --quiet) QUIET=true;; --no-deepClone) deepClone=;; --leave-dotGit) leaveDotGit=true;; @@ -96,7 +98,7 @@ for arg; do case $argfun in set_*) var=${argfun#set_} - eval $var=$arg + eval "$var=$(printf %q "$arg")" ;; esac argfun="" @@ -112,6 +114,10 @@ init_remote(){ local url=$1 clean_git init --initial-branch=master clean_git remote add origin "$url" + if [ -n "$sparseCheckout" ]; then + git config remote.origin.partialclonefilter "blob:none" + echo "$sparseCheckout" | git sparse-checkout set --stdin + fi ( [ -n "$http_proxy" ] && clean_git config http.proxy "$http_proxy" ) || true } From 8c26b2d60f971f3e9f827039913b179c722618f5 Mon Sep 17 00:00:00 2001 From: Zhong Jianxin Date: Wed, 8 Sep 2021 10:33:50 +0800 Subject: [PATCH 14/57] fetchgit: Add document for sparseCheckout --- doc/builders/fetchers.chapter.md | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/doc/builders/fetchers.chapter.md b/doc/builders/fetchers.chapter.md index 5b28b2dcb398..28388ba685d8 100644 --- a/doc/builders/fetchers.chapter.md +++ b/doc/builders/fetchers.chapter.md @@ -40,6 +40,24 @@ Used with Git. Expects `url` to a Git repo, `rev`, and `sha256`. `rev` in this c Additionally the following optional arguments can be given: `fetchSubmodules = true` makes `fetchgit` also fetch the submodules of a repository. If `deepClone` is set to true, the entire repository is cloned as opposing to just creating a shallow clone. `deepClone = true` also implies `leaveDotGit = true` which means that the `.git` directory of the clone won't be removed after checkout. +If only parts of the repository are needed, `sparseCheckout` can be used. This will prevent git from fetching unnecessary blobs from server, see [git sparse-checkout](https://git-scm.com/docs/git-sparse-checkout) and [git clone --filter](https://git-scm.com/docs/git-clone#Documentation/git-clone.txt---filterltfilter-specgt) for more infomation: + +```nix +{ stdenv, fetchgit }: + +stdenv.mkDerivation { + name = "hello"; + src = fetchgit { + url = "https://..."; + sparseCheckout = '' + path/to/be/included + another/path + ''; + sha256 = "0000000000000000000000000000000000000000000000000000"; + }; +} +``` + ## `fetchfossil` {#fetchfossil} Used with Fossil. Expects `url` to a Fossil archive, `rev`, and `sha256`. From 36cc03e1516edc4286e7840297de2ccffe536d35 Mon Sep 17 00:00:00 2001 From: Zhong Jianxin Date: Fri, 8 Oct 2021 00:17:41 +0800 Subject: [PATCH 15/57] fetchgit: Add test for sparseCheckout --- pkgs/build-support/fetchgit/tests.nix | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/pkgs/build-support/fetchgit/tests.nix b/pkgs/build-support/fetchgit/tests.nix index 6805473e2968..c558fb6efa4d 100644 --- a/pkgs/build-support/fetchgit/tests.nix +++ b/pkgs/build-support/fetchgit/tests.nix @@ -7,4 +7,15 @@ rev = "9d9dbe6ed05854e03811c361a3380e09183f4f4a"; sha256 = "sha256-7DszvbCNTjpzGRmpIVAWXk20P0/XTrWZ79KSOGLrUWY="; }; + + sparseCheckout = invalidateFetcherByDrvHash fetchgit { + name = "nix-source"; + url = "https://github.com/NixOS/nix"; + rev = "9d9dbe6ed05854e03811c361a3380e09183f4f4a"; + sparseCheckout = '' + src + tests + ''; + sha256 = "sha256-FknO6C/PSnMPfhUqObD4vsW4PhkwdmPa9blNzcNvJQ4="; + }; } From 57829cc246ef9d5d39cc6a94c92b7c0a17eba60a Mon Sep 17 00:00:00 2001 From: Zhong Jianxin Date: Mon, 24 Jan 2022 11:31:41 +0800 Subject: [PATCH 16/57] fetchgithub: Support sparseCheckout --- pkgs/build-support/fetchgithub/default.nix | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pkgs/build-support/fetchgithub/default.nix b/pkgs/build-support/fetchgithub/default.nix index d40a0478baba..4e4162368b91 100644 --- a/pkgs/build-support/fetchgithub/default.nix +++ b/pkgs/build-support/fetchgithub/default.nix @@ -3,6 +3,7 @@ { owner, repo, rev, name ? "source" , fetchSubmodules ? false, leaveDotGit ? null , deepClone ? false, private ? false, forceFetchGit ? false +, sparseCheckout ? "" , githubBase ? "github.com", varPrefix ? null , ... # For hash agility }@args: @@ -10,7 +11,7 @@ let baseUrl = "https://${githubBase}/${owner}/${repo}"; passthruAttrs = removeAttrs args [ "owner" "repo" "rev" "fetchSubmodules" "forceFetchGit" "private" "githubBase" "varPrefix" ]; varBase = "NIX${if varPrefix == null then "" else "_${varPrefix}"}_GITHUB_PRIVATE_"; - useFetchGit = fetchSubmodules || (leaveDotGit == true) || deepClone || forceFetchGit; + useFetchGit = fetchSubmodules || (leaveDotGit == true) || deepClone || forceFetchGit || (sparseCheckout != ""); # We prefer fetchzip in cases we don't need submodules as the hash # is more stable in that case. fetcher = if useFetchGit then fetchgit else fetchzip; @@ -30,7 +31,7 @@ let }; fetcherArgs = (if useFetchGit then { - inherit rev deepClone fetchSubmodules; url = "${baseUrl}.git"; + inherit rev deepClone fetchSubmodules sparseCheckout; url = "${baseUrl}.git"; } // lib.optionalAttrs (leaveDotGit != null) { inherit leaveDotGit; } else { url = "${baseUrl}/archive/${rev}.tar.gz"; } ) // privateAttrs // passthruAttrs // { inherit name; }; From ba3e91ed43c05a4a0984a6faa948949612fd113c Mon Sep 17 00:00:00 2001 From: Robert Hensing Date: Mon, 24 Jan 2022 01:07:32 +0100 Subject: [PATCH 17/57] lib.types: Add unique like uniq, but custom errors Couldn't extend types.uniq and it had a silly name anyway. Now we can have better error messages. --- lib/default.nix | 5 +++-- lib/options.nix | 6 ++++++ lib/types.nix | 15 ++++++++++++++- 3 files changed, 23 insertions(+), 3 deletions(-) diff --git a/lib/default.nix b/lib/default.nix index 2dfe62e82a8b..268422538803 100644 --- a/lib/default.nix +++ b/lib/default.nix @@ -122,8 +122,9 @@ let mkRenamedOptionModule mkMergedOptionModule mkChangedOptionModule mkAliasOptionModule mkDerivedConfig doRename; inherit (self.options) isOption mkEnableOption mkSinkUndeclaredOptions - mergeDefaultOption mergeOneOption mergeEqualOption getValues - getFiles optionAttrSetToDocList optionAttrSetToDocList' + mergeDefaultOption mergeOneOption mergeEqualOption mergeUniqueOption + getValues getFiles + optionAttrSetToDocList optionAttrSetToDocList' scrubOptionValue literalExpression literalExample literalDocBook showOption showFiles unknownModule mkOption; inherit (self.types) isType setType defaultTypeMerge defaultFunctor diff --git a/lib/options.nix b/lib/options.nix index 53001a3113f9..44ec335545ca 100644 --- a/lib/options.nix +++ b/lib/options.nix @@ -134,6 +134,12 @@ rec { throw "The unique option `${showOption loc}' is defined multiple times. Definition values:${showDefs defs}" else (head defs).value; + mergeUniqueOption = { message }: loc: defs: + if length defs == 1 + then (head defs).value + else assert length defs > 1; + throw "The option `${showOption loc}' is defined multiple times.\n${message}\nDefinition values:${showDefs defs}"; + /* "Merge" option definitions by checking that they all have the same value. */ mergeEqualOption = loc: defs: if defs == [] then abort "This case should never happen." diff --git a/lib/types.nix b/lib/types.nix index cc3ac5fdf6fb..f2f9b2bca985 100644 --- a/lib/types.nix +++ b/lib/types.nix @@ -32,7 +32,6 @@ let last length tail - unique ; inherit (lib.attrsets) attrNames @@ -48,6 +47,7 @@ let mergeDefaultOption mergeEqualOption mergeOneOption + mergeUniqueOption showFiles showOption ; @@ -470,6 +470,18 @@ rec { nestedTypes.elemType = elemType; }; + unique = { message }: type: mkOptionType rec { + name = "unique"; + inherit (type) description check; + merge = mergeUniqueOption { inherit message; }; + emptyValue = type.emptyValue; + getSubOptions = type.getSubOptions; + getSubModules = type.getSubModules; + substSubModules = m: uniq (type.substSubModules m); + functor = (defaultFunctor name) // { wrapped = type; }; + nestedTypes.elemType = type; + }; + # Null or value of ... nullOr = elemType: mkOptionType rec { name = "nullOr"; @@ -599,6 +611,7 @@ rec { # A value from a set of allowed ones. enum = values: let + inherit (lib.lists) unique; show = v: if builtins.isString v then ''"${v}"'' else if builtins.isInt v then builtins.toString v From 2aa7c25808847847bc40be93b57a1e6174aeda09 Mon Sep 17 00:00:00 2001 From: Robert Hensing Date: Thu, 20 Jan 2022 15:05:45 +0100 Subject: [PATCH 18/57] nixos: Document system.build.toplevel --- nixos/modules/system/activation/top-level.nix | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/nixos/modules/system/activation/top-level.nix b/nixos/modules/system/activation/top-level.nix index e10d668ad2cf..da8ff8ef145b 100644 --- a/nixos/modules/system/activation/top-level.nix +++ b/nixos/modules/system/activation/top-level.nix @@ -135,6 +135,16 @@ let pkgs.replaceDependency { inherit oldDependency newDependency drv; } ) baseSystemAssertWarn config.system.replaceRuntimeDependencies; + /* Workaround until https://github.com/NixOS/nixpkgs/pull/156533 + Call can be replaced by argument when that's merged. + */ + tmpFixupSubmoduleBoundary = subopts: + lib.mkOption { + type = lib.types.submoduleWith { + modules = [ { options = subopts; } ]; + }; + }; + in { @@ -216,6 +226,19 @@ in ''; }; + system.build = tmpFixupSubmoduleBoundary { + toplevel = mkOption { + type = types.package; + readOnly = true; + description = '' + This option contains the store path that typically represents a NixOS system. + + You can read this path in a custom deployment tool for example. + ''; + }; + }; + + system.copySystemConfiguration = mkOption { type = types.bool; default = false; From 511e89f5a66c77c378d30853e5e0ac6995e0013e Mon Sep 17 00:00:00 2001 From: Robert Hensing Date: Mon, 24 Jan 2022 12:49:58 +0100 Subject: [PATCH 19/57] nixos: Make system.build.installBootLoader a proper option This improves the error message when the configuration contains more than one boot loader. --- nixos/modules/system/activation/top-level.nix | 21 ++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/nixos/modules/system/activation/top-level.nix b/nixos/modules/system/activation/top-level.nix index da8ff8ef145b..b1e0274cff10 100644 --- a/nixos/modules/system/activation/top-level.nix +++ b/nixos/modules/system/activation/top-level.nix @@ -109,9 +109,7 @@ let utillinux = pkgs.util-linux; kernelParams = config.boot.kernelParams; - installBootLoader = - config.system.build.installBootLoader - or "echo 'Warning: do not know how to make this configuration bootable; please enable a boot loader.' 1>&2; true"; + installBootLoader = config.system.build.installBootLoader; activationScript = config.system.activationScripts.script; dryActivationScript = config.system.dryActivationScript; nixosLabel = config.system.nixos.label; @@ -227,6 +225,23 @@ in }; system.build = tmpFixupSubmoduleBoundary { + installBootLoader = mkOption { + internal = true; + default = "echo 'Warning: do not know how to make this configuration bootable; please enable a boot loader.' 1>&2; true"; + description = '' + A program that writes a bootloader installation script to the path passed in the first command line argument. + + See nixos/modules/system/activation/switch-to-configuration.pl. + ''; + type = types.unique { + message = '' + Only one bootloader can be enabled at a time. This requirement has not + been checked until NixOS 22.05. Earlier versions defaulted to the last + definition. Change your configuration to enable only one bootloader. + ''; + } (types.either types.str types.package); + }; + toplevel = mkOption { type = types.package; readOnly = true; From 4800f308413d03c39be5311ff63a218177af32df Mon Sep 17 00:00:00 2001 From: Robert Hensing Date: Mon, 24 Jan 2022 15:09:17 +0100 Subject: [PATCH 20/57] nixos: Explain system.build.installBootLoader's odd default I don't really approve of this solution, but documenting its purpose was the least I could do for now. --- nixos/modules/system/activation/top-level.nix | 3 +++ 1 file changed, 3 insertions(+) diff --git a/nixos/modules/system/activation/top-level.nix b/nixos/modules/system/activation/top-level.nix index b1e0274cff10..c9fef33c9403 100644 --- a/nixos/modules/system/activation/top-level.nix +++ b/nixos/modules/system/activation/top-level.nix @@ -227,6 +227,9 @@ in system.build = tmpFixupSubmoduleBoundary { installBootLoader = mkOption { internal = true; + # "; true" => make the `$out` argument from switch-to-configuration.pl + # go to `true` instead of `echo`, hiding the useless path + # from the log. default = "echo 'Warning: do not know how to make this configuration bootable; please enable a boot loader.' 1>&2; true"; description = '' A program that writes a bootloader installation script to the path passed in the first command line argument. From 8691ab3d47f1f9f94b51357fba7b8133cc8bcd88 Mon Sep 17 00:00:00 2001 From: Robert Hensing Date: Mon, 24 Jan 2022 16:23:18 +0100 Subject: [PATCH 21/57] lib.modules: Define mergeOneOption in terms of mergeUniqueOption --- lib/options.nix | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/lib/options.nix b/lib/options.nix index 44ec335545ca..ffe4b2651661 100644 --- a/lib/options.nix +++ b/lib/options.nix @@ -128,11 +128,7 @@ rec { else if all isInt list && all (x: x == head list) list then head list else throw "Cannot merge definitions of `${showOption loc}'. Definition values:${showDefs defs}"; - mergeOneOption = loc: defs: - if defs == [] then abort "This case should never happen." - else if length defs != 1 then - throw "The unique option `${showOption loc}' is defined multiple times. Definition values:${showDefs defs}" - else (head defs).value; + mergeOneOption = mergeUniqueOption { message = ""; }; mergeUniqueOption = { message }: loc: defs: if length defs == 1 From 48dbe26229124114f26cfe0eec32866a47888452 Mon Sep 17 00:00:00 2001 From: Robert Hensing Date: Mon, 24 Jan 2022 16:27:41 +0100 Subject: [PATCH 22/57] nixos/doc: Document types.unique --- .../manual/development/option-types.section.md | 6 ++++++ .../from_md/development/option-types.section.xml | 16 ++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/nixos/doc/manual/development/option-types.section.md b/nixos/doc/manual/development/option-types.section.md index ed557206659f..56ffa8e9d79c 100644 --- a/nixos/doc/manual/development/option-types.section.md +++ b/nixos/doc/manual/development/option-types.section.md @@ -250,6 +250,12 @@ Composed types are types that take a type as parameter. `listOf : Ensures that type *`t`* cannot be merged. It is used to ensure option definitions are declared only once. +`types.unique` `{ message = m }` *`t`* + +: Ensures that type *`t`* cannot be merged. Prints the message *`m`*, after + the line `The option