mirror of
https://github.com/ilyakooo0/nixpkgs.git
synced 2024-09-11 15:26:03 +03:00
snapTools: remove
`snapTools.makeSnap` has produced broken snaps since at least Oct 2020, as indicated by the following issue: https://github.com/NixOS/nixpkgs/issues/100618 No person has shown interest in maintaining it, and given that there is no fix available, it's assumed that all attempts made to fix that function have not succeeded. Given that `snapTools` only contained `makeSnap`, it was removed completely.
This commit is contained in:
parent
f7fca9d98b
commit
1d85557b50
@ -6,7 +6,6 @@ This chapter describes tools for creating various types of images.
|
||||
images/appimagetools.section.md
|
||||
images/dockertools.section.md
|
||||
images/ocitools.section.md
|
||||
images/snaptools.section.md
|
||||
images/portableservice.section.md
|
||||
images/makediskimage.section.md
|
||||
images/binarycache.section.md
|
||||
|
@ -1,71 +0,0 @@
|
||||
# pkgs.snapTools {#sec-pkgs-snapTools}
|
||||
|
||||
`pkgs.snapTools` is a set of functions for creating Snapcraft images. Snap and Snapcraft is not used to perform these operations.
|
||||
|
||||
## The makeSnap Function {#ssec-pkgs-snapTools-makeSnap-signature}
|
||||
|
||||
`makeSnap` takes a single named argument, `meta`. This argument mirrors [the upstream `snap.yaml` format](https://docs.snapcraft.io/snap-format) exactly.
|
||||
|
||||
The `base` should not be specified, as `makeSnap` will force set it.
|
||||
|
||||
Currently, `makeSnap` does not support creating GUI stubs.
|
||||
|
||||
## Build a Hello World Snap {#ssec-pkgs-snapTools-build-a-snap-hello}
|
||||
|
||||
The following expression packages GNU Hello as a Snapcraft snap.
|
||||
|
||||
``` {#ex-snapTools-buildSnap-hello .nix}
|
||||
let
|
||||
inherit (import <nixpkgs> { }) snapTools hello;
|
||||
in snapTools.makeSnap {
|
||||
meta = {
|
||||
name = "hello";
|
||||
summary = hello.meta.description;
|
||||
description = hello.meta.longDescription;
|
||||
architectures = [ "amd64" ];
|
||||
confinement = "strict";
|
||||
apps.hello.command = "${hello}/bin/hello";
|
||||
};
|
||||
}
|
||||
```
|
||||
|
||||
`nix-build` this expression and install it with `snap install ./result --dangerous`. `hello` will now be the Snapcraft version of the package.
|
||||
|
||||
## Build a Graphical Snap {#ssec-pkgs-snapTools-build-a-snap-firefox}
|
||||
|
||||
Graphical programs require many more integrations with the host. This example uses Firefox as an example because it is one of the most complicated programs we could package.
|
||||
|
||||
``` {#ex-snapTools-buildSnap-firefox .nix}
|
||||
let
|
||||
inherit (import <nixpkgs> { }) snapTools firefox;
|
||||
in snapTools.makeSnap {
|
||||
meta = {
|
||||
name = "nix-example-firefox";
|
||||
summary = firefox.meta.description;
|
||||
architectures = [ "amd64" ];
|
||||
apps.nix-example-firefox = {
|
||||
command = "${firefox}/bin/firefox";
|
||||
plugs = [
|
||||
"pulseaudio"
|
||||
"camera"
|
||||
"browser-support"
|
||||
"avahi-observe"
|
||||
"cups-control"
|
||||
"desktop"
|
||||
"desktop-legacy"
|
||||
"gsettings"
|
||||
"home"
|
||||
"network"
|
||||
"mount-observe"
|
||||
"removable-media"
|
||||
"x11"
|
||||
];
|
||||
};
|
||||
confinement = "strict";
|
||||
};
|
||||
}
|
||||
```
|
||||
|
||||
`nix-build` this expression and install it with `snap install ./result --dangerous`. `nix-example-firefox` will now be the Snapcraft version of the Firefox package.
|
||||
|
||||
The specific meaning behind plugs can be looked up in the [Snapcraft interface documentation](https://docs.snapcraft.io/supported-interfaces).
|
@ -1,4 +0,0 @@
|
||||
{ callPackage, hello }:
|
||||
{
|
||||
makeSnap = callPackage ./make-snap.nix { };
|
||||
}
|
@ -1,84 +0,0 @@
|
||||
{
|
||||
runCommand, squashfsTools, closureInfo, lib, jq, writeText
|
||||
}:
|
||||
|
||||
{
|
||||
# The meta parameter is the contents of the `snap.yaml`, NOT the
|
||||
# `snapcraft.yaml`.
|
||||
#
|
||||
# - `snap.yaml` is what is inside of the final Snap,
|
||||
# - `snapcraft.yaml` is used by `snapcraft` to build snaps
|
||||
#
|
||||
# Since we skip the `snapcraft` tool, we skip the `snapcraft.yaml`
|
||||
# file. For more information:
|
||||
#
|
||||
# https://docs.snapcraft.io/snap-format
|
||||
#
|
||||
# Note: unsquashfs'ing an existing snap from the store can be helpful
|
||||
# for determining what you you're missing.
|
||||
#
|
||||
meta
|
||||
}: let
|
||||
snap_yaml = let
|
||||
# Validate the snap's meta contains a name.
|
||||
# Also: automatically set the `base` parameter and the layout for
|
||||
# the `/nix` bind.
|
||||
validate = { name, ... } @ args:
|
||||
args // {
|
||||
# Combine the provided arguments with the required options.
|
||||
|
||||
# base: built from https://github.com/NixOS/snapd-nix-base
|
||||
# and published as The NixOS Foundation on the Snapcraft store.
|
||||
base = "nix-base";
|
||||
layout = (args.layout or {}) // {
|
||||
# Bind mount the Snap's root nix directory to `/nix` in the
|
||||
# execution environment's filesystem namespace.
|
||||
"/nix".bind = "$SNAP/nix";
|
||||
};
|
||||
};
|
||||
in writeText "snap.yaml"
|
||||
(builtins.toJSON (validate meta));
|
||||
|
||||
# These are specifically required by snapd, so don't change them
|
||||
# unless you've verified snapcraft / snapd can handle them. Best bet
|
||||
# is to just mirror this list against how snapcraft creates images.
|
||||
# from: https://github.com/snapcore/snapcraft/blob/b88e378148134383ffecf3658e3a940b67c9bcc9/snapcraft/internal/lifecycle/_packer.py#L96-L98
|
||||
mksquashfs_args = [
|
||||
"-noappend" "-comp" "xz" "-no-xattrs" "-no-fragments"
|
||||
|
||||
# Note: We want -all-root every time, since all the files are
|
||||
# owned by root anyway. This is true for Nix, but not true for
|
||||
# other builds.
|
||||
# from: https://github.com/snapcore/snapcraft/blob/b88e378148134383ffecf3658e3a940b67c9bcc9/snapcraft/internal/lifecycle/_packer.py#L100
|
||||
"-all-root"
|
||||
];
|
||||
|
||||
in runCommand "squashfs.img" {
|
||||
nativeBuildInputs = [ squashfsTools jq ];
|
||||
|
||||
closureInfo = closureInfo {
|
||||
rootPaths = [ snap_yaml ];
|
||||
};
|
||||
} ''
|
||||
root=$PWD/root
|
||||
mkdir $root
|
||||
|
||||
(
|
||||
# Put the snap.yaml in to `/meta/snap.yaml`, setting the version
|
||||
# to the hash part of the store path
|
||||
mkdir $root/meta
|
||||
version=$(echo $out | cut -d/ -f4 | cut -d- -f1)
|
||||
cat ${snap_yaml} | jq ". + { version: \"$version\" }" \
|
||||
> $root/meta/snap.yaml
|
||||
)
|
||||
|
||||
(
|
||||
# Copy the store closure in to the root
|
||||
mkdir -p $root/nix/store
|
||||
cat $closureInfo/store-paths | xargs -I{} cp -r {} $root/nix/store/
|
||||
)
|
||||
|
||||
# Generate the squashfs image.
|
||||
mksquashfs $root $out \
|
||||
${lib.concatStringsSep " " mksquashfs_args}
|
||||
''
|
@ -889,7 +889,7 @@ with pkgs;
|
||||
|
||||
tarsum = callPackage ../build-support/docker/tarsum.nix { };
|
||||
|
||||
snapTools = callPackage ../build-support/snap { };
|
||||
snapTools = throw "snapTools was removed because makeSnap produced broken snaps and it was the only function in snapTools. See https://github.com/NixOS/nixpkgs/issues/100618 for more details."; # 2024-03-04;
|
||||
|
||||
nix-prefetch-docker = callPackage ../build-support/docker/nix-prefetch-docker.nix { };
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user