-
Notifications
You must be signed in to change notification settings - Fork 33
Expand file tree
/
Copy pathmodule-filesToExclude.nix
More file actions
102 lines (86 loc) · 2.43 KB
/
module-filesToExclude.nix
File metadata and controls
102 lines (86 loc) · 2.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
{
pkgs,
self,
}:
let
# Create a dummy package with multiple binaries and other files
multiAppPackage =
(pkgs.runCommand "multi-app" { } ''
mkdir -p $out/bin
mkdir -p $out/share/applications
# Create multiple executables
cat > $out/bin/main-app <<'EOF'
#!/bin/sh
echo "Main app"
EOF
chmod +x $out/bin/main-app
cat > $out/bin/helper-tool <<'EOF'
#!/bin/sh
echo "Helper tool"
EOF
chmod +x $out/bin/helper-tool
cat > $out/bin/legacy-app <<'EOF'
#!/bin/sh
echo "Legacy app"
EOF
chmod +x $out/bin/legacy-app
# Create desktop files
cat > $out/share/applications/main-app.desktop <<EOF
[Desktop Entry]
Name=Main App
Exec=main-app
Type=Application
EOF
cat > $out/share/applications/helper.desktop <<EOF
[Desktop Entry]
Name=Helper
Exec=helper-tool
Type=Application
EOF
'')
// {
meta.mainProgram = "main-app";
};
# Test module interface usage
testModule = self.lib.wrapModule {
package = multiAppPackage;
filesToExclude = [
"bin/helper-tool"
"bin/legacy-app"
"share/applications/helper.desktop"
];
};
wrappedPackage = testModule.apply { inherit pkgs; };
in
pkgs.runCommand "module-filesToExclude-test" { } ''
echo "Testing filesToExclude in module interface..."
# Check that excluded files are NOT present
if [ -f "${wrappedPackage}/bin/helper-tool" ]; then
echo "FAIL: bin/helper-tool should be excluded but is present"
exit 1
fi
if [ -f "${wrappedPackage}/bin/legacy-app" ]; then
echo "FAIL: bin/legacy-app should be excluded but is present"
exit 1
fi
if [ -f "${wrappedPackage}/share/applications/helper.desktop" ]; then
echo "FAIL: share/applications/helper.desktop should be excluded but is present"
exit 1
fi
# Check that non-excluded files ARE present
if [ ! -f "${wrappedPackage}/bin/main-app" ]; then
echo "FAIL: bin/main-app should be present but is missing"
exit 1
fi
if [ ! -f "${wrappedPackage}/share/applications/main-app.desktop" ]; then
echo "FAIL: share/applications/main-app.desktop should be present but is missing"
exit 1
fi
# Verify the binary still works
if ! "${wrappedPackage}/bin/main-app" > /dev/null; then
echo "FAIL: main-app is not executable"
exit 1
fi
echo "SUCCESS: module filesToExclude test passed"
touch $out
''