Skip to content

Commit

Permalink
Make a static zip available for download from the docs site
Browse files Browse the repository at this point in the history
  • Loading branch information
Tom Sydney Kerckhove committed May 14, 2024
1 parent 0339c19 commit ba98acb
Show file tree
Hide file tree
Showing 6 changed files with 85 additions and 23 deletions.
1 change: 1 addition & 0 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@
in
{
release = self.packages.${system}.default;
static = self.packages.${system}.static;
shell = self.devShells.${system}.default;
e2e-test-current-compatibility = mkE2ETest {
name = "current-compatibility";
Expand Down
88 changes: 65 additions & 23 deletions nix/overlay.nix
Original file line number Diff line number Diff line change
Expand Up @@ -25,42 +25,82 @@ in
inherit (final) haskellPackages;
};


smosRelease = final.symlinkJoin {
name = "smos-release";
paths = attrValues final.smosReleasePackages;
passthru = final.smosReleasePackages;
};

smosClientZipped = final.runCommand "release.zip" { } ''
cd ${final.smosClientRelease}
${final.zip}/bin/zip $out -r .
'';

smosClientRelease = final.symlinkJoin {
name = "smos-client-release";
paths = attrValues final.smosClientPackages;
};

# Must not have the docs site
# Should not have test suite executables
smosClientPackages = builtins.removeAttrs final.smosReleasePackages [
"smos-server-gen"
"smos-docs-site"
];

smosReleasePackages =
let
enableStatic = pkg:
if final.stdenv.hostPlatform.isMusl
then
overrideCabal pkg
(old: {
configureFlags = (old.configureFlags or [ ]) ++ [
"--ghc-option=-optl=-static"
# Static
"--extra-lib-dirs=${final.gmp6.override { withStatic = true; }}/lib"
"--extra-lib-dirs=${final.zlib.static}/lib"
"--extra-lib-dirs=${final.libffi.overrideAttrs (old: { dontDisableStatic = true; })}/lib"
# for -ltinfo
"--extra-lib-dirs=${(final.ncurses.override { enableStatic = true; })}/lib"
];
enableSharedExecutables = false;
enableSharedLibraries = false;
(old:
let
# Until https://github.com/NixOS/nixpkgs/pull/311411
terminfoDirs = final.lib.concatStringsSep ":" [
"/etc/terminfo" # Debian, Fedora, Gentoo
"/lib/terminfo" # Debian
"/usr/share/terminfo" # upstream default, probably all FHS-based distros
"/run/current-system/sw/share/terminfo" # NixOS
];
staticNcurses = (
(final.ncurses.override {
enableStatic = true;
})
).overrideAttrs
(old: {
configureFlags = (old.configureFlags or [ ]) ++ [
"--with-terminfo-dirs=${terminfoDirs}"
];
});
in
{
configureFlags = (old.configureFlags or [ ]) ++ [
"--ghc-option=-optl=-static"
# Static
"--extra-lib-dirs=${final.gmp6.override { withStatic = true;
}}/lib"
"--extra-lib-dirs=${final.zlib.static}/lib"
"--extra-lib-dirs=${final.libffi.overrideAttrs (old: { dontDisableStatic = true;
})}/lib"
# for -ltinfo
"--extra-lib-dirs=${staticNcurses}/lib"
];
enableSharedExecutables = false;
enableSharedLibraries = false;

postInstall = (old.postInstall or "") + ''
for b in $out/bin/*
do
if ldd "$b"
then
echo "ldd succeeded on $b, which may mean that it is not statically linked"
exit 1
fi
done
'';
})
postInstall = (old.postInstall or "") + ''
for b in $out/bin/*
do
if ldd "$b"
then
echo "ldd succeeded on $b, which may mean that it is not statically linked"
exit 1
fi
done
'';
})
else pkg;

in
Expand Down Expand Up @@ -252,6 +292,8 @@ in
export SMOS_DOCS_NIXOS_MODULE_DOCS="${final.nixosModuleDocs}/share/doc/nixos/options.json"
export SMOS_DOCS_HOME_MANAGER_MODULE_DOCS="${final.homeManagerModuleDocs}/share/doc/nixos/options.json"
export SMOS_DOCS_DEPENDENCY_GRAPH="${final.smosDependencyGraph}/smos-dependency-graph.svg"
ln -s ${final.smosClientZipped} content/assets/smos-release.zip
'';
});
smos-docs-site = withLinksChecked "smos-docs-site" (
Expand Down
14 changes: 14 additions & 0 deletions smos-docs-site/content/pages/installation/download.markdown
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
title: Downloading the latest release
description: Documentation about installing Smos using downloaded statically-linked binaries
---

You can download the latest smos release here:

<a class="button" href=/assets/smos-release.zip>
Download Release
</a>
</br>
</br>

This zip file contains statically linked executables that you can download and run on (almost) any `x86_64-linux` machine.
1 change: 1 addition & 0 deletions smos-docs-site/content/unreleased.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
* Fixed that casts weren't showing up on the docs site.
* Fixed that booking would show an error when a quote was used in the organiser name.
* Fixed that `READY` timestamps with a later-than-now `AFTER` timestamp would still show up in the work report.
* Made the latest release zip available on the docs site.
1 change: 1 addition & 0 deletions smos-docs-site/smos-docs-site.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ extra-source-files:
content/pages/directories.markdown
content/pages/features.markdown
content/pages/file-browser.markdown
content/pages/installation/download.markdown
content/pages/installation/nix.markdown
content/pages/installation/nixos.markdown
content/pages/installation/stack.markdown
Expand Down
3 changes: 3 additions & 0 deletions smos-docs-site/templates/menu.hamlet
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@
<a href=@{PageR ["building-installation"]}>
Building/Installation
<ul>
<li>
<a href=@{PageR ["installation", "download"]}>
Download Release
<li>
<a href=@{PageR ["installation", "stack"]}>
Building with Stack
Expand Down

0 comments on commit ba98acb

Please sign in to comment.