Skip to content
This repository was archived by the owner on Feb 27, 2024. It is now read-only.
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: NixOS/snapd-nix-base
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 9752b978472c
Choose a base ref
...
head repository: NixOS/snapd-nix-base
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: d3bb24b30fb0
Choose a head ref
  • 1 commit
  • 4 files changed
  • 1 contributor

Commits on Jun 18, 2019

  1. Initial base image build code

    grahamc committed Jun 18, 2019
    Copy the full SHA
    d3bb24b View commit details
Showing with 82 additions and 0 deletions.
  1. +12 −0 README.md
  2. +8 −0 default.nix
  3. +7 −0 publish.sh
  4. +55 −0 snap.nix
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
Have a Snapcraft-capable machine

Hint: NixOS doesn't have Snapcraft at the time of publishing.

Then:

1. `snapcraft login`
2. `./publish.sh`

However, good news, you will probably never need to do this since the
base image has almost nothing in it but the minimum necessary
directories plus `/nix`.
8 changes: 8 additions & 0 deletions default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
let
nixpkgs = builtins.fetchTarball {
url = "https://github.com/NixOS/nixpkgs/archive/e6d320ec0ceefa56f9e711e389a6f39cdc985634.tar.gz";
sha256 = "1zzp6h0mnz7qkhvzrgrlmlp6ljwnkn5k942gldkmajhcbs6jddhb";
};

pkgs = import nixpkgs { system = "x86_64-linux"; };
in pkgs.callPackage ./snap.nix { }
7 changes: 7 additions & 0 deletions publish.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/sh

set -eux

resultpath=$(nix-build .)
snapcraft push --release=stable \
"$resultpath/nix-base_*_all.snap"
55 changes: 55 additions & 0 deletions snap.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
{
lib, runCommand, squashfsTools, closureInfo, jq
}:
let
meta = {
name = "nix-base";
type = "base";
confinement = "strict";
architectures = [ "all" ] ;
license = "CC0-1.0";
};

# from: https://github.com/snapcore/snapcraft/blob/b88e378148134383ffecf3658e3a940b67c9bcc9/snapcraft/internal/lifecycle/_packer.py#L96-L98
# These options need to match the review tools:
# http://bazaar.launchpad.net/~click-reviewers/click-reviewers-tools/trunk/view/head:/clickreviews/common.py#L38
mksquashfs_args = [
"-noappend" "-comp" "xz" "-no-xattrs" "-no-fragments"

# https://github.com/snapcore/snapcraft/blob/b88e378148134383ffecf3658e3a940b67c9bcc9/snapcraft/internal/lifecycle/_packer.py#L100
"-all-root"
];
in runCommand "nix-base" {
nativeBuildInputs = [ squashfsTools jq ];

snapMeta = builtins.toJSON meta;
passAsFile = [ "snapMeta" ];
}
''
root=$PWD/root
mkdir $root
version=$(echo $out | cut -d/ -f4 | cut -d- -f1)
(
mkdir $root/meta
cat $snapMetaPath | jq ". + { version: \"$version\" }" \
> $root/meta/snap.yaml
)
(
cd $root
mkdir --mode 755 -p meta sys tmp usr/lib/snapd usr/src \
bin nix snap etc root run dev home proc var/lib/snapd \
var/tmp var/snap var/log media \
usr/share/fonts usr/local/share/fonts \
var/cache/fontconfig
)
# Generate the squashfs image.
mksquashfs $root ./nix-base_''${version}_all.snap \
${lib.concatStringsSep " " mksquashfs_args}
mkdir $out
mv ./nix-base_*_all.snap $out/
''