Loading lib/generators.nix +21 −3 Original line number Diff line number Diff line Loading @@ -434,6 +434,7 @@ ${expr "" v} Configuration: * multiline - by default is true which results in indented block-like view. * indent - initial indent. * asBindings - by default generate single value, but with this use attrset to set global vars. Attention: Regardless of multiline parameter there is no trailing newline. Loading Loading @@ -464,18 +465,35 @@ ${expr "" v} /* If this option is true, the output is indented with newlines for attribute sets and lists */ multiline ? true, /* Initial indentation level */ indent ? "" indent ? "", /* Interpret as variable bindings */ asBindings ? false, }@args: v: with builtins; let innerIndent = "${indent} "; introSpace = if multiline then "\n${innerIndent}" else " "; outroSpace = if multiline then "\n${indent}" else " "; innerArgs = args // { indent = innerIndent; }; innerArgs = args // { indent = if asBindings then indent else innerIndent; asBindings = false; }; concatItems = concatStringsSep ",${introSpace}"; isLuaInline = { _type ? null, ... }: _type == "lua-inline"; generatedBindings = assert lib.assertMsg (badVarNames == []) "Bad Lua var names: ${toPretty {} badVarNames}"; libStr.concatStrings ( lib.attrsets.mapAttrsToList (key: value: "${indent}${key} = ${toLua innerArgs value}\n") v ); # https://en.wikibooks.org/wiki/Lua_Programming/variable#Variable_names matchVarName = match "[[:alpha:]_][[:alnum:]_]*(\\.[[:alpha:]_][[:alnum:]_]*)*"; badVarNames = filter (name: matchVarName name == null) (attrNames v); in if v == null then if asBindings then generatedBindings else if v == null then "nil" else if isInt v || isFloat v || isString v || isBool v then builtins.toJSON v Loading lib/tests/misc.nix +40 −0 Original line number Diff line number Diff line Loading @@ -4,6 +4,11 @@ with import ../default.nix; let testingThrow = expr: { expr = (builtins.tryEval (builtins.seq expr "didn't throw")); expected = { success = false; value = false; }; }; testingDeepThrow = expr: testingThrow (builtins.deepSeq expr expr); testSanitizeDerivationName = { name, expected }: let Loading Loading @@ -962,6 +967,41 @@ runTests { expected = ''{ 41, 43 }''; }; testToLuaEmptyBindings = { expr = generators.toLua { asBindings = true; } {}; expected = ""; }; testToLuaBindings = { expr = generators.toLua { asBindings = true; } { x1 = 41; _y = { a = 43; }; }; expected = '' _y = { ["a"] = 43 } x1 = 41 ''; }; testToLuaPartialTableBindings = { expr = generators.toLua { asBindings = true; } { "x.y" = 42; }; expected = '' x.y = 42 ''; }; testToLuaIndentedBindings = { expr = generators.toLua { asBindings = true; indent = " "; } { x = { y = 42; }; }; expected = " x = {\n [\"y\"] = 42\n }\n"; }; testToLuaBindingsWithSpace = testingThrow ( generators.toLua { asBindings = true; } { "with space" = 42; } ); testToLuaBindingsWithLeadingDigit = testingThrow ( generators.toLua { asBindings = true; } { "11eleven" = 42; } ); testToLuaBasicExample = { expr = generators.toLua {} { cmd = [ "typescript-language-server" "--stdio" ]; Loading nixos/modules/services/monitoring/datadog-agent.nix +1 −1 Original line number Diff line number Diff line Loading @@ -235,7 +235,7 @@ in { systemd.services = let makeService = attrs: recursiveUpdate { path = [ datadogPkg pkgs.python pkgs.sysstat pkgs.procps pkgs.iproute2 ]; path = [ datadogPkg pkgs.sysstat pkgs.procps pkgs.iproute2 ]; wantedBy = [ "multi-user.target" ]; serviceConfig = { User = "datadog"; Loading pkgs/applications/editors/gnome-builder/default.nix +2 −2 Original line number Diff line number Diff line Loading @@ -41,13 +41,13 @@ stdenv.mkDerivation rec { pname = "gnome-builder"; version = "44.1"; version = "44.2"; outputs = [ "out" "devdoc" ]; src = fetchurl { url = "mirror://gnome/sources/${pname}/${lib.versions.major version}/${pname}-${version}.tar.xz"; sha256 = "+Tmn+VtLbh0EvY20vpygtnsqp2W4bGP03yP9s6ftzz4="; sha256 = "z6aJx40/AiMcp0cVV99MZIKASio08nHDXRqWLX8XKbA="; }; patches = [ Loading pkgs/applications/graphics/veusz/default.nix +11 −12 Original line number Diff line number Diff line Loading @@ -6,14 +6,18 @@ python3Packages.buildPythonApplication rec { pname = "veusz"; version = "3.3.1"; version = "3.6.2"; src = python3Packages.fetchPypi { inherit pname version; sha256 = "4ClgYwiU21wHDve2q9cItSAVb9hbR2F+fJc8znGI8OA="; sha256 = "whcaxF5LMEJNj8NSYeLpnb5uJboRl+vCQ1WxBrJjldE="; }; nativeBuildInputs = [ wrapQtAppsHook python3Packages.sip_4 ]; nativeBuildInputs = [ wrapQtAppsHook python3Packages.sip python3Packages.tomli ]; buildInputs = [ qtbase ]; Loading @@ -24,22 +28,17 @@ python3Packages.buildPythonApplication rec { wrapQtApp "$out/bin/veusz" ''; # Since sip 6 (we use sip 4 here, but pyqt5 is built with sip 6), sip files are # placed in a different directory layout and --sip-dir won't work anymore. # --sip-dir expects a directory with a PyQt5 subdirectory (where sip files are located), # but the new directory layout places sip files in a subdirectory named 'bindings'. # To workaround this, we patch the full path into pyqtdistutils.py. # pyqt_setuptools.py uses the platlib path from sysconfig, but NixOS doesn't # really have a corresponding path, so patching the location of PyQt5 inplace postPatch = '' substituteInPlace pyqtdistutils.py \ --replace "'-I', pyqt5_include_dir," "'-I', '${python3Packages.pyqt5}/${python3Packages.python.sitePackages}/PyQt5/bindings'," substituteInPlace pyqt_setuptools.py \ --replace "get_path('platlib')" "'${python3Packages.pyqt5}/${python3Packages.python.sitePackages}'" patchShebangs tests/runselftest.py ''; # you can find these options at # https://github.com/veusz/veusz/blob/53b99dffa999f2bc41fdc5335d7797ae857c761f/pyqtdistutils.py#L71 # --sip-dir cannot be used here for the reasons explained above setupPyBuildFlags = [ "--qt-include-dir=${qtbase.dev}/include" # veusz tries to find a libinfix and fails without one # but we simply don't need a libinfix, so set it to empty here "--qt-libinfix=" Loading Loading
lib/generators.nix +21 −3 Original line number Diff line number Diff line Loading @@ -434,6 +434,7 @@ ${expr "" v} Configuration: * multiline - by default is true which results in indented block-like view. * indent - initial indent. * asBindings - by default generate single value, but with this use attrset to set global vars. Attention: Regardless of multiline parameter there is no trailing newline. Loading Loading @@ -464,18 +465,35 @@ ${expr "" v} /* If this option is true, the output is indented with newlines for attribute sets and lists */ multiline ? true, /* Initial indentation level */ indent ? "" indent ? "", /* Interpret as variable bindings */ asBindings ? false, }@args: v: with builtins; let innerIndent = "${indent} "; introSpace = if multiline then "\n${innerIndent}" else " "; outroSpace = if multiline then "\n${indent}" else " "; innerArgs = args // { indent = innerIndent; }; innerArgs = args // { indent = if asBindings then indent else innerIndent; asBindings = false; }; concatItems = concatStringsSep ",${introSpace}"; isLuaInline = { _type ? null, ... }: _type == "lua-inline"; generatedBindings = assert lib.assertMsg (badVarNames == []) "Bad Lua var names: ${toPretty {} badVarNames}"; libStr.concatStrings ( lib.attrsets.mapAttrsToList (key: value: "${indent}${key} = ${toLua innerArgs value}\n") v ); # https://en.wikibooks.org/wiki/Lua_Programming/variable#Variable_names matchVarName = match "[[:alpha:]_][[:alnum:]_]*(\\.[[:alpha:]_][[:alnum:]_]*)*"; badVarNames = filter (name: matchVarName name == null) (attrNames v); in if v == null then if asBindings then generatedBindings else if v == null then "nil" else if isInt v || isFloat v || isString v || isBool v then builtins.toJSON v Loading
lib/tests/misc.nix +40 −0 Original line number Diff line number Diff line Loading @@ -4,6 +4,11 @@ with import ../default.nix; let testingThrow = expr: { expr = (builtins.tryEval (builtins.seq expr "didn't throw")); expected = { success = false; value = false; }; }; testingDeepThrow = expr: testingThrow (builtins.deepSeq expr expr); testSanitizeDerivationName = { name, expected }: let Loading Loading @@ -962,6 +967,41 @@ runTests { expected = ''{ 41, 43 }''; }; testToLuaEmptyBindings = { expr = generators.toLua { asBindings = true; } {}; expected = ""; }; testToLuaBindings = { expr = generators.toLua { asBindings = true; } { x1 = 41; _y = { a = 43; }; }; expected = '' _y = { ["a"] = 43 } x1 = 41 ''; }; testToLuaPartialTableBindings = { expr = generators.toLua { asBindings = true; } { "x.y" = 42; }; expected = '' x.y = 42 ''; }; testToLuaIndentedBindings = { expr = generators.toLua { asBindings = true; indent = " "; } { x = { y = 42; }; }; expected = " x = {\n [\"y\"] = 42\n }\n"; }; testToLuaBindingsWithSpace = testingThrow ( generators.toLua { asBindings = true; } { "with space" = 42; } ); testToLuaBindingsWithLeadingDigit = testingThrow ( generators.toLua { asBindings = true; } { "11eleven" = 42; } ); testToLuaBasicExample = { expr = generators.toLua {} { cmd = [ "typescript-language-server" "--stdio" ]; Loading
nixos/modules/services/monitoring/datadog-agent.nix +1 −1 Original line number Diff line number Diff line Loading @@ -235,7 +235,7 @@ in { systemd.services = let makeService = attrs: recursiveUpdate { path = [ datadogPkg pkgs.python pkgs.sysstat pkgs.procps pkgs.iproute2 ]; path = [ datadogPkg pkgs.sysstat pkgs.procps pkgs.iproute2 ]; wantedBy = [ "multi-user.target" ]; serviceConfig = { User = "datadog"; Loading
pkgs/applications/editors/gnome-builder/default.nix +2 −2 Original line number Diff line number Diff line Loading @@ -41,13 +41,13 @@ stdenv.mkDerivation rec { pname = "gnome-builder"; version = "44.1"; version = "44.2"; outputs = [ "out" "devdoc" ]; src = fetchurl { url = "mirror://gnome/sources/${pname}/${lib.versions.major version}/${pname}-${version}.tar.xz"; sha256 = "+Tmn+VtLbh0EvY20vpygtnsqp2W4bGP03yP9s6ftzz4="; sha256 = "z6aJx40/AiMcp0cVV99MZIKASio08nHDXRqWLX8XKbA="; }; patches = [ Loading
pkgs/applications/graphics/veusz/default.nix +11 −12 Original line number Diff line number Diff line Loading @@ -6,14 +6,18 @@ python3Packages.buildPythonApplication rec { pname = "veusz"; version = "3.3.1"; version = "3.6.2"; src = python3Packages.fetchPypi { inherit pname version; sha256 = "4ClgYwiU21wHDve2q9cItSAVb9hbR2F+fJc8znGI8OA="; sha256 = "whcaxF5LMEJNj8NSYeLpnb5uJboRl+vCQ1WxBrJjldE="; }; nativeBuildInputs = [ wrapQtAppsHook python3Packages.sip_4 ]; nativeBuildInputs = [ wrapQtAppsHook python3Packages.sip python3Packages.tomli ]; buildInputs = [ qtbase ]; Loading @@ -24,22 +28,17 @@ python3Packages.buildPythonApplication rec { wrapQtApp "$out/bin/veusz" ''; # Since sip 6 (we use sip 4 here, but pyqt5 is built with sip 6), sip files are # placed in a different directory layout and --sip-dir won't work anymore. # --sip-dir expects a directory with a PyQt5 subdirectory (where sip files are located), # but the new directory layout places sip files in a subdirectory named 'bindings'. # To workaround this, we patch the full path into pyqtdistutils.py. # pyqt_setuptools.py uses the platlib path from sysconfig, but NixOS doesn't # really have a corresponding path, so patching the location of PyQt5 inplace postPatch = '' substituteInPlace pyqtdistutils.py \ --replace "'-I', pyqt5_include_dir," "'-I', '${python3Packages.pyqt5}/${python3Packages.python.sitePackages}/PyQt5/bindings'," substituteInPlace pyqt_setuptools.py \ --replace "get_path('platlib')" "'${python3Packages.pyqt5}/${python3Packages.python.sitePackages}'" patchShebangs tests/runselftest.py ''; # you can find these options at # https://github.com/veusz/veusz/blob/53b99dffa999f2bc41fdc5335d7797ae857c761f/pyqtdistutils.py#L71 # --sip-dir cannot be used here for the reasons explained above setupPyBuildFlags = [ "--qt-include-dir=${qtbase.dev}/include" # veusz tries to find a libinfix and fails without one # but we simply don't need a libinfix, so set it to empty here "--qt-libinfix=" Loading