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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
|
{
fetchFromGitHub,
git,
glibc,
lib,
makeWrapper,
nix-update-script,
python3,
squashfsTools,
stdenv,
}:
let
python = python3.override {
packageOverrides = self: super: {
pydantic-yaml = super.pydantic-yaml.overridePythonAttrs (old: rec {
version = "0.11.2";
src = fetchFromGitHub {
owner = "NowanIlfideme";
repo = "pydantic-yaml";
rev = "refs/tags/v${version}";
hash = "sha256-AeUyVav0/k4Fz69Qizn4hcJKoi/CDR9eUan/nJhWsDY=";
};
dependencies = with self; [
deprecated
importlib-metadata
pydantic_1
ruamel-yaml
types-deprecated
];
});
};
};
in
python.pkgs.buildPythonApplication rec {
pname = "snapcraft";
version = "8.3.1";
pyproject = true;
src = fetchFromGitHub {
owner = "canonical";
repo = "snapcraft";
rev = "refs/tags/${version}";
hash = "sha256-cdRlUY9hAJ8US93aiJymzsV27JVPY7lWCK7IUdjDmYE=";
};
patches = [
# Snapcraft is only officially distributed as a snap, as is LXD. The socket
# path for LXD must be adjusted so that it's at the correct location for LXD
# on NixOS. This patch will likely never be accepted upstream.
./lxd-socket-path.patch
# In certain places, Snapcraft expects an /etc/os-release file to determine
# host info which doesn't exist in our test environment. This is a
# relatively naive patch which helps the test suite pass - without it *many*
# of the tests fail. This patch will likely never be accepted upstream.
./os-platform.patch
# Snapcraft will try to inject itself as a snap *from the host system* into
# the build system. This patch short-circuits that logic and ensures that
# Snapcraft is installed on the build system from the snap store - because
# there is no snapd on NixOS hosts that can be used for the injection. This
# patch will likely never be accepted upstream.
./set-channel-for-nix.patch
# Certain paths (for extensions, schemas) are packaged in the snap by the
# upstream, so the paths are well-known, except here where Snapcraft is
# *not* in a snap, so this patch changes those paths to point to the correct
# place in the Nix store. This patch will likely never be accepted upstream.
./snapcraft-data-dirs.patch
];
postPatch = ''
substituteInPlace setup.py \
--replace-fail 'version=determine_version()' 'version="${version}"' \
--replace-fail 'gnupg' 'python-gnupg'
substituteInPlace requirements.txt \
--replace-fail 'gnupg==2.3.1' 'python-gnupg'
substituteInPlace snapcraft/__init__.py \
--replace-fail '__version__ = _get_version()' '__version__ = "${version}"'
substituteInPlace snapcraft_legacy/__init__.py \
--replace-fail '__version__ = _get_version()' '__version__ = "${version}"'
substituteInPlace snapcraft/elf/elf_utils.py \
--replace-fail 'arch_linker_path = Path(arch_config.dynamic_linker)' \
'return str(Path("${glibc}/lib/ld-linux-x86-64.so.2"))'
substituteInPlace pyproject.toml \
--replace-fail '"pytest-cov>=4.0",' "" \
--replace-fail "--cov=snapcraft" ""
'';
nativeBuildInputs = [ makeWrapper ];
dependencies = with python.pkgs; [
attrs
catkin-pkg
click
craft-application
craft-archives
craft-cli
craft-grammar
craft-parts
craft-providers
craft-store
debian
docutils
jsonschema
launchpadlib
lazr-restfulclient
lxml
macaroonbakery
mypy-extensions
overrides
packaging
progressbar
pyelftools
pygit2
pylxd
pymacaroons
python-apt
python-gnupg
pyxdg
pyyaml
raven
requests-toolbelt
requests-unixsocket
simplejson
snap-helpers
tabulate
toml
tinydb
typing-extensions
urllib3
validators
];
build-system = with python.pkgs; [ setuptools ];
pythonRelaxDeps = [
"docutils"
"jsonschema"
"pygit2"
"urllib3"
"validators"
];
postInstall = ''
wrapProgram $out/bin/snapcraft --prefix PATH : ${squashfsTools}/bin
'';
nativeCheckInputs =
with python.pkgs;
[
pytest-check
pytest-mock
pytest-subprocess
pytestCheckHook
responses
setuptools
]
++ [
git
squashfsTools
];
preCheck = ''
mkdir -p check-phase
export HOME="$(pwd)/check-phase"
'';
pytestFlagsArray = [ "tests/unit" ];
disabledTests = [
"test_bin_echo"
"test_classic_linter_filter"
"test_classic_linter"
"test_complex_snap_yaml"
"test_core24_try_command"
"test_get_base_configuration_snap_channel"
"test_get_base_configuration_snap_instance_name_default"
"test_get_base_configuration_snap_instance_name_not_running_as_snap"
"test_get_extensions_data_dir"
"test_get_os_platform_alternative_formats"
"test_get_os_platform_linux"
"test_get_os_platform_windows"
"test_lifecycle_pack_components_with_output"
"test_lifecycle_pack_components"
"test_lifecycle_write_component_metadata"
"test_parse_info_integrated"
"test_patch_elf"
"test_remote_builder_init"
"test_setup_assets_remote_icon"
"test_snap_command_fallback"
"test_validate_architectures_supported"
"test_validate_architectures_unsupported"
] ++ lib.optionals stdenv.isAarch64 [ "test_load_project" ];
disabledTestPaths = [
"tests/unit/commands/test_remote.py"
"tests/unit/elf"
"tests/unit/linters/test_classic_linter.py"
"tests/unit/linters/test_library_linter.py"
"tests/unit/parts/test_parts.py"
"tests/unit/services"
];
passthru.updateScript = nix-update-script { };
meta = {
mainProgram = "snapcraft";
description = "Build and publish Snap packages";
homepage = "https://github.com/canonical/snapcraft";
changelog = "https://github.com/canonical/snapcraft/releases/tag/${version}";
license = lib.licenses.gpl3Only;
maintainers = with lib.maintainers; [ jnsgruk ];
platforms = lib.platforms.linux;
};
}
|