From 98ce54f3109865c4b3fdf721971af1be18961197 Mon Sep 17 00:00:00 2001 From: Jan Tojnar Date: Sun, 14 Jul 2024 18:43:16 +0200 Subject: [PATCH] Switch to npins & abandon haskell.nix Flakes copy the whole gigantic repo to store all the time, quickly eating all the drive capacity. haskell.nix is PITA to use on lower-spec devices. --- .gitignore | 2 - 00-site.ps1 | 126 --- cabal.project | 1 + default.nix | 21 +- flake.lock | 935 ---------------------- flake.nix | 104 --- npins/default.nix | 80 ++ npins/sources.json | 29 + readme.md | 4 - shell.nix | 25 +- site/cabal.project | 9 - site/strom-roku2023-krk-litvinov-cz.cabal | 2 +- site/strom-roku2023-krk-litvinov-cz.nix | 39 + 13 files changed, 177 insertions(+), 1200 deletions(-) delete mode 100644 00-site.ps1 create mode 100644 cabal.project delete mode 100644 flake.lock delete mode 100644 flake.nix create mode 100644 npins/default.nix create mode 100644 npins/sources.json delete mode 100644 site/cabal.project create mode 100644 site/strom-roku2023-krk-litvinov-cz.nix diff --git a/.gitignore b/.gitignore index f2e012a..ebdfc8e 100644 --- a/.gitignore +++ b/.gitignore @@ -7,8 +7,6 @@ cabal.project.local .stack-work/ dist*/ -_generator/ - _cache/ public/ diff --git a/00-site.ps1 b/00-site.ps1 deleted file mode 100644 index 97900c0..0000000 --- a/00-site.ps1 +++ /dev/null @@ -1,126 +0,0 @@ -#!/usr/bin/env pwsh - -$Env:PATH = "$PSScriptRoot\_generator\site;$PSScriptRoot\_generator\vips;$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-zahradka.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 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: strom-roku-2023.krk-litvinov.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) - - $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($checkButton) + 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 -} diff --git a/cabal.project b/cabal.project new file mode 100644 index 0000000..ec159f3 --- /dev/null +++ b/cabal.project @@ -0,0 +1 @@ +packages: site diff --git a/default.nix b/default.nix index 2f2e032..875d586 100644 --- a/default.nix +++ b/default.nix @@ -1,14 +1,17 @@ -# SPDX-FileCopyrightText: 2022 Jan Tojnar +# SPDX-FileCopyrightText: 2024 Jan Tojnar # SPDX-License-Identifier: MIT let - lock = builtins.fromJSON (builtins.readFile ./flake.lock); - flake-compat = builtins.fetchTarball { - url = "https://github.com/edolstra/flake-compat/archive/${lock.nodes.flake-compat.locked.rev}.tar.gz"; - sha256 = lock.nodes.flake-compat.locked.narHash; - }; - flake = import flake-compat { - src = ./.; + sources = import ./npins; + pkgs = import sources.nixpkgs { }; + + haskellPackages = pkgs.haskellPackages.override { + overrides = final: prev: { + hakyll-contrib-tojnar = + final.callPackage "${sources.hakyll-contrib-tojnar}/hakyll-contrib-tojnar.nix" + { }; + strom-roku2023-krk-litvinov-cz = final.callPackage ./site/strom-roku2023-krk-litvinov-cz.nix { }; + }; }; in -flake.defaultNix +haskellPackages.strom-roku2023-krk-litvinov-cz diff --git a/flake.lock b/flake.lock deleted file mode 100644 index 83dff3a..0000000 --- a/flake.lock +++ /dev/null @@ -1,935 +0,0 @@ -{ - "nodes": { - "HTTP": { - "flake": false, - "locked": { - "lastModified": 1451647621, - "narHash": "sha256-oHIyw3x0iKBexEo49YeUDV1k74ZtyYKGR2gNJXXRxts=", - "owner": "phadej", - "repo": "HTTP", - "rev": "9bc0996d412fef1787449d841277ef663ad9a915", - "type": "github" - }, - "original": { - "owner": "phadej", - "repo": "HTTP", - "type": "github" - } - }, - "blank": { - "locked": { - "lastModified": 1625557891, - "narHash": "sha256-O8/MWsPBGhhyPoPLHZAuoZiiHo9q6FLlEeIDEXuj6T4=", - "owner": "divnix", - "repo": "blank", - "rev": "5a5d2684073d9f563072ed07c871d577a6c614a8", - "type": "github" - }, - "original": { - "owner": "divnix", - "repo": "blank", - "type": "github" - } - }, - "cabal-32": { - "flake": false, - "locked": { - "lastModified": 1603716527, - "narHash": "sha256-X0TFfdD4KZpwl0Zr6x+PLxUt/VyKQfX7ylXHdmZIL+w=", - "owner": "haskell", - "repo": "cabal", - "rev": "48bf10787e27364730dd37a42b603cee8d6af7ee", - "type": "github" - }, - "original": { - "owner": "haskell", - "ref": "3.2", - "repo": "cabal", - "type": "github" - } - }, - "cabal-34": { - "flake": false, - "locked": { - "lastModified": 1640353650, - "narHash": "sha256-N1t6M3/wqj90AEdRkeC8i923gQYUpzSr8b40qVOZ1Rk=", - "owner": "haskell", - "repo": "cabal", - "rev": "942639c18c0cd8ec53e0a6f8d120091af35312cd", - "type": "github" - }, - "original": { - "owner": "haskell", - "ref": "3.4", - "repo": "cabal", - "type": "github" - } - }, - "cabal-36": { - "flake": false, - "locked": { - "lastModified": 1641652457, - "narHash": "sha256-BlFPKP4C4HRUJeAbdembX1Rms1LD380q9s0qVDeoAak=", - "owner": "haskell", - "repo": "cabal", - "rev": "f27667f8ec360c475027dcaee0138c937477b070", - "type": "github" - }, - "original": { - "owner": "haskell", - "ref": "3.6", - "repo": "cabal", - "type": "github" - } - }, - "cardano-shell": { - "flake": false, - "locked": { - "lastModified": 1608537748, - "narHash": "sha256-PulY1GfiMgKVnBci3ex4ptk2UNYMXqGjJOxcPy2KYT4=", - "owner": "input-output-hk", - "repo": "cardano-shell", - "rev": "9392c75087cb9a3d453998f4230930dea3a95725", - "type": "github" - }, - "original": { - "owner": "input-output-hk", - "repo": "cardano-shell", - "type": "github" - } - }, - "devshell": { - "inputs": { - "flake-utils": [ - "haskellNix", - "tullia", - "std", - "flake-utils" - ], - "nixpkgs": [ - "haskellNix", - "tullia", - "std", - "nixpkgs" - ] - }, - "locked": { - "lastModified": 1663445644, - "narHash": "sha256-+xVlcK60x7VY1vRJbNUEAHi17ZuoQxAIH4S4iUFUGBA=", - "owner": "numtide", - "repo": "devshell", - "rev": "e3dc3e21594fe07bdb24bdf1c8657acaa4cb8f66", - "type": "github" - }, - "original": { - "owner": "numtide", - "repo": "devshell", - "type": "github" - } - }, - "dmerge": { - "inputs": { - "nixlib": [ - "haskellNix", - "tullia", - "std", - "nixpkgs" - ], - "yants": [ - "haskellNix", - "tullia", - "std", - "yants" - ] - }, - "locked": { - "lastModified": 1659548052, - "narHash": "sha256-fzI2gp1skGA8mQo/FBFrUAtY0GQkAIAaV/V127TJPyY=", - "owner": "divnix", - "repo": "data-merge", - "rev": "d160d18ce7b1a45b88344aa3f13ed1163954b497", - "type": "github" - }, - "original": { - "owner": "divnix", - "repo": "data-merge", - "type": "github" - } - }, - "flake-compat": { - "flake": false, - "locked": { - "lastModified": 1668681692, - "narHash": "sha256-Ht91NGdewz8IQLtWZ9LCeNXMSXHUss+9COoqu6JLmXU=", - "owner": "edolstra", - "repo": "flake-compat", - "rev": "009399224d5e398d03b22badca40a37ac85412a1", - "type": "github" - }, - "original": { - "owner": "edolstra", - "repo": "flake-compat", - "type": "github" - } - }, - "flake-compat_2": { - "flake": false, - "locked": { - "lastModified": 1635892615, - "narHash": "sha256-harGbMZr4hzat2BWBU+Y5OYXlu+fVz7E4WeQzHi5o8A=", - "owner": "input-output-hk", - "repo": "flake-compat", - "rev": "eca47d3377946315596da653862d341ee5341318", - "type": "github" - }, - "original": { - "owner": "input-output-hk", - "repo": "flake-compat", - "type": "github" - } - }, - "flake-compat_3": { - "flake": false, - "locked": { - "lastModified": 1650374568, - "narHash": "sha256-Z+s0J8/r907g149rllvwhb4pKi8Wam5ij0st8PwAh+E=", - "owner": "edolstra", - "repo": "flake-compat", - "rev": "b4a34015c698c7793d592d66adbab377907a2be8", - "type": "github" - }, - "original": { - "owner": "edolstra", - "repo": "flake-compat", - "type": "github" - } - }, - "flake-utils": { - "locked": { - "lastModified": 1667395993, - "narHash": "sha256-nuEHfE/LcWyuSWnS8t12N1wc105Qtau+/OdUAjtQ0rA=", - "owner": "numtide", - "repo": "flake-utils", - "rev": "5aed5285a952e0b949eb3ba02c12fa4fcfef535f", - "type": "github" - }, - "original": { - "owner": "numtide", - "repo": "flake-utils", - "type": "github" - } - }, - "flake-utils_2": { - "locked": { - "lastModified": 1644229661, - "narHash": "sha256-1YdnJAsNy69bpcjuoKdOYQX0YxZBiCYZo4Twxerqv7k=", - "owner": "numtide", - "repo": "flake-utils", - "rev": "3cecb5b042f7f209c56ffd8371b2711a290ec797", - "type": "github" - }, - "original": { - "owner": "numtide", - "repo": "flake-utils", - "type": "github" - } - }, - "flake-utils_3": { - "locked": { - "lastModified": 1653893745, - "narHash": "sha256-0jntwV3Z8//YwuOjzhV2sgJJPt+HY6KhU7VZUL0fKZQ=", - "owner": "numtide", - "repo": "flake-utils", - "rev": "1ed9fb1935d260de5fe1c2f7ee0ebaae17ed2fa1", - "type": "github" - }, - "original": { - "owner": "numtide", - "repo": "flake-utils", - "type": "github" - } - }, - "flake-utils_4": { - "locked": { - "lastModified": 1659877975, - "narHash": "sha256-zllb8aq3YO3h8B/U0/J1WBgAL8EX5yWf5pMj3G0NAmc=", - "owner": "numtide", - "repo": "flake-utils", - "rev": "c0e246b9b83f637f4681389ecabcb2681b4f3af0", - "type": "github" - }, - "original": { - "owner": "numtide", - "repo": "flake-utils", - "type": "github" - } - }, - "flake-utils_5": { - "locked": { - "lastModified": 1653893745, - "narHash": "sha256-0jntwV3Z8//YwuOjzhV2sgJJPt+HY6KhU7VZUL0fKZQ=", - "owner": "numtide", - "repo": "flake-utils", - "rev": "1ed9fb1935d260de5fe1c2f7ee0ebaae17ed2fa1", - "type": "github" - }, - "original": { - "owner": "numtide", - "repo": "flake-utils", - "type": "github" - } - }, - "ghc-8.6.5-iohk": { - "flake": false, - "locked": { - "lastModified": 1600920045, - "narHash": "sha256-DO6kxJz248djebZLpSzTGD6s8WRpNI9BTwUeOf5RwY8=", - "owner": "input-output-hk", - "repo": "ghc", - "rev": "95713a6ecce4551240da7c96b6176f980af75cae", - "type": "github" - }, - "original": { - "owner": "input-output-hk", - "ref": "release/8.6.5-iohk", - "repo": "ghc", - "type": "github" - } - }, - "gomod2nix": { - "inputs": { - "nixpkgs": "nixpkgs_2", - "utils": "utils" - }, - "locked": { - "lastModified": 1655245309, - "narHash": "sha256-d/YPoQ/vFn1+GTmSdvbSBSTOai61FONxB4+Lt6w/IVI=", - "owner": "tweag", - "repo": "gomod2nix", - "rev": "40d32f82fc60d66402eb0972e6e368aeab3faf58", - "type": "github" - }, - "original": { - "owner": "tweag", - "repo": "gomod2nix", - "type": "github" - } - }, - "hackage": { - "flake": false, - "locked": { - "lastModified": 1672446463, - "narHash": "sha256-N5dcK1V+BLQeri5oB0ZSk2ABPs/hTGBC7jZvcY9CVLs=", - "owner": "input-output-hk", - "repo": "hackage.nix", - "rev": "7289869780da23633bc193e11d2da94ecee1489d", - "type": "github" - }, - "original": { - "owner": "input-output-hk", - "repo": "hackage.nix", - "type": "github" - } - }, - "hakyll-contrib-tojnar": { - "flake": false, - "locked": { - "lastModified": 1676857737, - "narHash": "sha256-g9fLkJM06EKFqsajt0ShQbZZdQd3MiUCeJkdkeVgpY0=", - "owner": "tojnar.cz", - "repo": "hakyll-contrib-tojnar", - "rev": "d82a20509e9bd3705ac1edc07677d68109768a70", - "type": "gitlab" - }, - "original": { - "owner": "tojnar.cz", - "ref": "master", - "repo": "hakyll-contrib-tojnar", - "type": "gitlab" - } - }, - "haskellNix": { - "inputs": { - "HTTP": "HTTP", - "cabal-32": "cabal-32", - "cabal-34": "cabal-34", - "cabal-36": "cabal-36", - "cardano-shell": "cardano-shell", - "flake-compat": "flake-compat_2", - "flake-utils": "flake-utils_2", - "ghc-8.6.5-iohk": "ghc-8.6.5-iohk", - "hackage": "hackage", - "hpc-coveralls": "hpc-coveralls", - "hydra": "hydra", - "iserv-proxy": "iserv-proxy", - "nixpkgs": [ - "haskellNix", - "nixpkgs-unstable" - ], - "nixpkgs-2003": "nixpkgs-2003", - "nixpkgs-2105": "nixpkgs-2105", - "nixpkgs-2111": "nixpkgs-2111", - "nixpkgs-2205": "nixpkgs-2205", - "nixpkgs-2211": "nixpkgs-2211", - "nixpkgs-unstable": "nixpkgs-unstable", - "old-ghc-nix": "old-ghc-nix", - "stackage": "stackage", - "tullia": "tullia" - }, - "locked": { - "lastModified": 1672447880, - "narHash": "sha256-NB0wAAP7+/DZU4Nlw5yEWP8hcTiLjnMDElJH6K111bQ=", - "owner": "input-output-hk", - "repo": "haskell.nix", - "rev": "70d9708b5c932fbdd5e7e1124704844aeae975c3", - "type": "github" - }, - "original": { - "owner": "input-output-hk", - "repo": "haskell.nix", - "type": "github" - } - }, - "hpc-coveralls": { - "flake": false, - "locked": { - "lastModified": 1607498076, - "narHash": "sha256-8uqsEtivphgZWYeUo5RDUhp6bO9j2vaaProQxHBltQk=", - "owner": "sevanspowell", - "repo": "hpc-coveralls", - "rev": "14df0f7d229f4cd2e79f8eabb1a740097fdfa430", - "type": "github" - }, - "original": { - "owner": "sevanspowell", - "repo": "hpc-coveralls", - "type": "github" - } - }, - "hydra": { - "inputs": { - "nix": "nix", - "nixpkgs": [ - "haskellNix", - "hydra", - "nix", - "nixpkgs" - ] - }, - "locked": { - "lastModified": 1646878427, - "narHash": "sha256-KtbrofMtN8GlM7D+n90kixr7QpSlVmdN+vK5CA/aRzc=", - "owner": "NixOS", - "repo": "hydra", - "rev": "28b682b85b7efc5cf7974065792a1f22203a5927", - "type": "github" - }, - "original": { - "id": "hydra", - "type": "indirect" - } - }, - "iserv-proxy": { - "flake": false, - "locked": { - "lastModified": 1639165170, - "narHash": "sha256-QsWL/sBDL5GM8IXd/dE/ORiL4RvteEN+aok23tXgAoc=", - "rev": "6e95df7be6dd29680f983db07a057fc2f34f81f6", - "revCount": 7, - "type": "git", - "url": "https://gitlab.haskell.org/ghc/iserv-proxy.git" - }, - "original": { - "rev": "6e95df7be6dd29680f983db07a057fc2f34f81f6", - "type": "git", - "url": "https://gitlab.haskell.org/ghc/iserv-proxy.git" - } - }, - "lowdown-src": { - "flake": false, - "locked": { - "lastModified": 1633514407, - "narHash": "sha256-Dw32tiMjdK9t3ETl5fzGrutQTzh2rufgZV4A/BbxuD4=", - "owner": "kristapsdz", - "repo": "lowdown", - "rev": "d2c2b44ff6c27b936ec27358a2653caaef8f73b8", - "type": "github" - }, - "original": { - "owner": "kristapsdz", - "repo": "lowdown", - "type": "github" - } - }, - "mdbook-kroki-preprocessor": { - "flake": false, - "locked": { - "lastModified": 1661755005, - "narHash": "sha256-1TJuUzfyMycWlOQH67LR63/ll2GDZz25I3JfScy/Jnw=", - "owner": "JoelCourtney", - "repo": "mdbook-kroki-preprocessor", - "rev": "93adb5716d035829efed27f65f2f0833a7d3e76f", - "type": "github" - }, - "original": { - "owner": "JoelCourtney", - "repo": "mdbook-kroki-preprocessor", - "type": "github" - } - }, - "n2c": { - "inputs": { - "flake-utils": "flake-utils_5", - "nixpkgs": [ - "haskellNix", - "tullia", - "std", - "nixpkgs" - ] - }, - "locked": { - "lastModified": 1665039323, - "narHash": "sha256-SAh3ZjFGsaCI8FRzXQyp56qcGdAqgKEfJWPCQ0Sr7tQ=", - "owner": "nlewo", - "repo": "nix2container", - "rev": "b008fe329ffb59b67bf9e7b08ede6ee792f2741a", - "type": "github" - }, - "original": { - "owner": "nlewo", - "repo": "nix2container", - "type": "github" - } - }, - "nix": { - "inputs": { - "lowdown-src": "lowdown-src", - "nixpkgs": "nixpkgs", - "nixpkgs-regression": "nixpkgs-regression" - }, - "locked": { - "lastModified": 1643066034, - "narHash": "sha256-xEPeMcNJVOeZtoN+d+aRwolpW8mFSEQx76HTRdlhPhg=", - "owner": "NixOS", - "repo": "nix", - "rev": "a1cd7e58606a41fcf62bf8637804cf8306f17f62", - "type": "github" - }, - "original": { - "owner": "NixOS", - "ref": "2.6.0", - "repo": "nix", - "type": "github" - } - }, - "nix-nomad": { - "inputs": { - "flake-compat": "flake-compat_3", - "flake-utils": [ - "haskellNix", - "tullia", - "nix2container", - "flake-utils" - ], - "gomod2nix": "gomod2nix", - "nixpkgs": [ - "haskellNix", - "tullia", - "nixpkgs" - ], - "nixpkgs-lib": [ - "haskellNix", - "tullia", - "nixpkgs" - ] - }, - "locked": { - "lastModified": 1658277770, - "narHash": "sha256-T/PgG3wUn8Z2rnzfxf2VqlR1CBjInPE0l1yVzXxPnt0=", - "owner": "tristanpemble", - "repo": "nix-nomad", - "rev": "054adcbdd0a836ae1c20951b67ed549131fd2d70", - "type": "github" - }, - "original": { - "owner": "tristanpemble", - "repo": "nix-nomad", - "type": "github" - } - }, - "nix2container": { - "inputs": { - "flake-utils": "flake-utils_3", - "nixpkgs": "nixpkgs_3" - }, - "locked": { - "lastModified": 1658567952, - "narHash": "sha256-XZ4ETYAMU7XcpEeAFP3NOl9yDXNuZAen/aIJ84G+VgA=", - "owner": "nlewo", - "repo": "nix2container", - "rev": "60bb43d405991c1378baf15a40b5811a53e32ffa", - "type": "github" - }, - "original": { - "owner": "nlewo", - "repo": "nix2container", - "type": "github" - } - }, - "nixago": { - "inputs": { - "flake-utils": [ - "haskellNix", - "tullia", - "std", - "flake-utils" - ], - "nixago-exts": [ - "haskellNix", - "tullia", - "std", - "blank" - ], - "nixpkgs": [ - "haskellNix", - "tullia", - "std", - "nixpkgs" - ] - }, - "locked": { - "lastModified": 1661824785, - "narHash": "sha256-/PnwdWoO/JugJZHtDUioQp3uRiWeXHUdgvoyNbXesz8=", - "owner": "nix-community", - "repo": "nixago", - "rev": "8c1f9e5f1578d4b2ea989f618588d62a335083c3", - "type": "github" - }, - "original": { - "owner": "nix-community", - "repo": "nixago", - "type": "github" - } - }, - "nixpkgs": { - "locked": { - "lastModified": 1632864508, - "narHash": "sha256-d127FIvGR41XbVRDPVvozUPQ/uRHbHwvfyKHwEt5xFM=", - "owner": "NixOS", - "repo": "nixpkgs", - "rev": "82891b5e2c2359d7e58d08849e4c89511ab94234", - "type": "github" - }, - "original": { - "id": "nixpkgs", - "ref": "nixos-21.05-small", - "type": "indirect" - } - }, - "nixpkgs-2003": { - "locked": { - "lastModified": 1620055814, - "narHash": "sha256-8LEHoYSJiL901bTMVatq+rf8y7QtWuZhwwpKE2fyaRY=", - "owner": "NixOS", - "repo": "nixpkgs", - "rev": "1db42b7fe3878f3f5f7a4f2dc210772fd080e205", - "type": "github" - }, - "original": { - "owner": "NixOS", - "ref": "nixpkgs-20.03-darwin", - "repo": "nixpkgs", - "type": "github" - } - }, - "nixpkgs-2105": { - "locked": { - "lastModified": 1659914493, - "narHash": "sha256-lkA5X3VNMKirvA+SUzvEhfA7XquWLci+CGi505YFAIs=", - "owner": "NixOS", - "repo": "nixpkgs", - "rev": "022caabb5f2265ad4006c1fa5b1ebe69fb0c3faf", - "type": "github" - }, - "original": { - "owner": "NixOS", - "ref": "nixpkgs-21.05-darwin", - "repo": "nixpkgs", - "type": "github" - } - }, - "nixpkgs-2111": { - "locked": { - "lastModified": 1659446231, - "narHash": "sha256-hekabNdTdgR/iLsgce5TGWmfIDZ86qjPhxDg/8TlzhE=", - "owner": "NixOS", - "repo": "nixpkgs", - "rev": "eabc38219184cc3e04a974fe31857d8e0eac098d", - "type": "github" - }, - "original": { - "owner": "NixOS", - "ref": "nixpkgs-21.11-darwin", - "repo": "nixpkgs", - "type": "github" - } - }, - "nixpkgs-2205": { - "locked": { - "lastModified": 1663981975, - "narHash": "sha256-TKaxWAVJR+a5JJauKZqibmaM5e/Pi5tBDx9s8fl/kSE=", - "owner": "NixOS", - "repo": "nixpkgs", - "rev": "309faedb8338d3ae8ad8f1043b3ccf48c9cc2970", - "type": "github" - }, - "original": { - "owner": "NixOS", - "ref": "nixpkgs-22.05-darwin", - "repo": "nixpkgs", - "type": "github" - } - }, - "nixpkgs-2211": { - "locked": { - "lastModified": 1669997163, - "narHash": "sha256-vhjC0kZMFoN6jzK0GR+tBzKi5KgBXgehadfidW8+Va4=", - "owner": "NixOS", - "repo": "nixpkgs", - "rev": "6f87491a54d8d64d30af6663cb3bf5d2ee7db958", - "type": "github" - }, - "original": { - "owner": "NixOS", - "ref": "nixpkgs-22.11-darwin", - "repo": "nixpkgs", - "type": "github" - } - }, - "nixpkgs-regression": { - "locked": { - "lastModified": 1643052045, - "narHash": "sha256-uGJ0VXIhWKGXxkeNnq4TvV3CIOkUJ3PAoLZ3HMzNVMw=", - "owner": "NixOS", - "repo": "nixpkgs", - "rev": "215d4d0fd80ca5163643b03a33fde804a29cc1e2", - "type": "github" - }, - "original": { - "id": "nixpkgs", - "rev": "215d4d0fd80ca5163643b03a33fde804a29cc1e2", - "type": "indirect" - } - }, - "nixpkgs-unstable": { - "locked": { - "lastModified": 1663905476, - "narHash": "sha256-0CSwRKaYravh9v6qSlBpM0gNg0UhKT2lL7Yn6Zbx7UM=", - "owner": "NixOS", - "repo": "nixpkgs", - "rev": "e14f9fb57315f0d4abde222364f19f88c77d2b79", - "type": "github" - }, - "original": { - "owner": "NixOS", - "ref": "nixpkgs-unstable", - "repo": "nixpkgs", - "type": "github" - } - }, - "nixpkgs_2": { - "locked": { - "lastModified": 1653581809, - "narHash": "sha256-Uvka0V5MTGbeOfWte25+tfRL3moECDh1VwokWSZUdoY=", - "owner": "NixOS", - "repo": "nixpkgs", - "rev": "83658b28fe638a170a19b8933aa008b30640fbd1", - "type": "github" - }, - "original": { - "owner": "NixOS", - "ref": "nixos-unstable", - "repo": "nixpkgs", - "type": "github" - } - }, - "nixpkgs_3": { - "locked": { - "lastModified": 1654807842, - "narHash": "sha256-ADymZpr6LuTEBXcy6RtFHcUZdjKTBRTMYwu19WOx17E=", - "owner": "NixOS", - "repo": "nixpkgs", - "rev": "fc909087cc3386955f21b4665731dbdaceefb1d8", - "type": "github" - }, - "original": { - "owner": "NixOS", - "repo": "nixpkgs", - "type": "github" - } - }, - "nixpkgs_4": { - "locked": { - "lastModified": 1665087388, - "narHash": "sha256-FZFPuW9NWHJteATOf79rZfwfRn5fE0wi9kRzvGfDHPA=", - "owner": "nixos", - "repo": "nixpkgs", - "rev": "95fda953f6db2e9496d2682c4fc7b82f959878f7", - "type": "github" - }, - "original": { - "owner": "nixos", - "ref": "nixpkgs-unstable", - "repo": "nixpkgs", - "type": "github" - } - }, - "old-ghc-nix": { - "flake": false, - "locked": { - "lastModified": 1631092763, - "narHash": "sha256-sIKgO+z7tj4lw3u6oBZxqIhDrzSkvpHtv0Kki+lh9Fg=", - "owner": "angerman", - "repo": "old-ghc-nix", - "rev": "af48a7a7353e418119b6dfe3cd1463a657f342b8", - "type": "github" - }, - "original": { - "owner": "angerman", - "ref": "master", - "repo": "old-ghc-nix", - "type": "github" - } - }, - "root": { - "inputs": { - "flake-compat": "flake-compat", - "flake-utils": "flake-utils", - "hakyll-contrib-tojnar": "hakyll-contrib-tojnar", - "haskellNix": "haskellNix", - "nixpkgs": [ - "haskellNix", - "nixpkgs-unstable" - ] - } - }, - "stackage": { - "flake": false, - "locked": { - "lastModified": 1672445456, - "narHash": "sha256-mN7ErqNTaGhxZagKmraHENaGABlkTPvgjmBTqc0T4to=", - "owner": "input-output-hk", - "repo": "stackage.nix", - "rev": "471a9366faa919b285943bf053884cbb026cc284", - "type": "github" - }, - "original": { - "owner": "input-output-hk", - "repo": "stackage.nix", - "type": "github" - } - }, - "std": { - "inputs": { - "blank": "blank", - "devshell": "devshell", - "dmerge": "dmerge", - "flake-utils": "flake-utils_4", - "makes": [ - "haskellNix", - "tullia", - "std", - "blank" - ], - "mdbook-kroki-preprocessor": "mdbook-kroki-preprocessor", - "microvm": [ - "haskellNix", - "tullia", - "std", - "blank" - ], - "n2c": "n2c", - "nixago": "nixago", - "nixpkgs": "nixpkgs_4", - "yants": "yants" - }, - "locked": { - "lastModified": 1665513321, - "narHash": "sha256-D6Pacw9yf/HMs84KYuCxHXnNDL7v43gtcka5URagFqE=", - "owner": "divnix", - "repo": "std", - "rev": "94a90eedb9cfc115b12ae8f6622d9904788559e4", - "type": "github" - }, - "original": { - "owner": "divnix", - "repo": "std", - "type": "github" - } - }, - "tullia": { - "inputs": { - "nix-nomad": "nix-nomad", - "nix2container": "nix2container", - "nixpkgs": [ - "haskellNix", - "nixpkgs" - ], - "std": "std" - }, - "locked": { - "lastModified": 1668711738, - "narHash": "sha256-CBjky16o9pqsGE1bWu6nRlRajgSXMEk+yaFQLibqXcE=", - "owner": "input-output-hk", - "repo": "tullia", - "rev": "ead1f515c251f0e060060ef0e2356a51d3dfe4b0", - "type": "github" - }, - "original": { - "owner": "input-output-hk", - "repo": "tullia", - "type": "github" - } - }, - "utils": { - "locked": { - "lastModified": 1653893745, - "narHash": "sha256-0jntwV3Z8//YwuOjzhV2sgJJPt+HY6KhU7VZUL0fKZQ=", - "owner": "numtide", - "repo": "flake-utils", - "rev": "1ed9fb1935d260de5fe1c2f7ee0ebaae17ed2fa1", - "type": "github" - }, - "original": { - "owner": "numtide", - "repo": "flake-utils", - "type": "github" - } - }, - "yants": { - "inputs": { - "nixpkgs": [ - "haskellNix", - "tullia", - "std", - "nixpkgs" - ] - }, - "locked": { - "lastModified": 1660507851, - "narHash": "sha256-BKjq7JnVuUR/xDtcv6Vm9GYGKAblisXrAgybor9hT/s=", - "owner": "divnix", - "repo": "yants", - "rev": "0b895ca02a8fa72bad50b454cb3e7d8a66407c96", - "type": "github" - }, - "original": { - "owner": "divnix", - "repo": "yants", - "type": "github" - } - } - }, - "root": "root", - "version": 7 -} diff --git a/flake.nix b/flake.nix deleted file mode 100644 index f821d9e..0000000 --- a/flake.nix +++ /dev/null @@ -1,104 +0,0 @@ -{ - description = "Source for strom-roku-2023.krk-litvinov.cz"; - - inputs = { - flake-compat = { - url = "github:edolstra/flake-compat"; - flake = false; - }; - - haskellNix.url = "github:input-output-hk/haskell.nix"; - - nixpkgs.follows = "haskellNix/nixpkgs-unstable"; - - hakyll-contrib-tojnar = { - url = "gitlab:tojnar.cz/hakyll-contrib-tojnar?ref=master"; - flake = false; - }; - - flake-utils.url = "github:numtide/flake-utils"; - }; - - nixConfig = { - extra-substituters = ["https://cache.iog.io"]; - extra-trusted-public-keys = ["hydra.iohk.io:f/Ea+s+dFdN+3Y/G+FDgSq+a5NEWhJGzdjvKNGv0/EQ="]; - allow-import-from-derivation = "true"; - }; - - outputs = { self, flake-compat, haskellNix, hakyll-contrib-tojnar, nixpkgs, flake-utils }: - flake-utils.lib.eachDefaultSystem (system: - let - compiler = "ghc925"; - - overlays = [ - haskellNix.overlay - - (final: prev: { - strom-roku2023-krk-litvinov-cz = - final.haskell-nix.project' { - src = ./site; - compiler-nix-name = compiler; - shell.tools = { - cabal = {}; - }; - inputMap = { - "https://gitlab.com/tojnar.cz/hakyll-contrib-tojnar/master" = hakyll-contrib-tojnar; - }; - }; - }) - ]; - - pkgs = import nixpkgs { - inherit system; - inherit overlays; - inherit (haskellNix) config; - }; - - flake = pkgs.strom-roku2023-krk-litvinov-cz.flake { - crossPlatforms = p: [ - p.mingwW64 - ]; - }; - in flake // { - devShells = { - default = pkgs.mkShell { - nativeBuildInputs = [ - self.packages.${system}.default - pkgs.vips - ]; - }; - haskell = flake.devShells.default; - }; - - packages = { - default = flake.packages."strom-roku2023-krk-litvinov-cz:exe:site"; - win = flake.packages."x86_64-w64-mingw32:strom-roku2023-krk-litvinov-cz:exe:site"; - roots = pkgs.haskell-nix.roots compiler; - winCombined = - let - version = "8.14.1"; - vips = pkgs.fetchzip { - url = "https://github.com/libvips/build-win64-mxe/releases/download/v${version}/vips-dev-w64-all-${version}.zip"; - hash = "sha256-yGAoRwyfeMTiDSSOfWJp32N85Z8Jdyw8wrvEvmx7BWM="; - }; - in - pkgs.runCommand - "generator" - { - nativeBuildInputs = [ - pkgs.zip - ]; - } - '' - mkdir -p "$out" - mkdir generator - cp -r "${vips}/bin" "vips" - cp -r "${self.packages.${system}.win}/bin" "site" - zip -9 -r -q "$out/site-bundle.zip" vips/ site/ - ''; - }; - - legacyPackages = pkgs; - } - ); -} diff --git a/npins/default.nix b/npins/default.nix new file mode 100644 index 0000000..5e7d086 --- /dev/null +++ b/npins/default.nix @@ -0,0 +1,80 @@ +# Generated by npins. Do not modify; will be overwritten regularly +let + data = builtins.fromJSON (builtins.readFile ./sources.json); + version = data.version; + + mkSource = + spec: + assert spec ? type; + let + path = + if spec.type == "Git" then + mkGitSource spec + else if spec.type == "GitRelease" then + mkGitSource spec + else if spec.type == "PyPi" then + mkPyPiSource spec + else if spec.type == "Channel" then + mkChannelSource spec + else + builtins.throw "Unknown source type ${spec.type}"; + in + spec // { outPath = path; }; + + mkGitSource = + { + repository, + revision, + url ? null, + hash, + branch ? null, + ... + }: + assert repository ? type; + # At the moment, either it is a plain git repository (which has an url), or it is a GitHub/GitLab repository + # In the latter case, there we will always be an url to the tarball + if url != null then + (builtins.fetchTarball { + inherit url; + sha256 = hash; # FIXME: check nix version & use SRI hashes + }) + else + assert repository.type == "Git"; + let + urlToName = + url: rev: + let + matched = builtins.match "^.*/([^/]*)(\\.git)?$" repository.url; + + short = builtins.substring 0 7 rev; + + appendShort = if (builtins.match "[a-f0-9]*" rev) != null then "-${short}" else ""; + in + "${if matched == null then "source" else builtins.head matched}${appendShort}"; + name = urlToName repository.url revision; + in + builtins.fetchGit { + url = repository.url; + rev = revision; + inherit name; + # hash = hash; + }; + + mkPyPiSource = + { url, hash, ... }: + builtins.fetchurl { + inherit url; + sha256 = hash; + }; + + mkChannelSource = + { url, hash, ... }: + builtins.fetchTarball { + inherit url; + sha256 = hash; + }; +in +if version == 3 then + builtins.mapAttrs (_: mkSource) data.pins +else + throw "Unsupported format version ${toString version} in sources.json. Try running `npins upgrade`" diff --git a/npins/sources.json b/npins/sources.json new file mode 100644 index 0000000..38a286a --- /dev/null +++ b/npins/sources.json @@ -0,0 +1,29 @@ +{ + "pins": { + "hakyll-contrib-tojnar": { + "type": "Git", + "repository": { + "type": "GitLab", + "repo_path": "tojnar.cz/hakyll-contrib-tojnar", + "server": "https://gitlab.com/" + }, + "branch": "master", + "revision": "v0.2.2", + "url": "https://gitlab.com/api/v4/projects/tojnar.cz%2Fhakyll-contrib-tojnar/repository/archive.tar.gz?sha=v0.2.2", + "hash": "1s9qjwadl0krzvs77d537pbyvr4mkkmjgdl79kc8lgil4y182v3m" + }, + "nixpkgs": { + "type": "Git", + "repository": { + "type": "GitHub", + "owner": "NixOS", + "repo": "nixpkgs" + }, + "branch": "nixpkgs-unstable", + "revision": "aeb75dba965e790de427b73315d5addf91a54955", + "url": "https://github.com/NixOS/nixpkgs/archive/aeb75dba965e790de427b73315d5addf91a54955.tar.gz", + "hash": "119lcwpkr9yy49z9fgpq32hp33igc4apbip2y2ppc7hwxs0hwyjk" + } + }, + "version": 3 +} diff --git a/readme.md b/readme.md index e81587d..1404ba9 100644 --- a/readme.md +++ b/readme.md @@ -26,7 +26,3 @@ 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. diff --git a/shell.nix b/shell.nix index 57112ca..6bea2d7 100644 --- a/shell.nix +++ b/shell.nix @@ -1,14 +1,19 @@ -# SPDX-FileCopyrightText: 2022 Jan Tojnar +# SPDX-FileCopyrightText: 2024 Jan Tojnar # SPDX-License-Identifier: MIT +{ + dev ? false, +}: + let - lock = builtins.fromJSON (builtins.readFile ./flake.lock); - flake-compat = builtins.fetchTarball { - url = "https://github.com/edolstra/flake-compat/archive/${lock.nodes.flake-compat.locked.rev}.tar.gz"; - sha256 = lock.nodes.flake-compat.locked.narHash; - }; - flake = import flake-compat { - src = ./.; - }; + sources = import ./npins; + pkgs = import sources.nixpkgs { }; + inherit (pkgs) lib; + site = import ./.; in -flake.shellNix +pkgs.mkShell { + nativeBuildInputs = [ + site + pkgs.vips + ] ++ lib.optionals dev [ pkgs.cabal-install ]; +} diff --git a/site/cabal.project b/site/cabal.project deleted file mode 100644 index 73a6551..0000000 --- a/site/cabal.project +++ /dev/null @@ -1,9 +0,0 @@ -packages: . - -source-repository-package - type: git - location: https://gitlab.com/tojnar.cz/hakyll-contrib-tojnar - tag: master - -package hakyll-contrib-tojnar - flags: -gd diff --git a/site/strom-roku2023-krk-litvinov-cz.cabal b/site/strom-roku2023-krk-litvinov-cz.cabal index f25f196..cb29b75 100644 --- a/site/strom-roku2023-krk-litvinov-cz.cabal +++ b/site/strom-roku2023-krk-litvinov-cz.cabal @@ -13,7 +13,7 @@ executable site hakyll >= 4.9 && < 4.16, hakyll-contrib-tojnar >= 0.2.1 && < 0.3.0, filepath >= 1.4 && < 1.5, - pandoc >= 2.0 && < 2.18, + pandoc >= 2.0 && < 2.20, process >= 1.6 && < 1.7, time >= 1.9 && < 1.12, ghc-options: diff --git a/site/strom-roku2023-krk-litvinov-cz.nix b/site/strom-roku2023-krk-litvinov-cz.nix new file mode 100644 index 0000000..a7ea9a2 --- /dev/null +++ b/site/strom-roku2023-krk-litvinov-cz.nix @@ -0,0 +1,39 @@ +{ mkDerivation +, base +, containers +, directory +, extra +, filepath +, hakyll +, hakyll-contrib-tojnar +, pandoc +, process +, time +, lib +}: + +mkDerivation { + pname = "strom-roku2023-krk-litvinov-cz"; + version = "0.0.1"; + + # Keep the contents of the src/ directory and top-level .cabal file. + src = lib.sourceByRegex ./. [ "^src(/.+|$)" "[^/]+\.cabal$" ]; + + isLibrary = false; + isExecutable = true; + + executableHaskellDepends = [ + base + containers + directory + extra + filepath + hakyll + hakyll-contrib-tojnar + pandoc + process + time + ]; + + license = lib.licenses.mit; +}