aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar Alexander Foremny <aforemny@posteo.de>2025-03-02 16:12:52 +0100
committerLibravatar Alexander Foremny <aforemny@posteo.de>2025-03-02 16:12:52 +0100
commit75066cddefbeab6d69aa4efe0a4aa97915c98c84 (patch)
tree167d601d91d560c7373b18b0abac20568b604fae
parentfefb6424bddd6ac4bf0b68f30fbf6a7f59658cec (diff)
hybrid shell
-rw-r--r--README.md6
-rw-r--r--achat.cabal16
-rw-r--r--acms.hs4
-rw-r--r--cabal.project3
-rw-r--r--default.nix78
-rw-r--r--nix/sources.json2
-rw-r--r--pkgs/default.nix44
7 files changed, 97 insertions, 56 deletions
diff --git a/README.md b/README.md
index 87ee603..ff9541c 100644
--- a/README.md
+++ b/README.md
@@ -1,10 +1,10 @@
# achat
-## cabal (development)
+## development
```console
-cabal build
+build
acms serve content &
-python -m http.server -d dist-newstyle/build/javascript-ghcjs/ghc-9.10.1/achat-0.1.0.0/x/achat/build/achat/achat.jsexe &
+python -m http.server -d dist-newstyle/build/javascript-ghcjs/ghc-9.10.1/achat-0.1.0.0/x/frontend/build/frontend/frontend.jsexe &
firefox http://localhost:8000
```
diff --git a/achat.cabal b/achat.cabal
index 448a896..cd86478 100644
--- a/achat.cabal
+++ b/achat.cabal
@@ -8,7 +8,7 @@ author: Alexander Foremny
category: Web
build-type: Simple
-executable achat
+executable frontend
main-is: Main.hs
hs-source-dirs: app
default-language: Haskell2010
@@ -21,3 +21,17 @@ executable achat
protolude,
row-types,
unliftio
+
+ if !arch(javascript)
+ buildable: False
+
+executable backend
+ main-is: acms.hs
+ hs-source-dirs: .
+ default-language: Haskell2010
+ build-depends:
+ base,
+ acms
+
+ if arch(javascript)
+ buildable: False
diff --git a/acms.hs b/acms.hs
new file mode 100644
index 0000000..acb84d1
--- /dev/null
+++ b/acms.hs
@@ -0,0 +1,4 @@
+import ACMS.ACMS
+
+main =
+ ACMS.ACMS.run (error "TODO")
diff --git a/cabal.project b/cabal.project
deleted file mode 100644
index 4a0bae6..0000000
--- a/cabal.project
+++ /dev/null
@@ -1,3 +0,0 @@
-packages: .
-with-compiler: javascript-unknown-ghcjs-ghc
-with-hc-pkg: javascript-unknown-ghcjs-ghc-pkg
diff --git a/default.nix b/default.nix
index c6cbdbd..7daa1a8 100644
--- a/default.nix
+++ b/default.nix
@@ -1,42 +1,64 @@
{ pkgs ? import sources.nixpkgs {
overlays = [
- (import ./pkgs { inherit (pkgs.haskell) lib; })
+ (import "${sources.acms}/pkgs" { })
+ (import ./pkgs { })
(self: super: {
haskell = super.haskell // {
- packageOverrides = self.lib.composeManyExtensions
- [
- (super.haskell.packageOverrides or (self: super: self))
- (self: super: {
- ghcWithPackages = super.ghcWithPackages.override {
- installDocumentation = false; # XXX true (default)
- };
- })
- ];
+ packageOverrides = self.lib.composeManyExtensions [
+ super.haskell.packageOverrides
+ (self: super: {
+ ghcWithPackages = super.ghcWithPackages.override {
+ installDocumentation = false; # XXX true (default)
+ };
+ })
+ ];
};
})
];
}
, sources ? import ./nix/sources.nix
}:
-let
- ghc = "ghc910";
- haskellPackages = pkgs.pkgsCross.ghcjs.haskell.packages.${ghc};
- acms = (import sources.acms { }).acms;
-in
+let ghc = "ghc910"; in
rec {
- inherit haskellPackages;
- inherit (haskellPackages) achat;
- shell = haskellPackages.shellFor {
- packages = _: [
- haskellPackages.achat
- ];
- nativeBuildInputs = [
- acms
- pkgs.haskell.packages.${ghc}.cabal-install
- pkgs.haskell.packages.${ghc}.ormolu
+ frontend = pkgs.pkgsCross.ghcjs.haskell.packages.${ghc}.achat;
+ backend = pkgs.haskell.packages.${ghc}.achat;
+ shell = pkgs.mkShell {
+ inputsFrom = [
+ (pkgs.pkgsCross.ghcjs.haskell.packages.${ghc}.shellFor {
+ packages = haskellPackages: [
+ haskellPackages.achat
+ ];
+ })
+ (pkgs.haskell.packages.${ghc}.shellFor {
+ packages = haskellPackages: [
+ haskellPackages.achat
+ ];
+ })
+ (pkgs.mkShell {
+ buildInputs = [
+ pkgs.haskell.packages.${ghc}.cabal-install
+ pkgs.haskell.packages.${ghc}.ormolu
+ (pkgs.writers.writeDashBin "build-frontend" ''
+ set -efu
+ cabal \
+ --with-compiler=javascript-unknown-ghcjs-ghc \
+ --with-hc-pkg=javascript-unknown-ghcjs-ghc-pkg \
+ build
+ '')
+ (pkgs.writers.writeDashBin "build-backend" ''
+ set -efu
+ cabal build
+ '')
+ (pkgs.writers.writeDashBin "build" ''
+ set -efu
+ build-frontend
+ build-backend
+ '')
+ ];
+ shellHook = ''
+ export EM_CACHE="${toString ./.}/.emcache" # nixos/nixpkgs#282509
+ '';
+ })
];
- shellHook = ''
- export EM_CACHE="${toString ./.}/.emcache" # nixos/nixpkgs#282509
- '';
};
}
diff --git a/nix/sources.json b/nix/sources.json
index aaa40f9..1fd2198 100644
--- a/nix/sources.json
+++ b/nix/sources.json
@@ -2,7 +2,7 @@
"acms": {
"branch": "main",
"repo": "git@code.nomath.org:~/acms",
- "rev": "cec71796c025d49ad2248f27b6e1055f5a5eb7e2",
+ "rev": "3038c6ead2167c7116a3b3411c8b5025373b8dd1",
"type": "git"
},
"haskell-halogen": {
diff --git a/pkgs/default.nix b/pkgs/default.nix
index b46e6f8..3957c07 100644
--- a/pkgs/default.nix
+++ b/pkgs/default.nix
@@ -1,23 +1,27 @@
-{ lib
-, sources ? import ../nix/sources.nix
+{ sources ? import ../nix/sources.nix
, ...
}:
-(self: super: {
- haskell = super.haskell // {
- packageOverrides = self: super: {
- achat = (self.callCabal2nix "achat" ../. { }).overrideAttrs (_: {
- postInstall = ''
- mkdir -p $out/share
- cp -a ./dist/build/achat/achat.jsexe $out/share
- '';
- });
- haskell-halogen-core = lib.dontCheck (self.callCabal2nix "haskell-halogen-core" sources.haskell-halogen { });
- protolude = lib.dontHaddock (
- lib.appendConfigureFlags (lib.doJailbreak super.protolude) [
- "--ghc-option=-fno-safe-haskell"
- "--ghc-option=-fno-warn-x-partial"
- ]);
- clay = self.callHackage "clay" "0.15.0" { };
+(self: super:
+ let pkgs = self; in
+ {
+ haskell = super.haskell // {
+ packageOverrides = pkgs.lib.composeManyExtensions [
+ super.haskell.packageOverrides
+ (self: super: {
+ achat = (self.callCabal2nix "achat" ../. { }).overrideAttrs (_: {
+ postInstall = ''
+ mkdir -p $out/share
+ cp -a ./dist/build/achat/achat.jsexe $out/share
+ '';
+ });
+ haskell-halogen-core = pkgs.haskell.lib.dontCheck (self.callCabal2nix "haskell-halogen-core" sources.haskell-halogen { });
+ protolude = pkgs.haskell.lib.dontHaddock (
+ pkgs.haskell.lib.appendConfigureFlags (pkgs.haskell.lib.doJailbreak super.protolude) [
+ "--ghc-option=-fno-safe-haskell"
+ "--ghc-option=-fno-warn-x-partial"
+ ]);
+ clay = self.callHackage "clay" "0.15.0" { };
+ })
+ ];
};
- };
-})
+ })