Re-add haskell.nix toolchain
Adds support for Windows cross-compilation.
It needs to built and uploaded as follows:
nix-build site/h.nix -A win-bundle
scp result/site-bundle.zip ogion.cz:/var/www/ogion.cz/temp/site-tojnar.zip
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@@ -7,3 +7,5 @@ public
|
||||
.stack-work
|
||||
thumb/
|
||||
thumbs.db
|
||||
|
||||
_generator/
|
||||
|
||||
141
00-site.ps1
Normal file
141
00-site.ps1
Normal file
@@ -0,0 +1,141 @@
|
||||
#!/usr/bin/env pwsh
|
||||
|
||||
$Env:PATH = "$PSScriptRoot\_generator\site;$PSScriptRoot\_generator\vips;$PSScriptRoot\_generator\rsync;$Env:PATH"
|
||||
|
||||
# Check if ConsoleGuiTools are available.
|
||||
$cgt = Get-Module -ListAvailable Microsoft.PowerShell.ConsoleGuiTools
|
||||
if ($cgt -eq $null) {
|
||||
Write-Output 'Missing ConsoleGuiTools, please make sure you have PowerShell 7 and run the following command as an administrator:'
|
||||
Write-Output ' Install-Module Microsoft.PowerShell.ConsoleGuiTools'
|
||||
Read-Host
|
||||
Exit 1
|
||||
}
|
||||
|
||||
function FetchGenerator {
|
||||
$tempFile = New-TemporaryFile
|
||||
$url = 'https://temp.ogion.cz/site-tojnar.zip'
|
||||
Invoke-WebRequest -Uri $url -OutFile $tempFile
|
||||
Expand-Archive $tempFile -DestinationPath '_generator' -Force
|
||||
}
|
||||
|
||||
function EnsureGenerator {
|
||||
if (!(Test-Path '_generator/site/site.exe')) {
|
||||
FetchGenerator
|
||||
}
|
||||
}
|
||||
|
||||
function SiteWatch {
|
||||
EnsureGenerator
|
||||
site watch
|
||||
}
|
||||
|
||||
function SiteCheck {
|
||||
EnsureGenerator
|
||||
site check
|
||||
Read-Host
|
||||
}
|
||||
|
||||
function SiteDeploy {
|
||||
EnsureGenerator
|
||||
site deploy
|
||||
Read-Host
|
||||
}
|
||||
|
||||
function SiteBuild {
|
||||
EnsureGenerator
|
||||
site build
|
||||
Read-Host
|
||||
}
|
||||
|
||||
function SiteRebuild {
|
||||
EnsureGenerator
|
||||
site rebuild
|
||||
Read-Host
|
||||
}
|
||||
|
||||
function UpdateGenerator {
|
||||
FetchGenerator
|
||||
Read-Host
|
||||
}
|
||||
|
||||
function Terminate {
|
||||
[Terminal.Gui.Application]::RequestStop()
|
||||
}
|
||||
|
||||
$action = $null
|
||||
|
||||
function MakeUi {
|
||||
Import-Module Microsoft.PowerShell.ConsoleGuiTools
|
||||
$module = (Get-Module Microsoft.PowerShell.ConsoleGuiTools -List).ModuleBase
|
||||
Add-Type -Path (Join-path $module Terminal.Gui.dll)
|
||||
|
||||
[Terminal.Gui.Application]::Init()
|
||||
$window = [Terminal.Gui.Window]::new()
|
||||
$window.Title = 'site: tojnar.cz'
|
||||
[Terminal.Gui.Application]::Top.Add($window)
|
||||
|
||||
$watchButton = [Terminal.Gui.Button]::new()
|
||||
$watchButton.Text = 'watch: Start test server and watch for changes'
|
||||
$watchButton.add_Clicked({
|
||||
$script:action = $function:SiteWatch
|
||||
Terminate
|
||||
})
|
||||
$window.Add($watchButton)
|
||||
|
||||
$checkButton = [Terminal.Gui.Button]::new()
|
||||
$checkButton.Text = 'check: Check links'
|
||||
$checkButton.add_Clicked({
|
||||
$script:action = $function:SiteCheck
|
||||
Terminate
|
||||
})
|
||||
$checkButton.Y = [Terminal.Gui.Pos]::Bottom($watchButton)
|
||||
$window.Add($checkButton)
|
||||
|
||||
$deployButton = [Terminal.Gui.Button]::new()
|
||||
$deployButton.Text = 'deploy: Upload changes to web server'
|
||||
$deployButton.add_Clicked({
|
||||
$script:action = $function:SiteDeploy
|
||||
Terminate
|
||||
})
|
||||
$deployButton.Y = [Terminal.Gui.Pos]::Bottom($checkButton) + 1
|
||||
$window.Add($deployButton)
|
||||
|
||||
$buildButton = [Terminal.Gui.Button]::new()
|
||||
$buildButton.Text = 'build: Update output directory'
|
||||
$buildButton.add_Clicked({
|
||||
$script:action = $function:SiteBuild
|
||||
Terminate
|
||||
})
|
||||
$buildButton.Y = [Terminal.Gui.Pos]::Bottom($deployButton) + 1
|
||||
$window.Add($buildButton)
|
||||
|
||||
$rebuildButton = [Terminal.Gui.Button]::new()
|
||||
$rebuildButton.Text = 'rebuild: Rebuild site from scratch'
|
||||
$rebuildButton.add_Clicked({
|
||||
$result = [Terminal.Gui.MessageBox]::Query('Rebuild', "Do you want to rebuild the web site output from scratch?`nIt can take a minute", @('Yes', 'No'))
|
||||
if ($result -eq 0) {
|
||||
$script:action = $function:SiteRebuild
|
||||
Terminate
|
||||
}
|
||||
})
|
||||
$rebuildButton.Y = [Terminal.Gui.Pos]::Bottom($buildButton)
|
||||
$window.Add($rebuildButton)
|
||||
|
||||
$updateButton = [Terminal.Gui.Button]::new()
|
||||
$updateButton.Text = 'Update the site program'
|
||||
$updateButton.add_Clicked({
|
||||
$script:action = $function:UpdateGenerator
|
||||
Terminate
|
||||
})
|
||||
$updateButton.Y = [Terminal.Gui.Pos]::Bottom($rebuildButton) + 1
|
||||
$window.Add($updateButton)
|
||||
|
||||
[Terminal.Gui.Application]::Run()
|
||||
[Terminal.Gui.Application]::Shutdown()
|
||||
}
|
||||
|
||||
MakeUi
|
||||
|
||||
if ($action -ne $null) {
|
||||
& $action
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
packages: site
|
||||
@@ -12,6 +12,21 @@
|
||||
"url": "https://gitlab.com/api/v4/projects/tojnar.cz%2Fhakyll-contrib-tojnar/repository/archive.tar.gz?sha=v0.2.2",
|
||||
"hash": "1s9qjwadl0krzvs77d537pbyvr4mkkmjgdl79kc8lgil4y182v3m"
|
||||
},
|
||||
"haskellNix": {
|
||||
"type": "GitRelease",
|
||||
"repository": {
|
||||
"type": "GitHub",
|
||||
"owner": "input-output-hk",
|
||||
"repo": "haskell.nix"
|
||||
},
|
||||
"pre_releases": false,
|
||||
"version_upper_bound": null,
|
||||
"release_prefix": null,
|
||||
"version": "2024.08.04",
|
||||
"revision": "12913adbe6ea1d3045522cc15729e675efaaab98",
|
||||
"url": "https://api.github.com/repos/input-output-hk/haskell.nix/tarball/2024.08.04",
|
||||
"hash": "1qqscxapxx8ipiwa1vdc1zkqf86xz6spvs9c4dp8859ja18vh00d"
|
||||
},
|
||||
"nixpkgs": {
|
||||
"type": "Git",
|
||||
"repository": {
|
||||
|
||||
@@ -27,3 +27,7 @@ The `site` program needs to be run in this directory. It supports the following
|
||||
The project uses [Nix](https://nixos.org) package manager to build the `site` program. Run `nix-shell` to enter a shell containing `site` program for controlling the website.
|
||||
|
||||
If you have [`direnv`](https://direnv.net/) installed, you can instead run `direnv allow` and it will prepare the correct shell environment automatically every time you enter the directory.
|
||||
|
||||
### Windows
|
||||
|
||||
On Windows, you can right click `00-site.ps1` in the Explorer and click the “Run with PowerShell” context menu item. The script will download the `site` program and allow you to control it using a GUI.
|
||||
|
||||
9
site/cabal.project
Normal file
9
site/cabal.project
Normal file
@@ -0,0 +1,9 @@
|
||||
packages: .
|
||||
|
||||
source-repository-package
|
||||
type: git
|
||||
location: https://gitlab.com/tojnar.cz/hakyll-contrib-tojnar
|
||||
tag: master
|
||||
|
||||
package hakyll-contrib-tojnar
|
||||
flags: -gd
|
||||
52
site/h.nix
Normal file
52
site/h.nix
Normal file
@@ -0,0 +1,52 @@
|
||||
let
|
||||
sources = import ../npins;
|
||||
haskellNix = import sources.haskellNix {};
|
||||
|
||||
pkgs = import haskellNix.sources.nixpkgs-unstable haskellNix.nixpkgsArgs;
|
||||
|
||||
vipsVersion = "8.14.1";
|
||||
vips = pkgs.fetchzip {
|
||||
url = "https://github.com/libvips/build-win64-mxe/releases/download/v${vipsVersion}/vips-dev-w64-all-${vipsVersion}.zip";
|
||||
hash = "sha256-yGAoRwyfeMTiDSSOfWJp32N85Z8Jdyw8wrvEvmx7BWM=";
|
||||
};
|
||||
|
||||
unisonVersion = "2.53.5";
|
||||
unison = pkgs.fetchzip {
|
||||
url = "https://github.com/bcpierce00/unison/releases/download/v${unisonVersion}/unison-${unisonVersion}-windows-x86_64.zip";
|
||||
stripRoot = false;
|
||||
hash = "sha256-Y/J7buOKlZ7W15TeOECheGc8kYOzEbOX/d9FfE74obE=";
|
||||
};
|
||||
|
||||
tojnar-cz = pkgs.haskell-nix.project {
|
||||
src = pkgs.haskell-nix.haskellLib.cleanGit {
|
||||
name = "haskell-nix-project";
|
||||
src = ./.;
|
||||
};
|
||||
inputMap = {
|
||||
"https://gitlab.com/tojnar.cz/hakyll-contrib-tojnar/master" = sources.hakyll-contrib-tojnar;
|
||||
};
|
||||
compiler-nix-name = "ghc925";
|
||||
};
|
||||
|
||||
win = tojnar-cz.projectCross.mingwW64.hsPkgs.tojnar-cz.components.exes.site;
|
||||
|
||||
win-bundle = pkgs.runCommand
|
||||
"generator"
|
||||
{
|
||||
nativeBuildInputs = [
|
||||
pkgs.zip
|
||||
];
|
||||
}
|
||||
''
|
||||
mkdir -p "$out"
|
||||
mkdir generator
|
||||
cp -r "${vips}/bin" "vips"
|
||||
cp -r "${win}/bin" "site"
|
||||
cp -r "${unison}/bin" "unison"
|
||||
zip -9 -r -q "$out/site-bundle.zip" vips/ unison/ site/
|
||||
'';
|
||||
in
|
||||
{
|
||||
inherit tojnar-cz win win-bundle;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user