Simplify nix setup
This commit is contained in:
parent
61355405d5
commit
a37643b5cd
@ -32,3 +32,7 @@ $ nix develop
|
||||
$ nix run .#stack
|
||||
$ nix run .#ghc
|
||||
```
|
||||
|
||||
## TODO
|
||||
|
||||
- [ ] Benchmark, profile and optimize search
|
||||
|
81
flake.nix
81
flake.nix
@ -5,85 +5,32 @@
|
||||
|
||||
outputs = { self, nixpkgs }:
|
||||
let
|
||||
settings = import ./nix/settings.nix;
|
||||
haskellDeps = import ./nix/haskell-deps.nix;
|
||||
|
||||
pkgs = nixpkgs.legacyPackages.x86_64-linux;
|
||||
haskellPackages = pkgs.haskell.packages."${settings.ghc}";
|
||||
|
||||
ghc = haskellPackages.ghcWithPackages haskellDeps;
|
||||
|
||||
# Wrap stack to disable its slow Nix integration.
|
||||
# Instead, make it use the GHC defined above.
|
||||
stack = pkgs.stdenv.mkDerivation {
|
||||
name = "stack";
|
||||
|
||||
# The build is simply a call to makeWrapper, so we don't have to
|
||||
# do any of the typical build steps.
|
||||
phases = [ "installPhase" ];
|
||||
|
||||
nativeBuildInputs = [ pkgs.makeWrapper ];
|
||||
# makeBinaryWrapper creates a stack executable for us that uses
|
||||
# the GHC defined in this file.
|
||||
installPhase = ''
|
||||
makeWrapper ${pkgs.stack}/bin/stack $out/bin/stack \
|
||||
--prefix PATH : ${ghc}/bin \
|
||||
--add-flags '--no-nix --system-ghc --no-install-ghc'
|
||||
'';
|
||||
utoy = pkgs.haskellPackages.developPackage {
|
||||
root = ./.;
|
||||
};
|
||||
|
||||
utoy = pkgs.haskell.lib.justStaticExecutables (haskellPackages.callPackage
|
||||
({ mkDerivation }:
|
||||
mkDerivation {
|
||||
# Keep this in sync with package.yaml
|
||||
version = "0.6.1";
|
||||
pname = "utoy";
|
||||
license = pkgs.lib.licenses.mit;
|
||||
src =
|
||||
# We only need these files for building:
|
||||
let
|
||||
whitelist = [
|
||||
./LICENSE
|
||||
./utoy.cabal
|
||||
./Setup.hs
|
||||
./app
|
||||
./src
|
||||
./static
|
||||
./test
|
||||
];
|
||||
in
|
||||
pkgs.lib.sources.cleanSourceWith {
|
||||
src = ./.;
|
||||
filter = path: _type: pkgs.lib.any (prefix: pkgs.lib.hasPrefix (toString prefix) path) whitelist;
|
||||
};
|
||||
libraryHaskellDepends = haskellDeps haskellPackages;
|
||||
}) {});
|
||||
in {
|
||||
packages.x86_64-linux = {
|
||||
inherit ghc;
|
||||
inherit stack;
|
||||
|
||||
packages.x86_64-linux = rec {
|
||||
docker =
|
||||
pkgs.dockerTools.buildImage {
|
||||
name = "git.pbrinkmeier.de/paul/utoy";
|
||||
tag = utoy.version;
|
||||
config.Cmd = [ "${utoy}/bin/utoy" ];
|
||||
config.Cmd = [ "${pkgs.haskell.lib.justStaticExecutables utoy}/bin/utoy" ];
|
||||
};
|
||||
|
||||
default = utoy;
|
||||
};
|
||||
|
||||
devShells.x86_64-linux.default = pkgs.mkShell {
|
||||
packages = [
|
||||
stack
|
||||
ghc
|
||||
|
||||
haskellPackages.haskell-language-server
|
||||
haskellPackages.implicit-hie
|
||||
];
|
||||
shellHook = ''
|
||||
PS1+="(utoy) ";
|
||||
'';
|
||||
};
|
||||
devShells.x86_64-linux.default =
|
||||
(pkgs.haskellPackages.developPackage {
|
||||
root = ./.;
|
||||
modifier = drv:
|
||||
pkgs.haskell.lib.addBuildTools drv [
|
||||
pkgs.cabal-install
|
||||
pkgs.haskellPackages.implicit-hie
|
||||
pkgs.haskell-language-server
|
||||
];
|
||||
}).env;
|
||||
};
|
||||
}
|
||||
|
@ -1,13 +0,0 @@
|
||||
haskellPackages: with haskellPackages; [
|
||||
attoparsec
|
||||
blaze-html
|
||||
bytestring
|
||||
file-embed
|
||||
http-media
|
||||
servant-server
|
||||
text
|
||||
unicode-data
|
||||
unicode-data-names
|
||||
wai
|
||||
warp
|
||||
]
|
@ -1,5 +0,0 @@
|
||||
{
|
||||
# GHC version to use with Nix.
|
||||
# Should match the one in stack.yaml.
|
||||
ghc = "ghc944";
|
||||
}
|
70
package.yaml
70
package.yaml
@ -1,70 +0,0 @@
|
||||
# Adapted from new-template.hsfiles
|
||||
|
||||
name: utoy
|
||||
# Keep this in sync with the version in flake.nix.
|
||||
version: 0.6.1
|
||||
git: "https://git.pbrinkmeier.de/paul/utoy"
|
||||
license: MIT
|
||||
author: "Paul Brinkmeier"
|
||||
maintainer: "hallo@pbrinkmeier.de"
|
||||
copyright: "2023 Paul Brinkmeier"
|
||||
|
||||
extra-source-files:
|
||||
- README.md
|
||||
- static/utoy.css
|
||||
|
||||
dependencies:
|
||||
- base >= 4.7 && < 5
|
||||
- attoparsec
|
||||
- text
|
||||
|
||||
ghc-options:
|
||||
- -Wall
|
||||
- -Wcompat
|
||||
- -Widentities
|
||||
- -Wincomplete-record-updates
|
||||
- -Wincomplete-uni-patterns
|
||||
- -Wmissing-export-lists
|
||||
- -Wmissing-home-modules
|
||||
- -Wpartial-fields
|
||||
- -Wredundant-constraints
|
||||
|
||||
library:
|
||||
source-dirs: src
|
||||
|
||||
executables:
|
||||
utoy:
|
||||
main: Main.hs
|
||||
source-dirs: app
|
||||
ghc-options:
|
||||
- -threaded
|
||||
- -rtsopts
|
||||
- -with-rtsopts=-N
|
||||
dependencies:
|
||||
- utoy
|
||||
- blaze-html
|
||||
- bytestring
|
||||
- file-embed
|
||||
- http-media
|
||||
- servant-server
|
||||
- text
|
||||
- unicode-data
|
||||
- unicode-data-names
|
||||
- wai
|
||||
- warp
|
||||
# Fix "Multiple files use the same module name", see
|
||||
# https://stackoverflow.com/questions/67519851/multiple-files-use-the-same-module-name
|
||||
when:
|
||||
- condition: false
|
||||
other-modules: Paths_utoy
|
||||
|
||||
tests:
|
||||
utoy-test:
|
||||
main: Spec.hs
|
||||
source-dirs: test
|
||||
ghc-options:
|
||||
- -threaded
|
||||
- -rtsopts
|
||||
- -with-rtsopts=-N
|
||||
dependencies:
|
||||
- utoy
|
@ -1,5 +0,0 @@
|
||||
# You can get a working environment using nix develop.
|
||||
# Keep this in sync with nix/settings.nix
|
||||
resolver: ghc-9.4.4
|
||||
packages:
|
||||
- .
|
Loading…
x
Reference in New Issue
Block a user