Skip to content

Commit 66944df

Browse files
committed
Merge branches 'sb/add/beancount_payeeverif', 'sb/borgmatic', 'sb/nrfutil' and 'sb/tsduck'
4 parents ac08680 + 0726a88 + 4f7c654 + 86078c5 commit 66944df

8 files changed

Lines changed: 440 additions & 60 deletions

File tree

Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
--- a/tests/unit/test_logger.py
2+
+++ b/tests/unit/test_logger.py
3+
@@ -699,7 +699,7 @@
4+
)
5+
6+
7+
-def test_configure_logging_to_log_file_instead_of_syslog():
8+
+def test_configure_logging_to_log_file_instead_of_syslog(tmp_path):
9+
flexmock(module).should_receive('add_custom_log_levels')
10+
flexmock(module.logging).ANSWER = module.ANSWER
11+
fake_formatter = flexmock()
12+
@@ -716,20 +716,21 @@
13+
)
14+
flexmock(module.os.path).should_receive('exists').never()
15+
flexmock(module.logging.handlers).should_receive('SysLogHandler').never()
16+
- file_handler = logging.handlers.WatchedFileHandler('/tmp/logfile')
17+
+ log_file = str(tmp_path / 'logfile')
18+
+ file_handler = logging.handlers.WatchedFileHandler(log_file)
19+
flexmock(module.logging.handlers).should_receive('WatchedFileHandler').with_args(
20+
- '/tmp/logfile',
21+
+ log_file,
22+
).and_return(file_handler).once()
23+
24+
module.configure_logging(
25+
console_log_level=logging.INFO,
26+
syslog_log_level=logging.DISABLED,
27+
log_file_log_level=logging.DEBUG,
28+
- log_file='/tmp/logfile',
29+
+ log_file=log_file,
30+
)
31+
32+
33+
-def test_configure_logging_to_both_log_file_and_syslog():
34+
+def test_configure_logging_to_both_log_file_and_syslog(tmp_path):
35+
flexmock(module).should_receive('add_custom_log_levels')
36+
flexmock(module.logging).ANSWER = module.ANSWER
37+
fake_formatter = flexmock()
38+
@@ -752,20 +753,21 @@
39+
flexmock(module.logging.handlers).should_receive('SysLogHandler').with_args(
40+
address='/dev/log',
41+
).and_return(syslog_handler).once()
42+
- file_handler = logging.handlers.WatchedFileHandler('/tmp/logfile')
43+
+ log_file = str(tmp_path / 'logfile')
44+
+ file_handler = logging.handlers.WatchedFileHandler(log_file)
45+
flexmock(module.logging.handlers).should_receive('WatchedFileHandler').with_args(
46+
- '/tmp/logfile',
47+
+ log_file,
48+
).and_return(file_handler).once()
49+
50+
module.configure_logging(
51+
console_log_level=logging.INFO,
52+
syslog_log_level=logging.DEBUG,
53+
log_file_log_level=logging.DEBUG,
54+
- log_file='/tmp/logfile',
55+
+ log_file=log_file,
56+
)
57+
58+
59+
-def test_configure_logging_to_log_file_formats_with_custom_log_format():
60+
+def test_configure_logging_to_log_file_formats_with_custom_log_format(tmp_path):
61+
flexmock(module).should_receive('add_custom_log_levels')
62+
flexmock(module.logging).ANSWER = module.ANSWER
63+
flexmock(module).should_receive('Log_prefix_formatter').with_args(
64+
@@ -786,15 +788,16 @@
65+
)
66+
flexmock(module.os.path).should_receive('exists').with_args('/dev/log').and_return(True)
67+
flexmock(module.logging.handlers).should_receive('SysLogHandler').never()
68+
- file_handler = logging.handlers.WatchedFileHandler('/tmp/logfile')
69+
+ log_file = str(tmp_path / 'logfile')
70+
+ file_handler = logging.handlers.WatchedFileHandler(log_file)
71+
flexmock(module.logging.handlers).should_receive('WatchedFileHandler').with_args(
72+
- '/tmp/logfile',
73+
+ log_file,
74+
).and_return(file_handler).once()
75+
76+
module.configure_logging(
77+
console_log_level=logging.INFO,
78+
log_file_log_level=logging.DEBUG,
79+
- log_file='/tmp/logfile',
80+
+ log_file=log_file,
81+
log_file_format='{message}',
82+
)
83+
84+
--- a/tests/integration/config/test_generate.py
85+
+++ b/tests/integration/config/test_generate.py
86+
@@ -315,10 +315,10 @@
87+
module.write_configuration('config.yaml', 'config: yaml')
88+
89+
90+
-def test_write_configuration_with_already_existing_file_and_overwrite_does_not_raise():
91+
+def test_write_configuration_with_already_existing_file_and_overwrite_does_not_raise(tmp_path):
92+
flexmock(os.path).should_receive('exists').and_return(True)
93+
94+
- module.write_configuration('/tmp/config.yaml', 'config: yaml', overwrite=True)
95+
+ module.write_configuration(str(tmp_path / 'config.yaml'), 'config: yaml', overwrite=True)
96+
97+
98+
def test_write_configuration_with_already_existing_directory_does_not_raise():
99+
--- a/tests/integration/config/test_validate.py
100+
+++ b/tests/integration/config/test_validate.py
101+
@@ -222,11 +222,11 @@
102+
assert logs == []
103+
104+
105+
-def test_parse_configuration_raises_for_missing_config_file():
106+
+def test_parse_configuration_raises_for_missing_config_file(tmp_path):
107+
with pytest.raises(FileNotFoundError):
108+
module.parse_configuration(
109+
- '/tmp/config.yaml',
110+
- '/tmp/schema.yaml',
111+
+ str(tmp_path / 'nonexistent' / 'config.yaml'),
112+
+ str(tmp_path / 'nonexistent' / 'schema.yaml'),
113+
arguments={'global': flexmock()},
114+
)
115+

pkgs/by-name/bo/borgmatic/package.nix

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,12 @@ python3Packages.buildPythonApplication rec {
3434
]
3535
++ optional-dependencies.apprise;
3636

37+
patches = [
38+
# Tests write to hardcoded /tmp/ paths; use pytest's tmp_path fixture instead
39+
# to avoid PermissionError when stale files are owned by a different build user.
40+
./fix-hardcoded-tmp-in-tests.patch
41+
];
42+
3743
# - test_borgmatic_version_matches_news_version
3844
# The file NEWS not available on the pypi source, and this test is useless
3945
disabledTests = [

pkgs/by-name/nr/nrfutil/package.nix

Lines changed: 44 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -53,16 +53,18 @@ let
5353
inherit (package) hash;
5454
};
5555

56-
nativeBuildInputs = [
56+
nativeBuildInputs = lib.optionals (!stdenvNoCC.hostPlatform.isDarwin) [
5757
autoPatchelfHook
5858
];
5959

6060
buildInputs = [
61+
libusb1
62+
segger-jlink-headless
63+
]
64+
++ lib.optionals (!stdenvNoCC.hostPlatform.isDarwin) [
6165
xz
6266
zlib
63-
libusb1
6467
gcc.cc.lib
65-
segger-jlink-headless
6668
];
6769

6870
dontConfigure = true;
@@ -82,6 +84,12 @@ let
8284
versionCheckHook
8385
];
8486

87+
# nrfutil tries to write a log file to $HOME/.nrfutil/logs/, which fails in sandbox
88+
versionCheckKeepEnvironment = [ "HOME" ];
89+
preVersionCheck = ''
90+
export HOME=$(mktemp -d)
91+
'';
92+
8593
meta = sharedMeta // {
8694
mainProgram = name;
8795
};
@@ -90,8 +98,8 @@ let
9098
(
9199
[
92100
"nrfutil"
93-
"nrfutil-completion"
94101
]
102+
++ lib.optional (platformSources.packages ? nrfutil-completion) "nrfutil-completion"
95103
++ extensions
96104
);
97105

@@ -114,8 +122,18 @@ symlinkJoin {
114122
''--prefix PATH : "$out/bin"''
115123
''--prefix PATH : "$out"/lib/nrfutil-npm''
116124
''--prefix PATH : "$out"/lib/nrfutil-nrf5sdk-tools''
117-
"--prefix LD_LIBRARY_PATH : ${lib.makeLibraryPath [ libusb1 ]}"
118-
"--set NRF_JLINK_DLL_PATH '${segger-jlink-headless}'/lib/libjlinkarm.so"
125+
(
126+
if stdenvNoCC.hostPlatform.isDarwin then
127+
"--prefix DYLD_LIBRARY_PATH : ${lib.makeLibraryPath [ libusb1 ]}"
128+
else
129+
"--prefix LD_LIBRARY_PATH : ${lib.makeLibraryPath [ libusb1 ]}"
130+
)
131+
(
132+
if stdenvNoCC.hostPlatform.isDarwin then
133+
"--set NRF_JLINK_DLL_PATH '${segger-jlink-headless}'/Applications/SEGGER/JLink/libjlinkarm.dylib"
134+
else
135+
"--set NRF_JLINK_DLL_PATH '${segger-jlink-headless}'/lib/libjlinkarm.so"
136+
)
119137
''--set NRFUTIL_BLE_SNIFFER_SHIM_BIN_ENV "$out"/lib/nrfutil-ble-sniffer/wireshark-shim''
120138
''--set NRFUTIL_BLE_SNIFFER_HCI_SHIM_BIN_ENV "$out"/lib/nrfutil-ble-sniffer/wireshark-hci-shim''
121139
]
@@ -133,15 +151,28 @@ symlinkJoin {
133151
''
134152
wrapProgram "$out"/bin/nrfutil ${wrapProgramArgs}
135153
136-
installShellCompletion --cmd nrfutil \
137-
--bash $(realpath "$out"/share/nrfutil-completion/scripts/bash/setup.bash) \
138-
--zsh $(realpath "$out"/share/nrfutil-completion/scripts/zsh/_nrfutil)
154+
${lib.optionalString (platformSources.packages ? nrfutil-completion) ''
155+
installShellCompletion --cmd nrfutil \
156+
--bash $(realpath "$out"/share/nrfutil-completion/scripts/bash/setup.bash) \
157+
--zsh $(realpath "$out"/share/nrfutil-completion/scripts/zsh/_nrfutil)
158+
''}
139159
'';
140160

141-
passthru = {
142-
updateScript = ./update.sh;
143-
withExtensions = extensions: nrfutil.override { inherit extensions; };
144-
};
161+
passthru =
162+
let
163+
availableExtensions = lib.attrNames (
164+
lib.removeAttrs platformSources.packages [
165+
"nrfutil"
166+
"nrfutil-completion"
167+
]
168+
);
169+
in
170+
{
171+
updateScript = ./update.sh;
172+
allExtensions = availableExtensions;
173+
withExtensions = extensions: nrfutil.override { inherit extensions; };
174+
withAllExtensions = nrfutil.override { extensions = availableExtensions; };
175+
};
145176

146177
meta = sharedMeta // {
147178
mainProgram = "nrfutil";

pkgs/by-name/nr/nrfutil/source.nix

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,57 @@
11
{
2+
aarch64-darwin = {
3+
triplet = "aarch64-apple-darwin";
4+
packages = {
5+
nrfutil = {
6+
version = "8.1.1";
7+
hash = "sha256-uUSviI9sPRA4geccGTEe89uBU4vnPSjP+3Y5RM1oieM=";
8+
};
9+
nrfutil-91 = {
10+
version = "0.5.0";
11+
hash = "sha256-eRYmwolAW/k0nggSDvbQhU3AfOdNlfs7pMDUQBYgWjQ=";
12+
};
13+
nrfutil-ble-sniffer = {
14+
version = "0.16.2";
15+
hash = "sha256-NRdEzjfBV5SSMxzc5LCaSSGTwp5Lyd8G7aI8OKTwlaA=";
16+
};
17+
nrfutil-completion = {
18+
version = "1.5.0";
19+
hash = "sha256-8+HJUSgmGIDPztlLM3BPLQROeurgKMxZ4iPtGQJtkUI=";
20+
};
21+
nrfutil-device = {
22+
version = "2.15.1";
23+
hash = "sha256-goLcorkaAYnHkUd5elLt0irLvDwnqFWUJR0nBkXGEFQ=";
24+
};
25+
nrfutil-mcu-manager = {
26+
version = "0.8.0";
27+
hash = "sha256-1mKoXw5i/++6aUexmLml+S/Qp5KbqO5GXuDbUFJcA+4=";
28+
};
29+
nrfutil-npm = {
30+
version = "0.3.1";
31+
hash = "sha256-tyUQkzCCho6Y5sulwdKGMEazuWxeS2nQid4aOolHbNE=";
32+
};
33+
nrfutil-nrf5sdk-tools = {
34+
version = "1.1.0";
35+
hash = "sha256-TbGmQ8Nu/n4YmikQ8ND7aWCEjWvD53jZqIFcEknKQFo=";
36+
};
37+
nrfutil-sdk-manager = {
38+
version = "1.8.0";
39+
hash = "sha256-sHAwJmtoISbmJmSnl3Am+10/ulIRw5x4aVIFYpBy734=";
40+
};
41+
nrfutil-suit = {
42+
version = "0.9.0";
43+
hash = "sha256-G7/WhtkxQgr1yzFVz+mlx+zwn8cgEepGRQZcJadAkOY=";
44+
};
45+
nrfutil-toolchain-manager = {
46+
version = "0.15.0";
47+
hash = "sha256-lVdvEj5Z2O5QhtRkbOSnVVP5dzJE9S34tMVE1O32sO0=";
48+
};
49+
nrfutil-trace = {
50+
version = "4.0.1";
51+
hash = "sha256-gAqBw/EsLu1JMuq2IRVhYYfDRw8byldFY6MxNfs29Gc=";
52+
};
53+
};
54+
};
255
aarch64-linux = {
356
triplet = "aarch64-unknown-linux-gnu";
457
packages = {
@@ -28,6 +81,59 @@
2881
};
2982
};
3083
};
84+
x86_64-darwin = {
85+
triplet = "x86_64-apple-darwin";
86+
packages = {
87+
nrfutil = {
88+
version = "8.1.1";
89+
hash = "sha256-EShnbgjMDAchKff52cXqoG2v1jurgCkya1QuWUgM6ug=";
90+
};
91+
nrfutil-91 = {
92+
version = "0.5.0";
93+
hash = "sha256-6DPcqusR5da47QqXGAafZJ5p2lN3Pb97ZdHEW9u9ZcU=";
94+
};
95+
nrfutil-ble-sniffer = {
96+
version = "0.16.2";
97+
hash = "sha256-xFSUrEejkAaCKNq7hDXjvOquFOpZlOY2Xg16uEw48zg=";
98+
};
99+
nrfutil-completion = {
100+
version = "1.5.0";
101+
hash = "sha256-sI4U5yz12Sf4dw//r9+uLhlS1objnUd/TmnVYbEBjvI=";
102+
};
103+
nrfutil-device = {
104+
version = "2.15.1";
105+
hash = "sha256-/db36wX0bImlJuSEvUJbYcWH+l9MTlrJ6vi2kc4Ll3g=";
106+
};
107+
nrfutil-mcu-manager = {
108+
version = "0.8.0";
109+
hash = "sha256-lHyFz3CR/N+CEmxpNkLPUyi5AuN1jFqTfsnkbxRYsVg=";
110+
};
111+
nrfutil-npm = {
112+
version = "0.3.1";
113+
hash = "sha256-fhWcNve4GxjiedEJQT3pCYJbNZHVayZQo2QASNXS6j8=";
114+
};
115+
nrfutil-nrf5sdk-tools = {
116+
version = "1.1.0";
117+
hash = "sha256-oJSzVZhxTlovDLUd5TVd3MOdCC9Ow6kIve5gA9kIeFM=";
118+
};
119+
nrfutil-sdk-manager = {
120+
version = "1.8.0";
121+
hash = "sha256-Ub/P0bW/Mfq6ffP0Kj9hYzH7Xi6gVlojx23CPajnZG8=";
122+
};
123+
nrfutil-suit = {
124+
version = "0.9.0";
125+
hash = "sha256-Xfx7gA5lcRV2zMdu5fsYySq07ncQ+FdBqLKyMM163Lg=";
126+
};
127+
nrfutil-toolchain-manager = {
128+
version = "0.15.0";
129+
hash = "sha256-wxlk73Up4jiPPdTyV51eootdgAQtcq9Tq1mUTEhUXVk=";
130+
};
131+
nrfutil-trace = {
132+
version = "4.0.1";
133+
hash = "sha256-/HtbZKFUVV7mGtWuFj6T1ATDghXIP+hsGM0HVCmyRdA=";
134+
};
135+
};
136+
};
31137
x86_64-linux = {
32138
triplet = "x86_64-unknown-linux-gnu";
33139
packages = {

pkgs/by-name/nr/nrfutil/update.sh

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@ declare -A versions
1414
declare -A hashes
1515
declare -a packages
1616

17-
architectures["x86_64-linux"]="x86_64-unknown-linux-gnu"
17+
# same ordering as 'source.nix'
18+
architectures["aarch64-darwin"]="aarch64-apple-darwin"
1819
architectures["aarch64-linux"]="aarch64-unknown-linux-gnu"
19-
# NOTE: segger-jlink is not yet packaged for darwin
20-
# architectures["x86_64-darwin"]="x86_64-apple-darwin"
21-
# architectures["aarch64-darwin"]="aarch64-apple-darwin"
20+
architectures["x86_64-darwin"]="x86_64-apple-darwin"
21+
architectures["x86_64-linux"]="x86_64-unknown-linux-gnu"
2222

2323
packages=(
2424
"nrfutil"
@@ -53,7 +53,7 @@ done
5353

5454
{
5555
printf "{\n"
56-
for a in "${!architectures[@]}"; do
56+
for a in $(printf "%s\n" "${!architectures[@]}" | sort); do
5757
printf " %s = {\n" "$a"
5858
printf " triplet = \"%s\";\n" "${architectures["${a}"]}"
5959
printf " packages = {\n"

0 commit comments

Comments
 (0)