Initial static builds for HBS2

Use `nix build .#static` to start building
This commit is contained in:
Andrei Borzenkov 2024-10-03 14:16:05 +04:00
parent 4a8f734584
commit be86429c4b
No known key found for this signature in database
4 changed files with 173 additions and 120 deletions

View File

@ -85,12 +85,15 @@
} }
}, },
"flake-utils": { "flake-utils": {
"inputs": {
"systems": "systems"
},
"locked": { "locked": {
"lastModified": 1644229661, "lastModified": 1726560853,
"narHash": "sha256-1YdnJAsNy69bpcjuoKdOYQX0YxZBiCYZo4Twxerqv7k=", "narHash": "sha256-X6rJYSESBVr3hBoH0WbKE5KvhPU5bloyZ2L4K60/fPQ=",
"owner": "numtide", "owner": "numtide",
"repo": "flake-utils", "repo": "flake-utils",
"rev": "3cecb5b042f7f209c56ffd8371b2711a290ec797", "rev": "c1dfcf08411b08f6b8615f7d8971a2bfa81d5e8a",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -154,7 +157,9 @@
}, },
"haskell-flake-utils": { "haskell-flake-utils": {
"inputs": { "inputs": {
"flake-utils": "flake-utils" "flake-utils": [
"flake-utils"
]
}, },
"locked": { "locked": {
"lastModified": 1707809372, "lastModified": 1707809372,
@ -291,6 +296,7 @@
"inputs": { "inputs": {
"bytestring-mmap": "bytestring-mmap", "bytestring-mmap": "bytestring-mmap",
"db-pipe": "db-pipe", "db-pipe": "db-pipe",
"flake-utils": "flake-utils",
"fuzzy": "fuzzy", "fuzzy": "fuzzy",
"haskell-flake-utils": "haskell-flake-utils", "haskell-flake-utils": "haskell-flake-utils",
"hspup": "hspup", "hspup": "hspup",
@ -365,6 +371,21 @@
"type": "git", "type": "git",
"url": "https://git.hbs2.net/JAuk1UJzZfbDGKVazSQU5yYQ3NGfk4gVeZzBCduf5TgQ" "url": "https://git.hbs2.net/JAuk1UJzZfbDGKVazSQU5yYQ3NGfk4gVeZzBCduf5TgQ"
} }
},
"systems": {
"locked": {
"lastModified": 1681028828,
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
"owner": "nix-systems",
"repo": "default",
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
"type": "github"
},
"original": {
"owner": "nix-systems",
"repo": "default",
"type": "github"
}
} }
}, },
"root": "root", "root": "root",

146
flake.nix
View File

@ -5,7 +5,11 @@ inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable"; nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
# haskell-flake-utils.url = "github:ivanovs-4/haskell-flake-utils"; # haskell-flake-utils.url = "github:ivanovs-4/haskell-flake-utils";
haskell-flake-utils.url = "github:ivanovs-4/haskell-flake-utils/master"; flake-utils.url = "github:numtide/flake-utils";
haskell-flake-utils = { # we don't use haskell-flake-utils directly, but we override input evrywhere
url = "github:ivanovs-4/haskell-flake-utils/master";
inputs.flake-utils.follows = "flake-utils";
};
hspup.url = "github:voidlizard/hspup"; hspup.url = "github:voidlizard/hspup";
hspup.inputs.nixpkgs.follows = "nixpkgs"; hspup.inputs.nixpkgs.follows = "nixpkgs";
hspup.inputs.haskell-flake-utils.follows = "haskell-flake-utils"; hspup.inputs.haskell-flake-utils.follows = "haskell-flake-utils";
@ -41,9 +45,21 @@ inputs = {
}; };
outputs = { self, nixpkgs, haskell-flake-utils, ... }@inputs: outputs = { self, nixpkgs, flake-utils, ... }@inputs:
flake-utils.lib.eachSystem ["x86_64-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin"]
(system:
let let
packageNames = [ packageNames =
topLevelPackages ++ keymanPackages;
keymanPackages =
[
"hbs2-keyman"
"hbs2-keyman-direct-lib"
];
topLevelPackages =
[
"hbs2" "hbs2"
"hbs2-peer" "hbs2-peer"
"hbs2-core" "hbs2-core"
@ -51,65 +67,26 @@ outputs = { self, nixpkgs, haskell-flake-utils, ... }@inputs:
"hbs2-git" "hbs2-git"
"hbs2-git-dashboard" "hbs2-git-dashboard"
"hbs2-qblf" "hbs2-qblf"
"hbs2-keyman"
"hbs2-keyman-direct-lib"
"hbs2-fixer" "hbs2-fixer"
"hbs2-cli" "hbs2-cli"
"hbs2-sync" "hbs2-sync"
"fixme-new" "fixme-new"
]; ];
in
haskell-flake-utils.lib.simpleCabalProject2flake {
inherit self nixpkgs;
systems = [ "x86_64-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin" ];
name = "hbs2";
haskellFlakes = with inputs; [ pkgs = import nixpkgs {
suckless-conf inherit system;
db-pipe overlays = [defaultOverlay];
];
inherit packageNames;
packageDirs = {
"hbs2" = "./hbs2";
"hbs2-tests" = "./hbs2-tests";
"hbs2-core" = "./hbs2-core";
"hbs2-storage-simple" = "./hbs2-storage-simple";
"hbs2-peer" = "./hbs2-peer";
"hbs2-keyman" = "./hbs2-keyman/hbs2-keyman";
"hbs2-keyman-direct-lib" = "./hbs2-keyman/hbs2-keyman-direct-lib";
"hbs2-git" = "./hbs2-git";
"hbs2-git-dashboard" = "./hbs2-git-dashboard";
"hbs2-fixer" = "./hbs2-fixer";
"hbs2-cli" = "./hbs2-cli";
"hbs2-sync" = "./hbs2-sync";
"fixme-new" = "./fixme-new";
}; };
hpPreOverrides = {pkgs, ...}: final: prev: ((with pkgs; { defaultOverlay = final: prev:
saltine = prev.callCabal2nix "saltine" inputs.saltine { inherit (pkgs) libsodium; }; (prev.lib.composeManyExtensions
scotty = final.callHackage "scotty" "0.21" { }; [
bytestring-mmap = prev.callCabal2nix "bytestring-mmap" inputs.bytestring-mmap {}; overlay
skylighting-lucid = final.callHackage "skylighting-lucid" "1.0.4" { }; inputs.suckless-conf.overlays.default
# wai-app-file-cgi = final.callHackage "wai-app-file-cgi" "3.1.11" { }; inputs.db-pipe.overlays.default
# htags = final.callHackage "htags" "1.0.1" { }; ]) final prev;
}) //
(with haskell-flake-utils.lib;
with pkgs.haskell.lib;
let
donts = [
(jailbreakUnbreak pkgs)
# dontBenchmark
dontCoverage
dontCheck
];
in tunePackages pkgs prev {
wai-app-file-cgi = donts;
}
));
packagePostOverrides = { pkgs }: with pkgs; with haskell.lib; [ packagePostOverrides = pkg: with pkgs.haskell.lib.compose; pkgs.lib.pipe pkg [
disableExecutableProfiling disableExecutableProfiling
disableLibraryProfiling disableLibraryProfiling
dontBenchmark dontBenchmark
@ -123,20 +100,68 @@ outputs = { self, nixpkgs, haskell-flake-utils, ... }@inputs:
dontCheck dontCheck
(compose.overrideCabal (drv: { (overrideCabal (drv: {
preBuild = '' preBuild = ''
export GIT_HASH="${self.rev or self.dirtyRev or "dirty"}" export GIT_HASH="${self.rev or self.dirtyRev or "dirty"}"
''; '';
})) }))
]; ];
shell = {pkgs, ...}:
pkgs.haskellPackages.shellFor { jailbreakUnbreak = pkg:
pkgs.haskell.lib.doJailbreak (pkg.overrideAttrs (_: { meta = { }; }));
overlay = final: prev: let pkgs = prev; in
{
haskellPackages = pkgs.haskellPackages.override {
overrides = new: old: with pkgs.haskell.lib;
{
scotty = new.callHackage "scotty" "0.21" { };
bytestring-mmap = jailbreakUnbreak old.bytestring-mmap; # old.callCabal2nix "bytestring-mmap" inputs.bytestring-mmap {};
skylighting-lucid = new.callHackage "skylighting-lucid" "1.0.4" { };
wai-app-file-cgi = dontCoverage (dontCheck (jailbreakUnbreak old.wai-app-file-cgi));
saltine = old.callCabal2nix "saltine" inputs.saltine { inherit (pkgs) libsodium; };
}
// pkgs.lib.genAttrs topLevelPackages (name:
old.callCabal2nix name "${self}/${name}" {})
// pkgs.lib.genAttrs keymanPackages (name:
old.callCabal2nix name "${self}/hbs2-keyman/${name}" {});
};
};
makePackages = pkgs:
pkgs.lib.mapAttrs
(_name: packagePostOverrides) # we can't apply overrides inside our overlay because it will remove linking info
(pkgs.lib.getAttrs packageNames pkgs.haskellPackages);
# dynamic packages don't work at the moment, because
# ivanovs-4/bytestring-mmap doesn't compile with ghc 9.4
# and bytestring-mmap doesn't compire with ghc > 9.6
packagesDynamic = makePackages pkgs;
packagesStatic = makePackages pkgs.pkgsStatic;
in {
legacyPackages = pkgs;
packages =
packagesDynamic //
{
default =
pkgs.symlinkJoin {
name = "hbs2-all";
paths = builtins.attrValues packagesDynamic;
};
static =
pkgs.symlinkJoin {
name = "hbs2-static";
paths = builtins.attrValues packagesStatic;
};
};
devShell.default = pkgs.haskellPackages.shellFor {
packages = _: pkgs.lib.attrsets.attrVals packageNames pkgs.haskellPackages; packages = _: pkgs.lib.attrsets.attrVals packageNames pkgs.haskellPackages;
# withHoogle = true; # withHoogle = true;
buildInputs = ( buildInputs = (
with pkgs.haskellPackages; ([ with pkgs.haskellPackages; [
ghcid ghcid
cabal-install cabal-install
haskell-language-server haskell-language-server
@ -147,7 +172,7 @@ outputs = { self, nixpkgs, haskell-flake-utils, ... }@inputs:
pkgs.icu72 pkgs.icu72
pkgs.openssl pkgs.openssl
weeder weeder
]) ]
++ ++
[ pkgs.pkg-config [ pkgs.pkg-config
inputs.hspup.packages.${pkgs.system}.default inputs.hspup.packages.${pkgs.system}.default
@ -159,6 +184,7 @@ outputs = { self, nixpkgs, haskell-flake-utils, ... }@inputs:
''; '';
}; };
}; }
);
} }

View File

@ -1,4 +1,5 @@
{-# OPTIONS_GHC -fno-warn-orphans #-} {-# OPTIONS_GHC -fno-warn-orphans #-}
{-# LANGUAGE CPP #-}
module HBS2.Git.Web.Html.Fixme where module HBS2.Git.Web.Html.Fixme where
import HBS2.Git.DashBoard.Prelude import HBS2.Git.DashBoard.Prelude
@ -20,6 +21,10 @@ import Data.List qualified as List
import Web.Scotty.Trans as Scotty import Web.Scotty.Trans as Scotty
#if __GLASGOW_HASKELL__ < 906
import Control.Applicative -- add liftA2 into scope
#endif
instance ToHtml (H FixmeKey) where instance ToHtml (H FixmeKey) where
toHtmlRaw (H k) = toHtmlRaw $ take 10 $ show $ pretty k toHtmlRaw (H k) = toHtmlRaw $ take 10 $ show $ pretty k
toHtml (H k) = toHtml $ take 10 $ show $ pretty k toHtml (H k) = toHtml $ take 10 $ show $ pretty k
@ -93,5 +98,3 @@ repoFixme q@(FromParams p') lww = do
, hxSwap_ "afterend" , hxSwap_ "afterend"
] do ] do
td_ [colspan_ "3"] mempty td_ [colspan_ "3"] mempty

View File

@ -1,3 +1,5 @@
{-# LANGUAGE CPP #-}
module HBS2.Git.Web.Html.Issue (issuePage) where module HBS2.Git.Web.Html.Issue (issuePage) where
@ -20,6 +22,9 @@ import Data.Text qualified as Text
import Lucid.Base import Lucid.Base
import Lucid.Html5 hiding (for_) import Lucid.Html5 hiding (for_)
#if __GLASGOW_HASKELL__ < 906
import Control.Applicative -- add liftA2 into scope
#endif
data IssueOptionalArg w t = IssueOptionalArg w t data IssueOptionalArg w t = IssueOptionalArg w t
@ -146,5 +151,3 @@ issuePage repo@(RepoLww lww) f = rootPage do
where where
trim before seize txt = trim before seize txt =
Text.lines txt & drop before & take seize & Text.unlines Text.lines txt & drop before & take seize & Text.unlines