Skip to content

Commit

Permalink
Use flake
Browse files Browse the repository at this point in the history
  • Loading branch information
jezen committed Nov 17, 2024
1 parent b3ea39a commit 076e750
Show file tree
Hide file tree
Showing 6 changed files with 122 additions and 55 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ jobs:
with:
nix_path: nixpkgs=channel:nixos-unstable
- uses: DeterminateSystems/magic-nix-cache-action@v2
- run: nix-build
- run: ./result/bin/jgt rebuild
- run: nix build
- run: ./result/bin/site rebuild

- name: Deploy
uses: JamesIves/github-pages-deploy-action@v4
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
```bash
# Compile app
nix-build
nix build

# Development server
./result/bin/jgt watch
Expand Down
20 changes: 0 additions & 20 deletions default.nix

This file was deleted.

61 changes: 61 additions & 0 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

57 changes: 38 additions & 19 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -1,28 +1,47 @@
{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/dbb62c34bbb5cdf05f1aeab07638b24b0824d605";
nixpkgs.url = "github:NixOS/nixpkgs/nixos-24.05";
flake-utils.url = "github:numtide/flake-utils";
};

outputs = { self, nixpkgs }:
let
pkgs = import nixpkgs { };
in {
packages = {
default = pkgs.stdenv.mkDerivation {
pname = "jgt";
version = "0.1.0";

src = ./src;

phases = "unpackPhase buildPhase";
buildInputs = [
(pkgs.haskellPackages.ghcWithPackages (p: with p; [ hakyll pureMD5 ]))
outputs =
{ self
, nixpkgs
, flake-utils
}:
flake-utils.lib.eachDefaultSystem
(system:
let
pkgs = import nixpkgs {
inherit system;
overlays = [
self.overlays.default
];
};
in {
packages.default = pkgs.lib.trivial.pipe pkgs.haskellPackages.jgt
[
pkgs.haskell.lib.dontHaddock
pkgs.haskell.lib.enableStaticLibraries
pkgs.haskell.lib.justStaticExecutables
pkgs.haskell.lib.disableLibraryProfiling
pkgs.haskell.lib.disableExecutableProfiling
];
}) // {
overlays.default = _: prev: {
haskell = prev.haskell // {
packageOverrides = prev.lib.composeExtensions prev.haskell.packageOverrides (_: hprev: {

buildPhase = ''
mkdir -p $out/bin
ghc -O2 -dynamic --make Main.hs -o $out/bin/jgt
'';
jgt =
let
haskellSourceFilter = prev.lib.sourceFilesBySuffices ./. [
".cabal"
".hs"
"LICENSE"
];
in
hprev.callCabal2nix "jgt" haskellSourceFilter { };
});
};
};
};
Expand Down
33 changes: 20 additions & 13 deletions jgt.cabal
Original file line number Diff line number Diff line change
@@ -1,18 +1,25 @@
name: jgt
version: 0.1.0.0
build-type: Simple
license: GPL-3
license-file: LICENSE
cabal-version: >= 1.10
name: jgt
version: 0.1.0.0
build-type: Simple
license: GPL-3
license-file: LICENSE
cabal-version: >=1.10

executable site
main-is: Main.hs
build-depends: base == 4.*
, hakyll == 4.9.*
, blaze-html
, containers
, filepath
, pureMD5
other-modules: Redirects
build-depends:
base >=4 && <5
, blaze-html
, bytestring
, containers
, filepath
, hakyll >=4.16 && <4.17
, pandoc
, pureMD5
, time
, time-locale-compat

ghc-options: -threaded
Hs-source-dirs: src
hs-source-dirs: src
default-language: Haskell2010

0 comments on commit 076e750

Please sign in to comment.